Class NativePasswordPlugin
- java.lang.Object
-
- org.mariadb.jdbc.plugin.authentication.standard.NativePasswordPlugin
-
- All Implemented Interfaces:
AuthenticationPlugin
public class NativePasswordPlugin extends java.lang.Object implements AuthenticationPlugin
Native password implementation
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
authenticationData
private byte[]
seed
static java.lang.String
TYPE
plugin name
-
Constructor Summary
Constructors Constructor Description NativePasswordPlugin()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static byte[]
encryptPassword(java.lang.CharSequence password, byte[] seed)
Encrypts a password.byte[]
hash(Credential credential)
Return Hashvoid
initialize(java.lang.String authenticationData, byte[] seed, Configuration conf, HostAddress hostAddress)
Initialized data.boolean
isMitMProof()
Can plugins is MitM-proof, permitting returning HASHReadableByteBuf
process(Writer out, Reader in, Context context)
Process native password plugin authentication.java.lang.String
type()
Authentication plugin type.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.mariadb.jdbc.plugin.AuthenticationPlugin
requireSsl
-
-
-
-
Field Detail
-
TYPE
public static final java.lang.String TYPE
plugin name- See Also:
- Constant Field Values
-
authenticationData
private java.lang.String authenticationData
-
seed
private byte[] seed
-
-
Method Detail
-
encryptPassword
public static byte[] encryptPassword(java.lang.CharSequence password, byte[] seed)
Encrypts a password.protocol for authentication is like this:
- Server sends a random array of bytes (the seed)
- client makes a sha1 digest of the password
- client hashes the output of 2
- client digests the seed
- client updates the digest with the output from 3
- an xor of the output of 5 and 2 is sent to server
- server does the same thing and verifies that the scrambled passwords match
- Parameters:
password
- the password to encryptseed
- the seed to use- Returns:
- a scrambled password
-
type
public java.lang.String type()
Description copied from interface:AuthenticationPlugin
Authentication plugin type.- Specified by:
type
in interfaceAuthenticationPlugin
- Returns:
- authentication plugin type. ex: mysql_native_password
-
initialize
public void initialize(java.lang.String authenticationData, byte[] seed, Configuration conf, HostAddress hostAddress)
Initialized data.- Specified by:
initialize
in interfaceAuthenticationPlugin
- Parameters:
authenticationData
- authentication data (password/token)seed
- server provided seedconf
- Connection string optionshostAddress
- host information
-
process
public ReadableByteBuf process(Writer out, Reader in, Context context) throws java.io.IOException
Process native password plugin authentication. see https://mariadb.com/kb/en/library/authentication-plugin-mysql_native_password/- Specified by:
process
in interfaceAuthenticationPlugin
- Parameters:
out
- out streamin
- in streamcontext
- connection context- Returns:
- response packet
- Throws:
java.io.IOException
- if socket error
-
isMitMProof
public boolean isMitMProof()
Description copied from interface:AuthenticationPlugin
Can plugins is MitM-proof, permitting returning HASH- Specified by:
isMitMProof
in interfaceAuthenticationPlugin
- Returns:
- true if permitted
-
hash
public byte[] hash(Credential credential)
Return Hash- Specified by:
hash
in interfaceAuthenticationPlugin
- Parameters:
credential
- Credential- Returns:
- hash
-
-