本文整理汇总了Java中io.dropwizard.auth.AuthFactory类的典型用法代码示例。如果您正苦于以下问题:Java AuthFactory类的具体用法?Java AuthFactory怎么用?Java AuthFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AuthFactory类属于io.dropwizard.auth包,在下文中一共展示了AuthFactory类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: JWTAuthTestResourceConfig
import io.dropwizard.auth.AuthFactory; //导入依赖的package包/类
public JWTAuthTestResourceConfig() {
super(true, new MetricRegistry());
final Authenticator<String, String> authenticator = new Authenticator<String, String>() {
@Override
public Optional<String> authenticate(String credentials) throws AuthenticationException {
if ("good-one".equals(credentials)) {
return Optional.of("good-one");
}
if ("bad-one".equals(credentials)) {
throw new AuthenticationException("server ran out of entropy");
}
return Optional.absent();
}
};
register(AuthFactory.binder(new JwtAuthFactory<>(authenticator, REALM, String.class).prefix(PREFIX)));
register(AuthResource.class);
}
开发者ID:andban,项目名称:dropwizard-auth-jwt,代码行数:22,代码来源:JwtAuthFactoryTest.java
示例2: run
import io.dropwizard.auth.AuthFactory; //导入依赖的package包/类
@Override
public void run(final ServiceRegistryConfiguration configuration, final Environment environment) throws Exception {
final DataSourceFactory database = configuration.getDatabase();
// execute DB migrations
final Flyway flyway = new Flyway();
flyway.setDataSource(database.getUrl(), database.getUser(), database.getPassword());
log.debug("execute database migrations");
flyway.migrate();
log.info("database migrations successfully executed");
// create DBI instance
final DBIFactory factory = new DBIFactory();
final DBI jdbi = factory.build(environment, database, "postgresql");
environment.jersey().register(AuthFactory.binder(new BasicAuthFactory<>(
new ServiceRegistryAuthenticator(configuration.getCredentials()), "Realm", ServiceRegistryCaller.class))
);
environment.jersey().register(new ServiceResource(jdbi.onDemand(ServiceDAO.class)));
}
开发者ID:bitionaire,项目名称:el-bombillo,代码行数:21,代码来源:ServiceRegistryApplication.java
示例3: registerAuthorizationProviders
import io.dropwizard.auth.AuthFactory; //导入依赖的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
示例4: run
import io.dropwizard.auth.AuthFactory; //导入依赖的package包/类
@Override
public void run(DropwizardServerConfiguration configuration, Environment environment) throws Exception {
environment.healthChecks().register("template", guiceBundle.getInjector().getInstance(TemplateHealthCheck.class));
environment.jersey().register(guiceBundle.getInjector().getInstance(HelloWorldResource.class));
environment.jersey().register(guiceBundle.getInjector().getInstance(CarsResource.class));
environment.jersey().register(guiceBundle.getInjector().getInstance(CarResource.class));
environment.jersey().register(AuthFactory.binder(
new OAuthFactory<>(guiceBundle.getInjector().getInstance(FacebookTokenAuthenticator.class),
getName() + "-Realm",
User.class)));
}
开发者ID:cdelmas,项目名称:microservices-comparison,代码行数:12,代码来源:DropwizardApplication.java
示例5: run
import io.dropwizard.auth.AuthFactory; //导入依赖的package包/类
@Override
public void run(BiblioConfiguration configuration, Environment environment) throws Exception {
final IdGenerator idGenerator = new IdGenerator();
environment.jersey().register(new UnexpectedExceptionMapper(idGenerator));
environment.jersey().register(AuthenticationErrorMapper.class);
environment.jersey().register(UnauthorizedExceptionMapper.class);
environment.jersey().register(IllegalArgumentExceptionMapper.class);
final CacheConfiguration cacheConfig = configuration.getCacheConfiguration();
final JedisPool pool = new JedisPool(new GenericObjectPoolConfig(), cacheConfig.getAddress(),
cacheConfig.getPort(), cacheConfig.getSessionExpiration(), cacheConfig.getPassword(), Protocol.DEFAULT_DATABASE);
final Jedis jedis = pool.getResource();
pool.returnResource(jedis);
final UserDao userDao = new UserDao(hibernate.getSessionFactory());
final BookDao bookDao = new BookDao(hibernate.getSessionFactory());
final SessionDao sessionDao = new SessionDao(pool, configuration.getCacheConfiguration());
environment.jersey().register(new UserResource(userDao, sessionDao));
environment.jersey().register(new BarCodeResource(bookDao));
environment.jersey().register(new BookResource(bookDao));
environment.jersey().register(new IsbnResource(bookDao));
environment.jersey().register(new LendResource());
environment.jersey().register(
AuthFactory.binder(
new TokenAuthFactory<>(
new UserAuthenticator(userDao, sessionDao),
"SECURITY REALM",
User.class)));
}
开发者ID:adelolmo,项目名称:biblio-server,代码行数:35,代码来源:BiblioApplication.java
示例6: run
import io.dropwizard.auth.AuthFactory; //导入依赖的package包/类
@Override
public void run(final AccountServiceConfiguration configuration, final Environment environment) throws Exception {
final DataSourceFactory database = configuration.getDatabase();
this.executeDatabaseMigrations(database);
// create DBI instance
final DBIFactory factory = new DBIFactory();
final DBI jdbi = factory.build(environment, database, "postgresql");
// create a HTTP client
final Client client = new JerseyClientBuilder(environment).using(configuration.getHttpClient()).build("httpClient");
// setup listener which will register this service within the service registry
final AccountServiceLifecycleListener accountServiceLifecycleListener = new AccountServiceLifecycleListener(configuration.getServiceInformation(), configuration.getRegistryService(), client);
environment.lifecycle().addServerLifecycleListener(accountServiceLifecycleListener);
environment.healthChecks().register("registry", new ServiceRegistryHealthCheck(accountServiceLifecycleListener));
environment.admin().addTask(new ServiceRegistryTask(accountServiceLifecycleListener));
// enable the linking feature of jersey
environment.jersey().getResourceConfig().packages(getClass().getPackage().getName()).register(DeclarativeLinkingFeature.class);
// register authenticator
environment.jersey().register(AuthFactory.binder(new BasicAuthFactory<>(
new AccountServiceAuthenticator(configuration.getServiceInformation()), "Realm", AccountServiceCaller.class))
);
// register REST resources
environment.jersey().register(new AccountResource(jdbi.onDemand(AccountDAO.class)));
}
开发者ID:bitionaire,项目名称:el-bombillo,代码行数:30,代码来源:AccountServiceApplication.java
示例7: run
import io.dropwizard.auth.AuthFactory; //导入依赖的package包/类
@Override
public void run(T bundleConfiguration, Environment environment) throws Exception {
ApiKeyConfiguration configuration = bundleConfiguration.getApiKeyConfiguration();
Optional<AuthConfiguration> basic = configuration.getBasicConfiguration();
checkState(basic.isPresent(), "A basic-http configuration option must be specified");
AuthFactory<?, String> factory = createBasicAuthFactory(basic.get(), environment.metrics());
environment.jersey().register(AuthFactory.binder(factory));
}
开发者ID:dropwizard-bundles,项目名称:dropwizard-api-key-bundle,代码行数:11,代码来源:ApiKeyBundle.java
示例8: run
import io.dropwizard.auth.AuthFactory; //导入依赖的package包/类
@Override
public void run(CroudTripConfig configuration, Environment environment) throws Exception {
Injector injector = Guice.createInjector(
new DbModule(hibernateBundle.getSessionFactory()),
new DirectionsModule(configuration),
new GcmModule(configuration.getGoogleAPIKey()),
new TripsModule(),
new PlacesModule( configuration ));
// start managed instances (manually since deployment via WAR file does not seem to work)
injector.getInstance(TripReservationGarbageCollectionExecutor.class).start();
injector.getInstance(RunningTripQueryGarbageCollectionExecutor.class).start();
injector.getInstance(DisableTripOffersExecutor.class).start();
injector.getInstance(ExpireTripOffersExecutor.class).start();
injector.getInstance(ExpireJoinTripRequestsExecutor.class).start();
// setup REST api
environment.jersey().register(injector.getInstance(UsersResource.class));
environment.jersey().register(injector.getInstance(UsersHeadResource.class));
environment.jersey().register(injector.getInstance(AvatarsResource.class));
environment.jersey().register(injector.getInstance(TripsResource.class));
environment.jersey().register(injector.getInstance(VehicleResource.class));
environment.jersey().register(injector.getInstance(GcmRegistrationResource.class));
environment.jersey().register(injector.getInstance(LogsResource.class));
environment.jersey().register(injector.getInstance(NotFoundExceptionMapper.class));
environment.jersey().register(injector.getInstance(JsonExceptionMapper.class));
environment.jersey().register(injector.getInstance(RouteNotFoundExceptionMapper.class));
environment.jersey().register(injector.getInstance(ThrowableExceptionMapper.class));
environment.jersey().register(AuthFactory.binder(new BasicAuthFactory<>(
injector.getInstance(BasicAuthenticator.class),
"all secret",
User.class)));
// register a set of "default" users
SessionFactory sessionFactory = injector.getInstance(SessionFactory.class);
UserManager userManager = injector.getInstance(UserManager.class);
Session session = null;
try {
session = sessionFactory.openSession();
ManagedSessionContext.bind(session);
for (UserDescription user : configuration.getUsers()) {
if (!userManager.findUserByEmail(user.getEmail()).isPresent()) {
userManager.addUser(user);
}
}
} catch (Exception e) {
throw e;
} finally {
if (session != null) {
session.flush();
session.close();
}
}
}
开发者ID:AMOS-2015,项目名称:amos-ss15-proj2,代码行数:56,代码来源:CroudTripApplication.java
示例9: run
import io.dropwizard.auth.AuthFactory; //导入依赖的package包/类
@Override
public void run(DjConfiguration configuration,
Environment environment) {
final HttpClient client = new HttpClientBuilder(environment).using(configuration.getHttpClientConfiguration())
.build("http-client");
final DBIFactory factory = new DBIFactory();
final DBI jdbi = factory.build(environment, configuration.getDataSourceFactory(), "postgresql");
final DbMetaDAO meta = jdbi.onDemand(DbMetaDAO.class);
int currentDbVersion = 1; //if this is ever incremented, you need to fix the below code to be a "real" migration system!
if(!meta.songqueueTableExists()) {
//we are creating a fresh new db
meta.createSongqueueTable();
meta.createMetaTable();
meta.insertDbVersion(currentDbVersion);
}
if(!meta.metaTableExists()) {
//we are updating from version 0 of the db when there was no meta table
meta.createMetaTable();
meta.insertDbVersion(currentDbVersion);
meta.addSiteColumn();
meta.populateLegacySoundcloudIds();
meta.populateLegacyYoutubeIds();
}
jdbi.close(meta);
final SongQueueDAO dao = jdbi.onDemand(SongQueueDAO.class);
DjResource resource = new DjResource(configuration, client, dao);
environment.jersey().register(resource);
final ChannelCheck channelCheck = new ChannelCheck(resource);
if(configuration.isDjbotPublic()) {
String adminUsername = configuration.getAdminUsername();
String adminPassword = configuration.getAdminPassword();
if(StringUtils.isBlank(adminUsername) || StringUtils.isBlank(adminPassword)) {
throw new RuntimeException("Djbot is set to public, so it needs an adminUsername and adminPassword");
}
environment.jersey().register(AuthFactory.binder(
new BasicAuthFactory<User>(
new ConfiguredUserAuthenticator(adminUsername, adminPassword),
"djBotRealm",
User.class )));
}
environment.healthChecks().register("currentSong", channelCheck);
}
开发者ID:Hyphen-ated,项目名称:DJBot,代码行数:55,代码来源:DjApplication.java
示例10: createAuthProvider
import io.dropwizard.auth.AuthFactory; //导入依赖的package包/类
private Binder createAuthProvider() {
JsonWebTokenParser tokenParser = new DefaultJsonWebTokenParser();
final HmacSHA512Verifier tokenVerifier = new HmacSHA512Verifier(AuthHelper.authKey);
Binder authProvider = AuthFactory.binder(new JWTAuthFactory<>(new ExampleAuthenticator(), "realm", User.class, tokenVerifier, tokenParser));
return authProvider;
}
开发者ID:oregami,项目名称:oregami-server,代码行数:7,代码来源:OregamiApplication.java
注:本文中的io.dropwizard.auth.AuthFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论