Skip to content

Instantly share code, notes, and snippets.

@javaeeeee
Created February 10, 2015 03:58
Show Gist options
  • Select an option

  • Save javaeeeee/4b4712e81444c82ba1e1 to your computer and use it in GitHub Desktop.

Select an option

Save javaeeeee/4b4712e81444c82ba1e1 to your computer and use it in GitHub Desktop.
Dropwizard Authenticator with Configuration
public class GreetingAuthenticator
implements Authenticator<BasicCredentials, User> {
private String login;
private String password;
public GreetingAuthenticator(String login, String password) {
this.login = login;
this.password = password;
}
@Override
public Optional<User> authenticate(BasicCredentials credentials)
throws AuthenticationException {
if (password.equals(credentials.getPassword())
&& login.equals(credentials.getUsername())) {
return Optional.of(new User());
} else {
return Optional.absent();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment