public class AuthFactory extends Object
AuthProvider.className
system property. For example, if you have configured Openfire to use LDAP for user information,
you'd want to send a custom implementation of AuthFactory to make LDAP auth queries.
After changing the AuthProvider.className
system property, you must restart your
application server.Constructor and Description |
---|
AuthFactory() |
Modifier and Type | Method and Description |
---|---|
static AuthToken |
authenticate(String username,
String password)
Authenticates a user with a username and plain text password and returns and
AuthToken.
|
static AuthToken |
authenticate(String username,
String token,
String digest)
Authenticates a user with a username, token, and digest and returns an AuthToken.
|
static String |
createDigest(String token,
String password)
Returns a digest given a token and password, according to JEP-0078.
|
static String |
decryptPassword(String encryptedPassword)
Returns a decrypted version of the encrypted password.
|
static String |
encryptPassword(String password)
Returns an encrypted version of the plain-text password.
|
static AuthProvider |
getAuthProvider()
Deprecated.
Prefer using the corresponding factory method, rather than
invoking methods on the provider directly
|
static String |
getPassword(String username)
Returns the user's password.
|
static boolean |
isDigestSupported()
Returns true if the currently installed
AuthProvider supports
digest authentication according to JEP-0078. |
static boolean |
isPlainSupported()
Returns true if the currently installed
AuthProvider supports authentication
using plain-text passwords according to JEP-0078. |
static boolean |
isProviderInstanceOf(Class<?> c)
Returns whether the currently-installed AuthProvider is instance of a specific class.
|
static void |
setPassword(String username,
String password)
Sets the users's password.
|
static boolean |
supportsPasswordRetrieval()
Returns true if the currently installed
AuthProvider supports password
retrieval. |
public static AuthProvider getAuthProvider()
public static boolean isProviderInstanceOf(Class<?> c)
c
- the class to compare withpublic static boolean supportsPasswordRetrieval()
AuthProvider
supports password
retrieval. Certain implementation utilize password hashes and other authentication
mechanisms that do not require the original password.public static boolean isPlainSupported()
AuthProvider
supports authentication
using plain-text passwords according to JEP-0078. Plain-text authentication is
not secure and should generally only be used over a TLS/SSL connection.public static boolean isDigestSupported()
AuthProvider
supports
digest authentication according to JEP-0078.public static String getPassword(String username) throws UserNotFoundException, UnsupportedOperationException
username
- the username of the user.UserNotFoundException
- if the given user could not be found.UnsupportedOperationException
- if the provider does not
support the operation (this is an optional operation).public static void setPassword(String username, String password) throws UserNotFoundException, UnsupportedOperationException, ConnectionException, InternalUnauthenticatedException
username
- the username of the user.password
- the new plaintext password for the user.UserNotFoundException
- if the given user could not be loaded.UnsupportedOperationException
- if the provider does not
support the operation (this is an optional operation).ConnectionException
InternalUnauthenticatedException
public static AuthToken authenticate(String username, String password) throws UnauthorizedException, ConnectionException, InternalUnauthenticatedException
username
- the username.password
- the password.UnauthorizedException
- if the username and password do not match any existing user
or the account is locked out.ConnectionException
InternalUnauthenticatedException
public static AuthToken authenticate(String username, String token, String digest) throws UnauthorizedException, ConnectionException, InternalUnauthenticatedException
createDigest(String, String)
method.
If the username and digest do not match the record of any user in the system, the
method throws an UnauthorizedException.username
- the username.token
- the token that was used with plain-text password to generate the digest.digest
- the digest generated from plain-text password and unique token.UnauthorizedException
- if the username and password do not match any
existing user or the account is locked out.ConnectionException
InternalUnauthenticatedException
public static String createDigest(String token, String password)
token
- the token used in the digest.password
- the plain-text password to be digested.public static String encryptPassword(String password)
password
- the plain-text password.UnsupportedOperationException
- if encryption/decryption is not possible;
for example, during setup mode.public static String decryptPassword(String encryptedPassword)
encryptedPassword
- the encrypted password.UnsupportedOperationException
- if encryption/decryption is not possible;
for example, during setup mode.Copyright © 2003-2008 Jive Software.