Class PasswordFileCredentialStore
- java.lang.Object
-
- net.officefloor.web.security.store.PasswordFileCredentialStore
-
- All Implemented Interfaces:
CredentialStore
public class PasswordFileCredentialStore extends java.lang.Object implements CredentialStore
Password file implementation ofCredentialStore.- Author:
- Daniel Sagenschneider
-
-
Field Summary
-
Fields inherited from interface net.officefloor.web.security.store.CredentialStore
DEFAULT_ALGORITHM, NO_ALGORITHM
-
-
Constructor Summary
Constructors Constructor Description PasswordFileCredentialStore(PasswordFile file)Initiate.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetAlgorithm()Obtains the algorithm used to encrypt credentials within thisCredentialStore.static PasswordFileloadPasswordFile(java.io.File rawFile)Loads thePasswordFilefrom the raw file.CredentialEntryretrieveCredentialEntry(java.lang.String userId, java.lang.String realm)Retrieves theCredentialEntry.
-
-
-
Constructor Detail
-
PasswordFileCredentialStore
public PasswordFileCredentialStore(PasswordFile file)
Initiate.- Parameters:
file-PasswordFile.
-
-
Method Detail
-
loadPasswordFile
public static PasswordFile loadPasswordFile(java.io.File rawFile) throws java.io.IOException
Loads the
PasswordFilefrom the raw file.The password file must be of the form:
# comment line algorithm=[algorithm] [UserId]:[Credentials]:[Role],[Role]
where items in brackets, [x], should be replaced with appropriate information.
The algorithm must be specified as first data line. Typically the [algorithm] value would be
MD5.The may be many
UserIdentry lines with the user having manyRole's defined separated by commas (,).The binary credentials must be
Base64encoded.- Parameters:
rawFile- Raw file containing the password details.- Returns:
- Populated
PasswordFilefrom the raw file. - Throws:
java.io.IOException- If failure reading the passwordFile.
-
getAlgorithm
public java.lang.String getAlgorithm()
Description copied from interface:CredentialStoreObtains the algorithm used to encrypt credentials within this
CredentialStore.Should the return be
null, blank orCredentialStore.NO_ALGORITHMthen the password is considered to be stored in plain text. This is however only useful for theBASICauthentication scheme due to the nature of the other authentication schemes (such asDIGEST).It is expected that the credentials for
DIGESTwill be stored as the algorithm applied touserId:realm:password(as per RFC 2617). This is necessary as the password is never supplied and therefore forDIGESTthis MUST return an algorithm.- Specified by:
getAlgorithmin interfaceCredentialStore- Returns:
- Algorithm.
-
retrieveCredentialEntry
public CredentialEntry retrieveCredentialEntry(java.lang.String userId, java.lang.String realm)
Description copied from interface:CredentialStoreRetrieves theCredentialEntry.- Specified by:
retrieveCredentialEntryin interfaceCredentialStore- Parameters:
userId- User identifier.realm- Realm. May benull(especially in the case forBasicauthentication).- Returns:
CredentialEntryornullif noCredentialEntryexists for parameters.
-
-