Search in sources :

Example 1 with AuthenticationException

use of org.neo4j.server.security.enterprise.auth.plugin.api.AuthenticationException in project neo4j by neo4j.

the class LdapGroupHasUsersAuthPlugin method authenticateAndAuthorize.

@Override
public AuthInfo authenticateAndAuthorize(AuthToken authToken) throws AuthenticationException {
    try {
        String username = authToken.principal();
        char[] password = authToken.credentials();
        LdapContext ctx = authenticate(username, password);
        Set<String> roles = authorize(ctx, username);
        return AuthInfo.of(username, roles);
    } catch (NamingException e) {
        throw new AuthenticationException(e.getMessage());
    }
}
Also used : AuthenticationException(org.neo4j.server.security.enterprise.auth.plugin.api.AuthenticationException) NamingException(javax.naming.NamingException) InitialLdapContext(javax.naming.ldap.InitialLdapContext) LdapContext(javax.naming.ldap.LdapContext)

Aggregations

NamingException (javax.naming.NamingException)1 InitialLdapContext (javax.naming.ldap.InitialLdapContext)1 LdapContext (javax.naming.ldap.LdapContext)1 AuthenticationException (org.neo4j.server.security.enterprise.auth.plugin.api.AuthenticationException)1