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.filter; 017 018import java.util.Collection; 019import java.util.Collections; 020import java.util.LinkedList; 021import java.util.List; 022 023import com.fasterxml.jackson.annotation.JsonPropertyDescription; 024import org.forgerock.json.JsonPointer; 025 026/** 027 * Represents a FilterPolicy which contains the includeIf and excludeIf values for the filter. The includeIf property 028 * lists fields/values in {@link JsonPointer} syntax to include for the audit event. By default all audit event fields 029 * are included. The excludeIf property lists fields/values in {@link JsonPointer} syntax to exclude for the audit 030 * event. 031 * 032 * The listed fields/values should be prefixed with the topic the {@link JsonPointer} applies to. For example, the 033 * following excludeIf value: 034 * <pre> 035 * "/access/exclude/field" 036 * </pre> 037 * 038 * would exclude the field "/exclude/field" for the access audit topic. 039 * 040 * The following is an example FilterPolicy in json format. 041 * <pre> 042 * { 043 * "excludeIf" : [ 044 * "/access/exclude/field" 045 * ], 046 * "includeIf" : [ 047 * "/access/include/field" 048 * ] 049 * } 050 * </pre> 051 */ 052public class FilterPolicy { 053 @JsonPropertyDescription("audit.events.filter.policies.include") 054 private List<String> includeIf; 055 056 @JsonPropertyDescription("audit.events.filter.policies.exclude") 057 private List<String> excludeIf; 058 059 /** 060 * Gets the includeIf list. The includeIf is a list of values to include in the audit event. 061 * @return The list of includeIfs. 062 */ 063 public List<String> getIncludeIf() { 064 return includeIf == null ? Collections.<String>emptyList() : includeIf; 065 } 066 067 /** 068 * Sets the includeIf list. The includeIf is a list of values to include in the audit event. 069 * @param includeIf The list of includeIfs. 070 */ 071 public void setIncludeIf(Collection<String> includeIf) { 072 this.includeIf = new LinkedList<>(includeIf); 073 } 074 075 /** 076 * Gets the excludeIf list. The excludeIf is a list of values to exclude from the audit event. 077 * @return The list of excludeIfs. 078 */ 079 public List<String> getExcludeIf() { 080 return excludeIf == null ? Collections.<String>emptyList() : excludeIf; 081 } 082 083 /** 084 * Sets the excludeIf list. The excludeIf is a list of values to exclude from the audit event. 085 * @param excludeIf The list of excludeIfs. 086 */ 087 public void setExcludeIf(Collection<String> excludeIf) { 088 this.excludeIf = new LinkedList<>(excludeIf); 089 } 090}