public class PopulateAuditContext extends AbstractProfileAction
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.
EventIds.PROCEED_EVENT_ID, EventIds.INVALID_PROFILE_CTX| Modifier and Type | Field and Description |
|---|---|
private Function<org.opensaml.profile.context.ProfileRequestContext,AuditContext> |
auditContextCreationStrategy
Strategy used to locate or create the
AuditContext to populate. |
private AuditContext |
auditCtx
AuditContext to populate. |
private String |
dateTimeFormat
Formatting string for
DateTime fields. |
private Map<String,Function<org.opensaml.profile.context.ProfileRequestContext,Object>> |
fieldExtractors
Map of fields to extract and the corresponding extraction functions.
|
private Map<String,String> |
fieldReplacements
Map allowing substitutions of values during field extraction.
|
private Set<String> |
fieldsToExtract
Fields being audited, to optimize extraction..
|
private org.slf4j.Logger |
log
Class logger.
|
private boolean |
useDefaultTimeZone
Convert
DateTime fields to default time zone. |
| Constructor and Description |
|---|
PopulateAuditContext()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
private void |
addField(String key,
Object value)
Add a non-null field to the audit record.
|
protected void |
doExecute(org.opensaml.profile.context.ProfileRequestContext profileRequestContext) |
protected boolean |
doPreExecute(org.opensaml.profile.context.ProfileRequestContext profileRequestContext) |
void |
setAuditContextCreationStrategy(Function<org.opensaml.profile.context.ProfileRequestContext,AuditContext> strategy)
Set the strategy used to locate the
AuditContext associated with a given
ProfileRequestContext. |
void |
setDateTimeFormat(String format)
|
void |
setFieldExtractors(Map<String,Function<org.opensaml.profile.context.ProfileRequestContext,Object>> map)
Set the map of fields and extraction functions to run.
|
void |
setFieldReplacements(Map<String,String> map)
Set the map of field values to replace, and the replacement values.
|
void |
setFormattingMap(Map<String,String> map)
Set the map of logging category to formatting strings for log entries.
|
void |
setUseDefaultTimeZone(boolean flag)
Convert
DateTime-valued fields to default time zone. |
doExecute, execute, getMessage, getMessage, getMessage, getProfileContextLookupStrategy, getRequestContext, getResult, setMessageSource, setProfileContextLookupStrategygetActivationCondition, setActivationConditiondoPostExecute, doPostExecute, execute, getHttpServletRequest, getHttpServletResponse, getLogPrefix, setHttpServletRequest, setHttpServletResponsedestroy, doDestroy, doInitialize, initialize, isDestroyed, isInitializedclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitinitialize, isInitialized@Nonnull private final org.slf4j.Logger log
@Nonnull private Function<org.opensaml.profile.context.ProfileRequestContext,AuditContext> auditContextCreationStrategy
AuditContext to populate.@Nonnull @NonnullElements private Map<String,Function<org.opensaml.profile.context.ProfileRequestContext,Object>> fieldExtractors
@Nonnull @NonnullElements private Set<String> fieldsToExtract
@Nonnull private Map<String,String> fieldReplacements
private boolean useDefaultTimeZone
DateTime fields to default time zone.@Nullable private AuditContext auditCtx
AuditContext to populate.public void setAuditContextCreationStrategy(@Nonnull Function<org.opensaml.profile.context.ProfileRequestContext,AuditContext> strategy)
AuditContext associated with a given
ProfileRequestContext.strategy - lookup strategypublic void setFieldExtractors(@Nonnull@NonnullElements Map<String,Function<org.opensaml.profile.context.ProfileRequestContext,Object>> map)
map - map from field name to extraction functionpublic void setFormattingMap(@Nonnull@NonnullElements Map<String,String> map)
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.
map - map of categories to formatting stringspublic void setFieldReplacements(@Nullable Map<String,String> map)
map - map of replacementspublic void setDateTimeFormat(@Nullable@NotEmpty String format)
format - formatting stringpublic void setUseDefaultTimeZone(boolean flag)
DateTime-valued fields to default time zone.flag - flag to setprotected boolean doPreExecute(@Nonnull org.opensaml.profile.context.ProfileRequestContext profileRequestContext)
doPreExecute in class org.opensaml.profile.action.AbstractConditionalProfileActionprotected void doExecute(@Nonnull org.opensaml.profile.context.ProfileRequestContext profileRequestContext)
doExecute in class org.opensaml.profile.action.AbstractProfileActionCopyright © 1999–2017 Shibboleth Consortium. All rights reserved.