Interface Validator<V>

Type Parameters:
V - type of the value to be validated
All Superinterfaces:
net.shibboleth.shared.component.Component, net.shibboleth.shared.component.DestructableComponent, net.shibboleth.shared.component.IdentifiableComponent, net.shibboleth.shared.component.IdentifiedComponent, net.shibboleth.shared.component.InitializableComponent
All Known Implementing Classes:
AbstractX509Validator, AcceptAllValidator, AcceptStringRegexValidator, AcceptStringValueValidator, AsDomainNameStringValidator, AsLiteralTailStringValidator, AsURLStringValidator, BaseAsValidator, EmptyPortURLValidator, HTTPSProtocolURLValidator, MissingHostURLValidator, RejectAllValidator, RejectDomainNameNotUnderPublicSuffixValidator, RejectDomainNamePublicSuffixValidator, RejectStringRegexValidator, RejectStringValueValidator, ValidatorSequence, X509DSADetector, X509ROCAValidator, X509RSAExponentValidator, X509RSAKeyLengthValidator, X509RSAOpenSSLKeylistValidator

@ThreadSafe public interface Validator<V> extends net.shibboleth.shared.component.DestructableComponent, net.shibboleth.shared.component.IdentifiableComponent, net.shibboleth.shared.component.InitializableComponent
Interface for a validator to be applied to an value in the context of a given Item, to which status metadata will be added when appropriate.

A validate call may be provided with a "value context" String indicating the larger validation of which this call is a component. For example, a validation of the host component of a URL value might be provided with a value context of the entire URL. If the value context is not required, it may be omitted either by passing null or by using the validate method lacking that parameter.

The interface provides default method bodies for both forms of validate so that implementing classes only need to provide one or the other in most cases.

Validators must be thread-safe.

Since:
0.9.0
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static enum 
    Validator instances are normally applied in sequence in a chain of responsibility pattern orchestrated by the caller.
  • Method Summary

    Modifier and Type
    Method
    Description
    validate(V value, Item<?> item, String callerId)
    Apply the validator to a value in the context of the given Item.
    validate(V value, Item<?> item, String callerId, String valueContext)
    Apply the validator to a value in the context of the given Item.

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

    destroy, isDestroyed

    Methods inherited from interface net.shibboleth.shared.component.IdentifiableComponent

    setId

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

    getId

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

    initialize, isInitialized
  • Method Details

    • validate

      @Nonnull default Validator.Action validate(@Nonnull V value, @Nonnull Item<?> item, @Nonnull String callerId, @Nullable String valueContext) throws StageProcessingException
      Apply the validator to a value in the context of the given Item.

      The validator influences future processing by adding item metadata to the Item.

      A common case is that the validator will add a StatusMetadata to the Item, for example a ErrorStatus. In this case, the convention is that the componentId of the ErrorStatus would be created by combining the callerId with a / and the validator's own identifier. For example, a validator val called by a stage stage would normally use a componentId of stage/val.

      The valueContext makes the original context of the value available to help in constructing meaningful error messages. For example, the validation of a complex structured value such as a URI might be broken down into multiple sub-validations of its components: scheme, for example. When relevant, the valueContext provides a representation of the original complex value while value is the component currently being validated.

      Parameters:
      value - the value to be validated
      item - the Item context for the validation
      callerId - a String identifying the caller
      valueContext - an additional String indicating the value context, or null
      Returns:
      an indication of whether to process additional validators
      Throws:
      StageProcessingException - if an error occurs during validation
      Since:
      0.10.0
    • validate

      @Nonnull default Validator.Action validate(@Nonnull V value, @Nonnull Item<?> item, @Nonnull String callerId) throws StageProcessingException
      Apply the validator to a value in the context of the given Item.

      The validator influences future processing by adding item metadata to the Item.

      A common case is that the validator will add a StatusMetadata to the Item, for example a ErrorStatus. In this case, the convention is that the componentId of the ErrorStatus would be created by combining the callerId with a / and the validator's own identifier. For example, a validator val called by a stage stage would normally use a componentId of stage/val.

      Parameters:
      value - the value to be validated
      item - the Item context for the validation
      callerId - a String identifying the caller
      Returns:
      an indication of whether to process additional validators
      Throws:
      StageProcessingException - if an error occurs during validation