Java 类io.dropwizard.auth.basic.BasicAuthProvider 实例源码

项目:log-dropwizard-eureka-mongo-sample    文件:BreakerboxService.java   
private static void setupLdapAuth(LdapConfiguration ldapConfiguration, Environment environment) {
    final LdapAuthenticator ldapAuthenticator = new LdapAuthenticator(ldapConfiguration);
    final ResourceAuthenticator canAuthenticate = new ResourceAuthenticator(
            new LdapCanAuthenticate(ldapConfiguration));
    final CachingAuthenticator<BasicCredentials, BasicCredentials> cachingAuthenticator =
            new CachingAuthenticator<>(
                    environment.metrics(),
                    TenacityAuthenticator.wrap(
                            new ResourceAuthenticator(ldapAuthenticator), BreakerboxDependencyKey.BRKRBX_LDAP_AUTH),
                    ldapConfiguration.getCachePolicy()
            );

    environment.healthChecks().register("ldap-auth", new LdapHealthCheck<>(TenacityAuthenticator
            .wrap(canAuthenticate, BreakerboxDependencyKey.BRKRBX_LDAP_AUTH)));
    environment.jersey().register(new BasicAuthProvider<>(cachingAuthenticator, "breakerbox"));
}
项目:restwars    文件:CompositionRoot.java   
@Inject
public CompositionRoot(SystemResource systemResource, PlayerResource playerResource, TechnologyResource technologyResource, PlanetResource planetResource, MetadataResource metadataResource, EventResource eventResource, FightResource fightResource, RootResource rootResource, FlightResource flightResource, Clock clock, LockingFilter lockingFilter, UnitOfWorkService unitOfWorkService, BasicAuthProvider<Player> basicAuthProvider) {
    this.systemResource = systemResource;
    this.playerResource = playerResource;
    this.technologyResource = technologyResource;
    this.planetResource = planetResource;
    this.metadataResource = metadataResource;
    this.eventResource = eventResource;
    this.fightResource = fightResource;
    this.rootResource = rootResource;
    this.flightResource = flightResource;
    this.clock = clock;
    this.lockingFilter = lockingFilter;
    this.unitOfWorkService = unitOfWorkService;
    this.basicAuthProvider = basicAuthProvider;
}
项目:dropwizard    文件:App.java   
@Override
public void run(BookConfiguration c, Environment e)
        throws Exception {
    LOGGER.info("Restful book app running by "
            + c.getTeam()
            + " team with "
            + c.getTeamSize()
            + " members.");

    // Add the resource to the environment
    e.jersey().register(new BookResource());
    e.jersey().register(new BasicAuthProvider<Boolean>(new DefaultAuthenticator(), "Restfull API authentication"));
}
项目:dropwizard    文件:App.java   
/**
 * example of registering cache authenticator
 *
 * @param e
 */
private void registerCacheAuthenticator(Environment e) {
    CachingAuthenticator<BasicCredentials, Boolean> authenticator
            = new CachingAuthenticator<BasicCredentials, Boolean>(
            e.metrics(), new DefaultAuthenticator(), CacheBuilderSpec.parse("maximumSize=100, expireAfterAccess=30m")
    );
    e.jersey().register(new BasicAuthProvider<Boolean>(authenticator, "Cached restfull API authentication"));

}
项目:dropwizard    文件:App.java   
@Override
public void run(BookConfiguration c, Environment e)
        throws Exception {
    LOGGER.info("Restful book app running by "
            + c.getTeam()
            + " team with "
            + c.getTeamSize()
            + " members.");

    // Add the resource to the environment
    e.jersey().register(new BookResource());
    e.jersey().register(new BasicAuthProvider<Boolean>(new DefaultAuthenticator(), "Restfull API authentication"));
}
项目:dropwizard    文件:App.java   
/**
 * example of registering cache authenticator
 *
 * @param e
 */
private void registerCacheAuthenticator(Environment e) {
    CachingAuthenticator<BasicCredentials, Boolean> authenticator
            = new CachingAuthenticator<BasicCredentials, Boolean>(
            e.metrics(), new DefaultAuthenticator(), CacheBuilderSpec.parse("maximumSize=100, expireAfterAccess=30m")
    );
    e.jersey().register(new BasicAuthProvider<Boolean>(authenticator, "Cached restfull API authentication"));

}
项目:api_dropwizard    文件:RentMyCourtApplication.java   
@Override
public void run(RentMyCourtConfiguration configuration, Environment environment) {
   configureCors(environment);
   environment.jersey().register(new BasicAuthProvider<User>(new SimpleAuthenticator(), "SUPER SECRET STUFF"));
   final DataHealthCheck dataHealthCheck = new DataHealthCheck(configuration.getRestaurants());
   environment.healthChecks().register("data", dataHealthCheck);
   final UserDAO dao = new UserDAO(hibernate.getSessionFactory());
   environment.jersey().register(new UserResource(dao));
   swaggerDropwizard.onRun(configuration, environment, this.getNameServer());
}
项目:Ka-Websocket    文件:ExampleApplication.java   
@Override
public void run(ExampleConfiguration configuration, Environment environment) throws Exception {
    Authenticator<BasicCredentials, User> authenticator = new ExampleAuthenticator();
    WebSocketInitializer<ExampleConfiguration> webSocketInitializer =
                new WebSocketInitializer.Builder<ExampleConfiguration>(configuration, environment)
                    .basicAuthenticator(authenticator).build();
     environment.jersey().register(new PingResource());
    webSocketInitializer.onRun();
    webSocketInitializer.addWebocket(new ChatServer());
    environment.servlets().setSessionHandler(new SessionHandler());
    environment.jersey().register(new BasicAuthProvider<User>(authenticator, "My Realm"));

}
项目:restwars    文件:RestWarsModule.java   
@Provides
BasicAuthProvider<Player> providesAuthProvider(PlayerAuthenticationCache playerAuthenticationCache) {
    return new BasicAuthProvider<>(playerAuthenticationCache.getAuthenticator(), securityRealm);
}
项目:restwars    文件:CompositionRoot.java   
public BasicAuthProvider<Player> getBasicAuthProvider() {
    return basicAuthProvider;
}
项目:restwars    文件:AbstractResourceTest.java   
protected static ResourceTestRule.Builder createRule() {
    return ResourceTestRule.builder()
            .addProvider(new BasicAuthProvider<>(new DummyAuthenticator("username", "password", Data.Player1.PLAYER), "test"));
}