Package org.jivesoftware.openfire.auth
Interface AuthProvider
- All Known Implementing Classes:
AuthMultiProvider,CrowdAuthProvider,DefaultAuthProvider,HybridAuthProvider,JDBCAuthProvider,LdapAuthProvider,MappedAuthProvider,NativeAuthProvider,POP3AuthProvider
public interface AuthProvider
Provider interface for authentication. Users that wish to integrate with
their own authentication system must implement this class and then register
the implementation with Openfire in the
openfire.xml
file. An entry in that file would look like the following:
<provider>
<auth>
<className>com.foo.auth.CustomAuthProvider</className>
</auth>
</provider>- Author:
- Matt Tucker
-
Method Summary
Modifier and TypeMethodDescriptionvoidauthenticate(String username, String password) Returns if the username and password are valid; otherwise this method throws an UnauthorizedException.Returns the names of the SCRAM mechanisms that can be assumed to be usable by any user, for use when the user that is going to authenticate cannot be identified.intgetIterations(String username) Deprecated, for removal: This API element is subject to removal in a future version.Use getIterations(String, String) with the mechanism name.default intgetIterations(String username, String mechanism) Returns a SCRAM iteration count for a user and mechanism.getPassword(String username) Returns the user's password.Deprecated, for removal: This API element is subject to removal in a future version.Use getSalt(String, String) with the mechanism name.default StringReturns a SCRAM salt for a user and mechanism.default ScramCredentialDatagetScramCredential(String username, String mechanism) Returns SCRAM credentials for a user and mechanism.getScramMechanisms(String username) Returns the names of the SCRAM mechanisms for which credentials are available for a user.getServerKey(String username) Deprecated, for removal: This API element is subject to removal in a future version.Use getServerKey(String, String) with the mechanism name.default StringgetServerKey(String username, String mechanism) Returns a SCRAM server key for a user and mechanism.getStoredKey(String username) Deprecated, for removal: This API element is subject to removal in a future version.Use getStoredKey(String, String) with the mechanism name.default StringgetStoredKey(String username, String mechanism) Returns a SCRAM stored key for a user and mechanism.booleanvoidsetPassword(String username, String password) Sets the user's password.booleanReturns true if this UserProvider is able to retrieve user passwords from the backend user store.
-
Method Details
-
authenticate
void authenticate(String username, String password) throws UnauthorizedException, ConnectionException, InternalUnauthenticatedException Returns if the username and password are valid; otherwise this method throws an UnauthorizedException.- Parameters:
username- the username or full JID.password- the password- Throws:
UnauthorizedException- if the username and password do not match any existing user.ConnectionException- it there is a problem connecting to user and group systemInternalUnauthenticatedException- if there is a problem authentication Openfire itself into the user and group system
-
getPassword
Returns the user's password. This method should throw an UnsupportedOperationException if this operation is not supported by the backend user store.- Parameters:
username- the username of the user.- Returns:
- the user's password.
- Throws:
UserNotFoundException- if the given user's password could not be loaded.UnsupportedOperationException- if the provider does not support the operation (this is an optional operation).
-
setPassword
void setPassword(String username, String password) throws UserNotFoundException, UnsupportedOperationException Sets the user's password. This method should throw an UnsupportedOperationException if this operation is not supported by the backend user store.- Parameters:
username- the username of the user.password- the new plaintext password for the user.- Throws:
UserNotFoundException- if the given user could not be loaded.UnsupportedOperationException- if the provider does not support the operation (this is an optional operation).
-
supportsPasswordRetrieval
boolean supportsPasswordRetrieval()Returns true if this UserProvider is able to retrieve user passwords from the backend user store. If this operation is not supported thengetPassword(String)will throw anUnsupportedOperationExceptionif invoked.- Returns:
- true if this UserProvider is able to retrieve user passwords from the backend user store.
-
isScramSupported
boolean isScramSupported() -
getScramMechanisms
Returns the names of the SCRAM mechanisms for which credentials are available for a user. Implementations must not create or modify credentials as a side effect: this method is invoked before authentication, with a username that is supplied by an unauthenticated peer. Implementations should not distinguish between a user that does not exist and one that has no credentials. That indistinguishability is deliberate and is what keeps this method from becoming a way for an unauthenticated peer to enumerate usernames: were a user that is not served answered differently from one that is, a peer could learn which usernames exist by watching the advertised set change. The cost is that a mechanism may be reported for a user that cannot in fact use it. That is the safe direction: such an attempt fails in the same way a wrong password does, whereas withholding a mechanism that a user does hold locks that user out entirely, as an inbound mechanism that was never advertised is rejected outright.- Parameters:
username- the username to check- Returns:
- the names of the SCRAM mechanisms for which credentials are available for the user.
-
getFallbackScramMechanisms
Returns the names of the SCRAM mechanisms that can be assumed to be usable by any user, for use when the user that is going to authenticate cannot be identified.Implementations must not create or modify credentials as a side effect.
- Returns:
- the names of the SCRAM mechanisms that every user is assumed to have credentials for.
-
getScramCredential
default ScramCredentialData getScramCredential(String username, String mechanism) throws UnsupportedOperationException, UserNotFoundException Returns SCRAM credentials for a user and mechanism. This default implementation is backed by the deprecated single-argument accessors, which can only supplySCRAM-SHA-1material. It therefore supports only theSCRAM-SHA-1mechanism (with or without the-PLUSsuffix). Providers that add support for other SCRAM mechanisms must override this method.- Parameters:
username- the username of the user.mechanism- the SCRAM mechanism name.- Returns:
- the SCRAM credentials for the user under the (normalized) mechanism.
- Throws:
UnsupportedOperationException- if the mechanism is notSCRAM-SHA-1.UserNotFoundException- if the user's credentials could not be loaded.
-
getSalt
default String getSalt(String username, String mechanism) throws UnsupportedOperationException, UserNotFoundException Returns a SCRAM salt for a user and mechanism. -
getIterations
default int getIterations(String username, String mechanism) throws UnsupportedOperationException, UserNotFoundException Returns a SCRAM iteration count for a user and mechanism. -
getServerKey
default String getServerKey(String username, String mechanism) throws UnsupportedOperationException, UserNotFoundException Returns a SCRAM server key for a user and mechanism. -
getStoredKey
default String getStoredKey(String username, String mechanism) throws UnsupportedOperationException, UserNotFoundException Returns a SCRAM stored key for a user and mechanism. -
getSalt
@Deprecated(forRemoval=true) String getSalt(String username) throws UnsupportedOperationException, UserNotFoundException Deprecated, for removal: This API element is subject to removal in a future version.Use getSalt(String, String) with the mechanism name.Returns a SCRAM-SHA-1 salt for a user. -
getIterations
@Deprecated(forRemoval=true) int getIterations(String username) throws UnsupportedOperationException, UserNotFoundException Deprecated, for removal: This API element is subject to removal in a future version.Use getIterations(String, String) with the mechanism name.Returns a SCRAM-SHA-1 iteration count for a user. -
getServerKey
@Deprecated(forRemoval=true) String getServerKey(String username) throws UnsupportedOperationException, UserNotFoundException Deprecated, for removal: This API element is subject to removal in a future version.Use getServerKey(String, String) with the mechanism name.Returns a SCRAM-SHA-1 server key for a user. -
getStoredKey
@Deprecated(forRemoval=true) String getStoredKey(String username) throws UnsupportedOperationException, UserNotFoundException Deprecated, for removal: This API element is subject to removal in a future version.Use getStoredKey(String, String) with the mechanism name.Returns a SCRAM-SHA-1 stored key for a user.
-