org.apache.qpid.server.security.auth.database
Class Base64MD5PasswordFilePrincipalDatabase

java.lang.Object
  extended by org.apache.qpid.server.security.auth.database.Base64MD5PasswordFilePrincipalDatabase
All Implemented Interfaces:
PrincipalDatabase

public class Base64MD5PasswordFilePrincipalDatabase
extends Object
implements PrincipalDatabase

Represents a user database where the account information is stored in a simple flat file. The file is expected to be in the form: username:password username1:password1 ... usernamen:passwordn where a carriage return separates each username/password pair. Passwords are assumed to be in plain text.


Field Summary
(package private)  AMQUserManagementMBean _mbean
           
static String DEFAULT_ENCODING
           
 
Constructor Summary
Base64MD5PasswordFilePrincipalDatabase()
           
 
Method Summary
 boolean createPrincipal(Principal principal, char[] password)
          Create a new principal in the database
 boolean deletePrincipal(Principal principal)
          Delete a principal
 Map<String,AuthenticationProviderInitialiser> getMechanisms()
           
 Principal getUser(String username)
          Get the principal from the database with the given username
 List<Principal> getUsers()
           
 void reload()
          Reload the database to its ensure contents are up to date
 void setPassword(Principal principal, PasswordCallback callback)
          SASL Callback Mechanism - sets the Password in the PasswordCallback based on the value in the PasswordFile If you want to change the password for a user, use updatePassword instead.
 void setPasswordFile(String passwordFile)
           
 boolean updatePassword(Principal principal, char[] password)
          Changes the password for the specified user
 boolean verifyPassword(String principal, char[] password)
          Used to verify that the presented Password is correct.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_mbean

AMQUserManagementMBean _mbean

DEFAULT_ENCODING

public static final String DEFAULT_ENCODING
See Also:
Constant Field Values
Constructor Detail

Base64MD5PasswordFilePrincipalDatabase

public Base64MD5PasswordFilePrincipalDatabase()
Method Detail

setPasswordFile

public void setPasswordFile(String passwordFile)
                     throws IOException
Throws:
IOException

setPassword

public void setPassword(Principal principal,
                        PasswordCallback callback)
                 throws AccountNotFoundException
SASL Callback Mechanism - sets the Password in the PasswordCallback based on the value in the PasswordFile If you want to change the password for a user, use updatePassword instead.

Specified by:
setPassword in interface PrincipalDatabase
Parameters:
principal - The Principal to set the password for
callback - The PasswordCallback to call setPassword on
Throws:
AccountNotFoundException - If the Principal cannont be found in this Database

verifyPassword

public boolean verifyPassword(String principal,
                              char[] password)
                       throws AccountNotFoundException
Used to verify that the presented Password is correct. Currently only used by Management Console

Specified by:
verifyPassword in interface PrincipalDatabase
Parameters:
principal - The principal to authenticate
password - The password to check
Returns:
true if password is correct
Throws:
AccountNotFoundException - if the principal cannot be found

updatePassword

public boolean updatePassword(Principal principal,
                              char[] password)
                       throws AccountNotFoundException
Changes the password for the specified user

Specified by:
updatePassword in interface PrincipalDatabase
Parameters:
principal - to change the password for
password - plaintext password to set the password too
Returns:
True if change was successful
Throws:
AccountNotFoundException - If the given principal doesn't exist in the Database

createPrincipal

public boolean createPrincipal(Principal principal,
                               char[] password)
Description copied from interface: PrincipalDatabase
Create a new principal in the database

Specified by:
createPrincipal in interface PrincipalDatabase
Parameters:
principal - The principal to create
password - The password to set for the principal
Returns:
True on a successful creation

deletePrincipal

public boolean deletePrincipal(Principal principal)
                        throws AccountNotFoundException
Description copied from interface: PrincipalDatabase
Delete a principal

Specified by:
deletePrincipal in interface PrincipalDatabase
Parameters:
principal - The principal to delete
Returns:
True on a successful creation
Throws:
AccountNotFoundException - If the given principal doesn't exist in the Database

getMechanisms

public Map<String,AuthenticationProviderInitialiser> getMechanisms()
Specified by:
getMechanisms in interface PrincipalDatabase

getUsers

public List<Principal> getUsers()
Specified by:
getUsers in interface PrincipalDatabase

getUser

public Principal getUser(String username)
Description copied from interface: PrincipalDatabase
Get the principal from the database with the given username

Specified by:
getUser in interface PrincipalDatabase
Parameters:
username - of the principal to lookup
Returns:
The Principal object for the given username or null if not found.

reload

public void reload()
            throws IOException
Description copied from interface: PrincipalDatabase
Reload the database to its ensure contents are up to date

Specified by:
reload in interface PrincipalDatabase
Throws:
IOException - If there was an error reloading the database


Licensed to the Apache Software Foundation