Class PasswordFileCredentialStore

java.lang.Object
net.officefloor.web.security.store.PasswordFileCredentialStore
All Implemented Interfaces:
CredentialStore

public class PasswordFileCredentialStore extends Object implements CredentialStore
Password file implementation of CredentialStore.
Author:
Daniel Sagenschneider
  • Constructor Details

    • PasswordFileCredentialStore

      public PasswordFileCredentialStore(PasswordFile file)
      Initiate.
      Parameters:
      file - PasswordFile.
  • Method Details

    • loadPasswordFile

      public static PasswordFile loadPasswordFile(File rawFile) throws IOException

      Loads the PasswordFile from 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 UserId entry lines with the user having many Role's defined separated by commas (,).

      The binary credentials must be Base64 encoded.

      Parameters:
      rawFile - Raw file containing the password details.
      Returns:
      Populated PasswordFile from the raw file.
      Throws:
      IOException - If failure reading the password File.
    • getAlgorithm

      public String getAlgorithm()
      Description copied from interface: CredentialStore

      Obtains the algorithm used to encrypt credentials within this CredentialStore.

      Should the return be null, blank or CredentialStore.NO_ALGORITHM then the password is considered to be stored in plain text. This is however only useful for the BASIC authentication scheme due to the nature of the other authentication schemes (such as DIGEST).

      It is expected that the credentials for DIGEST will be stored as the algorithm applied to userId:realm:password (as per RFC 2617). This is necessary as the password is never supplied and therefore for DIGEST this MUST return an algorithm.

      Specified by:
      getAlgorithm in interface CredentialStore
      Returns:
      Algorithm.
    • retrieveCredentialEntry

      public CredentialEntry retrieveCredentialEntry(String userId, String realm)
      Description copied from interface: CredentialStore
      Retrieves the CredentialEntry.
      Specified by:
      retrieveCredentialEntry in interface CredentialStore
      Parameters:
      userId - User identifier.
      realm - Realm. May be null (especially in the case for Basic authentication).
      Returns:
      CredentialEntry or null if no CredentialEntry exists for parameters.