Class CachingSha2PasswordPlugin

    • Field Detail

      • authenticationData

        private java.lang.String authenticationData
      • seed

        private byte[] seed
    • Constructor Detail

      • CachingSha2PasswordPlugin

        public CachingSha2PasswordPlugin()
    • Method Detail

      • sha256encryptPassword

        public static byte[] sha256encryptPassword​(java.lang.String password,
                                                   byte[] seed,
                                                   java.lang.String passwordCharacterEncoding)
                                            throws java.security.NoSuchAlgorithmException,
                                                   java.io.UnsupportedEncodingException
        Send a SHA-2 encrypted password. encryption XOR(SHA256(password), SHA256(seed, SHA256(SHA256(password))))
        Parameters:
        password - password
        seed - seed
        passwordCharacterEncoding - option if not using default byte encoding
        Returns:
        encrypted pwd
        Throws:
        java.security.NoSuchAlgorithmException - if SHA-256 algorithm is unknown
        java.io.UnsupportedEncodingException - if SHA-256 algorithm is unknown
      • name

        public java.lang.String name()
        Description copied from interface: AuthenticationPlugin
        Authentication plugin name.
        Specified by:
        name in interface AuthenticationPlugin
        Returns:
        authentication plugin name. ex: Mysql native password
      • type

        public java.lang.String type()
        Description copied from interface: AuthenticationPlugin
        Authentication plugin type.
        Specified by:
        type in interface AuthenticationPlugin
        Returns:
        authentication plugin type. ex: mysql_native_password
      • initialize

        public void initialize​(java.lang.String authenticationData,
                               byte[] seed,
                               Options options)
        Initialized data.
        Specified by:
        initialize in interface AuthenticationPlugin
        Parameters:
        authenticationData - authentication data (password/token)
        seed - server provided seed
        options - Connection string options
      • process

        public Buffer process​(PacketOutputStream out,
                              PacketInputStream in,
                              java.util.concurrent.atomic.AtomicInteger sequence)
                       throws java.io.IOException,
                              java.sql.SQLException
        Process native password plugin authentication. see https://mariadb.com/kb/en/library/authentication-plugin-mysql_native_password/
        Specified by:
        process in interface AuthenticationPlugin
        Parameters:
        out - out stream
        in - in stream
        sequence - packet sequence
        Returns:
        response packet
        Throws:
        java.io.IOException - if socket error
        java.sql.SQLException - if plugin exception