@Override protected void configure() { bind(AuthConfiguration.class).toInstance(authConfiguration); bind(ApiKeyCredentials.class).asEagerSingleton(); bind(new TypeLiteral<Authenticator<String, AuthPrincipal>>() { }) .annotatedWith(Names.named("oauthAppAuthenticator")) .to(TokenOAuthAuthenticator.class); bind(new TypeLiteral<Authorizer<AuthPrincipal>>() { }) .annotatedWith(Names.named("oauthAppAuthorizer")) .to(TokenAuthorizer.class); bind(new TypeLiteral<Authenticator<BasicCredentials, AuthPrincipal>>() { }) .annotatedWith(Names.named("basicAppAuthenticator")) .to(BasicAuthenticator.class); List<String> multipleGroupAccessList = Lists.newArrayList(); multipleGroupAccessList.addAll( Splitter.on(",").splitToList(authConfiguration.multipleGroupAccessList)); bind(new TypeLiteral<List<String>>() { }).annotatedWith(Names.named("multipleGroupAccessList")).toInstance(multipleGroupAccessList); bind(AccessControlSupport.class).asEagerSingleton(); bind(UnauthorizedHandler.class).to(DefaultUnauthorizedHandler.class); OkHttpClient.Builder builder = new OkHttpClient.Builder() .connectTimeout(authConfiguration.remoteOAuthServer.connectTimeout, TimeUnit.MILLISECONDS) .readTimeout(authConfiguration.remoteOAuthServer.connectTimeout, TimeUnit.MILLISECONDS); OkHttpClient client = builder.build(); bind(OkHttpClient.class) .annotatedWith(Names.named("OAuthServiceClient")) .toInstance(client); logger.info("op=configure_oauth,remote_oauth_lookup_url={}", authConfiguration.remoteOAuthServer.tokenLookupURI); bind(URI.class) .annotatedWith(Names.named("OAuthServiceTokenLookupUri")) .toInstance(authConfiguration.remoteOAuthServer.tokenLookupURI); }
public OAuth2AuthFilter.Builder<C, P, T, A> setUnauthorizedHandler(UnauthorizedHandler unauthorizedHandler) { this.unauthorizedHandler = unauthorizedHandler; return this; }
/** * Sets the given unauthorized handler * * @param unauthorizedHandler an {@link UnauthorizedHandler} * @return the current builder */ public AuthFilterBuilder<C, P, T> setUnauthorizedHandler(UnauthorizedHandler unauthorizedHandler) { this.unauthorizedHandler = unauthorizedHandler; return this; }