当前位置: 首页>>代码示例>>Java>>正文


Java CachingAuthenticator类代码示例

本文整理汇总了Java中io.dropwizard.auth.CachingAuthenticator的典型用法代码示例。如果您正苦于以下问题:Java CachingAuthenticator类的具体用法?Java CachingAuthenticator怎么用?Java CachingAuthenticator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CachingAuthenticator类属于io.dropwizard.auth包,在下文中一共展示了CachingAuthenticator类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configure

import io.dropwizard.auth.CachingAuthenticator; //导入依赖的package包/类
@Override
public boolean configure(final FeatureContext featureContext) {
    final UserRepository userRepo = CDI.current().select(UserRepository.class).get();
    final Authenticator<String, User> authenticator = new GoogleAuthenticator(
            authConfig.getClientId(), userRepo, authConfig.getHostedDomain()
    );

    final Authenticator<String, User> cachingAuthenticator = new CachingAuthenticator<>(
            metricRegistry, authenticator, authConfig.getAuthenticationCachePolicy()
    );

    featureContext.register(new AuthDynamicFeature(
            new OAuthCredentialAuthFilter.Builder<User>()
            .setAuthenticator(cachingAuthenticator)
            .setPrefix("Bearer")
            .buildAuthFilter()));
    featureContext.register(new AuthValueFactoryProvider.Binder<>(User.class));

    return true;
}
 
开发者ID:PaperCutSoftware,项目名称:dust-api,代码行数:21,代码来源:AuthenticatorFeature.java

示例2: setupLdapAuth

import io.dropwizard.auth.CachingAuthenticator; //导入依赖的package包/类
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"));
}
 
开发者ID:guggens,项目名称:log-dropwizard-eureka-mongo-sample,代码行数:17,代码来源:BreakerboxService.java

示例3: setupLdapAuth

import io.dropwizard.auth.CachingAuthenticator; //导入依赖的package包/类
private static void setupLdapAuth(LdapConfiguration ldapConfiguration, Environment environment) {
    final LdapAuthenticator ldapAuthenticator = new LdapAuthenticator(ldapConfiguration);
    final CachingAuthenticator<BasicCredentials, User> cachingAuthenticator =
            new CachingAuthenticator<>(
                    environment.metrics(),
                    TenacityAuthenticator.wrap(
                            new ResourceAuthenticator(ldapAuthenticator), BreakerboxDependencyKey.BRKRBX_LDAP_AUTH),
                    ldapConfiguration.getCachePolicy()
            );
    environment.jersey().register(new AuthDynamicFeature(
                    new BasicCredentialAuthFilter.Builder<User>()
                            .setAuthenticator(cachingAuthenticator)
                            .setRealm("breakerbox")
                            .buildAuthFilter()));
    environment.jersey().register(new AuthValueFactoryProvider.Binder<>(User.class));
}
 
开发者ID:yammer,项目名称:breakerbox,代码行数:17,代码来源:BreakerboxService.java

示例4: run

import io.dropwizard.auth.CachingAuthenticator; //导入依赖的package包/类
@Override
public void run(ExampleAppConfiguration configuration, Environment environment) throws Exception {
    final LdapConfiguration ldapConfiguration = configuration.getLdapConfiguration();

    Authenticator<BasicCredentials, User> ldapAuthenticator = new CachingAuthenticator<>(
            environment.metrics(),
            new ResourceAuthenticator(new LdapAuthenticator(ldapConfiguration)),
            ldapConfiguration.getCachePolicy());

    environment.jersey().register(new AuthDynamicFeature(
            new BasicCredentialAuthFilter.Builder<User>()
                    .setAuthenticator(ldapAuthenticator)
                    .setRealm("LDAP")
                    .buildAuthFilter()));

    environment.jersey().register(new AuthValueFactoryProvider.Binder<>(User.class));

    environment.healthChecks().register("ldap", new LdapHealthCheck<>(
            new ResourceAuthenticator(new LdapCanAuthenticate(ldapConfiguration))));
}
 
开发者ID:yammer,项目名称:dropwizard-auth-ldap,代码行数:21,代码来源:ExampleAppTest.java

示例5: registerAuthorizationProviders

import io.dropwizard.auth.CachingAuthenticator; //导入依赖的package包/类
private void registerAuthorizationProviders(final AugmentedConfiguration augmentedConfiguration, final Environment environment) {
    final UserDao userDao = injector.getInstance(UserDao.class);
    final BasicAuthenticator basicAuthenticator = new BasicAuthenticator(userDao);
    final CachingAuthenticator cachingAuthenticator = new CachingAuthenticator(environment.metrics(), basicAuthenticator,
            augmentedConfiguration.getAuthCacheBuilder());
    final Binder authBinder = AuthFactory.binder(new BasicAuthFactory(cachingAuthenticator, "Basic auth", User.class));
    environment.jersey().register(authBinder);
}
 
开发者ID:blstream,项目名称:AugumentedSzczecin_java,代码行数:9,代码来源:AugmentedApplication.java

示例6: setupAuthentication

