1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.forgerock.audit.handlers.csv;
17
18 import org.forgerock.audit.events.handlers.FileBasedEventHandlerConfiguration;
19 import org.forgerock.util.Reject;
20 import org.forgerock.util.time.Duration;
21
22 import com.fasterxml.jackson.annotation.JsonIgnore;
23 import com.fasterxml.jackson.annotation.JsonProperty;
24 import com.fasterxml.jackson.annotation.JsonPropertyDescription;
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54 public class CsvAuditEventHandlerConfiguration extends FileBasedEventHandlerConfiguration {
55
56 @JsonProperty(required = true)
57 @JsonPropertyDescription("audit.handlers.csv.logDirectory")
58 private String logDirectory;
59
60 @JsonPropertyDescription("audit.handlers.csv.formatting")
61 private CsvFormatting formatting = new CsvFormatting();
62
63 @JsonPropertyDescription("audit.handlers.csv.security")
64 private CsvSecurity security = new CsvSecurity();
65
66
67 @JsonPropertyDescription("audit.handlers.csv.buffering")
68 protected EventBufferingConfiguration buffering = new EventBufferingConfiguration();
69
70
71
72
73
74
75 public String getLogDirectory() {
76 return logDirectory;
77 }
78
79
80
81
82
83
84
85 public void setLogDirectory(String directory) {
86 logDirectory = directory;
87 }
88
89
90
91
92
93
94 public CsvFormatting getFormatting() {
95 return formatting;
96 }
97
98
99
100
101
102
103
104 public void setFormatting(CsvFormatting formatting) {
105 this.formatting = Reject.checkNotNull(formatting);
106 }
107
108
109
110
111
112
113 public CsvSecurity getSecurity() {
114 return security;
115 }
116
117
118
119
120
121
122
123 public void setSecurity(CsvSecurity security) {
124 this.security = Reject.checkNotNull(security);
125 }
126
127
128
129
130
131
132 public EventBufferingConfiguration getBuffering() {
133 return buffering;
134 }
135
136
137
138
139
140
141
142 public void setBufferingConfiguration(EventBufferingConfiguration bufferingConfiguration) {
143 this.buffering = bufferingConfiguration;
144 }
145
146 @Override
147 public boolean isUsableForQueries() {
148 return true;
149 }
150
151
152
153
154 public static class CsvFormatting {
155 @JsonPropertyDescription("audit.handlers.csv.formatting.quoteChar")
156 private char quoteChar = '"';
157
158 @JsonPropertyDescription("audit.handlers.csv.formatting.delimiterChar")
159 private char delimiterChar = ',';
160
161 @JsonPropertyDescription("audit.handlers.csv.formatting.endOfLineSymbols")
162 private String endOfLineSymbols = System.getProperty("line.separator");
163
164
165
166
167
168 public char getQuoteChar() {
169 return quoteChar;
170 }
171
172
173
174
175
176 public void setQuoteChar(char quoteChar) {
177 this.quoteChar = quoteChar;
178 }
179
180
181
182
183
184 public char getDelimiterChar() {
185 return delimiterChar;
186 }
187
188
189
190
191
192 public void setDelimiterChar(char delimiterChar) {
193 this.delimiterChar = delimiterChar;
194 }
195
196
197
198
199
200 public String getEndOfLineSymbols() {
201 return endOfLineSymbols;
202 }
203
204
205
206
207
208 public void setEndOfLineSymbols(String endOfLineSymbols) {
209 this.endOfLineSymbols = endOfLineSymbols;
210 }
211 }
212
213
214
215
216 public static class CsvSecurity {
217
218 @JsonPropertyDescription("audit.handlers.csv.security.enabled")
219 private boolean enabled = false;
220
221 @JsonPropertyDescription("audit.handlers.csv.security.filename")
222 private String filename;
223
224 @JsonPropertyDescription("audit.handlers.csv.security.password")
225 private String password;
226
227 @JsonPropertyDescription("audit.handlers.csv.security.keyStoreHandlerName")
228 private String keyStoreHandlerName;
229
230 @JsonPropertyDescription("audit.handlers.csv.security.signatureInterval")
231 private String signatureInterval;
232
233 @JsonIgnore
234 private Duration signatureIntervalDuration;
235
236
237
238
239
240
241 public void setEnabled(boolean enabled) {
242 this.enabled = enabled;
243 }
244
245
246
247
248
249
250
251 public boolean isEnabled() {
252 return enabled;
253 }
254
255
256
257
258
259 public void setFilename(String filename) {
260 this.filename = filename;
261 }
262
263
264
265
266
267 public String getFilename() {
268 return filename;
269 }
270
271
272
273
274
275 public void setPassword(String password) {
276 this.password = password;
277 }
278
279
280
281
282
283 public String getPassword() {
284 return password;
285 }
286
287
288
289
290
291 public void setSignatureInterval(String signatureInterval) {
292 this.signatureInterval = signatureInterval;
293 this.signatureIntervalDuration = Duration.duration(signatureInterval);
294 }
295
296
297
298
299
300 public String getSignatureInterval() {
301 return signatureInterval;
302 }
303
304
305
306
307
308 public Duration getSignatureIntervalDuration() {
309 return signatureIntervalDuration;
310 }
311
312
313
314
315
316 public void setKeyStoreHandlerName(String keyStoreName) {
317 this.keyStoreHandlerName = keyStoreName;
318 }
319
320
321
322
323
324 public String getKeyStoreHandlerName() {
325 return keyStoreHandlerName;
326 }
327
328 }
329
330
331
332
333 public static class EventBufferingConfiguration {
334
335 @JsonPropertyDescription("audit.handlers.csv.buffering.enabled")
336 private boolean enabled;
337
338 @JsonPropertyDescription("audit.handlers.csv.buffering.autoFlush")
339 private boolean autoFlush = true;
340
341
342
343
344
345
346 public boolean isEnabled() {
347 return enabled;
348 }
349
350
351
352
353
354
355
356 public void setEnabled(boolean enabled) {
357 this.enabled = enabled;
358 }
359
360
361
362
363
364
365 public boolean isAutoFlush() {
366 return autoFlush;
367 }
368
369
370
371
372
373
374
375 public void setAutoFlush(boolean auto) {
376 this.autoFlush = auto;
377 }
378
379 }
380 }