Interface PrincipalDatabase
-
- All Known Implementing Classes:
AbstractPasswordFilePrincipalDatabase
,Base64MD5PasswordFilePrincipalDatabase
,PlainPasswordFilePrincipalDatabase
public interface PrincipalDatabase
Represents a "user database" which is really a way of storing principals (i.e. usernames) and passwords.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
createPrincipal(Principal principal, char[] password)
Create a new principal in the databaseSaslNegotiator
createSaslNegotiator(String mechanism, SaslSettings saslSettings)
boolean
deletePrincipal(Principal principal)
Delete a principalPasswordCredentialManagingAuthenticationProvider<?>
getAuthenticationProvider()
List<String>
getMechanisms()
Get the list of mechanisms supported for use with the PrincipalDatabasePrincipal
getUser(String username)
Get the principal from the database with the given usernameList<Principal>
getUsers()
void
open(File passwordFile)
void
reload()
Reload the database to its ensure contents are up to datevoid
setPassword(Principal principal, PasswordCallback callback)
Set the password for a given principal in the specified callback.boolean
updatePassword(Principal principal, char[] password)
Update(Change) the password for the given principalboolean
verifyPassword(String principal, char[] password)
Used to verify that the presented Password is correct.
-
-
-
Method Detail
-
open
void open(File passwordFile) throws IOException
- Throws:
IOException
-
setPassword
void setPassword(Principal principal, PasswordCallback callback) throws IOException, AccountNotFoundException
Set the password for a given principal in the specified callback. This is used for certain SASL providers. The user database implementation should look up the password in any way it chooses and set it in the callback by calling its setPassword method.- Parameters:
principal
- the principalcallback
- the password callback that wants to receive the password- Throws:
AccountNotFoundException
- if the account for specified principal could not be foundIOException
- if there was an error looking up the principal
-
verifyPassword
boolean verifyPassword(String principal, char[] password) throws AccountNotFoundException
Used to verify that the presented Password is correct. Currently only used by Management Console- Parameters:
principal
- The principal to authenticatepassword
- The password to check- Returns:
- true if password is correct
- Throws:
AccountNotFoundException
- if the principal cannot be found
-
updatePassword
boolean updatePassword(Principal principal, char[] password) throws AccountNotFoundException
Update(Change) the password for the given principal- Parameters:
principal
- Who's password is to be changedpassword
- The new password to use- Returns:
- True if change was successful
- Throws:
AccountNotFoundException
- If the given principal doesn't exist in the Database
-
createPrincipal
boolean createPrincipal(Principal principal, char[] password)
Create a new principal in the database- Parameters:
principal
- The principal to createpassword
- The password to set for the principal- Returns:
- True on a successful creation
-
deletePrincipal
boolean deletePrincipal(Principal principal) throws AccountNotFoundException
Delete a principal- Parameters:
principal
- The principal to delete- Returns:
- True on a successful creation
- Throws:
AccountNotFoundException
- If the given principal doesn't exist in the Database
-
getUser
Principal getUser(String username)
Get the principal from the database with the given username- Parameters:
username
- of the principal to lookup- Returns:
- The Principal object for the given username or null if not found.
-
reload
void reload() throws IOException
Reload the database to its ensure contents are up to date- Throws:
IOException
- If there was an error reloading the database
-
getMechanisms
List<String> getMechanisms()
Get the list of mechanisms supported for use with the PrincipalDatabase- Returns:
- space separated list of supported Sasl mechanisms
-
createSaslNegotiator
SaslNegotiator createSaslNegotiator(String mechanism, SaslSettings saslSettings)
-
getAuthenticationProvider
PasswordCredentialManagingAuthenticationProvider<?> getAuthenticationProvider()
-
-