Class CachingSha2PasswordPlugin

    • Constructor Detail

      • CachingSha2PasswordPlugin

        public CachingSha2PasswordPlugin()
    • Method Detail

      • sha256encryptPassword

        public static byte[] sha256encryptPassword​(CharSequence password,
                                                   byte[] seed)
        Send an SHA-2 encrypted password. encryption XOR(SHA256(password), SHA256(seed, SHA256(SHA256(password))))
        Parameters:
        password - password
        seed - seed
        Returns:
        encrypted pwd
      • initialize

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

        public static PublicKey readPublicKeyFromFile​(String serverRsaPublicKeyFile)
                                               throws SQLException
        Read public Key from file.
        Parameters:
        serverRsaPublicKeyFile - RSA public key file
        Returns:
        public key
        Throws:
        SQLException - if having an error reading file or file content is not a public key.
      • generatePublicKey

        public static PublicKey generatePublicKey​(byte[] publicKeyBytes)
                                           throws SQLException
        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)
                              throws SQLException
        Encode password with seed and public key.
        Parameters:
        publicKey - public key
        password - password
        seed - seed
        Returns:
        encoded password
        Throws:
        SQLException - if cannot encode password