Class HybridAuthProvider
- All Implemented Interfaces:
AuthProvider
- Attempt authentication using the primary provider. If that fails:
- If the secondary provider is defined, attempt authentication (otherwise return). If that fails:
- If the tertiary provider is defined, attempt authentication.
MappedAuthProvider. The Hybrid variant of the provider iterates
over providers, operating on the first applicable instance. The Mapped variant, however, maps each user to exactly
one provider.
To enable this provider, set the provider.auth.className system property to
org.jivesoftware.openfire.auth.HybridAuthProvider.
The primary, secondary, and tertiary providers are configured be setting system properties similar to
the following:
hybridAuthProvider.primaryProvider = org.jivesoftware.openfire.auth.DefaultAuthProviderhybridAuthProvider.secondaryProvider = org.jivesoftware.openfire.auth.NativeAuthProvider
The primary provider is required, but all other properties are optional. Each provider should be configured as it is normally, using whatever XML configuration options it specifies. When using multiple providers of the same type, it typically is desirable to have distinct configuration for each provider. To do so, a property with the name 'config' can be used. If used, the value of this property is passed as a string to the constructor of the provider (for this to work, the provider must have a constructor that takes exactly one argument: a string). Typically, this value is used to reference another property name that the provider can use to obtain its information for, but the value is treated as an opaque string by this implementation. The full list of properties:
hybridAuthProvider.primaryProvider.className(required) -- the class name of the auth provider.hybridAuthProvider.primaryProvider.config-- A value used by the auth provider for configuration (typically the name of another property).hybridAuthProvider.primaryProvider.overrideList-- a comma-delimited list of usernames for which authentication will only be tried with this provider.hybridAuthProvider.secondaryProvider.className-- the class name of the auth provider.hybridAuthProvider.secondaryProvider.config-- A value used by the auth provider for configuration (typically the name of another property).hybridAuthProvider.secondaryProvider.overrideList-- a comma-delimited list of usernames for which authentication will only be tried with this provider.hybridAuthProvider.tertiaryProvider.className-- the class name of the auth provider.hybridAuthProvider.tertiaryProvider.config-- A value used by the auth provider for configuration (typically the name of another property).hybridAuthProvider.tertiaryProvider.overrideList-- a comma-delimited list of usernames for which authentication will only be tried with this provider.
- Author:
- Matt Tucker
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final SystemProperty<Class>static final SystemProperty<String>static final SystemProperty<Class>static final SystemProperty<String>static final SystemProperty<Class>static final SystemProperty<String> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidauthenticate(String username, String password) Returns if the username and password are valid; otherwise this method throws an UnauthorizedException.intgetIterations(String username) Deprecated, for removal: This API element is subject to removal in a future version.getPassword(String username) Returns the user's password.Deprecated, for removal: This API element is subject to removal in a future version.getScramCredential(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.getStoredKey(String username) Deprecated, for removal: This API element is subject to removal in a future version.voidsetPassword(String username, String password) Sets the user's password.Methods inherited from class org.jivesoftware.openfire.auth.AuthMultiProvider
getFallbackScramMechanisms, getIterations, getSalt, getServerKey, getStoredKey, instantiate, instantiate, isScramSupported, supportsPasswordRetrieval
-
Field Details
-
PRIMARY_PROVIDER
-
PRIMARY_PROVIDER_CONFIG
-
SECONDARY_PROVIDER
-
SECONDARY_PROVIDER_CONFIG
-
TERTIARY_PROVIDER
-
TERTIARY_PROVIDER_CONFIG
-
-
Constructor Details
-
HybridAuthProvider
public HybridAuthProvider()
-
-
Method Details
-
getScramMechanisms
Returns the names of the SCRAM mechanisms for which credentials are available for a user. Unlike the mapped variant, this provider attempts authentication with each backing provider in turn, so a mechanism that any of them can service is usable: the reported set is their union. When no provider reports anything, the inherited fallback applies, which is deliberately the intersection of what the providers guarantee, as it must hold for a user that cannot be identified at all.- Specified by:
getScramMechanismsin interfaceAuthProvider- Overrides:
getScramMechanismsin classAuthMultiProvider- Parameters:
username- the username to check- Returns:
- the names of the SCRAM mechanisms for which credentials are available for the user.
-
authenticate
public void authenticate(String username, String password) throws UnauthorizedException, ConnectionException, InternalUnauthenticatedException Description copied from interface:AuthProviderReturns if the username and password are valid; otherwise this method throws an UnauthorizedException.- Specified by:
authenticatein interfaceAuthProvider- Overrides:
authenticatein classAuthMultiProvider- 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
public String getPassword(String username) throws UserNotFoundException, UnsupportedOperationException Description copied from interface:AuthProviderReturns the user's password. This method should throw an UnsupportedOperationException if this operation is not supported by the backend user store.- Specified by:
getPasswordin interfaceAuthProvider- Overrides:
getPasswordin classAuthMultiProvider- 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
public void setPassword(String username, String password) throws UserNotFoundException, UnsupportedOperationException Description copied from interface:AuthProviderSets the user's password. This method should throw an UnsupportedOperationException if this operation is not supported by the backend user store.- Specified by:
setPasswordin interfaceAuthProvider- Overrides:
setPasswordin classAuthMultiProvider- 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).
-
getSalt
@Deprecated(forRemoval=true) public String getSalt(String username) throws UnsupportedOperationException, UserNotFoundException Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:AuthProviderReturns a SCRAM-SHA-1 salt for a user.- Specified by:
getSaltin interfaceAuthProvider- Overrides:
getSaltin classAuthMultiProvider- Throws:
UnsupportedOperationExceptionUserNotFoundException
-
getIterations
@Deprecated(forRemoval=true) public int getIterations(String username) throws UnsupportedOperationException, UserNotFoundException Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:AuthProviderReturns a SCRAM-SHA-1 iteration count for a user.- Specified by:
getIterationsin interfaceAuthProvider- Overrides:
getIterationsin classAuthMultiProvider- Throws:
UnsupportedOperationExceptionUserNotFoundException
-
getServerKey
@Deprecated(forRemoval=true) public String getServerKey(String username) throws UnsupportedOperationException, UserNotFoundException Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:AuthProviderReturns a SCRAM-SHA-1 server key for a user.- Specified by:
getServerKeyin interfaceAuthProvider- Overrides:
getServerKeyin classAuthMultiProvider- Throws:
UnsupportedOperationExceptionUserNotFoundException
-
getStoredKey
@Deprecated(forRemoval=true) public String getStoredKey(String username) throws UnsupportedOperationException, UserNotFoundException Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:AuthProviderReturns a SCRAM-SHA-1 stored key for a user.- Specified by:
getStoredKeyin interfaceAuthProvider- Overrides:
getStoredKeyin classAuthMultiProvider- Throws:
UnsupportedOperationExceptionUserNotFoundException
-
getScramCredential
public ScramCredentialData getScramCredential(String username, String mechanism) throws UnsupportedOperationException, UserNotFoundException Returns SCRAM credentials for a user and mechanism.- Specified by:
getScramCredentialin interfaceAuthProvider- Overrides:
getScramCredentialin classAuthMultiProvider- 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.
-