Skip to content

Instantly share code, notes, and snippets.

Last active December 21, 2015 17:49
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Example of different authenticators in dropwizard
abstract class MyPrincipal {};
class BasicAuthPrincipal extends MyPrincipal {};
class OAuthPrincipal extends MyPrincipal {};
class BasicAuthenticator implements Authenticator<BasicCredentials, BasicAuthPrincipal> {
public Optional<BasicAuthPrincipal> authenticate(BasicCredentials creds) {
return new BasicAuthPrincipal();
class OAuthAuthenticator implements Authenticator<String, OAuthPrincipal> {
public Optional<OAuthPrincipal> authenticate(String creds) {
return new OAuthPrincipal();
class BasicResource
public String get(@Auth BasicAuthPrincipal user) {
return "Basic!"
class OAuthResource
public String get(@Auth OAuthPrincipal user) {
return "OAuth!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment