public class NativeAuthenticationProvider extends java.lang.Object implements AuthenticationProvider<NativePacketPayload>
| Modifier and Type | Field and Description |
|---|---|
private static int |
AUTH_411_OVERHEAD |
private java.util.Map<java.lang.String,AuthenticationPlugin<NativePacketPayload>> |
authenticationPlugins
Contains instances of authentication plugins that implements
AuthenticationPlugin interface. |
private MysqlCallbackHandler |
callbackHandler
A callback for updating the username from the authentication plugin.
|
private boolean |
clientDefaultAuthenticationPluginExplicitelySet
Was the client default authentication plugin explicitly set?
|
private java.lang.String |
clientDefaultAuthenticationPluginName
Protocol name of default authentication plugin in client
|
private java.lang.String |
database |
private ExceptionInterceptor |
exceptionInterceptor |
private static java.lang.String |
NONE |
private java.lang.String |
password |
private PropertySet |
propertySet |
private Protocol<NativePacketPayload> |
protocol |
private java.lang.String |
seed |
private java.lang.String |
serverDefaultAuthenticationPluginName
Protocol name of default authentication plugin in server
|
private boolean |
useConnectWithDb |
private java.lang.String |
username |
| Constructor and Description |
|---|
NativeAuthenticationProvider() |
| Modifier and Type | Method and Description |
|---|---|
private void |
appendConnectionAttributes(NativePacketPayload buf,
java.lang.String attributes,
java.lang.String enc) |
void |
changeUser(java.lang.String user,
java.lang.String pass,
java.lang.String db)
Re-authenticates as the given user and password
|
private void |
checkConfidentiality(AuthenticationPlugin<?> plugin)
Check if given plugin requires confidentiality, but connection is without SSL
|
void |
connect(java.lang.String user,
java.lang.String pass,
java.lang.String db)
Initialize communications with the MySQL server.
|
private NativePacketPayload |
createChangeUserPacket(ServerSession serverSession,
java.lang.String pluginName,
NativePacketPayload authData) |
private NativePacketPayload |
createHandshakeResponsePacket(ServerSession serverSession,
java.lang.String pluginName,
NativePacketPayload authData) |
private AuthenticationPlugin<NativePacketPayload> |
getAuthenticationPlugin(java.lang.String pluginName)
Get an authentication plugin instance from the authentication plugins map by pluginName key.
|
private java.util.Map<java.lang.String,java.lang.String> |
getConnectionAttributesMap(java.lang.String attStr) |
ExceptionInterceptor |
getExceptionInterceptor() |
private java.lang.String |
getNthFactorPassword(int nthFactor) |
void |
init(Protocol<NativePacketPayload> prot,
PropertySet propSet,
ExceptionInterceptor excInterceptor) |
private void |
loadAuthenticationPlugins()
Fill the authentication plugins map.
|
private void |
proceedHandshakeWithPluggableAuthentication(NativePacketPayload challenge)
Performs an authentication handshake to authorize connection to a given database as a given MySQL user.
|
private static final int AUTH_411_OVERHEAD
private static final java.lang.String NONE
private java.lang.String seed
private java.lang.String username
private java.lang.String password
private java.lang.String database
private boolean useConnectWithDb
private ExceptionInterceptor exceptionInterceptor
private PropertySet propertySet
private Protocol<NativePacketPayload> protocol
private java.util.Map<java.lang.String,AuthenticationPlugin<NativePacketPayload>> authenticationPlugins
AuthenticationPlugin interface. Key values are MySQL protocol plugin names, for
example "mysql_native_password" and "mysql_old_password" for built-in plugins.private java.lang.String clientDefaultAuthenticationPluginName
private boolean clientDefaultAuthenticationPluginExplicitelySet
private java.lang.String serverDefaultAuthenticationPluginName
private MysqlCallbackHandler callbackHandler
public void init(Protocol<NativePacketPayload> prot, PropertySet propSet, ExceptionInterceptor excInterceptor)
init in interface AuthenticationProvider<NativePacketPayload>public void connect(java.lang.String user,
java.lang.String pass,
java.lang.String db)
connect in interface AuthenticationProvider<NativePacketPayload>user - user namepass - passworddb - database nameprivate void loadAuthenticationPlugins()
AuthenticationPlugin.getProtocolPluginName() thus it is possible to replace built-in plugins with custom
implementations. To do it, the custom plugin should return one of the values "mysql_native_password", "mysql_clear_password", "sha256_password",
"caching_sha2_password", "mysql_old_password", "authentication_ldap_sasl_client" or "authentication_kerberos_client" from its own getProtocolPluginName()
method.private AuthenticationPlugin<NativePacketPayload> getAuthenticationPlugin(java.lang.String pluginName)
AuthenticationPlugin.isReusable() is called and if the value returned is false then a new instance of the plugin is returned
otherwise the instance that already exists is returned.
If plugin is not found method returns null, in such case the subsequent behavior
of handshake process depends on type of last packet received from server:
if it was Auth Challenge Packet then handshake will proceed with default plugin,
if it was Auth Method Switch Request Packet then handshake will be interrupted with exception.pluginName - mysql protocol plugin names, for example "mysql_native_password" and "mysql_old_password" for built-in pluginsprivate void checkConfidentiality(AuthenticationPlugin<?> plugin)
plugin - AuthenticationPluginprivate void proceedHandshakeWithPluggableAuthentication(NativePacketPayload challenge)
challenge - the Auth Challenge Packet received from server if
this method is used during the initial connection.
Otherwise null.private java.lang.String getNthFactorPassword(int nthFactor)
private java.util.Map<java.lang.String,java.lang.String> getConnectionAttributesMap(java.lang.String attStr)
private void appendConnectionAttributes(NativePacketPayload buf, java.lang.String attributes, java.lang.String enc)
public ExceptionInterceptor getExceptionInterceptor()
public void changeUser(java.lang.String user,
java.lang.String pass,
java.lang.String db)
changeUser in interface AuthenticationProvider<NativePacketPayload>user - user namepass - passworddb - database nameprivate NativePacketPayload createHandshakeResponsePacket(ServerSession serverSession, java.lang.String pluginName, NativePacketPayload authData)
private NativePacketPayload createChangeUserPacket(ServerSession serverSession, java.lang.String pluginName, NativePacketPayload authData)