Class HTPasswdCredentialValidator

  • All Implemented Interfaces:
    net.shibboleth.idp.authn.CredentialValidator, net.shibboleth.idp.authn.principal.PrincipalSupportingComponent, net.shibboleth.utilities.java.support.component.Component, net.shibboleth.utilities.java.support.component.DestructableComponent, net.shibboleth.utilities.java.support.component.IdentifiableComponent, net.shibboleth.utilities.java.support.component.IdentifiedComponent, net.shibboleth.utilities.java.support.component.InitializableComponent

    @ThreadSafe
    public class HTPasswdCredentialValidator
    extends net.shibboleth.idp.authn.AbstractUsernamePasswordCredentialValidator
    A password validator that authenticates against Apache htpasswd files.
    Since:
    4.0.0
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface net.shibboleth.idp.authn.CredentialValidator

        net.shibboleth.idp.authn.CredentialValidator.ErrorHandler, net.shibboleth.idp.authn.CredentialValidator.WarningHandler
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private boolean authenticate​(net.shibboleth.idp.authn.context.UsernamePasswordContext usernamePasswordContext, String storedPassword)
      Compare input password to stored value.
      protected void doInitialize()
      protected Subject doValidate​(org.opensaml.profile.context.ProfileRequestContext profileRequestContext, net.shibboleth.idp.authn.context.AuthenticationContext authenticationContext, net.shibboleth.idp.authn.context.UsernamePasswordContext usernamePasswordContext, net.shibboleth.idp.authn.CredentialValidator.WarningHandler warningHandler, net.shibboleth.idp.authn.CredentialValidator.ErrorHandler errorHandler)
      private Map<String,​String> readCredentials​(InputStream is)
      Reads the credentials from stream.
      private void refreshCredentials()
      Check for file refresh.
      void setResource​(Resource resource)
      Set the resource to use.
      • Methods inherited from class net.shibboleth.idp.authn.AbstractUsernamePasswordCredentialValidator

        applyTransforms, doValidate, populateSubject, removeContextAfterValidation, savePasswordToCredentialSet, setLowercase, setMatchExpression, setRemoveContextAfterValidation, setSavePasswordToCredentialSet, setTransforms, setTrim, setUppercase, setUsernamePasswordContextLookupStrategy
      • Methods inherited from class net.shibboleth.idp.authn.AbstractCredentialValidator

        getLogPrefix, getSupportedPrincipals, isAcceptable, populateSubject, setActivationCondition, setId, setSupportedPrincipals, validate
      • Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractIdentifiedInitializableComponent

        getId
      • Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent

        destroy, doDestroy, initialize, isDestroyed, isInitialized
      • Methods inherited from interface net.shibboleth.utilities.java.support.component.IdentifiedComponent

        getId
    • Field Detail

      • log

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

        @NonnullAfterInit
        private net.shibboleth.utilities.java.support.codec.StringDigester digester
        Digester for SHA-1.
      • htPasswdResource

        @Nullable
        private Resource htPasswdResource
        Source of information.
      • lastModified

        @Nullable
        private long lastModified
        File timestamp.
      • credentialMap

        @Nonnull
        @NonnullElements
        private final Map<String,​String> credentialMap
        In-memory copy of entries.
    • Constructor Detail

      • HTPasswdCredentialValidator

        public HTPasswdCredentialValidator()
        Constructor.
    • Method Detail

      • setResource

        public void setResource​(@Nonnull
                                Resource resource)
        Set the resource to use.
        Parameters:
        resource - resource to use
      • doInitialize

        protected void doInitialize()
                             throws net.shibboleth.utilities.java.support.component.ComponentInitializationException
        Overrides:
        doInitialize in class net.shibboleth.utilities.java.support.component.AbstractIdentifiedInitializableComponent
        Throws:
        net.shibboleth.utilities.java.support.component.ComponentInitializationException
      • doValidate

        @Nullable
        protected Subject doValidate​(@Nonnull
                                     org.opensaml.profile.context.ProfileRequestContext profileRequestContext,
                                     @Nonnull
                                     net.shibboleth.idp.authn.context.AuthenticationContext authenticationContext,
                                     @Nonnull
                                     net.shibboleth.idp.authn.context.UsernamePasswordContext usernamePasswordContext,
                                     @Nullable
                                     net.shibboleth.idp.authn.CredentialValidator.WarningHandler warningHandler,
                                     @Nullable
                                     net.shibboleth.idp.authn.CredentialValidator.ErrorHandler errorHandler)
                              throws Exception
        Specified by:
        doValidate in class net.shibboleth.idp.authn.AbstractUsernamePasswordCredentialValidator
        Throws:
        Exception
      • authenticate

        @Nonnull
        private boolean authenticate​(@Nonnull
                                     net.shibboleth.idp.authn.context.UsernamePasswordContext usernamePasswordContext,
                                     @Nonnull
                                     String storedPassword)
        Compare input password to stored value.
        Parameters:
        usernamePasswordContext - input context
        storedPassword - the stored string
        Returns:
        true iff the password matches
      • refreshCredentials

        private void refreshCredentials()
        Check for file refresh.
      • readCredentials

        @Nonnull
        @NonnullElements
        private Map<String,​String> readCredentials​(@Nonnull
                                                         InputStream is)
        Reads the credentials from stream.
        Parameters:
        is - input stream
        Returns:
        map of credentials