Search in sources :

Example 1 with JerseyEnvironment

use of io.dropwizard.jersey.setup.JerseyEnvironment in project dropwizard by dropwizard.

the class HibernateBundleTest method setUp.

@Before
@SuppressWarnings("unchecked")
public void setUp() throws Exception {
    when(environment.healthChecks()).thenReturn(healthChecks);
    when(environment.jersey()).thenReturn(jerseyEnvironment);
    when(jerseyEnvironment.getResourceConfig()).thenReturn(new DropwizardResourceConfig());
    when(factory.build(eq(bundle), any(Environment.class), any(DataSourceFactory.class), anyList(), eq("hibernate"))).thenReturn(sessionFactory);
}
Also used : DataSourceFactory(io.dropwizard.db.DataSourceFactory) DropwizardResourceConfig(io.dropwizard.jersey.DropwizardResourceConfig) Environment(io.dropwizard.setup.Environment) JerseyEnvironment(io.dropwizard.jersey.setup.JerseyEnvironment) Before(org.junit.Before)

Example 2 with JerseyEnvironment

use of io.dropwizard.jersey.setup.JerseyEnvironment in project keywhiz by square.

the class KeywhizService method run.

@SuppressWarnings("unchecked")
@Override
public void run(KeywhizConfig config, Environment environment) throws Exception {
    if (injector == null) {
        logger.debug("No existing guice injector; creating new one");
        injector = Guice.createInjector(new ServiceModule(config, environment));
    }
    JerseyEnvironment jersey = environment.jersey();
    logger.debug("Registering resource filters");
    jersey.register(injector.getInstance(ClientCertificateFilter.class));
    logger.debug("Registering servlet filters");
    environment.servlets().addFilter("security-headers-filter", injector.getInstance(SecurityHeadersFilter.class)).addMappingForUrlPatterns(null, /* Default is for requests */
    false, /* Can be after other filters */
    "/*");
    jersey.register(injector.getInstance(CookieRenewingFilter.class));
    environment.servlets().addFilter("xsrf-filter", injector.getInstance(XsrfServletFilter.class)).addMappingForUrlPatterns(null, /* Default is for requests */
    false, /* Can be after other filters */
    "/admin/*");
    logger.debug("Registering providers");
    jersey.register(new AuthResolver.Binder(injector.getInstance(ClientAuthFactory.class), injector.getInstance(AutomationClientAuthFactory.class), injector.getInstance(UserAuthFactory.class)));
    logger.debug("Registering resources");
    jersey.register(injector.getInstance(ClientResource.class));
    jersey.register(injector.getInstance(ClientsResource.class));
    jersey.register(injector.getInstance(GroupResource.class));
    jersey.register(injector.getInstance(GroupsResource.class));
    jersey.register(injector.getInstance(MembershipResource.class));
    jersey.register(injector.getInstance(SecretsDeliveryResource.class));
    jersey.register(injector.getInstance(SecretResource.class));
    jersey.register(injector.getInstance(SecretsResource.class));
    jersey.register(injector.getInstance(SecretDeliveryResource.class));
    jersey.register(injector.getInstance(SessionLoginResource.class));
    jersey.register(injector.getInstance(SessionLogoutResource.class));
    jersey.register(injector.getInstance(SessionMeResource.class));
    jersey.register(injector.getInstance(AutomationClientResource.class));
    jersey.register(injector.getInstance(AutomationGroupResource.class));
    jersey.register(injector.getInstance(AutomationSecretResource.class));
    jersey.register(injector.getInstance(AutomationEnrollClientGroupResource.class));
    jersey.register(injector.getInstance(AutomationSecretAccessResource.class));
    jersey.register(injector.getInstance(StatusResource.class));
    ManualStatusHealthCheck mshc = new ManualStatusHealthCheck();
    environment.healthChecks().register("manualStatus", mshc);
    environment.admin().addServlet("manualStatus", new ManualStatusServlet(mshc)).addMapping("/status/*");
    validateDatabase(config);
    logger.debug("Keywhiz configuration complete");
}
Also used : CookieRenewingFilter(keywhiz.service.filters.CookieRenewingFilter) StatusResource(keywhiz.service.resources.StatusResource) AutomationSecretAccessResource(keywhiz.service.resources.automation.AutomationSecretAccessResource) AutomationClientResource(keywhiz.service.resources.automation.AutomationClientResource) JerseyEnvironment(io.dropwizard.jersey.setup.JerseyEnvironment) AutomationSecretResource(keywhiz.service.resources.automation.AutomationSecretResource) AutomationGroupResource(keywhiz.service.resources.automation.AutomationGroupResource) AutomationSecretResource(keywhiz.service.resources.automation.AutomationSecretResource) SecretResource(keywhiz.service.resources.automation.v2.SecretResource) AuthResolver(keywhiz.service.providers.AuthResolver) AutomationClientResource(keywhiz.service.resources.automation.AutomationClientResource) ClientResource(keywhiz.service.resources.automation.v2.ClientResource) SecretsDeliveryResource(keywhiz.service.resources.SecretsDeliveryResource) SecretDeliveryResource(keywhiz.service.resources.SecretDeliveryResource) AutomationEnrollClientGroupResource(keywhiz.service.resources.automation.AutomationEnrollClientGroupResource) AutomationGroupResource(keywhiz.service.resources.automation.AutomationGroupResource) GroupResource(keywhiz.service.resources.automation.v2.GroupResource) ClientCertificateFilter(keywhiz.auth.mutualssl.ClientCertificateFilter) AutomationEnrollClientGroupResource(keywhiz.service.resources.automation.AutomationEnrollClientGroupResource)