import io.dropwizard.auth.CachingAuthenticator; //导入依赖的package包/类
private void setupAuthentication(ApiServerConfig cfg, Environment env) throws Exception {
    final Client client = new RestClientBuilder(env, cfg).build(getName());

    // Health check for oauth2 server presence
    final OAuth2HealthCheck healthCheck = new OAuth2HealthCheck(cfg.getOauth2Config(), client);
    env.healthChecks().register("Oauth2 server", healthCheck);

    // Setting up the oauth2 authenticator
    CookieEncrypter cookieEncrypter = new CookieEncrypter(cfg.getOauth2Config().getCookieSecretKey());
    boolean https = ((DefaultServerFactory)cfg.getServerFactory()).getApplicationConnectors().get(0) instanceof HttpsConnectorFactory;
    cookieEncrypter.setSecureFlag(https);
    OAuth2Authenticator authenticator = new OAuth2Authenticator(cfg.getOauth2Config(), client);

    // Using cache authenticator
    CachingAuthenticator<OAuth2Credentials, User> cachingAuthenticator =
            new CachingAuthenticator<OAuth2Credentials, User>(env.metrics(), authenticator, cfg.getCacheSpec());

    final OAuth2AuthFilter<User> oAuth2AuthFilter =
            new OAuth2AuthFilter.Builder<OAuth2Credentials, User, OAuth2AuthFilter<User>, CachingAuthenticator<OAuth2Credentials, User>>()
                    .setAuthenticator(cachingAuthenticator)
                    .setCookieEncrypter(cookieEncrypter)
                    .build();

    env.jersey().register(new AuthDynamicFeature(oAuth2AuthFilter));
    env.jersey().register(RolesAllowedDynamicFeature.class);
    env.jersey().register(new AuthValueFactoryProvider.Binder<User>(User.class));

    // Register the oauth2 resource that handles client authentication
    final OAuth2Resource or = new OAuth2Resource(client, cfg.getOauth2Config(), cookieEncrypter);
    env.jersey().register(or);
}
 
开发者ID:edeoliveira,项目名称:oauth2-dropwizard,代码行数:32,代码来源:ApiServer.java

示例7: testCreateCachingAuthentiator

import io.dropwizard.auth.CachingAuthenticator; //导入依赖的package包/类
@Test
public void testCreateCachingAuthentiator() throws AuthenticationException {
    AllowedPeerConfiguration config = new AllowedPeerConfiguration();
    config.setCredentialFile("peers/test-peers.properties");
    config.setCachePolicy(CacheBuilderSpec.parse("maximumSize=100, expireAfterAccess=10m"));

    CachingAuthenticator<BasicCredentials, Peer> cachingAuthenticator =
            config.createCachingAuthenticator(new MetricRegistry());
    assertTrue(cachingAuthenticator.authenticate(new BasicCredentials("foo", "bar")).isPresent());
}
 
开发者ID:washingtonpost,项目名称:dropwizard-peer-authenticator,代码行数:11,代码来源:TestAllowedPeerConfiguration.java

示例8: createBasicAuthFactory

import io.dropwizard.auth.CachingAuthenticator; //导入依赖的package包/类
private BasicAuthFactory<String> createBasicAuthFactory(AuthConfiguration config,
                                                        MetricRegistry metrics) {
  Authenticator<BasicCredentials, String> authenticator = createAuthenticator(config);

  Optional<String> cacheSpec = config.getCacheSpec();
  if (cacheSpec.isPresent()) {
    CacheBuilderSpec spec = CacheBuilderSpec.parse(cacheSpec.get());
    authenticator = new CachingAuthenticator<>(metrics, authenticator, spec);
  }

  return new BasicAuthFactory<>(authenticator, config.getRealm(), String.class);
}
 
开发者ID:dropwizard-bundles,项目名称:dropwizard-api-key-bundle,代码行数:13,代码来源:ApiKeyBundle.java

示例9: registerCacheAuthenticator

import io.dropwizard.auth.CachingAuthenticator; //导入依赖的package包/类
/**
 * 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"));

}
 
开发者ID:JingGe,项目名称:dropwizard,代码行数:14,代码来源:App.java

示例10: createCachingAuthenticator

import io.dropwizard.auth.CachingAuthenticator; //导入依赖的package包/类
/**
 * @param metrics A metrics registry
 * @return The Authenticator you'd get by calling {@code createAuthenticator} directly, but wrapped in the Dropwizard
 * CachingAuthenticator proxy with this configuration object's {@code cachePolicy} applied to it.
 */
public CachingAuthenticator<BasicCredentials, Peer> createCachingAuthenticator(MetricRegistry metrics) {
    Preconditions.checkNotNull(this.cachePolicy, "Illegal call to createCachingAuthenticator() when the configuration "
            + "object's cachePolicy attribute is null");
    return new CachingAuthenticator<>(metrics, createAuthenticator(), this.cachePolicy);
}
 
开发者ID:washingtonpost,项目名称:dropwizard-peer-authenticator,代码行数:11,代码来源:AllowedPeerConfiguration.java


注:本文中的io.dropwizard.auth.CachingAuthenticator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。