Class PopulateAuditContext
java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
org.opensaml.profile.action.AbstractProfileAction
org.opensaml.profile.action.AbstractConditionalProfileAction
net.shibboleth.idp.profile.AbstractProfileAction
net.shibboleth.idp.profile.audit.impl.PopulateAuditContext
- All Implemented Interfaces:
Component,DestructableComponent,InitializableComponent,ProfileAction,Aware,MessageSource,MessageSourceAware,Action
Action that populates fields in an
AuditContext using injected functions.
Each function is registered against a field specifier, and the result of the function is added to that field in the context's map. This reduces the code footprint required to implement, and extend, the fields logged, instead of requiring a dedicated action for a particular field or set of fields.
The eventual map of formatting strings is also provided in order to recognize which extractors actually need to be run.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classParser for the formatting strings that exposes a final set of field labels that are present in any of the input formatters. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Function<ProfileRequestContext,AuditContext> Strategy used to locate or create theAuditContextto populate.private AuditContextAuditContextto populate.private booleanFlag signalling to clear context on entry.private DateTimeFormatterFormatter for date/time fields.private Map<String,Function<ProfileRequestContext, Object>> Map of fields to extract and the corresponding extraction functions.Map allowing substitutions of values during field extraction.Fields being audited, to optimize extraction..private final org.slf4j.LoggerClass logger.private booleanConvert date/time fields to default time zone. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidAdd a non-null field to the audit record.protected voiddoExecute(ProfileRequestContext profileRequestContext) protected voidprotected booleandoPreExecute(ProfileRequestContext profileRequestContext) voidSet the strategy used to locate theAuditContextassociated with a givenProfileRequestContext.voidsetClearAuditContext(boolean flag) Sets whether to clear any existing fields from the audit context.voidsetDateTimeFormat(String format) Set the formatting string to apply when extracting date/time fields.voidSet the map of fields and extraction functions to run.voidsetFieldReplacements(Map<String, String> map) Set the map of field values to replace, and the replacement values.voidSet the parsed map of logging category to formatting strings for log entries.voidsetUseDefaultTimeZone(boolean flag) Convert date/time fields to default time zone.Methods inherited from class net.shibboleth.idp.profile.AbstractProfileAction
doExecute, 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. -
auditContextCreationStrategy
Strategy used to locate or create theAuditContextto populate. -
fieldExtractors
Map of fields to extract and the corresponding extraction functions. -
fieldsToExtract
Fields being audited, to optimize extraction.. -
fieldReplacements
Map allowing substitutions of values during field extraction. -
dateTimeFormatter
Formatter for date/time fields. -
useDefaultTimeZone
private boolean useDefaultTimeZoneConvert date/time fields to default time zone. -
clearAuditContext
private boolean clearAuditContextFlag signalling to clear context on entry. -
auditCtx
AuditContextto populate.
-
-
Constructor Details
-
PopulateAuditContext
public PopulateAuditContext()Constructor.
-
-
Method Details
-
setAuditContextCreationStrategy
public void setAuditContextCreationStrategy(@Nonnull Function<ProfileRequestContext, AuditContext> strategy) Set the strategy used to locate theAuditContextassociated with a givenProfileRequestContext.- Parameters:
strategy- lookup strategy
-
setFieldExtractors
Set the map of fields and extraction functions to run.- Parameters:
map- map from field name to extraction function
-
setFormattingMapParser
Set the parsed 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.
The input class exposes the parsed field data for efficiency.
- Parameters:
parser- the parsed map
-
setFieldReplacements
Set the map of field values to replace, and the replacement values.- Parameters:
map- map of replacements
-
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
-
setClearAuditContext
public void setClearAuditContext(boolean flag) Sets whether to clear any existing fields from the audit context.Defaults to false.
- Parameters:
flag- flag to set- Since:
- 4.3.0
-
doInitialize
- Overrides:
doInitializein classAbstractInitializableComponent- Throws:
ComponentInitializationException
-
doPreExecute
- Overrides:
doPreExecutein classAbstractConditionalProfileAction
-
doExecute
- Overrides:
doExecutein classAbstractProfileAction
-
addField
Add a non-null field to the audit record.- Parameters:
key- field labelvalue- value to add
-