Class AbstractCredentialValidator

    • Field Detail

      • log

        @Nonnull
        private final org.slf4j.Logger log
        Class logger.
      • logPrefix

        @Nullable
        private String logPrefix
        Cached log prefix.
      • customPrincipals

        @Nullable
        private Subject customPrincipals
        Container that carries additional Principal objects.
    • Constructor Detail

      • AbstractCredentialValidator

        public AbstractCredentialValidator()
        Constructor.
    • Method Detail

      • setActivationCondition

        public void setActivationCondition​(@Nonnull
                                           Predicate<ProfileRequestContext> condition)
        Set the activation condition controlling use of validator.
        Parameters:
        condition - condition to use
      • setSupportedPrincipals

        public void setSupportedPrincipals​(@Nullable @NonnullElements
                                           Collection<Principal> principals)
        Set supported non-user-specific principals that the validator will include in the subjects it generates.
        Parameters:
        principals - supported principals to include
      • validate

        public Subject validate​(@Nonnull
                                ProfileRequestContext profileRequestContext,
                                @Nonnull
                                AuthenticationContext authenticationContext,
                                @Nullable
                                CredentialValidator.WarningHandler warningHandler,
                                @Nullable
                                CredentialValidator.ErrorHandler errorHandler)
                         throws Exception
        Validate any credentials found in a supported form within the input context tree and produce a Subject as the outcome.

        A null result is used to signal that validation was not attempted.

        Specified by:
        validate in interface CredentialValidator
        Parameters:
        profileRequestContext - profile request context
        authenticationContext - authentication context
        warningHandler - optional warning handler interface
        errorHandler - optional error handler interface
        Returns:
        result of a successful validation, or null
        Throws:
        Exception - when validation is unsuccessful due to a failed attempt
      • doValidate

        @Nullable
        protected abstract Subject doValidate​(@Nonnull
                                              ProfileRequestContext profileRequestContext,
                                              @Nonnull
                                              AuthenticationContext authenticationContext,
                                              @Nullable
                                              CredentialValidator.WarningHandler warningHandler,
                                              @Nullable
                                              CredentialValidator.ErrorHandler errorHandler)
                                       throws Exception
        Override method for subclasses to use to perform the actual validation.
        Parameters:
        profileRequestContext - profile request context
        authenticationContext - authentication context
        warningHandler - optional warning handler interface
        errorHandler - optional error handler interface
        Returns:
        the validated result, or null if inapplicable
        Throws:
        Exception - if an error occurs
      • populateSubject

        @Nonnull
        protected Subject populateSubject​(@Nonnull
                                          Subject subject)
        Decorate the subject with custom principals if needed.
        Parameters:
        subject - the subject being returned
        Returns:
        the decorated subject
      • getLogPrefix

        @Nonnull
        @NotEmpty
        protected String getLogPrefix()
        Return a prefix for logging messages for this component.
        Returns:
        a string for insertion at the beginning of any log messages
      • isAcceptable

        protected boolean isAcceptable​(@Nullable
                                       RequestedPrincipalContext requestedPrincipalCtx,
                                       @Nullable
                                       Subject subject,
                                       @Nonnull @NotEmpty
                                       String configName)
        Checks a particular request and principal collection for suitability.
        Parameters:
        requestedPrincipalCtx - the relevant context
        subject - collection of custom principals to check, embedded in a subject
        configName - name for logging
        Returns:
        true iff the request does not specify requirements or the principal collection is empty or the combination is acceptable