• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java BasicAuthFactory类的典型用法和代码示例

java 1次浏览

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

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

示例1: run

点赞 3

import io.dropwizard.auth.basic.BasicAuthFactory; //导入依赖的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

示例2: registerAuthorizationProviders

点赞 2

import io.dropwizard.auth.basic.BasicAuthFactory; //导入依赖的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

示例3: run

点赞 2

import io.dropwizard.auth.basic.BasicAuthFactory; //导入依赖的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

示例4: createBasicAuthFactory

点赞 2

import io.dropwizard.auth.basic.BasicAuthFactory; //导入依赖的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

示例5: run

点赞 2

import io.dropwizard.auth.basic.BasicAuthFactory; //导入依赖的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

示例6: run

点赞 2

import io.dropwizard.auth.basic.BasicAuthFactory; //导入依赖的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


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)