public class Sha256PasswordPlugin extends java.lang.Object implements AuthenticationPlugin
| Modifier and Type | Field and Description |
|---|---|
private java.lang.String |
authenticationData |
private Options |
options |
private byte[] |
seed |
| Constructor and Description |
|---|
Sha256PasswordPlugin() |
| Modifier and Type | Method and Description |
|---|---|
static byte[] |
encrypt(java.security.PublicKey publicKey,
java.lang.String password,
byte[] seed,
java.lang.String passwordCharacterEncoding)
Encode password with seed and public key.
|
static java.security.PublicKey |
generatePublicKey(byte[] publicKeyBytes)
Read public pem key from String.
|
void |
initialize(java.lang.String authenticationData,
byte[] seed,
Options options)
Initialization.
|
java.lang.String |
name()
Authentication plugin name.
|
Buffer |
process(PacketOutputStream out,
PacketInputStream in,
java.util.concurrent.atomic.AtomicInteger sequence)
Process SHA 256 password plugin authentication.
|
static java.security.PublicKey |
readPublicKeyFromFile(java.lang.String serverRsaPublicKeyFile)
Read public Key from file.
|
static java.security.PublicKey |
readPublicKeyFromSocket(PacketInputStream reader,
java.util.concurrent.atomic.AtomicInteger sequence)
Read public Key from socket.
|
java.lang.String |
type()
Authentication plugin type.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitmustUseSslprivate java.lang.String authenticationData
private Options options
private byte[] seed
public static java.security.PublicKey readPublicKeyFromFile(java.lang.String serverRsaPublicKeyFile)
throws java.sql.SQLException
serverRsaPublicKeyFile - RSA public key filejava.sql.SQLException - if cannot read file or file content is not a public key.public static java.security.PublicKey readPublicKeyFromSocket(PacketInputStream reader, java.util.concurrent.atomic.AtomicInteger sequence) throws java.sql.SQLException, java.io.IOException
reader - input stream readersequence - current exchange sequencejava.sql.SQLException - if server return an Error packet or public key cannot be parsed.java.io.IOException - if error reading socketpublic static java.security.PublicKey generatePublicKey(byte[] publicKeyBytes)
throws java.sql.SQLException
publicKeyBytes - public key bytes valuejava.sql.SQLException - if key cannot be parsedpublic static byte[] encrypt(java.security.PublicKey publicKey,
java.lang.String password,
byte[] seed,
java.lang.String passwordCharacterEncoding)
throws java.sql.SQLException,
java.io.UnsupportedEncodingException
publicKey - public keypassword - passwordseed - seedpasswordCharacterEncoding - password encodingjava.sql.SQLException - if cannot encode passwordjava.io.UnsupportedEncodingException - if password encoding is unknownpublic java.lang.String name()
AuthenticationPluginname in interface AuthenticationPluginpublic java.lang.String type()
AuthenticationPlugintype in interface AuthenticationPluginpublic void initialize(java.lang.String authenticationData,
byte[] seed,
Options options)
initialize in interface AuthenticationPluginauthenticationData - authentication data (password/token)seed - server provided seedoptions - Connection string optionspublic Buffer process(PacketOutputStream out, PacketInputStream in, java.util.concurrent.atomic.AtomicInteger sequence) throws java.io.IOException, java.sql.SQLException
process in interface AuthenticationPluginout - out streamin - in streamsequence - packet sequencejava.io.IOException - if socket errorjava.sql.SQLException - if plugin exception