~ubuntu-branches/ubuntu/trusty/mysql-connector-java/trusty

« back to all changes in this revision

Viewing changes to src/com/mysql/jdbc/authentication/MysqlClearPasswordPlugin.java

  • Committer: Package Import Robot
  • Author(s): Emmanuel Bourg, Miguel Landaeta
  • Date: 2013-07-02 17:07:51 UTC
  • mfrom: (1.1.8) (3.1.6 sid)
  • Revision ID: package-import@ubuntu.com-20130702170751-f4rszjabxg0391fr
Tags: 5.1.25-1
* New upstream release
* Refreshed the patches
* Added a patch to build with one JDK and removed the build
  dependency on java-gcj-compat-dev
* Updated Standards-Version to 3.9.4 (no changes)
* Use canonical URLs for the Vcs-* fields
* debian/rules: Improved the clean target to allow rebuilds
* Updated the watch file
* Renamed debian/README.Debian-source to README.source

[ Miguel Landaeta ] 
* Fix FTBFS with OpenJDK 7 (Closes: #706668)
* Remove Michael Koch from Uploaders list.
  Thanks for your work on this package. (Closes: #654122).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
 
3
 
 
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>.
 
9
 
 
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
 
12
  of the License.
 
13
 
 
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.
 
17
 
 
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
 
21
 
 
22
 */
 
23
 
 
24
package com.mysql.jdbc.authentication;
 
25
 
 
26
import java.sql.SQLException;
 
27
import java.util.List;
 
28
import java.util.Properties;
 
29
 
 
30
import com.mysql.jdbc.AuthenticationPlugin;
 
31
import com.mysql.jdbc.Buffer;
 
32
import com.mysql.jdbc.Connection;
 
33
import com.mysql.jdbc.StringUtils;
 
34
 
 
35
/**
 
36
 * MySQL Clear Password Authentication Plugin
 
37
 *
 
38
 */
 
39
public class MysqlClearPasswordPlugin implements AuthenticationPlugin {
 
40
        
 
41
        private String password = null;
 
42
 
 
43
        public void init(Connection conn, Properties props) throws SQLException {
 
44
        }
 
45
 
 
46
        public void destroy() {
 
47
                this.password = null;
 
48
        }
 
49
 
 
50
        public String getProtocolPluginName() {
 
51
                return "mysql_clear_password";
 
52
        }
 
53
 
 
54
        public boolean requiresConfidentiality() {
 
55
                return true;
 
56
        }
 
57
 
 
58
        public boolean isReusable() {
 
59
                return true;
 
60
        }
 
61
 
 
62
        public void setAuthenticationParameters(String user, String password) {
 
63
                this.password = password;
 
64
        }
 
65
 
 
66
        public boolean nextAuthenticationStep(Buffer fromServer, List<Buffer> toServer) throws SQLException {
 
67
                toServer.clear();
 
68
 
 
69
                Buffer bresp = new Buffer(StringUtils.getBytes(this.password != null ? this.password : ""));
 
70
 
 
71
                bresp.setPosition(bresp.getBufLength());
 
72
                int oldBufLength = bresp.getBufLength();
 
73
                
 
74
                bresp.writeByte((byte)0);
 
75
                
 
76
                bresp.setBufLength(oldBufLength + 1);
 
77
                bresp.setPosition(0);
 
78
 
 
79
                toServer.add(bresp);
 
80
                return true;
 
81
        }
 
82
 
 
83
}