Class BaseValidator
- All Implemented Interfaces:
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
- Direct Known Subclasses:
AbstractX509Validator,AcceptAllValidator,BaseAsValidator,BaseStringRegexValidator,BaseStringValueValidator,EmptyPortURLValidator,HTTPSProtocolURLValidator,MissingHostURLValidator,RejectAllValidator,RejectDomainNameNotUnderPublicSuffixValidator,RejectDomainNamePublicSuffixValidator,ValidatorSequence,X509DSADetector
Encapsulates the notion of an identifier for each validator class, and helper methods for constructing status metadata.
- Since:
- 0.9.0
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructor.protectedBaseValidator(String message) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidAdd anErrorStatusto the givenItem.protected voidaddErrorMessage(Object extra, Item<?> item, String callerId) Add anErrorStatusto the givenItem.protected voidaddErrorMessage(Object extra, Item<?> item, String callerId, String valueContext) Add anErrorStatusto the givenItem.protected voidaddErrorMessage(Object extra, Item<?> item, String callerId, Throwable cause) Add anErrorStatusto the givenItem.protected voidprotected voidaddWarning(String mess, Item<?> item, String callerId) Add aWarningStatusto the givenItem.private StringformatMessage(Object subject) Formats the message with the given subject.private StringformatMessage(Object subject, Throwable cause) Formats the message with the given subject.private StringformatValueContext(String valueContext) Formats a value context for presentation as a message prefix.final StringReturns the message format string.protected StringmakeComponentId(String callerId) Construct a modified component identifier by combining the identifier for the caller with the validator's own identifier.final voidsetMessage(String newMessage) Set the message format string.Methods inherited from class net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent
setIdMethods inherited from class net.shibboleth.shared.component.AbstractIdentifiedInitializableComponent
doInitialize, ensureId, getId, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentExceptionMethods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent
checkComponentActive, checkSetterPreconditions, destroy, doDestroy, 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.IdentifiedComponent
getId
-
Field Details
-
message
Message format string.The generated message is formatted using this with the value being validated passed as an argument.
Defaults to
"value rejected: '%s'". May be overwritten by a subclass via its constructor, or by setting themessageproperty explicitly as configuration.- Since:
- 0.10.0
-
-
Constructor Details
-
BaseValidator
protected BaseValidator()Constructor.- Since:
- 0.10.0
-
BaseValidator
Constructor.- Parameters:
message- default value for themessageproperty- Since:
- 0.10.0
-
-
Method Details
-
getMessage
Returns the message format string.- Returns:
- the message format string
- Since:
- 0.10.0
-
setMessage
Set the message format string.- Parameters:
newMessage- the new message format string- Since:
- 0.10.0
-
makeComponentId
Construct a modified component identifier by combining the identifier for the caller with the validator's own identifier.- Parameters:
callerId- aStringidentifying the caller- Returns:
- composite component identifier
-
addError
Add anErrorStatusto the givenItem. -
addWarning
Add aWarningStatusto the givenItem. -
addStatus
protected void addStatus(boolean error, @Nonnull String mess, @Nonnull Item<?> item, @Nonnull String callerId) - Parameters:
error-trueif anErrorStatusshould be addedmess- message to include in the status metadataitem-Itemto add the status metadata tocallerId- aStringidentifying the caller
-
formatValueContext
Formats a value context for presentation as a message prefix.If there is no explicit value context, returns an empty string.
- Parameters:
valueContext- value context string, ornull- Returns:
- formatted value context prefix
- Since:
- 0.10.0
-
formatMessage
Formats the message with the given subject.- Parameters:
subject- subject of the validation, to be provided as an argument to the formatting string.- Returns:
- formatted message
- Since:
- 0.10.0
-
formatMessage
Formats the message with the given subject.If the supplied
Throwablehas a non-nulldetail message, this is added to the resulting formatted string.- Parameters:
subject- subject of the validation, to be provided as an argument to the formatting string.cause- aThrowablewhich is to be interpreted as the cause of the validation failure.- Returns:
- formatted message
- Since:
- 0.10.0
-
addErrorMessage
protected void addErrorMessage(@Nonnull Object extra, @Nonnull Item<?> item, @Nonnull String callerId, @Nullable String valueContext) Add anErrorStatusto the givenItem.The status message included in the
ErrorStatusis generated by formatting the provided value with themessagefield.If a
valueContexthas been provided, it will be included in the resulting message as a prefix. -
addErrorMessage
protected void addErrorMessage(@Nonnull Object extra, @Nonnull Item<?> item, @Nonnull String callerId) Add anErrorStatusto the givenItem.The status message included in the
ErrorStatusis generated by formatting the provided value with themessagefield. -
addErrorMessage
protected void addErrorMessage(@Nonnull Object extra, @Nonnull Item<?> item, @Nonnull String callerId, @Nonnull Throwable cause) Add anErrorStatusto the givenItem.The status message included in the
ErrorStatusis generated by formatting the provided value with themessagefield.
-