Package org.jboss.as.controller.audit
Class ManagedAuditLoggerImpl
- java.lang.Object
-
- org.jboss.as.controller.audit.ManagedAuditLoggerImpl
-
- All Implemented Interfaces:
AuditLogger
,ManagedAuditLogger
,ManagedAuditLogger.AuditLogHandlerUpdater
public class ManagedAuditLoggerImpl extends Object implements ManagedAuditLogger, ManagedAuditLogger.AuditLogHandlerUpdater
Audit logger wrapper- Author:
- Brian Stansberry (c) 2012 Red Hat Inc., Kabir Khan
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.jboss.as.controller.audit.AuditLogger
AuditLogger.Status
-
Nested classes/interfaces inherited from interface org.jboss.as.controller.audit.ManagedAuditLogger
ManagedAuditLogger.AuditLogHandlerUpdater
-
-
Field Summary
-
Fields inherited from interface org.jboss.as.controller.audit.AuditLogger
NO_OP_LOGGER
-
-
Constructor Summary
Constructors Constructor Description ManagedAuditLoggerImpl(String asVersion, boolean server)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addFormatter(AuditLogItemFormatter formatter)
Add a formattervoid
addHandler(org.jboss.as.controller.audit.AuditLogHandler handler)
Adds a new handler, this handler will be used when logging the current operationvoid
addHandlerReference(PathAddress referenceAddress)
Add a handler reference.void
applyChanges()
Apply the changes.void
bootDone()
Callback for the controller to call when the controller has been bootedManagedAuditLoggerImpl
createNewConfiguration(boolean manualCommit)
Create another audit logger configuration, e.g.boolean
getHandlerDisabledDueToFailure(String name)
Get whether a handler was disabled due to failuresint
getHandlerFailureCount(String name)
Get the current failure count of a handlerJsonAuditLogItemFormatter
getJsonFormatter(String name)
Gets a formatter by its nameAuditLogger.Status
getLoggerStatus()
Gets the status of the audit loggerManagedAuditLogger.AuditLogHandlerUpdater
getUpdater()
Gets the handler updater used to schedule updates to the handlersboolean
isLogBoot()
Get whether this audit logger logs operations on bootboolean
isLogReadOnly()
Get whether this audit logger logs read-only operationsList<org.jboss.dmr.ModelNode>
listLastEntries(String name)
Gets the last log entriesvoid
log(boolean readOnly, OperationContext.ResultAction resultAction, String userId, String domainUUID, AccessMechanism accessMechanism, InetAddress remoteAddress, Resource resultantModel, List<org.jboss.dmr.ModelNode> operations)
void
logJmxMethodAccess(boolean readOnly, String userId, String domainUUID, AccessMechanism accessMechanism, InetAddress remoteAddress, String methodName, String[] methodSignature, Object[] methodParams, Throwable error)
void
recycleHandler(String name)
Recycles a handler.void
removeFormatter(String name)
Remove a formattervoid
removeHandler(String name)
Remove a handler.void
removeHandlerReference(PathAddress referenceAddress)
Add a handler reference.void
rollbackChanges()
Roll back changes made as part of the current operation.void
setLogBoot(boolean logBoot)
Set whether to log operations on bootvoid
setLoggerStatus(AuditLogger.Status newStatus)
Sets the status of the audit loggervoid
setLogReadOnly(boolean logReadOnly)
Set whether to log read-only operationsvoid
startBoot()
Callback for the controller to call before the controller is bootedvoid
updateHandler(org.jboss.as.controller.audit.AuditLogHandler handler)
Update a handler.void
updateHandlerFormatter(String name, String formatterName)
Update the handler formatter.void
updateHandlerMaxFailureCount(String name, int count)
Update the handler max failure count.void
updateInMemoryHandlerMaxHistory(String name, int maxHistory)
Update the handler history size.void
updateSyslogHandlerAppName(String name, String appName)
Update the handler app-name.void
updateSyslogHandlerFacility(String name, SyslogAuditLogHandler.Facility facility)
Update the syslog handler facility.void
updateSyslogHandlerReconnectTimeout(String name, int reconnectTimeout)
Update the handler reconnect timeout.
-
-
-
Constructor Detail
-
ManagedAuditLoggerImpl
public ManagedAuditLoggerImpl(String asVersion, boolean server)
-
-
Method Detail
-
log
public void log(boolean readOnly, OperationContext.ResultAction resultAction, String userId, String domainUUID, AccessMechanism accessMechanism, InetAddress remoteAddress, Resource resultantModel, List<org.jboss.dmr.ModelNode> operations)
- Specified by:
log
in interfaceAuditLogger
-
logJmxMethodAccess
public void logJmxMethodAccess(boolean readOnly, String userId, String domainUUID, AccessMechanism accessMechanism, InetAddress remoteAddress, String methodName, String[] methodSignature, Object[] methodParams, Throwable error)
- Specified by:
logJmxMethodAccess
in interfaceAuditLogger
-
createNewConfiguration
public ManagedAuditLoggerImpl createNewConfiguration(boolean manualCommit)
Description copied from interface:ManagedAuditLogger
Create another audit logger configuration, e.g. for JMX which has its own global config of the audit logger- Specified by:
createNewConfiguration
in interfaceManagedAuditLogger
- Parameters:
manualCommit
- iftrue
the caller is responsible for applying the changes themselves, iffalse
the changes will be committed after the next log records has been written- Returns:
- the new configuration
-
isLogReadOnly
public boolean isLogReadOnly()
Description copied from interface:ManagedAuditLogger
Get whether this audit logger logs read-only operations- Specified by:
isLogReadOnly
in interfaceManagedAuditLogger
- Returns:
- whether this audit logger logs read-only operations
-
setLogReadOnly
public void setLogReadOnly(boolean logReadOnly)
Description copied from interface:ManagedAuditLogger
Set whether to log read-only operations- Specified by:
setLogReadOnly
in interfaceManagedAuditLogger
- Parameters:
logReadOnly
- wheter to log read-only operations
-
isLogBoot
public boolean isLogBoot()
Description copied from interface:ManagedAuditLogger
Get whether this audit logger logs operations on boot- Specified by:
isLogBoot
in interfaceManagedAuditLogger
- Returns:
- whether this audit logger logs operations on boot
-
setLogBoot
public void setLogBoot(boolean logBoot)
Description copied from interface:ManagedAuditLogger
Set whether to log operations on boot- Specified by:
setLogBoot
in interfaceManagedAuditLogger
- Parameters:
logBoot
- whether to log operations on boot
-
getLoggerStatus
public AuditLogger.Status getLoggerStatus()
Description copied from interface:ManagedAuditLogger
Gets the status of the audit logger- Specified by:
getLoggerStatus
in interfaceManagedAuditLogger
- Returns:
- the status
-
recycleHandler
public void recycleHandler(String name)
Description copied from interface:ManagedAuditLogger
Recycles a handler. This stops it, and resets the failure count so that the next time it is used it will reinitialize.- Specified by:
recycleHandler
in interfaceManagedAuditLogger
- Parameters:
name
- the name of the handler
-
setLoggerStatus
public void setLoggerStatus(AuditLogger.Status newStatus)
Description copied from interface:ManagedAuditLogger
Sets the status of the audit logger- Specified by:
setLoggerStatus
in interfaceManagedAuditLogger
- Parameters:
newStatus
- the status
-
getUpdater
public ManagedAuditLogger.AuditLogHandlerUpdater getUpdater()
Description copied from interface:ManagedAuditLogger
Gets the handler updater used to schedule updates to the handlers- Specified by:
getUpdater
in interfaceManagedAuditLogger
- Returns:
- the handler updater
-
addHandler
public void addHandler(org.jboss.as.controller.audit.AuditLogHandler handler)
Description copied from interface:ManagedAuditLogger.AuditLogHandlerUpdater
Adds a new handler, this handler will be used when logging the current operation- Specified by:
addHandler
in interfaceManagedAuditLogger.AuditLogHandlerUpdater
- Parameters:
handler
- the handler
-
updateHandler
public void updateHandler(org.jboss.as.controller.audit.AuditLogHandler handler)
Description copied from interface:ManagedAuditLogger.AuditLogHandlerUpdater
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.- Specified by:
updateHandler
in interfaceManagedAuditLogger.AuditLogHandlerUpdater
- Parameters:
handler
- the updated handler
-
removeHandler
public void removeHandler(String name)
Description copied from interface:ManagedAuditLogger.AuditLogHandlerUpdater
Remove a handler. The removal will only take effect after the current operation has been logged.- Specified by:
removeHandler
in interfaceManagedAuditLogger.AuditLogHandlerUpdater
- Parameters:
name
- the name of the handler to be removed
-
addHandlerReference
public void addHandlerReference(PathAddress referenceAddress)
Description copied from interface:ManagedAuditLogger.AuditLogHandlerUpdater
Add a handler reference. This reference will take effect when logging the current operation- Specified by:
addHandlerReference
in interfaceManagedAuditLogger.AuditLogHandlerUpdater
- Parameters:
referenceAddress
- the address of the handler reference (the value of the last element is the name of the referenced handler)
-
removeHandlerReference
public void removeHandlerReference(PathAddress referenceAddress)
Description copied from interface:ManagedAuditLogger.AuditLogHandlerUpdater
Add a handler reference. This reference removal will only take effect after the current operation has been logged.- Specified by:
removeHandlerReference
in interfaceManagedAuditLogger.AuditLogHandlerUpdater
- Parameters:
referenceAddress
- the address of the handler reference (the value of the last element is the name of the referenced handler)
-
rollbackChanges
public void rollbackChanges()
Description copied from interface:ManagedAuditLogger.AuditLogHandlerUpdater
Roll back changes made as part of the current operation.- Specified by:
rollbackChanges
in interfaceManagedAuditLogger.AuditLogHandlerUpdater
-
applyChanges
public void applyChanges()
Description copied from interface:ManagedAuditLogger.AuditLogHandlerUpdater
Apply the changes. This is only allowed for update tasks for new audit log configurations which specify that manual commit should be used.- Specified by:
applyChanges
in interfaceManagedAuditLogger.AuditLogHandlerUpdater
-
removeFormatter
public void removeFormatter(String name)
Description copied from interface:ManagedAuditLogger
Remove a formatter- Specified by:
removeFormatter
in interfaceManagedAuditLogger
- Parameters:
name
- the formatter name
-
addFormatter
public void addFormatter(AuditLogItemFormatter formatter)
Description copied from interface:ManagedAuditLogger
Add a formatter- Specified by:
addFormatter
in interfaceManagedAuditLogger
- Parameters:
formatter
- the formatter
-
updateHandlerFormatter
public void updateHandlerFormatter(String name, String formatterName)
Description copied from interface:ManagedAuditLogger
Update the handler formatter. This will take effect immediately.- Specified by:
updateHandlerFormatter
in interfaceManagedAuditLogger
- Parameters:
name
- the name of the handlerformatterName
- the name of the formatter
-
updateHandlerMaxFailureCount
public void updateHandlerMaxFailureCount(String name, int count)
Description copied from interface:ManagedAuditLogger
Update the handler max failure count. This will take effect immediately- Specified by:
updateHandlerMaxFailureCount
in interfaceManagedAuditLogger
- Parameters:
name
- the name of the handlercount
- the max failure count
-
getHandlerFailureCount
public int getHandlerFailureCount(String name)
Description copied from interface:ManagedAuditLogger
Get the current failure count of a handler- Specified by:
getHandlerFailureCount
in interfaceManagedAuditLogger
- Parameters:
name
- the name of the handler- Returns:
- the failure count
-
updateSyslogHandlerFacility
public void updateSyslogHandlerFacility(String name, SyslogAuditLogHandler.Facility facility)
Description copied from interface:ManagedAuditLogger
Update the syslog handler facility. This will take effect immediately.- Specified by:
updateSyslogHandlerFacility
in interfaceManagedAuditLogger
- Parameters:
name
- the name of the syslog handlerfacility
- the facility
-
updateSyslogHandlerAppName
public void updateSyslogHandlerAppName(String name, String appName)
Description copied from interface:ManagedAuditLogger
Update the handler app-name. This will take effect immediately- Specified by:
updateSyslogHandlerAppName
in interfaceManagedAuditLogger
- Parameters:
name
- the name of the handlerappName
- the app name
-
updateSyslogHandlerReconnectTimeout
public void updateSyslogHandlerReconnectTimeout(String name, int reconnectTimeout)
Description copied from interface:ManagedAuditLogger
Update the handler reconnect timeout. This will take effect immediately- Specified by:
updateSyslogHandlerReconnectTimeout
in interfaceManagedAuditLogger
- Parameters:
name
- the name of the handlerreconnectTimeout
- the app name
-
getHandlerDisabledDueToFailure
public boolean getHandlerDisabledDueToFailure(String name)
Description copied from interface:ManagedAuditLogger
Get whether a handler was disabled due to failures- Specified by:
getHandlerDisabledDueToFailure
in interfaceManagedAuditLogger
- Parameters:
name
- the name of the handler- Returns:
- whether it is disabled
-
getJsonFormatter
public JsonAuditLogItemFormatter getJsonFormatter(String name)
Description copied from interface:ManagedAuditLogger
Gets a formatter by its name- Specified by:
getJsonFormatter
in interfaceManagedAuditLogger
- Parameters:
name
- the name of the formatter- Returns:
- the formatter
-
listLastEntries
public List<org.jboss.dmr.ModelNode> listLastEntries(String name)
Description copied from interface:ManagedAuditLogger
Gets the last log entries- Specified by:
listLastEntries
in interfaceManagedAuditLogger
- Parameters:
name
- the name of the handler- Returns:
- the last log entries of the handler
-
updateInMemoryHandlerMaxHistory
public void updateInMemoryHandlerMaxHistory(String name, int maxHistory)
Description copied from interface:ManagedAuditLogger
Update the handler history size.- Specified by:
updateInMemoryHandlerMaxHistory
in interfaceManagedAuditLogger
- Parameters:
name
- the name of the handlermaxHistory
- the history size of the handler
-
bootDone
public void bootDone()
Description copied from interface:ManagedAuditLogger
Callback for the controller to call when the controller has been booted- Specified by:
bootDone
in interfaceManagedAuditLogger
-
startBoot
public void startBoot()
Description copied from interface:ManagedAuditLogger
Callback for the controller to call before the controller is booted- Specified by:
startBoot
in interfaceManagedAuditLogger
-
-