Package net.shibboleth.idp.attribute.resolver.ad.impl

# Class DateTimeAttributeDefinition

java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent
net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent
net.shibboleth.idp.attribute.resolver.AbstractResolverPlugin<IdPAttribute>
net.shibboleth.idp.attribute.resolver.AbstractAttributeDefinition
net.shibboleth.idp.attribute.resolver.ad.impl.DateTimeAttributeDefinition

All Implemented Interfaces:
  `AttributeDefinition`, `ResolverPlugin<IdPAttribute>`, `Component`, `DestructableComponent`, `IdentifiableComponent`, `IdentifiedComponent`, `InitializableComponent`, `UnmodifiableComponent`, `DisposableBean`

@ThreadSafe public class DateTimeAttributeDefinition extends AbstractAttributeDefinition
An `AttributeDefinition` that creates an attribute whose values are the values of all its dependencies, passed through or converted into a `DateTimeAttributeValue`.

Values already of this type are simple passed through, while `StringAttributeValue` objects are converted. It is optional whether to omit incompatible values or raise an error.

Since:
  4.3.0

## Field Summary

Fields
Modifier and Type
Field
Description
`private boolean`
`epochInSeconds`
Convert numeric strings into epoch as seconds.
`private DateTimeFormatter`
`formatter`
Formatter for string to date/time conversion.
`private boolean`
`ignoreConversionErrors`
Do we ignore converstion failures?
`private org.slf4j.Logger`
`log`
Class logger.

## Constructor Summary

Constructors
Constructor
Description
`DateTimeAttributeDefinition()`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`protected DateTimeAttributeValue`
`convert(IdPAttributeValue input)`
Convert an input value into a `DateTimeAttributeValue` if possible.
`protected IdPAttribute`
`doAttributeDefinitionResolve(AttributeResolutionContext resolutionContext, AttributeResolverWorkContext workContext)`
Creates and populates the values for the resolved attribute.
`protected void`
`doInitialize()`
`DateTimeFormatter`
`getDateTimeFormatter()`
Get the formatter to use to convert string data into an `Instant`.
`boolean`
`isEpochInSeconds()`
Get whether to convert numeric string data into an epoch using seconds instead of milliseconds.
`boolean`
`isIgnoreConversionErrors()`
Get whether to ignore conversion failures.
`void`
`setDateTimeFormatter(DateTimeFormatter f)`
Set a formatter to use to convert string data into an `Instant`.
`void`
`setEpochInSeconds(boolean flag)`
Set whether to convert numeric string data into an epoch using seconds instead of milliseconds.
`void`
`setIgnoreConversionErrors(boolean flag)`
Set whether to ignore conversion failures.

### Methods inherited from class net.shibboleth.idp.attribute.resolver.AbstractAttributeDefinition

`doResolve, getLogPrefix, isDependencyOnly, isPreRequested, setDependencyOnly, setPreRequested`

### Methods inherited from class net.shibboleth.idp.attribute.resolver.AbstractResolverPlugin

`doDestroy, equals, getActivationCondition, getAttributeDependencies, getDataConnectorDependencies, hashCode, isPropagateResolutionExceptions, resolve, setActivationCondition, setAttributeDependencies, setDataConnectorDependencies, setPropagateResolutionExceptions`

### Methods inherited from class net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent

`setId`

### Methods inherited from class net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent

`ensureId, getId, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentException`

### Methods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent

`checkComponentActive, checkSetterPreconditions, destroy, initialize, isDestroyed, isInitialized`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface net.shibboleth.shared.component.DestructableComponent

`destroy, isDestroyed`

### Methods inherited from interface org.springframework.beans.factory.DisposableBean

`destroy`

### Methods inherited from interface net.shibboleth.shared.component.IdentifiedComponent

`getId`

### Methods inherited from interface net.shibboleth.shared.component.InitializableComponent

`initialize, isInitialized`

### Methods inherited from interface net.shibboleth.idp.attribute.resolver.ResolverPlugin

`getActivationCondition, getAttributeDependencies, getDataConnectorDependencies, isPropagateResolutionExceptions, resolve`

## Field Details

### log

@Nonnull private org.slf4j.Logger log
Class logger.

### formatter

@Nullable private DateTimeFormatter formatter
Formatter for string to date/time conversion.

### epochInSeconds

private boolean epochInSeconds
Convert numeric strings into epoch as seconds.

### ignoreConversionErrors

private boolean ignoreConversionErrors
Do we ignore converstion failures?

## Constructor Details

### DateTimeAttributeDefinition

public DateTimeAttributeDefinition()
Constructor.

## Method Details

### setEpochInSeconds

public void setEpochInSeconds(boolean flag)
Set whether to convert numeric string data into an epoch using seconds instead of milliseconds.

Defaults to true.

Parameters:
  `flag` - true if the epoch is in seconds.

### isEpochInSeconds

public boolean isEpochInSeconds()
Get whether to convert numeric string data into an epoch using seconds instead of milliseconds.

Returns:
  true iff epoch conversion should be based on seconds

### setIgnoreConversionErrors

public void setIgnoreConversionErrors(boolean flag)
Set whether to ignore conversion failures.

Parameters:
  `flag` - flag to set

### isIgnoreConversionErrors

public boolean isIgnoreConversionErrors()
Get whether to ignore conversion failures.

Returns:
  whether to ignore conversion failures

### setDateTimeFormatter

public void setDateTimeFormatter(@Nullable DateTimeFormatter f)
Set a formatter to use to convert string data into an `Instant`.

Parameters:
  `f` - formatter

### getDateTimeFormatter

@Nullable public DateTimeFormatter getDateTimeFormatter()
Get the formatter to use to convert string data into an `Instant`.

Returns:
  formatter

### doInitialize

protected void doInitialize() throws ComponentInitializationException

Overrides:
  `doInitialize` in class `AbstractAttributeDefinition`
Throws:
  `ComponentInitializationException`

### doAttributeDefinitionResolve

@Nonnull protected IdPAttribute doAttributeDefinitionResolve(@Nonnull AttributeResolutionContext resolutionContext, @Nonnull AttributeResolverWorkContext workContext) throws ResolutionException
Creates and populates the values for the resolved attribute. Implementations should not set, or otherwise manage, the resolved attribute's display name, description or encoders. Nor should the resultant attribute be recorded in the given resolution context.

Specified by:
  `doAttributeDefinitionResolve` in class `AbstractAttributeDefinition`
Parameters:
  `resolutionContext` - current attribute resolution context
  `workContext` - current resolver work context
Returns:
  resolved attribute or null if nothing to resolve.
Throws:
  `ResolutionException` - thrown if there is a problem resolving and creating the attribute

### convert

@Nullable protected DateTimeAttributeValue convert(@Nonnull IdPAttributeValue input)
Convert an input value into a `DateTimeAttributeValue` if possible.

Parameters:
  `input` - input value
Returns:
  converted value or null