Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.mysql.jdbc
Class Security  view Security download Security.java

java.lang.Object
  extended bycom.mysql.jdbc.Security

class Security
extends java.lang.Object

Methods for doing secure authentication with MySQL-4.1 and newer.

Version:
$Id: Security.java,v 1.1.4.6 2004/08/09 22:15:12 mmatthew Exp $

Field Summary
private static char PVERSION41_CHAR
           
private static int SHA1_HASH_SIZE
           
 
Constructor Summary
private Security()
          Prevent construction.
 
Method Summary
private static int charVal(char c)
          Returns hex value for given char
(package private) static byte[] createKeyFromOldPassword(java.lang.String passwd)
          Creates key from old password to decode scramble Used in 4.1 authentication with passwords stored pre-4.1 hashing.
(package private) static byte[] getBinaryPassword(int[] salt, boolean usingNewPasswords)
          DOCUMENT ME!
private static int[] getSaltFromPassword(java.lang.String password)
           
private static java.lang.String longToHex(long val)
           
(package private) static java.lang.String makeScrambledPassword(java.lang.String password)
          Creates password to be stored in user database from raw string.
(package private) static void passwordCrypt(byte[] from, byte[] to, byte[] password, int length)
          Encrypt/Decrypt function used for password encryption in authentication Simple XOR is used here but it is OK as we crypt random strings
(package private) static byte[] passwordHashStage1(java.lang.String password)
          Stage one password hashing, used in MySQL 4.1 password handling
(package private) static byte[] passwordHashStage2(byte[] hashedPassword, byte[] salt)
          Stage two password hashing used in MySQL 4.1 password handling
(package private) static byte[] scramble411(java.lang.String password, java.lang.String seed)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SHA1_HASH_SIZE

private static final int SHA1_HASH_SIZE
See Also:
Constant Field Values

PVERSION41_CHAR

private static final char PVERSION41_CHAR
See Also:
Constant Field Values
Constructor Detail

Security

private Security()
Prevent construction.

Method Detail

getBinaryPassword

static byte[] getBinaryPassword(int[] salt,
                                boolean usingNewPasswords)
                         throws java.security.NoSuchAlgorithmException
DOCUMENT ME!


createKeyFromOldPassword

static byte[] createKeyFromOldPassword(java.lang.String passwd)
                                throws java.security.NoSuchAlgorithmException
Creates key from old password to decode scramble Used in 4.1 authentication with passwords stored pre-4.1 hashing.


makeScrambledPassword

static java.lang.String makeScrambledPassword(java.lang.String password)
                                       throws java.security.NoSuchAlgorithmException
Creates password to be stored in user database from raw string. Handles Pre-MySQL 4.1 passwords.


passwordCrypt

static void passwordCrypt(byte[] from,
                          byte[] to,
                          byte[] password,
                          int length)
Encrypt/Decrypt function used for password encryption in authentication Simple XOR is used here but it is OK as we crypt random strings


passwordHashStage1

static byte[] passwordHashStage1(java.lang.String password)
                          throws java.security.NoSuchAlgorithmException
Stage one password hashing, used in MySQL 4.1 password handling


passwordHashStage2

static byte[] passwordHashStage2(byte[] hashedPassword,
                                 byte[] salt)
                          throws java.security.NoSuchAlgorithmException
Stage two password hashing used in MySQL 4.1 password handling


getSaltFromPassword

private static int[] getSaltFromPassword(java.lang.String password)

charVal

private static int charVal(char c)
Returns hex value for given char


longToHex

private static java.lang.String longToHex(long val)

scramble411

static byte[] scramble411(java.lang.String password,
                          java.lang.String seed)
                   throws java.security.NoSuchAlgorithmException