2
Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
4
The MySQL Connector/J is licensed under the terms of the GPLv2
5
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most MySQL Connectors.
6
There are special exceptions to the terms and conditions of the GPLv2 as it is applied to
7
this software, see the FLOSS License Exception
8
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
10
This program is free software; you can redistribute it and/or modify it under the terms
11
of the GNU General Public License as published by the Free Software Foundation; version 2
14
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
See the GNU General Public License for more details.
18
You should have received a copy of the GNU General Public License along with this
19
program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth
20
Floor, Boston, MA 02110-1301 USA
24
package com.mysql.jdbc.authentication;
26
import java.sql.SQLException;
27
import java.util.List;
28
import java.util.Properties;
30
import com.mysql.jdbc.AuthenticationPlugin;
31
import com.mysql.jdbc.Buffer;
32
import com.mysql.jdbc.Connection;
33
import com.mysql.jdbc.StringUtils;
36
* MySQL Clear Password Authentication Plugin
39
public class MysqlClearPasswordPlugin implements AuthenticationPlugin {
41
private String password = null;
43
public void init(Connection conn, Properties props) throws SQLException {
46
public void destroy() {
50
public String getProtocolPluginName() {
51
return "mysql_clear_password";
54
public boolean requiresConfidentiality() {
58
public boolean isReusable() {
62
public void setAuthenticationParameters(String user, String password) {
63
this.password = password;
66
public boolean nextAuthenticationStep(Buffer fromServer, List<Buffer> toServer) throws SQLException {
69
Buffer bresp = new Buffer(StringUtils.getBytes(this.password != null ? this.password : ""));
71
bresp.setPosition(bresp.getBufLength());
72
int oldBufLength = bresp.getBufLength();
74
bresp.writeByte((byte)0);
76
bresp.setBufLength(oldBufLength + 1);