Class SendPamAuthPacket

  • All Implemented Interfaces:
    AuthenticationPlugin

    public class SendPamAuthPacket
    extends java.lang.Object
    implements AuthenticationPlugin
    PAM (dialog) authentication plugin. This is a multi-step exchange password. If more than one step, passwordX (password2, password3, ...) options must be set.
    • Field Detail

      • authenticationData

        private final java.lang.String authenticationData
      • counter

        private int counter
    • Constructor Detail

      • SendPamAuthPacket

        public SendPamAuthPacket​(java.lang.String authenticationData,
                                 Configuration conf)
        Initialization.
        Parameters:
        authenticationData - authentication data (password/token)
        conf - Connection string options
    • Method Detail

      • process

        public ReadableByteBuf process​(Writer out,
                                       Reader in,
                                       Context context,
                                       boolean sslFingerPrintValidation)
                                throws java.sql.SQLException,
                                       java.io.IOException
        Process PAM plugin authentication. see https://mariadb.com/kb/en/library/authentication-plugin-pam/
        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
        java.sql.SQLException - if plugin exception
      • resolvePassword

        private java.lang.String resolvePassword​(ReadableByteBuf serverPacket)
                                          throws java.sql.SQLException
        Pick the answer for the current PAM/dialog round. Round 1 uses the connection password, later rounds prefer the application-registered AuthDialogCallback (so a UI can surface the actual server prompt). When no callback is registered, or the callback returns null, we fall back to the historical passwordN URL options.
        Throws:
        java.sql.SQLException
      • dialogCallback

        private static AuthDialogCallback dialogCallback()
        Look up the application-registered AuthDialogCallback via ServiceLoader. Java equivalent of the C connector's dlsym(RTLD_DEFAULT, "mariadb_auth_dialog"). Returns null when nothing is registered.