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 2015 ForgeRock AS.
015 */
016package org.forgerock.audit.events.handlers;
017
018import java.util.Set;
019
020import com.fasterxml.jackson.annotation.JsonIgnore;
021import com.fasterxml.jackson.annotation.JsonPropertyDescription;
022/**
023 * Base class for audit event handler configuration.
024 */
025public abstract class EventHandlerConfiguration {
026
027    /** Whether or not this handler is enabled. */
028    @JsonPropertyDescription("audit.handlers.all.enabled")
029    private boolean enabled = true;
030
031    /** Name of this audit event handler. */
032    @JsonPropertyDescription("audit.handlers.all.name")
033    private String name;
034
035    /** The set of topics that this audit event handler accepts. */
036    @JsonPropertyDescription("audit.handlers.all.topics")
037    private Set<String> topics;
038
039    /**
040     * Checks if the audit event handler is enabled.
041     * @return
042     *      True - If the audit event handler is enabled.
043     *      False - If the audit event handler is disabled.
044     */
045    public boolean isEnabled() {
046        return enabled;
047    }
048
049    /**
050     * Sets the enabled flag for an audit event handler.
051     * @param enabled
052     *      True - Enable the audit event handler.
053     *      False - Disable the audit event handler.
054     */
055    public void setEnabled(final boolean enabled) {
056        this.enabled = enabled;
057    }
058
059    /**
060     * Returns the name of this handler.
061     *
062     * @return the name
063     */
064    public String getName() {
065        return name;
066    }
067
068    /**
069     * Sets the name of this handler.
070     *
071     * @param name
072     *          The name
073     */
074    public void setName(String name) {
075        this.name = name;
076    }
077
078    /**
079     * Returns the names of the topics accepted by this handler.
080     *
081     * @return the set of topic names
082     */
083    public Set<String> getTopics() {
084        return topics;
085    }
086
087    /**
088     * Sets the topics accepted by this handler.
089     *
090     * @param topics
091     *          The names of all accepted topics
092     */
093    public void setTopics(Set<String> topics) {
094        this.topics = topics;
095    }
096
097    /**
098     * States if an {@link AuditEventHandler} can be used for queries.
099     * @return True - If the {@link AuditEventHandler} can be used for queries.
100     *         False - If the {@link AuditEventHandler} can not be used for queries.
101     */
102    @JsonIgnore
103    public abstract boolean isUsableForQueries();
104}