-
Notifications
You must be signed in to change notification settings - Fork 460
/
ManagedAuditLogger.java
286 lines (252 loc) · 9.21 KB
/
ManagedAuditLogger.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
/*
*
* * JBoss, Home of Professional Open Source.
* * Copyright 2013, Red Hat, Inc., and individual contributors
* * as indicated by the @author tags. See the copyright.txt file in the
* * distribution for a full listing of individual contributors.
* *
* * This is free software; you can redistribute it and/or modify it
* * under the terms of the GNU Lesser General Public License as
* * published by the Free Software Foundation; either version 2.1 of
* * the License, or (at your option) any later version.
* *
* * This software is distributed in the hope that it will be useful,
* * but WITHOUT ANY WARRANTY; without even the implied warranty of
* * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* * Lesser General Public License for more details.
* *
* * You should have received a copy of the GNU Lesser General Public
* * License along with this software; if not, write to the Free
* * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*
*/
package org.jboss.as.controller.audit;
import java.util.Collections;
import java.util.List;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.audit.SyslogAuditLogHandler.Facility;
import org.jboss.dmr.ModelNode;
/**
* Abstract base class for {@link AuditLogger} implementations.
*
* @author Brian Stansberry (c) 2012 Red Hat Inc.
*/
public interface ManagedAuditLogger extends AuditLogger {
/**
* Get whether this audit logger logs read-only operations
*
* @return whether this audit logger logs read-only operations
*/
boolean isLogReadOnly();
/**
* Set whether to log read-only operations
*
* @param logReadOnly wheter to log read-only operations
*/
void setLogReadOnly(boolean logReadOnly);
/**
* Get whether this audit logger logs operations on boot
*
* @return whether this audit logger logs operations on boot
*/
boolean isLogBoot();
/**
* Set whether to log operations on boot
*
* @param logBoot whether to log operations on boot
*/
void setLogBoot(boolean logBoot);
/**
* Gets the status of the audit logger
*
* @return the status
*/
Status getLoggerStatus();
/**
* Sets the status of the audit logger
*
* @param newStatus the status
*/
void setLoggerStatus(Status newStatus);
/**
* Gets the handler updater used to schedule updates to the handlers
*
* @return the handler updater
*/
AuditLogHandlerUpdater getUpdater();
/**
* Recycles a handler. This stops it, and resets the failure count so that the next time it is used
* it will reinitialize.
*
* @param name the name of the handler
*/
void recycleHandler(String name);
/**
* Create another audit logger configuration, e.g. for JMX which has its own global config of the audit logger
*
* @param manualCommit if {@code true} the caller is responsible for applying the changes themselves, if {@code false} the changes will be committed after the next log records has been written
* @return the new configuration
*/
ManagedAuditLogger createNewConfiguration(boolean manualCommit);
/**
* Add a formatter
*
* @param formatter the formatter
*/
void addFormatter(AuditLogItemFormatter formatter);
// Immediate updates - TODO find some better way to do these if we end up adding more handler types!
/**
* Update the handler formatter. This will take effect immediately.
*
* @param name the name of the handler
* @param formatterName the name of the formatter
*/
void updateHandlerFormatter(String name, String formatterName);
/**
* Update the handler max failure count. This will take effect immediately
*
* @param name the name of the handler
* @param count the max failure count
*/
void updateHandlerMaxFailureCount(String name, int count);
/**
* Update the syslog handler facility. This will take effect immediately.
*
* @param name the name of the syslog handler
* @param facility the facility
*/
void updateSyslogHandlerFacility(String name, Facility facility);
/**
* Update the handler app-name. This will take effect immediately
*
* @param name the name of the handler
* @param appName the app name
*/
void updateSyslogHandlerAppName(String name, String appName);
/**
* Update the handler reconnect timeout. This will take effect immediately
*
* @param name the name of the handler
* @param reconnectTimeout the app name
*/
void updateSyslogHandlerReconnectTimeout(String name, int reconnectTimeout);
//ImmediateUpdates - end
/**
* Update the handler history size.
*
* @param name the name of the handler
* @param maxHistory the history size of the handler
*/
void updateInMemoryHandlerMaxHistory(String name, int maxHistory);
/**
* Remove a formatter
*
* @param name the formatter name
*/
void removeFormatter(String name);
/**
* Get the current failure count of a handler
*
* @param name the name of the handler
* @return the failure count
*/
int getHandlerFailureCount(String name);
/**
* Get whether a handler was disabled due to failures
*
* @param name the name of the handler
* @return whether it is disabled
*/
boolean getHandlerDisabledDueToFailure(String name);
/**
* Gets a formatter by its name
*
* @param name the name of the formatter
* @return the formatter
*/
JsonAuditLogItemFormatter getJsonFormatter(String name);
/**
* Gets the last log entries
*
* @param name the name of the handler
* @return the last log entries of the handler
*/
default List<ModelNode> listLastEntries(String name){
return Collections.emptyList();
}
/**
* Callback for the controller to call before the controller is booted
*/
void startBoot();
/**
* Callback for the controller to call when the controller has been booted
*/
void bootDone();
/**
* <p>The audit log handler updater. Additive changes will be used for the audit log record as a result of
* management operations causing updates here. Removals and updates will not take effect until the current audit log
* record has been written.
* </p>
* <p>
* This means that if a new handler is added and a reference is added, the new handler will be used to log the
* operations causing that to happen.
* </p>
* <p>
* If a handler is removed, the operations causing the removal will be logged to the handler, before removing it.
* </p>
* <p>
* If a handler is changed, for example to change the location of a file handler or the protocol of a syslog
* handler, the operations causing the change will be logged to the current handler location. The next incoming
* log message will be written to the new handler location.
* </p>
*/
interface AuditLogHandlerUpdater {
/**
* Adds a new handler, this handler will be used when logging the current operation
*
* @param handler the handler
*/
void addHandler(AuditLogHandler handler);
/**
* Update a handler. The update will only take place if the handler has actually been changed. The
* changes to the handler will only take effect after the current operation has been logged.
*
* @param handler the updated handler
*/
void updateHandler(AuditLogHandler handler);
/**
* Remove a handler. The removal will only take effect after the current operation has been logged.
*
* @param name the name of the handler to be removed
* @throws IllegalStateException if the handler still has references to it
*/
void removeHandler(String name);
/**
* Add a handler reference. This reference will take effect when logging the current operation
*
* @param referenceAddress the address of the handler reference (the value of the last element is the name of
* the referenced handler)
*/
void addHandlerReference(PathAddress referenceAddress);
/**
* Add a handler reference. This reference removal will only take effect after the current operation has been
* logged.
*
* @param referenceAddress the address of the handler reference (the value of the last element is the name of
* the referenced handler)
*/
void removeHandlerReference(PathAddress referenceAddress);
/**
* Roll back changes made as part of the current operation.
*/
void rollbackChanges();
/**
* Apply the changes. This is only allowed for update tasks for new audit log configurations which specify that manual commit
* should be used.
*
* @throws IllegalStateException if manual commit should not be used
*/
void applyChanges();
}
}