Class LdapPasswordAuthenticator

  • All Implemented Interfaces:
    org.apache.sshd.server.auth.password.PasswordAuthenticator

    public class LdapPasswordAuthenticator
    extends LdapAuthenticator
    implements org.apache.sshd.server.auth.password.PasswordAuthenticator
    Uses LDAP to authenticate a user and password. By default it can achieve this using 2 ways:

    1. Comparing the provided password with the one stored in LDAP. In this case, the bind DN and password patterns can be either empty (if anonymous access allowed) or can contain the administrative username / password required to run the LDAP query. The search filter pattern should be set to require a match for both the username and password - e.g., "(&(user={0})(password={1}))". The set default (DEFAULT_SEARCH_FILTER_PATTERN) uses the most commonly encountered attributes names for this purpose.
    2. Using the original username + password to access LDAP - in which case the very success of retrieving anything can be considered a successful authentication. In this case, the bind DN and password patterns should be set up to generate the correct credentials - the default is to "echo" the provided username and password as-is. E.g., if the username is always the alias part of a known e-mail, the bind DN should be set to "{0}@my.domain.com".
    • Field Detail

      • DEFAULT_PASSWORD_ATTR_NAME

        public static final java.lang.String DEFAULT_PASSWORD_ATTR_NAME
        See Also:
        Constant Field Values
      • DEFAULT_SEARCH_FILTER_PATTERN

        public static final java.lang.String DEFAULT_SEARCH_FILTER_PATTERN
        See Also:
        Constant Field Values
    • Constructor Detail

      • LdapPasswordAuthenticator

        public LdapPasswordAuthenticator()
    • Method Detail

      • authenticate

        public boolean authenticate​(java.lang.String username,
                                    java.lang.String password,
                                    org.apache.sshd.server.session.ServerSession session)
                             throws org.apache.sshd.server.auth.password.PasswordChangeRequiredException
        Specified by:
        authenticate in interface org.apache.sshd.server.auth.password.PasswordAuthenticator
        Throws:
        org.apache.sshd.server.auth.password.PasswordChangeRequiredException
      • authenticate

        protected boolean authenticate​(java.lang.String username,
                                       java.lang.String password,
                                       org.apache.sshd.server.session.ServerSession session,
                                       java.util.Map<java.lang.String,​?> attrs)