Class CachingSha2PasswordPlugin
java.lang.Object
org.mariadb.jdbc.plugin.authentication.standard.CachingSha2PasswordPlugin
- All Implemented Interfaces:
AuthenticationPlugin
Mysql caching sha2 password plugin
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate String
private Configuration
private HostAddress
private byte[]
static final String
plugin name -
Constructor Summary
ConstructorsConstructorDescriptionCachingSha2PasswordPlugin
(String authenticationData, byte[] seed, Configuration conf, HostAddress hostAddress) -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]
Encode password with seed and public key.static PublicKey
generatePublicKey
(byte[] publicKeyBytes) Read public pem key from String.void
initialize
(String authenticationData, byte[] seed, Configuration conf, HostAddress hostAddress) Initialized data.Process native password plugin authentication.static PublicKey
readPublicKeyFromFile
(String serverRsaPublicKeyFile) Read public Key from file.static byte[]
sha256encryptPassword
(CharSequence password, byte[] seed) Send an SHA-2 encrypted password.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
hash, isMitMProof
-
Field Details
-
TYPE
plugin name- See Also:
-
authenticationData
-
seed
private byte[] seed -
conf
-
hostAddress
-
-
Constructor Details
-
CachingSha2PasswordPlugin
public CachingSha2PasswordPlugin(String authenticationData, byte[] seed, Configuration conf, HostAddress hostAddress)
-
-
Method Details
-
sha256encryptPassword
Send an SHA-2 encrypted password. encryption XOR(SHA256(password), SHA256(seed, SHA256(SHA256(password))))- Parameters:
password
- passwordseed
- seed- Returns:
- encrypted pwd
-
readPublicKeyFromFile
Read public Key from file.- Parameters:
serverRsaPublicKeyFile
- RSA public key file- Returns:
- public key
- Throws:
SQLException
- if having an error reading file or file content is not a public key.
-
generatePublicKey
Read public pem key from String.- Parameters:
publicKeyBytes
- public key bytes value- Returns:
- public key
- Throws:
SQLException
- if key cannot be parsed
-
encrypt
Encode password with seed and public key.- Parameters:
publicKey
- public keypassword
- passwordseed
- seed- Returns:
- encoded password
- Throws:
SQLException
- if cannot encode password
-
initialize
public void initialize(String authenticationData, byte[] seed, Configuration conf, HostAddress hostAddress) Initialized data.- 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 IOException, SQLException 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:
IOException
- if socket errorSQLException
- if plugin exception
-