Class PlainTextAuthProvider

  • All Implemented Interfaces:
    AuthProvider, ExtendedAuthProvider

    public class PlainTextAuthProvider
    extends Object
    implements ExtendedAuthProvider
    A simple AuthProvider implementation.

    This provider allows to programmatically define authentication information that will then apply to all hosts. The PlainTextAuthenticator instances it returns support SASL authentication using the PLAIN mechanism for version 2 (or above) of the CQL native protocol.

    • Constructor Detail

      • PlainTextAuthProvider

        public PlainTextAuthProvider​(String username,
                                     String password)
        Creates a new simple authentication information provider with the supplied credentials.
        Parameters:
        username - to use for authentication requests
        password - to use for authentication requests
    • Method Detail

      • setUsername

        public void setUsername​(String username)
        Changes the user name.

        The new credentials will be used for all connections initiated after this method was called.

        Parameters:
        username - the new name.
      • setPassword

        public void setPassword​(String password)
        Changes the password.

        The new credentials will be used for all connections initiated after this method was called.

        Parameters:
        password - the new password.
      • newAuthenticator

        public Authenticator newAuthenticator​(EndPoint host,
                                              String authenticator)
        Uses the supplied credentials and the SASL PLAIN mechanism to login to the server.
        Specified by:
        newAuthenticator in interface ExtendedAuthProvider
        Parameters:
        host - the Cassandra host with which we want to authenticate
        authenticator - the configured authenticator on the host
        Returns:
        an Authenticator instance which can be used to perform authentication negotiations on behalf of the client