Class NativePasswordPlugin

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String authenticationData  
      private byte[] seed  
    • Constructor Summary

      Constructors 
      Constructor Description
      NativePasswordPlugin​(java.lang.String authenticationData, byte[] seed)
      Initialized data.
    • Field Detail

      • authenticationData

        private final java.lang.String authenticationData
      • seed

        private final byte[] seed
    • Constructor Detail

      • NativePasswordPlugin

        public NativePasswordPlugin​(java.lang.String authenticationData,
                                    byte[] seed)
        Initialized data.
        Parameters:
        authenticationData - authentication data (password/token)
        seed - server provided seed
    • Method Detail

      • encryptPassword

        public static byte[] encryptPassword​(java.lang.CharSequence password,
                                             byte[] seed)
        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 encrypt
        seed - the seed to use
        Returns:
        a scrambled password
      • process

        public ReadableByteBuf process​(Writer out,
                                       Reader in,
                                       Context context,
                                       boolean sslFingerPrintValidation)
                                throws java.io.IOException
        Process native password plugin authentication. see authentication-plugin-mysql_native_password
        Specified by:
        process in interface AuthenticationPlugin
        Parameters:
        out - out stream
        in - in stream
        context - connection context
        sslFingerPrintValidation - true if SSL certificate fingerprint validation is enabled
        Returns:
        response packet
        Throws:
        java.io.IOException - if socket error
      • hash

        public byte[] hash​(Credential credential)
        Return Hash
        Specified by:
        hash in interface AuthenticationPlugin
        Parameters:
        credential - Credential
        Returns:
        hash