1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.forgerock.audit.handlers.elasticsearch;
17
18 import org.forgerock.audit.events.handlers.EventHandlerConfiguration;
19
20 import com.fasterxml.jackson.annotation.JsonPropertyDescription;
21
22
23
24
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 public class ElasticsearchAuditEventHandlerConfiguration extends EventHandlerConfiguration {
50
51 @JsonPropertyDescription("audit.handlers.elasticsearch.connection")
52 private ConnectionConfiguration connection = new ConnectionConfiguration();
53
54 @JsonPropertyDescription("audit.handlers.elasticsearch.indexMapping")
55 private IndexMappingConfiguration indexMapping = new IndexMappingConfiguration();
56
57 @JsonPropertyDescription("audit.handlers.elasticsearch.buffering")
58 private EventBufferingConfiguration buffering = new EventBufferingConfiguration();
59
60
61
62
63
64
65 public ConnectionConfiguration getConnection() {
66 return connection;
67 }
68
69
70
71
72
73
74 public void setConnection(ConnectionConfiguration connection) {
75 this.connection = connection;
76 }
77
78
79
80
81
82
83 public IndexMappingConfiguration getIndexMapping() {
84 return indexMapping;
85 }
86
87
88
89
90
91
92 public void setIndexMapping(IndexMappingConfiguration indexMapping) {
93 this.indexMapping = indexMapping;
94 }
95
96
97
98
99
100
101 public EventBufferingConfiguration getBuffering() {
102 return buffering;
103 }
104
105
106
107
108
109
110 public void setBuffering(EventBufferingConfiguration buffering) {
111 this.buffering = buffering;
112 }
113
114 @Override
115 public boolean isUsableForQueries() {
116 return true;
117 }
118
119
120
121
122 public static class ConnectionConfiguration {
123
124
125
126
127 private static final String DEFAULT_HOST = "localhost";
128
129
130
131
132 private static final int DEFAULT_PORT = 9200;
133
134 @JsonPropertyDescription("audit.handlers.elasticsearch.connection.useSSL")
135 private boolean useSSL;
136
137 @JsonPropertyDescription("audit.handlers.elasticsearch.connection.host")
138 private String host;
139
140 @JsonPropertyDescription("audit.handlers.elasticsearch.connection.port")
141 private int port;
142
143 @JsonPropertyDescription("audit.handlers.elasticsearch.connection.username")
144 private String username;
145
146 @JsonPropertyDescription("audit.handlers.elasticsearch.connection.password")
147 private String password;
148
149
150
151
152
153
154 public boolean isUseSSL() {
155 return useSSL;
156 }
157
158
159
160
161
162
163 public void setUseSSL(boolean useSSL) {
164 this.useSSL = useSSL;
165 }
166
167
168
169
170
171
172 public String getHost() {
173 return host != null && !host.isEmpty() ? host : DEFAULT_HOST;
174 }
175
176
177
178
179
180
181 public void setHost(String host) {
182 this.host = host;
183 }
184
185
186
187
188
189
190 public int getPort() {
191 return port > 0 ? port : DEFAULT_PORT;
192 }
193
194
195
196
197
198
199 public void setPort(int port) {
200 this.port = port;
201 }
202
203
204
205
206
207
208 public String getPassword() {
209 return password;
210 }
211
212
213
214
215
216
217 public void setPassword(String password) {
218 this.password = password;
219 }
220
221
222
223
224
225
226 public String getUsername() {
227 return username;
228 }
229
230
231
232
233
234
235 public void setUsername(String username) {
236 this.username = username;
237 }
238 }
239
240
241
242
243 public static class IndexMappingConfiguration {
244
245 private static final String DEFAULT_INDEX_NAME = "audit";
246
247 @JsonPropertyDescription("audit.handlers.elasticsearch.indexMapping.indexName")
248 private String indexName;
249
250
251
252
253
254
255 public String getIndexName() {
256 return indexName != null && !indexName.isEmpty() ? indexName : DEFAULT_INDEX_NAME;
257 }
258
259
260
261
262
263
264 public void setIndexName(String indexName) {
265 this.indexName = indexName;
266 }
267 }
268
269
270
271
272 public static class EventBufferingConfiguration {
273
274 @JsonPropertyDescription("audit.handlers.elasticsearch.buffering.enabled")
275 private boolean enabled;
276
277 @JsonPropertyDescription("audit.handlers.elasticsearch.buffering.maxSize")
278 private int maxSize;
279
280 @JsonPropertyDescription("audit.handlers.elasticsearch.buffering.writeInterval")
281 private String writeInterval;
282
283 @JsonPropertyDescription("audit.handlers.elasticsearch.buffering.maxBatchedEvents")
284 private int maxBatchedEvents;
285
286
287
288
289
290
291 public boolean isEnabled() {
292 return enabled;
293 }
294
295
296
297
298
299
300 public void setEnabled(boolean enabled) {
301 this.enabled = enabled;
302 }
303
304
305
306
307
308
309 public int getMaxSize() {
310 return maxSize;
311 }
312
313
314
315
316
317
318 public void setMaxSize(int maxSize) {
319 this.maxSize = maxSize;
320 }
321
322
323
324
325
326
327 public String getWriteInterval() {
328 return writeInterval;
329 }
330
331
332
333
334
335
336 public void setWriteInterval(String writeInterval) {
337 this.writeInterval = writeInterval;
338 }
339
340
341
342
343
344
345 public int getMaxBatchedEvents() {
346 return maxBatchedEvents;
347 }
348
349
350
351
352
353
354 public void setMaxBatchedEvents(int maxBatchedEvents) {
355 this.maxBatchedEvents = maxBatchedEvents;
356 }
357 }
358 }