Class Sha256PasswordPlugin
java.lang.Object
org.mariadb.jdbc.internal.com.send.authentication.Sha256PasswordPlugin
- All Implemented Interfaces:
AuthenticationPlugin
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]Encode password with seed and public key.static PublicKeygeneratePublicKey(byte[] publicKeyBytes) Read public pem key from String.voidinitialize(String authenticationData, byte[] seed, Options options) Initialization.name()Authentication plugin name.process(PacketOutputStream out, PacketInputStream in, AtomicInteger sequence) Process SHA 256 password plugin authentication.static PublicKeyreadPublicKeyFromFile(String serverRsaPublicKeyFile) Read public Key from file.static PublicKeyreadPublicKeyFromSocket(PacketInputStream reader, AtomicInteger sequence) Read public Key from socket.type()Authentication plugin type.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface AuthenticationPlugin
mustUseSsl
-
Constructor Details
-
Sha256PasswordPlugin
public Sha256PasswordPlugin()
-
-
Method Details
-
readPublicKeyFromFile
Read public Key from file.- Parameters:
serverRsaPublicKeyFile- RSA public key file- Returns:
- public key
- Throws:
SQLException- if cannot read file or file content is not a public key.
-
readPublicKeyFromSocket
public static PublicKey readPublicKeyFromSocket(PacketInputStream reader, AtomicInteger sequence) throws SQLException, IOException Read public Key from socket.- Parameters:
reader- input stream readersequence- current exchange sequence- Returns:
- public key
- Throws:
SQLException- if server return an Error packet or public key cannot be parsed.IOException- if error reading socket
-
generatePublicKey
Read public pem key from String.- Parameters:
publicKeyBytes- public key bytes value- Returns:
- public key
- Throws:
SQLException- if key cannot be parsed
-
encrypt
public static byte[] encrypt(PublicKey publicKey, String password, byte[] seed, String passwordCharacterEncoding) throws SQLException, UnsupportedEncodingException Encode password with seed and public key.- Parameters:
publicKey- public keypassword- passwordseed- seedpasswordCharacterEncoding- password encoding- Returns:
- encoded password
- Throws:
SQLException- if cannot encode passwordUnsupportedEncodingException- if password encoding is unknown
-
name
Description copied from interface:AuthenticationPluginAuthentication plugin name.- Specified by:
namein interfaceAuthenticationPlugin- Returns:
- authentication plugin name. ex: Mysql native password
-
type
Description copied from interface:AuthenticationPluginAuthentication plugin type.- Specified by:
typein interfaceAuthenticationPlugin- Returns:
- authentication plugin type. ex: mysql_native_password
-
initialize
Initialization.- Specified by:
initializein interfaceAuthenticationPlugin- Parameters:
authenticationData- authentication data (password/token)seed- server provided seedoptions- Connection string options
-
process
public Buffer process(PacketOutputStream out, PacketInputStream in, AtomicInteger sequence) throws IOException, SQLException Process SHA 256 password plugin authentication. see https://mariadb.com/kb/en/library/authentication-plugin-ed25519/- Specified by:
processin interfaceAuthenticationPlugin- Parameters:
out- out streamin- in streamsequence- packet sequence- Returns:
- response packet
- Throws:
IOException- if socket errorSQLException- if plugin exception
-