Search in sources :

Example 6 with AMAuditServiceConfiguration

use of org.forgerock.openam.audit.configuration.AMAuditServiceConfiguration in project OpenAM by OpenRock.

the class AuditServiceProviderImplTest method shouldNotRegisterHandlersWhenDefaultAuditServiceDisabled.

@Test
public void shouldNotRegisterHandlersWhenDefaultAuditServiceDisabled() throws Exception {
    // Given
    auditServiceConfig = new AMAuditServiceConfiguration(false);
    // When
    configListener.globalConfigurationChanged();
    // Then
    assertThat(provider.getDefaultAuditService().getRegisteredHandler("Mock Handler")).isNull();
}
Also used : AMAuditServiceConfiguration(org.forgerock.openam.audit.configuration.AMAuditServiceConfiguration) Test(org.testng.annotations.Test)

Example 7 with AMAuditServiceConfiguration

use of org.forgerock.openam.audit.configuration.AMAuditServiceConfiguration in project OpenAM by OpenRock.

the class AuditEventPublisherImplTest method givenDefaultAuditService.

private void givenDefaultAuditService() throws ServiceUnavailableException, AuditException {
    AMAuditServiceConfiguration serviceConfig = new AMAuditServiceConfiguration(true);
    AuditServiceBuilder builder = AuditServiceBuilder.newAuditService().withConfiguration(serviceConfig).withAuditEventHandler(mockHandler);
    AMAuditService auditService = new DefaultAuditServiceProxy(builder.build(), serviceConfig);
    auditService.startup();
    when(auditServiceProvider.getDefaultAuditService()).thenReturn(auditService);
}
Also used : AuditServiceBuilder(org.forgerock.audit.AuditServiceBuilder) AMAuditServiceConfiguration(org.forgerock.openam.audit.configuration.AMAuditServiceConfiguration)

Example 8 with AMAuditServiceConfiguration

use of org.forgerock.openam.audit.configuration.AMAuditServiceConfiguration in project OpenAM by OpenRock.

the class AuditEventPublisherImplTest method givenSuppressedFailureAuditService.

private void givenSuppressedFailureAuditService() throws ServiceUnavailableException, AuditException {
    AMAuditServiceConfiguration serviceConfig = new AMAuditServiceConfiguration(true);
    AuditServiceBuilder builder = AuditServiceBuilder.newAuditService().withConfiguration(serviceConfig).withAuditEventHandler(mockHandler);
    AMAuditService auditService = new RealmAuditServiceProxy(builder.build(), mock(AMAuditService.class), serviceConfig);
    auditService.startup();
    when(auditServiceProvider.getAuditService(FAILURE_SUPPRESSED_REALM)).thenReturn(auditService);
}
Also used : AuditServiceBuilder(org.forgerock.audit.AuditServiceBuilder) AMAuditServiceConfiguration(org.forgerock.openam.audit.configuration.AMAuditServiceConfiguration)

Example 9 with AMAuditServiceConfiguration

use of org.forgerock.openam.audit.configuration.AMAuditServiceConfiguration in project OpenAM by OpenRock.

the class AuditServiceProviderImpl method refreshRealmAuditService.

private void refreshRealmAuditService(String realm) {
    AMAuditServiceConfiguration configuration = configProvider.getRealmConfiguration(realm);
    AuditServiceBuilder builder = AuditServiceBuilder.newAuditService().withEventTopicsMetaData(eventTopicsMetaData).withConfiguration(configuration);
    if (configuration.isAuditEnabled()) {
        configureEventHandlers(builder, configProvider.getRealmEventHandlerConfigurations(realm));
    }
    AMAuditService auditService = auditServices.get(realm);
    try {
        if (auditService == null) {
            auditService = new RealmAuditServiceProxy(builder.build(), defaultAuditService, configuration);
            auditService.startup();
            auditServices.put(realm, auditService);
        } else {
            auditService.setDelegate(builder.build(), configuration);
        }
    } catch (ServiceUnavailableException e) {
        debug.error("New Audit Service configuration for realm {} failed.", e, realm);
        // remove it so that we can fall back to the default service
        auditServices.remove(realm);
    }
}
Also used : AuditServiceBuilder(org.forgerock.audit.AuditServiceBuilder) AMAuditServiceConfiguration(org.forgerock.openam.audit.configuration.AMAuditServiceConfiguration) ServiceUnavailableException(org.forgerock.json.resource.ServiceUnavailableException)

Example 10 with AMAuditServiceConfiguration

use of org.forgerock.openam.audit.configuration.AMAuditServiceConfiguration in project OpenAM by OpenRock.

the class AuditServiceProviderImpl method createDefaultAuditService.

private DefaultAuditServiceProxy createDefaultAuditService() {
    AMAuditServiceConfiguration configuration = new AMAuditServiceConfiguration(false);
    configuration.setAvailableAuditEventHandlers(Collections.<String>emptyList());
    AuditServiceBuilder builder = AuditServiceBuilder.newAuditService().withEventTopicsMetaData(eventTopicsMetaData).withConfiguration(configuration);
    DefaultAuditServiceProxy auditServiceProxy = new DefaultAuditServiceProxy(builder.build(), configuration);
    try {
        auditServiceProxy.startup();
    } catch (ServiceUnavailableException e) {
        debug.error("Default Audit Service configuration failed.", e);
    }
    return auditServiceProxy;
}
Also used : AuditServiceBuilder(org.forgerock.audit.AuditServiceBuilder) AMAuditServiceConfiguration(org.forgerock.openam.audit.configuration.AMAuditServiceConfiguration) ServiceUnavailableException(org.forgerock.json.resource.ServiceUnavailableException)

Aggregations

AMAuditServiceConfiguration (org.forgerock.openam.audit.configuration.AMAuditServiceConfiguration)10 AuditServiceBuilder (org.forgerock.audit.AuditServiceBuilder)7 ServiceUnavailableException (org.forgerock.json.resource.ServiceUnavailableException)3 Test (org.testng.annotations.Test)3 BeforeMethod (org.testng.annotations.BeforeMethod)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 AuditEvent (org.forgerock.audit.events.AuditEvent)1 AuditEventHandler (org.forgerock.audit.events.handlers.AuditEventHandler)1 AMAuditService (org.forgerock.openam.audit.AMAuditService)1 AuditEventFactory (org.forgerock.openam.audit.AuditEventFactory)1 AuditEventPublisher (org.forgerock.openam.audit.AuditEventPublisher)1 AuditServiceProvider (org.forgerock.openam.audit.AuditServiceProvider)1 DefaultAuditServiceProxy (org.forgerock.openam.audit.DefaultAuditServiceProxy)1 AuditEventHandlerConfiguration (org.forgerock.openam.audit.configuration.AuditEventHandlerConfiguration)1 Context (org.forgerock.services.context.Context)1 Restlet (org.restlet.Restlet)1