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")); }
@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; }
@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")); }
/** * 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")); }
@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()); }
@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")); }
@Provides BasicAuthProvider<Player> providesAuthProvider(PlayerAuthenticationCache playerAuthenticationCache) { return new BasicAuthProvider<>(playerAuthenticationCache.getAuthenticator(), securityRealm); }
public BasicAuthProvider<Player> getBasicAuthProvider() { return basicAuthProvider; }
protected static ResourceTestRule.Builder createRule() { return ResourceTestRule.builder() .addProvider(new BasicAuthProvider<>(new DummyAuthenticator("username", "password", Data.Player1.PLAYER), "test")); }