Example 3 with JerseyEnvironment

use of io.dropwizard.jersey.setup.JerseyEnvironment in project dropwizard by dropwizard.

the class DBIExceptionsBundleTest method test.

@Test
public void test() {
    Environment environment = mock(Environment.class);
    JerseyEnvironment jerseyEnvironment = mock(JerseyEnvironment.class);
    when(environment.jersey()).thenReturn(jerseyEnvironment);
    new DBIExceptionsBundle().run(environment);
    verify(jerseyEnvironment, times(1)).register(isA(LoggingSQLExceptionMapper.class));
    verify(jerseyEnvironment, times(1)).register(isA(LoggingDBIExceptionMapper.class));
}
Also used : JerseyEnvironment(io.dropwizard.jersey.setup.JerseyEnvironment) LoggingDBIExceptionMapper(io.dropwizard.jdbi.jersey.LoggingDBIExceptionMapper) LoggingSQLExceptionMapper(io.dropwizard.jdbi.jersey.LoggingSQLExceptionMapper) Environment(io.dropwizard.setup.Environment) JerseyEnvironment(io.dropwizard.jersey.setup.JerseyEnvironment) Test(org.junit.Test)

Aggregations

JerseyEnvironment (io.dropwizard.jersey.setup.JerseyEnvironment)3 Environment (io.dropwizard.setup.Environment)2 DataSourceFactory (io.dropwizard.db.DataSourceFactory)1 LoggingDBIExceptionMapper (io.dropwizard.jdbi.jersey.LoggingDBIExceptionMapper)1 LoggingSQLExceptionMapper (io.dropwizard.jdbi.jersey.LoggingSQLExceptionMapper)1 DropwizardResourceConfig (io.dropwizard.jersey.DropwizardResourceConfig)1 ClientCertificateFilter (keywhiz.auth.mutualssl.ClientCertificateFilter)1 CookieRenewingFilter (keywhiz.service.filters.CookieRenewingFilter)1 AuthResolver (keywhiz.service.providers.AuthResolver)1 SecretDeliveryResource (keywhiz.service.resources.SecretDeliveryResource)1 SecretsDeliveryResource (keywhiz.service.resources.SecretsDeliveryResource)1 StatusResource (keywhiz.service.resources.StatusResource)1 AutomationClientResource (keywhiz.service.resources.automation.AutomationClientResource)1 AutomationEnrollClientGroupResource (keywhiz.service.resources.automation.AutomationEnrollClientGroupResource)1 AutomationGroupResource (keywhiz.service.resources.automation.AutomationGroupResource)1 AutomationSecretAccessResource (keywhiz.service.resources.automation.AutomationSecretAccessResource)1 AutomationSecretResource (keywhiz.service.resources.automation.AutomationSecretResource)1 ClientResource (keywhiz.service.resources.automation.v2.ClientResource)1 GroupResource (keywhiz.service.resources.automation.v2.GroupResource)1 SecretResource (keywhiz.service.resources.automation.v2.SecretResource)1