Class WriteAuditLog
- All Implemented Interfaces:
Component,DestructableComponent,InitializableComponent,ProfileAction,Aware,MessageSource,MessageSourceAware,Action
AuditContext and one or more formatting strings.- Event:
EventIds.PROCEED_EVENT_ID
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Function<ProfileRequestContext,AuditContext> Strategy used to locate theAuditContextassociated with a givenProfileRequestContext.private AuditContextThe AuditContext to operate on.private Collection<String>Explicit categories to log fromformattingMap.private DateTimeFormatterFormatter for date/time fields.Map of log category to formatting tokens and literals to output.private booleanInclude profile's logging ID in category.private final org.slf4j.LoggerClass logger.private RequestContextThe Spring RequestContext to operate on.private booleanConvert date/time fields to default time zone. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoExecute(ProfileRequestContext profileRequestContext) protected EventdoExecute(RequestContext springRequestContext, ProfileRequestContext profileRequestContext) Spring-aware actions can override this method to fully control the execution of an Action by the Web Flow engine.protected voidprotected booleandoPreExecute(ProfileRequestContext profileRequestContext) protected voidfilter(StringBuilder entry) Optional override to filter the outgoing log message, does nothing by default.Get the map of logging category to formatting tokens for log entries.voidSet the strategy used to locate theAuditContextassociated with a givenProfileRequestContext.voidsetCategoriesToLog(Collection<String> categories) Set categories to log explicitly.voidsetDateTimeFormat(String format) Set the formatting string to apply when extracting date/time fields.voidsetFormattingMap(Map<String, String> map) Set the map of logging category to formatting strings for log entries.voidsetIncludeProfileLoggingId(boolean flag) Sets whether to suffix the profile's logging ID to the category to log against.voidsetUseDefaultTimeZone(boolean flag) Convert date/time fields to default time zone.Methods inherited from class net.shibboleth.idp.profile.AbstractProfileAction
execute, getBean, getBean, getMessage, getMessage, getMessage, getParameter, getParameter, getProfileContextLookupStrategy, getRequestContext, getResult, setMessageSource, setProfileContextLookupStrategyMethods inherited from class org.opensaml.profile.action.AbstractConditionalProfileAction
getActivationCondition, setActivationConditionMethods inherited from class org.opensaml.profile.action.AbstractProfileAction
doPostExecute, doPostExecute, ensureHttpServletRequest, ensureHttpServletResponse, execute, getHttpServletRequest, getHttpServletRequestSupplier, getHttpServletResponse, getHttpServletResponseSupplier, getLogPrefix, isPreExecuteCalled, setHttpServletRequestSupplier, setHttpServletResponseSupplierMethods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent
checkComponentActive, checkSetterPreconditions, destroy, doDestroy, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentException, initialize, isDestroyed, isInitializedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.shibboleth.shared.component.InitializableComponent
initialize, isInitialized
-
Field Details
-
log
@Nonnull private final org.slf4j.Logger logClass logger. -
auditContextLookupStrategy
Strategy used to locate theAuditContextassociated with a givenProfileRequestContext. -
formattingMap
Map of log category to formatting tokens and literals to output. -
categoriesToLog
Explicit categories to log fromformattingMap. -
dateTimeFormatter
Formatter for date/time fields. -
useDefaultTimeZone
private boolean useDefaultTimeZoneConvert date/time fields to default time zone. -
includeProfileLoggingId
private boolean includeProfileLoggingIdInclude profile's logging ID in category. -
requestContext
The Spring RequestContext to operate on. -
auditCtx
The AuditContext to operate on.
-
-
Constructor Details
-
WriteAuditLog
public WriteAuditLog()Constructor.
-
-
Method Details
-
setAuditContextLookupStrategy
public void setAuditContextLookupStrategy(@Nonnull Function<ProfileRequestContext, AuditContext> strategy) Set the strategy used to locate theAuditContextassociated with a givenProfileRequestContext.- Parameters:
strategy- lookup strategy
-
getFormattingMap
Get the map of logging category to formatting tokens for log entries.- Returns:
- map of formatting tokens
-
setFormattingMap
Set the map of logging category to formatting strings for log entries.A formatting string consists of tokens prefixed by '%' separated by any non-alphanumeric or whitespace. Tokens can contain any letter or number or a hyphen. Anything other than a token, including whitespace, is a literal.
- Parameters:
map- map of categories to formatting strings
-
setCategoriesToLog
Set categories to log explicitly.In the absence of any, the original behavior that iterates over the whole formatting map and logs each key is retained.
- Parameters:
categories- categories to log- Since:
- 4.3.0
-
setDateTimeFormat
Set the formatting string to apply when extracting date/time fields.- Parameters:
format- formatting string
-
setUseDefaultTimeZone
public void setUseDefaultTimeZone(boolean flag) Convert date/time fields to default time zone.- Parameters:
flag- flag to set
-
setIncludeProfileLoggingId
public void setIncludeProfileLoggingId(boolean flag) Sets whether to suffix the profile's logging ID to the category to log against.Defaults to true.
- Parameters:
flag- flag to set- Since:
- 4.3.0
-
doInitialize
- Overrides:
doInitializein classAbstractInitializableComponent- Throws:
ComponentInitializationException
-
doExecute
@Nullable protected Event doExecute(@Nonnull RequestContext springRequestContext, @Nonnull ProfileRequestContext profileRequestContext) Spring-aware actions can override this method to fully control the execution of an Action by the Web Flow engine.Alternatively they may override
AbstractProfileAction.doExecute(ProfileRequestContext)and access Spring information via aSpringRequestContextattached to the profile request context.The default implementation attaches the Spring Web Flow request context to the profile request context tree to "narrow" the execution signature to the basic OpenSAML
ProfileActioninterface. After execution, anEventContextis sought, and used to return a result back to the Web Flow engine. If no context exists, a "proceed" event is signaled.- Overrides:
doExecutein classAbstractProfileAction- Parameters:
springRequestContext- the Spring request contextprofileRequestContext- a profile request context- Returns:
- a Web Flow event produced by the action
-
doPreExecute
- Overrides:
doPreExecutein classAbstractConditionalProfileAction
-
doExecute
- Overrides:
doExecutein classAbstractProfileAction
-
filter
Optional override to filter the outgoing log message, does nothing by default.- Parameters:
entry- log entry
-