Class AbstractPasswordFilePrincipalDatabase<U extends org.apache.qpid.server.security.auth.database.PasswordPrincipal>
- java.lang.Object
-
- org.apache.qpid.server.security.auth.database.AbstractPasswordFilePrincipalDatabase<U>
-
- All Implemented Interfaces:
PrincipalDatabase
- Direct Known Subclasses:
Base64MD5PasswordFilePrincipalDatabase
,PlainPasswordFilePrincipalDatabase
public abstract class AbstractPasswordFilePrincipalDatabase<U extends org.apache.qpid.server.security.auth.database.PasswordPrincipal> extends java.lang.Object implements PrincipalDatabase
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.String
DEFAULT_ENCODING
-
Constructor Summary
Constructors Constructor Description AbstractPasswordFilePrincipalDatabase(PasswordCredentialManagingAuthenticationProvider<?> authenticationProvider)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected boolean
compareCharArray(char[] a, char[] b)
boolean
createPrincipal(java.security.Principal principal, char[] password)
Create a new principal in the databaseprotected abstract U
createUserFromFileData(java.lang.String[] result)
protected abstract U
createUserFromPassword(java.security.Principal principal, char[] passwd)
boolean
deletePrincipal(java.security.Principal principal)
Delete a principalPasswordCredentialManagingAuthenticationProvider<?>
getAuthenticationProvider()
protected abstract org.slf4j.Logger
getLogger()
protected PasswordSource
getPasswordSource()
java.security.Principal
getUser(java.lang.String username)
Get the principal from the database with the given usernamejava.util.List<java.security.Principal>
getUsers()
protected char[]
lookupPassword(java.lang.String name)
Looks up the password for a specified user in the password file.void
open(java.io.File passwordFile)
void
reload()
Reload the database to its ensure contents are up to dateprotected void
savePasswordFile()
void
setPassword(java.security.Principal principal, javax.security.auth.callback.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.boolean
updatePassword(java.security.Principal principal, char[] password)
Changes the password for the specified user-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.qpid.server.security.auth.database.PrincipalDatabase
createSaslNegotiator, getMechanisms, verifyPassword
-
-
-
-
Field Detail
-
DEFAULT_ENCODING
protected static final java.lang.String DEFAULT_ENCODING
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractPasswordFilePrincipalDatabase
public AbstractPasswordFilePrincipalDatabase(PasswordCredentialManagingAuthenticationProvider<?> authenticationProvider)
-
-
Method Detail
-
getAuthenticationProvider
public final PasswordCredentialManagingAuthenticationProvider<?> getAuthenticationProvider()
- Specified by:
getAuthenticationProvider
in interfacePrincipalDatabase
-
open
public final void open(java.io.File passwordFile) throws java.io.IOException
- Specified by:
open
in interfacePrincipalDatabase
- Throws:
java.io.IOException
-
setPassword
public final void setPassword(java.security.Principal principal, javax.security.auth.callback.PasswordCallback callback) throws javax.security.auth.login.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 interfacePrincipalDatabase
- Parameters:
principal
- The Principal to set the password forcallback
- The PasswordCallback to call setPassword on- Throws:
javax.security.auth.login.AccountNotFoundException
- If the Principal cannot be found in this Database
-
lookupPassword
protected final char[] lookupPassword(java.lang.String name)
Looks up the password for a specified user in the password file.- Parameters:
name
- The principal name to lookup- Returns:
- a char[] for use in SASL.
-
compareCharArray
protected boolean compareCharArray(char[] a, char[] b)
-
updatePassword
public boolean updatePassword(java.security.Principal principal, char[] password) throws javax.security.auth.login.AccountNotFoundException
Changes the password for the specified user- Specified by:
updatePassword
in interfacePrincipalDatabase
- Parameters:
principal
- to change the password forpassword
- plaintext password to set the password too- Returns:
- True if change was successful
- Throws:
javax.security.auth.login.AccountNotFoundException
- If the given principal doesn't exist in the Database
-
getPasswordSource
protected PasswordSource getPasswordSource()
-
createUserFromFileData
protected abstract U createUserFromFileData(java.lang.String[] result)
-
getLogger
protected abstract org.slf4j.Logger getLogger()
-
savePasswordFile
protected void savePasswordFile() throws java.io.IOException
- Throws:
java.io.IOException
-
createUserFromPassword
protected abstract U createUserFromPassword(java.security.Principal principal, char[] passwd)
-
reload
public void reload() throws java.io.IOException
Description copied from interface:PrincipalDatabase
Reload the database to its ensure contents are up to date- Specified by:
reload
in interfacePrincipalDatabase
- Throws:
java.io.IOException
- If there was an error reloading the database
-
getUsers
public java.util.List<java.security.Principal> getUsers()
- Specified by:
getUsers
in interfacePrincipalDatabase
-
getUser
public java.security.Principal getUser(java.lang.String username)
Description copied from interface:PrincipalDatabase
Get the principal from the database with the given username- Specified by:
getUser
in interfacePrincipalDatabase
- Parameters:
username
- of the principal to lookup- Returns:
- The Principal object for the given username or null if not found.
-
deletePrincipal
public boolean deletePrincipal(java.security.Principal principal) throws javax.security.auth.login.AccountNotFoundException
Description copied from interface:PrincipalDatabase
Delete a principal- Specified by:
deletePrincipal
in interfacePrincipalDatabase
- Parameters:
principal
- The principal to delete- Returns:
- True on a successful creation
- Throws:
javax.security.auth.login.AccountNotFoundException
- If the given principal doesn't exist in the Database
-
createPrincipal
public boolean createPrincipal(java.security.Principal principal, char[] password)
Description copied from interface:PrincipalDatabase
Create a new principal in the database- Specified by:
createPrincipal
in interfacePrincipalDatabase
- Parameters:
principal
- The principal to createpassword
- The password to set for the principal- Returns:
- True on a successful creation
-
-