AuditEventPublisher.java revision 2dd75eff92ef66e22cca286b6f4fe5a9c929af9d
/*
* The contents of this file are subject to the terms of the Common Development and
* Distribution License (the License). You may not use this file except in compliance with the
* License.
*
* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
* specific language governing permission and limitations under the License.
*
* When distributing Covered Software, include this CDDL Header Notice in each file and include
* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions copyright [year] [name of copyright owner]".
*
* Copyright 2015 ForgeRock AS.
*/
/**
* Responsible for publishing locally created audit events to the AuditService.
*
* @since 13.0.0
*/
public class AuditEventPublisher {
private final AuditService auditService;
private final ConnectionFactory auditServiceConnectionFactory;
private final AuditServiceConfigurator configurator;
/**
* @param auditService AuditService to which events should be published.
*/
this.auditService = auditService;
this.configurator = configurator;
}
/**
* Publishes the provided AuditEvent to the specified topic of the AuditService.
* <p/>
* If an error occurs that prevents the AuditEvent from being published, then details regarding the error
* are recorded in the debug logs. However, the debug logs are not be treated as the fallback destination
* for audit information. If we need guaranteed capture of audit information then this needs to be a feature
* of the audit service itself. Also, the audit event may contain sensitive information that shouldn't be
* stored in debug logs.
* <p/>
* After recording details of the error, the exception will only be propagated back to the caller if the
* 'suppress exceptions' configuration option is set to false.
*
* @param topic Coarse-grained categorization of the AuditEvent's type.
* @param auditEvent The AuditEvent to publish.
*
* @throws AuditException if an exception occurs while trying to publish the audit event.
*/
try {
} catch (ResourceException e) {
if (!isSuppressExceptions()) {
}
}
}
/**
* Tries to publish the provided AuditEvent to the specified topic of the AuditService.
* <p/>
* If an exception occurs, details are logged but the exception is suppressed.
*
* @param topic Coarse-grained categorization of the AuditEvent's type.
* @param auditEvent The AuditEvent to publish.
*/
try {
} catch (AuditException e) {
// suppress
}
}
}
return configurator.getAuditServiceConfiguration().isAuditEnabled() && auditService.isAuditing(topic);
}
/**
* @return True if the operation being audited can proceed if an exception occurs while publishing an audit event.
*/
public boolean isSuppressExceptions() {
}
}