Created
February 10, 2015 03:58
-
-
Save javaeeeee/4b4712e81444c82ba1e1 to your computer and use it in GitHub Desktop.
Dropwizard Authenticator with Configuration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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