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:
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.AbstractUsernamePasswordCredentialValidatorA password validator that authenticates against Apache htpasswd files.- Since:
- 4.0.0
-
-
Field Summary
Fields Modifier and Type Field Description private Map<String,String>credentialMapIn-memory copy of entries.private net.shibboleth.utilities.java.support.codec.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(net.shibboleth.idp.authn.context.UsernamePasswordContext usernamePasswordContext, String storedPassword)Compare input password to stored value.protected voiddoInitialize()protected SubjectdoValidate(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 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
-
-
-
-
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.
-
-
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:
doInitializein classnet.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:
doValidatein classnet.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 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
-
-