Java 类io.dropwizard.java8.auth.Authenticator 实例源码

项目:keywhiz    文件:LdapAuthenticatorFactory.java   
@Override public Authenticator<BasicCredentials, User> build(DSLContext dslContext) {
  logger.debug("Creating LDAP authenticator");
  LdapConnectionFactory connectionFactory =
      new LdapConnectionFactory(getServer(), getPort(), getUserDN(), getPassword(),
          getTrustStorePath(), getTrustStorePassword(), getTrustStoreType());
  return new LdapAuthenticator(connectionFactory, getLookup());
}
项目:keywhiz    文件:SessionLoginResource.java   
@Inject
public SessionLoginResource(@Readonly Authenticator<BasicCredentials, User> userAuthenticator,
    AuthenticatedEncryptedCookieFactory cookieFactory, XsrfProtection xsrfProtection) {
  this.userAuthenticator = userAuthenticator;
  this.cookieFactory = cookieFactory;
  this.xsrfProtection = xsrfProtection;
}
项目:dropwizard-java8    文件:AuthUtil.java   
public static Authenticator<BasicCredentials, Principal> getBasicAuthenticator(final List<String> validUsers) {
    return credentials -> {
        if (validUsers.contains(credentials.getUsername()) && "secret".equals(credentials.getPassword())) {
            return Optional.<Principal>of(new PrincipalImpl(credentials.getUsername()));
        }
        if ("bad-guy".equals(credentials.getUsername())) {
            throw new AuthenticationException("CRAP");
        }
        return Optional.empty();
    };
}
项目:dropwizard-java8    文件:AuthUtil.java   
public static Authenticator<String, Principal> getSingleUserOAuthAuthenticator(final String presented,
                                                                               final String returned) {
    return user -> {
        if (presented.equals(user)) {
            return Optional.<Principal>of(new PrincipalImpl(returned));
        }
        if ("bad-guy".equals(user)) {
            throw new AuthenticationException("CRAP");
        }
        return Optional.empty();
    };
}
项目:dropwizard-java8    文件:AuthUtil.java   
public static Authenticator<String, Principal> getMultiplyUsersOAuthAuthenticator(final List<String> validUsers) {
    return credentials -> {
        if (validUsers.contains(credentials)) {
            return Optional.<Principal>of(new PrincipalImpl(credentials));
        }
        if (credentials.equals("bad-guy")) {
            throw new AuthenticationException("CRAP");
        }
        return Optional.empty();
    };
}
项目:keywhiz    文件:BcryptAuthenticatorFactory.java   
@Override public Authenticator<BasicCredentials, User> build(DSLContext dslContext) {
  logger.debug("Creating BCrypt authenticator");
  UserDAO userDAO = new UserDAO(dslContext);
  return new BcryptAuthenticator(userDAO);
}
项目:keywhiz    文件:ServiceModule.java   
@Provides @Singleton
@Readonly Authenticator<BasicCredentials, User> authenticator(KeywhizConfig config,
    @Readonly DSLContext jooqContext) {
  return config.getUserAuthenticatorFactory().build(jooqContext);
}
项目:keywhiz    文件:UserAuthenticatorFactory.java   
/**
 * Builds an authenticator from username/password credentials to a {@link User}.
 */
Authenticator<BasicCredentials, User> build(DSLContext dslContext);