Package net.shibboleth.idp.authn.impl
Class HTPasswdCredentialValidator
- java.lang.Object
-
- net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
-
- net.shibboleth.utilities.java.support.component.AbstractIdentifiedInitializableComponent
-
- net.shibboleth.idp.authn.AbstractCredentialValidator
-
- net.shibboleth.idp.authn.AbstractUsernamePasswordCredentialValidator
-
- net.shibboleth.idp.authn.impl.HTPasswdCredentialValidator
-
- All Implemented Interfaces:
CredentialValidator,PrincipalSupportingComponent,Component,DestructableComponent,IdentifiableComponent,IdentifiedComponent,InitializableComponent
@ThreadSafeAfterInit public class HTPasswdCredentialValidator extends 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
CredentialValidator.ErrorHandler, CredentialValidator.WarningHandler
-
-
Field Summary
Fields Modifier and Type Field Description private Map<String,String>credentialMapIn-memory copy of entries.private StringDigesterdigesterDigester for SHA-1.private ResourcehtPasswdResourceSource of information.private longlastModifiedFile timestamp.private org.slf4j.LoggerlogClass logger.
-
Constructor Summary
Constructors Constructor Description HTPasswdCredentialValidator()Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private booleanauthenticate(UsernamePasswordContext usernamePasswordContext, String storedPassword)Compare input password to stored value.protected voiddoInitialize()protected SubjectdoValidate(ProfileRequestContext profileRequestContext, AuthenticationContext authenticationContext, UsernamePasswordContext usernamePasswordContext, CredentialValidator.WarningHandler warningHandler, CredentialValidator.ErrorHandler errorHandler)private Map<String,String>readCredentials(InputStream is)Reads the credentials from stream.private voidrefreshCredentials()Check for file refresh.voidsetResource(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 class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
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 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.
-
-
Method Detail
-
setResource
public void setResource(@Nonnull Resource resource)Set the resource to use.- Parameters:
resource- resource to use
-
doInitialize
protected void doInitialize() throws ComponentInitializationException- Overrides:
doInitializein classAbstractIdentifiedInitializableComponent- Throws:
ComponentInitializationException
-
doValidate
@Nullable protected Subject doValidate(@Nonnull ProfileRequestContext profileRequestContext, @Nonnull AuthenticationContext authenticationContext, @Nonnull UsernamePasswordContext usernamePasswordContext, @Nullable CredentialValidator.WarningHandler warningHandler, @Nullable CredentialValidator.ErrorHandler errorHandler) throws Exception
- Specified by:
doValidatein classAbstractUsernamePasswordCredentialValidator- Throws:
Exception
-
authenticate
@Nonnull private boolean authenticate(@Nonnull UsernamePasswordContext usernamePasswordContext, @Nonnull String storedPassword)Compare input password to stored value.- Parameters:
usernamePasswordContext- input contextstoredPassword- 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
-
-