Class NativePasswordPlugin
java.lang.Object
org.mariadb.jdbc.plugin.authentication.standard.NativePasswordPlugin
- All Implemented Interfaces:
AuthenticationPlugin
Native password implementation
-
Constructor Summary
ConstructorsConstructorDescriptionNativePasswordPlugin(String authenticationData, byte[] seed) Initialized data. -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]encryptPassword(CharSequence password, byte[] seed) Encrypts a password.byte[]hash(Credential credential) Return HashbooleanCan plugins is MitM-proof, permitting returning HASHorg.mariadb.jdbc.client.ReadableByteBufProcess native password plugin authentication.
-
Constructor Details
-
NativePasswordPlugin
Initialized data.- Parameters:
authenticationData- authentication data (password/token)seed- server provided seed
-
-
Method Details
-
encryptPassword
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
-
process
public org.mariadb.jdbc.client.ReadableByteBuf process(Writer out, Reader in, org.mariadb.jdbc.client.Context context) throws IOException Process native password plugin authentication. see https://mariadb.com/kb/en/library/authentication-plugin-mysql_native_password/- Specified by:
processin interfaceAuthenticationPlugin- Parameters:
out- out streamin- in streamcontext- connection context- Returns:
- response packet
- Throws:
IOException- if socket error
-
isMitMProof
public boolean isMitMProof()Description copied from interface:AuthenticationPluginCan plugins is MitM-proof, permitting returning HASH- Specified by:
isMitMProofin interfaceAuthenticationPlugin- Returns:
- true if permitted
-
hash
Return Hash- Specified by:
hashin interfaceAuthenticationPlugin- Parameters:
credential- Credential- Returns:
- hash
-