001/*
002 * The contents of this file are subject to the terms of the Common Development and
003 * Distribution License (the License). You may not use this file except in compliance with the
004 * License.
005 *
006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
007 * specific language governing permission and limitations under the License.
008 *
009 * When distributing Covered Software, include this CDDL Header Notice in each file and include
010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
011 * Header, with the fields enclosed by brackets [] replaced by your own identifying
012 * information: "Portions copyright [year] [name of copyright owner]".
013 *
014 * Copyright 2014 ForgeRock AS.
015 */
016
017package org.forgerock.openig.audit;
018
019/**
020 * An AuditSystem is an OpenIG service that helps to decouple {@link AuditEvent} producers and consumers.
021 * The AuditSystem is the primary target for audit notifications generated by decorated heap objects, it can then
022 * pre-process them before forwarding them to registered agents ({@link AuditEventListener}).
023 * <p>
024 * Concrete {@link AuditSystem} implementations could:
025 * <ul>
026 *     <li>Persist the notifications</li>
027 *     <li>Call agents in an asynchronous way (limit the latency in exchange processing, but consume more CPU)</li>
028 *     <li>Pre-filter the notifications</li>
029 * </ul>
030 */
031public interface AuditSystem extends AuditEventListener {
032    /**
033     * Key to retrieve a default {@link AuditSystem} instance from the {@link org.forgerock.openig.heap.Heap}.
034     */
035    String AUDIT_SYSTEM_HEAP_KEY = "AuditSystem";
036
037    /**
038     * Registers an event listener into this audit system.
039     * Once registered, it will receive all events generated by audit decorators hooked in this AuditSystem instance.
040     *
041     * @param listener registered listener
042     * @see ConditionalAuditEventListener
043     */
044    void registerListener(AuditEventListener listener);
045
046    /**
047     * Un-registers an event listener from this audit system.
048     * Once un-registered, it will not receive any event anymore.
049     *
050     * @param listener registered listener to un-register
051     * @see ConditionalAuditEventListener
052     */
053    void unregisterListener(AuditEventListener listener);
054}