Search in sources :

Example 6 with AuditServiceBuilder

use of org.forgerock.audit.AuditServiceBuilder 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 7 with AuditServiceBuilder

use of org.forgerock.audit.AuditServiceBuilder 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

AuditServiceBuilder (org.forgerock.audit.AuditServiceBuilder)7 AMAuditServiceConfiguration (org.forgerock.openam.audit.configuration.AMAuditServiceConfiguration)7 ServiceUnavailableException (org.forgerock.json.resource.ServiceUnavailableException)3 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 Context (org.forgerock.services.context.Context)1 Restlet (org.restlet.Restlet)1 BeforeMethod (org.testng.annotations.BeforeMethod)1 Test (org.testng.annotations.Test)1