com.yammer.dropwizard.authenticator.ResourceAuthenticator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dropwizard-auth-ldap Show documentation
Show all versions of dropwizard-auth-ldap Show documentation
Dropwizard Authentication Module for LDAP using JNDI
package com.yammer.dropwizard.authenticator;
import com.google.common.base.Optional;
import io.dropwizard.auth.AuthenticationException;
import io.dropwizard.auth.Authenticator;
import io.dropwizard.auth.basic.BasicCredentials;
import static com.google.common.base.Preconditions.checkNotNull;
public class ResourceAuthenticator implements Authenticator {
private final LdapAuthenticator ldapAuthenticator;
public ResourceAuthenticator(LdapAuthenticator ldapAuthenticator) {
this.ldapAuthenticator = checkNotNull(ldapAuthenticator);
}
@Override
public Optional authenticate(BasicCredentials credentials) throws AuthenticationException {
if (ldapAuthenticator.authenticate(credentials)) {
return Optional.of(credentials);
} else {
return Optional.absent();
}
}
}