Class AuthenticationConfiguration
- java.lang.Object
-
- org.wildfly.security.auth.client.AuthenticationConfiguration
-
public final class AuthenticationConfiguration extends Object
A configuration which controls how authentication is performed.- Author:
- David M. Lloyd, Darran Lofthouse
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
AuthenticationConfiguration.ClientCallbackHandler
-
Field Summary
-
Constructor Summary
Constructors Modifier Constructor Description private
AuthenticationConfiguration()
Construct the empty configuration instance.private
AuthenticationConfiguration(AuthenticationConfiguration original, int port)
Copy constructor for mutating the port number.private
AuthenticationConfiguration(AuthenticationConfiguration original, int what, Object value)
Copy constructor for mutating one object field.private
AuthenticationConfiguration(AuthenticationConfiguration original, int what1, Object value1, int what2, Object value2)
Copy constructor for mutating two object fields.private
AuthenticationConfiguration(AuthenticationConfiguration original, int what1, Object value1, int what2, Object value2, int what3, Object value3)
Copy constructor for mutating three object fields.private
AuthenticationConfiguration(AuthenticationConfiguration original, AuthenticationConfiguration other)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description AuthenticationConfiguration
captureAuthorizationIdentity()
Create a new configuration which is the same as this configuration, but which attempts to authorize to the principal from the current identity from the configured security domain.(package private) CallbackHandler
createCallbackHandler()
(package private) SaslClient
createSaslClient(URI uri, Collection<String> serverMechanisms, UnaryOperator<SaslClientFactory> factoryOperator, SSLSession sslSession)
(package private) Principal
doRewriteUser(Principal original)
static AuthenticationConfiguration
empty()
An empty configuration which can be used as the basis for any configuration.boolean
equals(Object obj)
Determine whether this configuration is equal to another object.boolean
equals(AuthenticationConfiguration other)
Determine whether this configuration is equal to another object.(package private) Principal
getAuthorizationPrincipal()
(package private) AccessControlContext
getCapturedContext()
(package private) CredentialSource
getCredentialSource()
(package private) String
getHost()
Deprecated.private static int
getOrDefault(int value, int defVal)
private static <T> T
getOrDefault(T value, T defVal)
(package private) int
getPort()
Deprecated.(package private) Principal
getPrincipal()
(package private) String
getProtocol()
Deprecated.(package private) Supplier<Provider[]>
getProviderSupplier()
private SaslClientFactory
getSaslClientFactory()
(package private) SaslClientFactory
getSaslClientFactory(Supplier<Provider[]> providers)
(package private) String
getSaslProtocol()
(package private) CallbackHandler
getUserCallbackHandler()
(package private) EnumSet<CallbackKind>
getUserCallbackKinds()
(package private) String
getWsHttpMechanism()
(package private) String
getWsSecurityType()
(package private) SecurityFactory<X509KeyManager>
getX509KeyManagerFactory()
(package private) SecurityFactory<X509TrustManager>
getX509TrustManagerFactory()
int
hashCode()
Get the hash code of this authentication configuration.private static <K,V>
Map<K,V>optimizeMap(Map<K,V> orig)
AuthenticationConfiguration
rewriteUser(NameRewriter rewriter)
Create a new configuration which is the same as this configuration, but rewrites the user name using the given name rewriter.AuthenticationConfiguration
rewriteUserOnlyWith(NameRewriter rewriter)
Create a new configuration which is the same as this configuration, but rewrites the user name using only the given name rewriter.private void
sanitazeOnMutation(int what)
(package private) boolean
saslSupportedByConfiguration(String mechanismName)
Determine if this SASL mechanism is supported by this configuration (not policy).AuthenticationConfiguration
setSaslMechanismSelector(SaslMechanismSelector saslMechanismSelector)
Set the SASL mechanism selector for this authentication configuration.String
toString()
AuthenticationConfiguration
useAnonymous()
Create a new configuration which is the same as this configuration, but which uses an anonymous login.AuthenticationConfiguration
useAuthorizationName(String name)
Create a new configuration which is the same as this configuration, but which attempts to authorize to the given name after authentication.AuthenticationConfiguration
useAuthorizationPrincipal(Principal principal)
Create a new configuration which is the same as this configuration, but which attempts to authorize to the given principal after authentication.AuthenticationConfiguration
useBearerTokenCredential(BearerTokenCredential credential)
Create a new configuration which is the same as this configuration, but which uses the givenBearerTokenCredential
to authenticate.AuthenticationConfiguration
useCallbackHandler(CallbackHandler callbackHandler)
Create a new configuration which is the same as this configuration, but which uses the given callback handler to authenticate.AuthenticationConfiguration
useCallbackHandler(CallbackHandler callbackHandler, Set<CallbackKind> callbackKinds)
Create a new configuration which is the same as this configuration, but which uses the given callback handler to authenticate.AuthenticationConfiguration
useCertificateCredential(PrivateKey privateKey, X509Certificate... certificateChain)
Create a new configuration which is the same as this configuration, but which uses the given private key and X.509 certificate chain to authenticate.AuthenticationConfiguration
useCertificateCredential(X509CertificateChainPrivateCredential credential)
Create a new configuration which is the same as this configuration, but which uses the given private key and X.509 certificate chain to authenticate.AuthenticationConfiguration
useChoice(BiPredicate<Class<? extends ChoiceCallback>,String> matchPredicate, String choice)
Create a new configuration which is the same as this configuration, but which uses the given choice if the given predicate evaluates totrue
.AuthenticationConfiguration
useCredential(Credential credential)
Create a new configuration which is the same as this configuration, but which uses the given credential to authenticate.AuthenticationConfiguration
useCredentialCallbackHandler(CallbackHandler callbackHandler)
Create a new configuration which is the same as this configuration, but which uses the given callback handler to acquire a password with which to authenticate, when a password-based authentication algorithm is in use.AuthenticationConfiguration
useCredentials(CredentialSource credentials)
Create a new configuration which is the same as this configuration, but which uses the given identity credentials to acquire the credential required for authentication.AuthenticationConfiguration
useCredentialStoreEntry(CredentialStore credentialStore, String alias)
Create a new configuration which is the same as this configuration, but uses credentials found at the given alias and credential store.AuthenticationConfiguration
useDefaultProviders()
Use the default provider discovery behaviour of combining service loader discovered providers with the system default security providers when locating security implementations.AuthenticationConfiguration
useForwardedAuthenticationCredentials(SecurityDomain securityDomain)
Create a new configuration which is the same as this configuration, but which forwards the authentication credentials from the current identity of the given security domain.AuthenticationConfiguration
useForwardedAuthenticationIdentity(SecurityDomain securityDomain)
Create a new configuration which is the same as this configuration, but which forwards the authentication name from the current identity of the given security domain.AuthenticationConfiguration
useForwardedAuthorizationIdentity(SecurityDomain securityDomain)
Create a new configuration which is the same as this configuration, but which forwards the authorization name from the current identity of the given security domain.AuthenticationConfiguration
useForwardedIdentity(SecurityDomain securityDomain)
Create a new configuration which is the same as this configuration, but which forwards the authentication name and credentials from the current identity of the given security domain.AuthenticationConfiguration
useGSSCredential(GSSCredential credential)
Create a new configuration which is the same as this configuration, but which uses the given GSS-API credential to authenticate.AuthenticationConfiguration
useHost(String hostName)
Deprecated.This configuration is not supported by most providers and will be removed in a future release.AuthenticationConfiguration
useKerberosSecurityFactory(SecurityFactory<? extends Credential> kerberosSecurityFactory)
Deprecated.AuthenticationConfiguration
useKeyManagerCredential(X509KeyManager keyManager)
Create a new configuration which is the same as this configuration, but which uses the given key manager to acquire the credential required for authentication.AuthenticationConfiguration
useKeyStoreCredential(KeyStore.Entry keyStoreEntry)
Create a new configuration which is the same as this configuration, but which uses the given key store and alias to acquire the credential required for authentication.AuthenticationConfiguration
useKeyStoreCredential(KeyStore keyStore, String alias)
Create a new configuration which is the same as this configuration, but which uses the given key store and alias to acquire the credential required for authentication.AuthenticationConfiguration
useKeyStoreCredential(KeyStore keyStore, String alias, KeyStore.ProtectionParameter protectionParameter)
Create a new configuration which is the same as this configuration, but which uses the given key store and alias to acquire the credential required for authentication.AuthenticationConfiguration
useLocalKerberosCredential(Oid[] mechanismOids)
Deprecated.can be ommited - kerberos based authentication mechanism obtains credential himselfAuthenticationConfiguration
useMaskedPassword(byte[] maskedPasswordBytes, String algorithm, char[] initialKeyMaterial, int iterationCount, byte[] salt, byte[] initializationVector)
Create a new configuration which is the same as this configuration, but which uses the given masked password to authenticate.AuthenticationConfiguration
useMaskedPassword(String maskedPassword, String algorithm, String initialKeyMaterial, int iterationCount, String salt, String initializationVector)
Create a new configuration which is the same as this configuration, but which uses the given masked password to authenticate.AuthenticationConfiguration
useMaskedPassword(MaskedPassword password)
Create a new configuration which is the same as this configuration, but converts the given masked password to a clear password and uses the clear password to authenticate.AuthenticationConfiguration
useMechanismProperties(Map<String,?> mechanismProperties)
Deprecated.AuthenticationConfiguration
useMechanismProperties(Map<String,?> mechanismProperties, boolean exclusive)
Deprecated.AuthenticationConfiguration
useName(String name)
Create a new configuration which is the same as this configuration, but which uses the given login name to authenticate.AuthenticationConfiguration
useParameterSpec(AlgorithmParameterSpec parameterSpec)
Create a new configuration which is the same as this configuration, but which uses the given parameter specification.AuthenticationConfiguration
usePassword(char[] password)
Create a new configuration which is the same as this configuration, but which uses the given password to authenticate.AuthenticationConfiguration
usePassword(String password)
Create a new configuration which is the same as this configuration, but which uses the given password to authenticate.AuthenticationConfiguration
usePassword(Password password)
Create a new configuration which is the same as this configuration, but which uses the given password to authenticate.AuthenticationConfiguration
usePort(int port)
Deprecated.This configuration is not supported by most providers and will be removed in a future release.AuthenticationConfiguration
usePrincipal(Principal principal)
Create a new configuration which is the same as this configuration, but which uses the given principal to authenticate.AuthenticationConfiguration
usePrincipal(NamePrincipal principal)
Create a new configuration which is the same as this configuration, but which uses the given principal to authenticate.AuthenticationConfiguration
useProtocol(String protocol)
Deprecated.This configuration is not supported by most providers and will be removed in a future release.AuthenticationConfiguration
useProviders(Supplier<Provider[]> providerSupplier)
Use the given security provider supplier to locate security implementations.AuthenticationConfiguration
useProvidersFromClassLoader(ClassLoader classLoader)
Use security providers from the given class loader.AuthenticationConfiguration
useRealm(String realm)
Create a new configuration which is the same as this configuration, but uses the given realm for authentication.AuthenticationConfiguration
useSaslClientFactory(Supplier<SaslClientFactory> saslClientFactory)
Use the given sasl client factory supplier to obtain theSaslClientFactory
to use.AuthenticationConfiguration
useSaslClientFactory(SaslClientFactory saslClientFactory)
Use a pre-existingSaslClientFactory
instead of discovery.AuthenticationConfiguration
useSaslClientFactoryFromProviders()
Use provider based discovery to load availableSaslClientFactory
implementations.AuthenticationConfiguration
useSaslMechanismProperties(Map<String,?> mechanismProperties)
Create a new configuration which is the same as this configuration, but which sets the properties that will be passed to theSaslClientFactory
when the mechanism is created.AuthenticationConfiguration
useSaslMechanismProperties(Map<String,?> mechanismProperties, boolean exclusive)
Create a new configuration which is the same as this configuration, but which sets the properties that will be passed to theSaslClientFactory
when the mechanism is created.AuthenticationConfiguration
useSaslProtocol(String saslProtocol)
Create a new configuration which is the same as this configuration, but which specifies a different protocol to be passed to the authentication mechanisms.AuthenticationConfiguration
useTrustManager(X509TrustManager trustManager)
Create a new configuration which is the same as this configuration, but which uses the given trust manager for trust verification.AuthenticationConfiguration
useWebServices(Map<String,?> webservicesProperties)
AuthenticationConfiguration
useWebServicesProperties(Map<String,?> webServicesProperties)
Create a new configuration which is the same as this configuration, but which sets the properties that can be used by WebServices client.AuthenticationConfiguration
with(AuthenticationConfiguration other)
Create a new configuration which is the same as this configuration, but which adds or replaces every item in theother
configuration with that item, overwriting any corresponding such item in this configuration.AuthenticationConfiguration
withCapturedAccessControlContext()
Create a new configuration which is the same as this configuration, but which captures the caller's access control context to be used in authentication decisions.
-
-
-
Field Detail
-
NO_PRINCIPALS
private static final Principal[] NO_PRINCIPALS
-
NO_CALLBACKS
private static final Callback[] NO_CALLBACKS
-
NO_STRINGS
private static final String[] NO_STRINGS
-
NO_CALLBACK_KINDS
private static final EnumSet<CallbackKind> NO_CALLBACK_KINDS
-
SET_PRINCIPAL
private static final int SET_PRINCIPAL
- See Also:
- Constant Field Values
-
SET_HOST
private static final int SET_HOST
- See Also:
- Constant Field Values
-
SET_PROTOCOL
private static final int SET_PROTOCOL
- See Also:
- Constant Field Values
-
SET_REALM
private static final int SET_REALM
- See Also:
- Constant Field Values
-
SET_AUTHZ_PRINCIPAL
private static final int SET_AUTHZ_PRINCIPAL
- See Also:
- Constant Field Values
-
SET_FWD_AUTH_NAME_DOMAIN
private static final int SET_FWD_AUTH_NAME_DOMAIN
- See Also:
- Constant Field Values
-
SET_USER_CBH
private static final int SET_USER_CBH
- See Also:
- Constant Field Values
-
SET_USER_CB_KINDS
private static final int SET_USER_CB_KINDS
- See Also:
- Constant Field Values
-
SET_CRED_SOURCE
private static final int SET_CRED_SOURCE
- See Also:
- Constant Field Values
-
SET_PROVIDER_SUPPLIER
private static final int SET_PROVIDER_SUPPLIER
- See Also:
- Constant Field Values
-
SET_KEY_MGR_FAC
private static final int SET_KEY_MGR_FAC
- See Also:
- Constant Field Values
-
SET_SASL_SELECTOR
private static final int SET_SASL_SELECTOR
- See Also:
- Constant Field Values
-
SET_FWD_AUTH_CRED_DOMAIN
private static final int SET_FWD_AUTH_CRED_DOMAIN
- See Also:
- Constant Field Values
-
SET_PRINCIPAL_RW
private static final int SET_PRINCIPAL_RW
- See Also:
- Constant Field Values
-
SET_SASL_FAC_SUP
private static final int SET_SASL_FAC_SUP
- See Also:
- Constant Field Values
-
SET_PARAM_SPECS
private static final int SET_PARAM_SPECS
- See Also:
- Constant Field Values
-
SET_TRUST_MGR_FAC
private static final int SET_TRUST_MGR_FAC
- See Also:
- Constant Field Values
-
SET_SASL_MECH_PROPS
private static final int SET_SASL_MECH_PROPS
- See Also:
- Constant Field Values
-
SET_ACCESS_CTXT
private static final int SET_ACCESS_CTXT
- See Also:
- Constant Field Values
-
SET_CALLBACK_INTERCEPT
private static final int SET_CALLBACK_INTERCEPT
- See Also:
- Constant Field Values
-
SET_SASL_PROTOCOL
private static final int SET_SASL_PROTOCOL
- See Also:
- Constant Field Values
-
SET_FWD_AUTHZ_NAME_DOMAIN
private static final int SET_FWD_AUTHZ_NAME_DOMAIN
- See Also:
- Constant Field Values
-
SET_WEBSERVICES_PROPS
private static final int SET_WEBSERVICES_PROPS
- See Also:
- Constant Field Values
-
JBOSS_LOCAL_USER_QUIET_AUTH
private static final String JBOSS_LOCAL_USER_QUIET_AUTH
- See Also:
- Constant Field Values
-
JBOSS_LOCAL_USER_LEGACY_QUIET_AUTH
private static final String JBOSS_LOCAL_USER_LEGACY_QUIET_AUTH
- See Also:
- Constant Field Values
-
WILDFLY_ELYTRON_CAPTURE_ACCESS_CONTROL_CONTEXT_PROPERTY_NAME
static final String WILDFLY_ELYTRON_CAPTURE_ACCESS_CONTROL_CONTEXT_PROPERTY_NAME
- See Also:
- Constant Field Values
-
WILDFLY_ELYTRON_CAPTURE_ACCESS_CONTROL_CONTEXT_PROPERTY
static final boolean WILDFLY_ELYTRON_CAPTURE_ACCESS_CONTROL_CONTEXT_PROPERTY
-
EMPTY
@Deprecated public static final AuthenticationConfiguration EMPTY
Deprecated.to obtain empty configuration useempty()
method insteadAn empty configuration which can be used as the basis for any configuration. This configuration supports no remapping of any kind, and always uses an anonymous principal.
-
saslClientFactory
private volatile SaslClientFactory saslClientFactory
-
hashCode
private int hashCode
-
toString
private String toString
-
capturedAccessContext
final AccessControlContext capturedAccessContext
-
principal
@NotNull final Principal principal
-
setHost
final String setHost
-
setProtocol
final String setProtocol
-
setRealm
final String setRealm
-
setAuthzPrincipal
final Principal setAuthzPrincipal
-
authenticationNameForwardSecurityDomain
final SecurityDomain authenticationNameForwardSecurityDomain
-
authenticationCredentialsForwardSecurityDomain
final SecurityDomain authenticationCredentialsForwardSecurityDomain
-
authorizationNameForwardSecurityDomain
final SecurityDomain authorizationNameForwardSecurityDomain
-
userCallbackHandler
final CallbackHandler userCallbackHandler
-
userCallbackKinds
final EnumSet<CallbackKind> userCallbackKinds
-
credentialSource
final CredentialSource credentialSource
-
setPort
final int setPort
-
keyManagerFactory
final SecurityFactory<X509KeyManager> keyManagerFactory
-
saslMechanismSelector
final SaslMechanismSelector saslMechanismSelector
-
saslClientFactorySupplier
final Supplier<SaslClientFactory> saslClientFactorySupplier
-
parameterSpecs
final List<AlgorithmParameterSpec> parameterSpecs
-
trustManagerFactory
final SecurityFactory<X509TrustManager> trustManagerFactory
-
saslProtocol
final String saslProtocol
-
-
Constructor Detail
-
AuthenticationConfiguration
private AuthenticationConfiguration()
Construct the empty configuration instance.
-
AuthenticationConfiguration
private AuthenticationConfiguration(AuthenticationConfiguration original, int what, Object value)
Copy constructor for mutating one object field. It's not pretty but the alternative (many constructors) is much worse.- Parameters:
original
- the original configuration (must not benull
)what
- the field to mutatevalue
- the field value to set
-
AuthenticationConfiguration
private AuthenticationConfiguration(AuthenticationConfiguration original, int what1, Object value1, int what2, Object value2)
Copy constructor for mutating two object fields. It's not pretty but the alternative (many constructors) is much worse.- Parameters:
original
- the original configuration (must not benull
)what1
- the field to mutatevalue1
- the field value to setwhat2
- the field to mutatevalue2
- the field value to set
-
AuthenticationConfiguration
private AuthenticationConfiguration(AuthenticationConfiguration original, int what1, Object value1, int what2, Object value2, int what3, Object value3)
Copy constructor for mutating three object fields.- Parameters:
original
- the original configuration (must not benull
)what1
- the field to mutatevalue1
- the field value to setwhat2
- the field to mutatevalue2
- the field value to setwhat3
- the field to mutatevalue3
- the field value to set
-
AuthenticationConfiguration
private AuthenticationConfiguration(AuthenticationConfiguration original, int port)
Copy constructor for mutating the port number.- Parameters:
original
- the original configuration (must not benull
)port
- the port number
-
AuthenticationConfiguration
private AuthenticationConfiguration(AuthenticationConfiguration original, AuthenticationConfiguration other)
-
-
Method Detail
-
empty
public static AuthenticationConfiguration empty()
An empty configuration which can be used as the basis for any configuration. This configuration supports no remapping of any kind, and always uses an anonymous principal.
-
getOrDefault
private static <T> T getOrDefault(T value, T defVal)
-
getOrDefault
private static int getOrDefault(int value, int defVal)
-
getPrincipal
Principal getPrincipal()
-
getHost
@Deprecated String getHost()
Deprecated.
-
getProtocol
@Deprecated String getProtocol()
Deprecated.
-
getSaslProtocol
String getSaslProtocol()
-
getPort
@Deprecated int getPort()
Deprecated.
-
getWsHttpMechanism
String getWsHttpMechanism()
-
getWsSecurityType
String getWsSecurityType()
-
saslSupportedByConfiguration
boolean saslSupportedByConfiguration(String mechanismName)
Determine if this SASL mechanism is supported by this configuration (not policy). Implementations must combine using boolean-OR operations.- Parameters:
mechanismName
- the mech name (must not benull
)- Returns:
true
if supported,false
otherwise
-
getAuthorizationPrincipal
Principal getAuthorizationPrincipal()
-
getSaslClientFactory
SaslClientFactory getSaslClientFactory(Supplier<Provider[]> providers)
-
getX509TrustManagerFactory
SecurityFactory<X509TrustManager> getX509TrustManagerFactory()
-
getX509KeyManagerFactory
SecurityFactory<X509KeyManager> getX509KeyManagerFactory()
-
getCredentialSource
CredentialSource getCredentialSource()
-
rewriteUser
public AuthenticationConfiguration rewriteUser(NameRewriter rewriter)
Create a new configuration which is the same as this configuration, but rewrites the user name using the given name rewriter. The name rewriter is appended to the the existing name rewrite function.- Parameters:
rewriter
- the name rewriter- Returns:
- the new configuration
-
rewriteUserOnlyWith
public AuthenticationConfiguration rewriteUserOnlyWith(NameRewriter rewriter)
Create a new configuration which is the same as this configuration, but rewrites the user name using only the given name rewriter. Any name rewriters on this configuration are ignored for the new configuration.- Parameters:
rewriter
- the name rewriter- Returns:
- the new configuration
-
useAnonymous
public AuthenticationConfiguration useAnonymous()
Create a new configuration which is the same as this configuration, but which uses an anonymous login.- Returns:
- the new configuration
-
usePrincipal
public AuthenticationConfiguration usePrincipal(NamePrincipal principal)
Create a new configuration which is the same as this configuration, but which uses the given principal to authenticate.- Parameters:
principal
- the principal to use (must not benull
)- Returns:
- the new configuration
-
usePrincipal
public AuthenticationConfiguration usePrincipal(Principal principal)
Create a new configuration which is the same as this configuration, but which uses the given principal to authenticate.- Parameters:
principal
- the principal to use (must not benull
)- Returns:
- the new configuration
-
useName
public AuthenticationConfiguration useName(String name)
Create a new configuration which is the same as this configuration, but which uses the given login name to authenticate.- Parameters:
name
- the principal to use (must not benull
)- Returns:
- the new configuration
-
useAuthorizationName
public AuthenticationConfiguration useAuthorizationName(String name)
Create a new configuration which is the same as this configuration, but which attempts to authorize to the given name after authentication. Only mechanisms which support an authorization name principal will be selected.- Parameters:
name
- the name to use, ornull
to not request authorization in the new configuration- Returns:
- the new configuration
-
useAuthorizationPrincipal
public AuthenticationConfiguration useAuthorizationPrincipal(Principal principal)
Create a new configuration which is the same as this configuration, but which attempts to authorize to the given principal after authentication. Only mechanisms which support an authorization principal of the given type will be selected.- Parameters:
principal
- the principal to use, ornull
to not request authorization in the new configuration- Returns:
- the new configuration
-
useCredential
public AuthenticationConfiguration useCredential(Credential credential)
Create a new configuration which is the same as this configuration, but which uses the given credential to authenticate.- Parameters:
credential
- the credential to authenticate- Returns:
- the new configuration
-
usePassword
public AuthenticationConfiguration usePassword(Password password)
Create a new configuration which is the same as this configuration, but which uses the given password to authenticate.- Parameters:
password
- the password to use- Returns:
- the new configuration
-
usePassword
public AuthenticationConfiguration usePassword(char[] password)
Create a new configuration which is the same as this configuration, but which uses the given password to authenticate.- Parameters:
password
- the password to use- Returns:
- the new configuration
-
usePassword
public AuthenticationConfiguration usePassword(String password)
Create a new configuration which is the same as this configuration, but which uses the given password to authenticate.- Parameters:
password
- the password to use- Returns:
- the new configuration
-
useMaskedPassword
public AuthenticationConfiguration useMaskedPassword(MaskedPassword password) throws NoSuchAlgorithmException, InvalidKeySpecException
Create a new configuration which is the same as this configuration, but converts the given masked password to a clear password and uses the clear password to authenticate.- Parameters:
password
- the password to use- Returns:
- the new configuration
- Throws:
NoSuchAlgorithmException
- if algorithm used to get PasswordFactory instance is invalidInvalidKeySpecException
- if invalid spec is used to generate password
-
useMaskedPassword
public AuthenticationConfiguration useMaskedPassword(byte[] maskedPasswordBytes, String algorithm, char[] initialKeyMaterial, int iterationCount, byte[] salt, byte[] initializationVector) throws NoSuchAlgorithmException, InvalidKeySpecException
Create a new configuration which is the same as this configuration, but which uses the given masked password to authenticate.- Parameters:
maskedPasswordBytes
- the masked password bytes (must not benull
)algorithm
- the algorithm (can benull
, default:"masked-MD5-DES")initialKeyMaterial
- the initial key material (can benull
, default:"somearbitrarycrazystringthatdoesnotmatter")iterationCount
- the iteration count (must not be less than 1)salt
- the salt bytes (must not benull
)initializationVector
- the initialization vector (can benull
)- Returns:
- the new configuration
- Throws:
NoSuchAlgorithmException
- if algorithm used to get PasswordFactory instance is invalidInvalidKeySpecException
- if invalid spec is used to generate password
-
useMaskedPassword
public AuthenticationConfiguration useMaskedPassword(String maskedPassword, String algorithm, String initialKeyMaterial, int iterationCount, String salt, String initializationVector) throws InvalidKeySpecException, NoSuchAlgorithmException
Create a new configuration which is the same as this configuration, but which uses the given masked password to authenticate.- Parameters:
maskedPassword
- the masked password, as a string (must not benull
)algorithm
- the algorithm (can benull
, default:"masked-MD5-DES")initialKeyMaterial
- the initial key material, as a string(can benull
, default:"somearbitrarycrazystringthatdoesnotmatter")iterationCount
- the iteration count, as an integer (must not be less than 1)salt
- the salt, as a string (must not benull
)initializationVector
- the initialization vector, as a string (can benull
)- Returns:
- the new configuration
- Throws:
NoSuchAlgorithmException
- if algorithm used to get PasswordFactory instance is invalidInvalidKeySpecException
- if invalid spec is used to generate password
-
useCredentialCallbackHandler
public AuthenticationConfiguration useCredentialCallbackHandler(CallbackHandler callbackHandler)
Create a new configuration which is the same as this configuration, but which uses the given callback handler to acquire a password with which to authenticate, when a password-based authentication algorithm is in use.- Parameters:
callbackHandler
- the password callback handler- Returns:
- the new configuration
-
useCallbackHandler
public AuthenticationConfiguration useCallbackHandler(CallbackHandler callbackHandler)
Create a new configuration which is the same as this configuration, but which uses the given callback handler to authenticate.Important notes: It is important to ensure that each distinct client identity uses a distinct
CallbackHandler
instance in order to avoid mis-pooling of connections, identity crossovers, and other potentially serious problems. It is not recommended that aCallbackHandler
implementequals()
andhashCode()
, however if it does, it is important to ensure that these methods consider equality based on an authenticating identity that does not change between instances. In particular, a callback handler which requests user input on each usage is likely to cause a problem if the user name can change on each authentication request.Because
CallbackHandler
instances are unique per identity, it is often useful for instances to cache identity information, credentials, and/or other authentication-related information in order to facilitate fast re-authentication.- Parameters:
callbackHandler
- the callback handler to use- Returns:
- the new configuration
-
useCallbackHandler
public AuthenticationConfiguration useCallbackHandler(CallbackHandler callbackHandler, Set<CallbackKind> callbackKinds)
Create a new configuration which is the same as this configuration, but which uses the given callback handler to authenticate.Important notes: It is important to ensure that each distinct client identity uses a distinct
CallbackHandler
instance in order to avoid mis-pooling of connections, identity crossovers, and other potentially serious problems. It is not recommended that aCallbackHandler
implementequals()
andhashCode()
, however if it does, it is important to ensure that these methods consider equality based on an authenticating identity that does not change between instances. In particular, a callback handler which requests user input on each usage is likely to cause a problem if the user name can change on each authentication request.Because
CallbackHandler
instances are unique per identity, it is often useful for instances to cache identity information, credentials, and/or other authentication-related information in order to facilitate fast re-authentication.- Parameters:
callbackHandler
- the callback handler to usecallbackKinds
- the kinds of callbacks that the handler should use- Returns:
- the new configuration
-
useGSSCredential
public AuthenticationConfiguration useGSSCredential(GSSCredential credential)
Create a new configuration which is the same as this configuration, but which uses the given GSS-API credential to authenticate.- Parameters:
credential
- the GSS-API credential to use- Returns:
- the new configuration
-
useKeyStoreCredential
public AuthenticationConfiguration useKeyStoreCredential(KeyStore.Entry keyStoreEntry)
Create a new configuration which is the same as this configuration, but which uses the given key store and alias to acquire the credential required for authentication.- Parameters:
keyStoreEntry
- the key store entry to use- Returns:
- the new configuration
-
useKeyStoreCredential
public AuthenticationConfiguration useKeyStoreCredential(KeyStore keyStore, String alias)
Create a new configuration which is the same as this configuration, but which uses the given key store and alias to acquire the credential required for authentication.- Parameters:
keyStore
- the key store to usealias
- the key store alias- Returns:
- the new configuration
-
useKeyStoreCredential
public AuthenticationConfiguration useKeyStoreCredential(KeyStore keyStore, String alias, KeyStore.ProtectionParameter protectionParameter)
Create a new configuration which is the same as this configuration, but which uses the given key store and alias to acquire the credential required for authentication.- Parameters:
keyStore
- the key store to usealias
- the key store aliasprotectionParameter
- the protection parameter to use to access the key store entry- Returns:
- the new configuration
-
useCertificateCredential
public AuthenticationConfiguration useCertificateCredential(PrivateKey privateKey, X509Certificate... certificateChain)
Create a new configuration which is the same as this configuration, but which uses the given private key and X.509 certificate chain to authenticate.- Parameters:
privateKey
- the client private keycertificateChain
- the client certificate chain- Returns:
- the new configuration
-
useCertificateCredential
public AuthenticationConfiguration useCertificateCredential(X509CertificateChainPrivateCredential credential)
Create a new configuration which is the same as this configuration, but which uses the given private key and X.509 certificate chain to authenticate.- Parameters:
credential
- the credential containing the private key and certificate chain- Returns:
- the new configuration
-
useCredentialStoreEntry
public AuthenticationConfiguration useCredentialStoreEntry(CredentialStore credentialStore, String alias)
Create a new configuration which is the same as this configuration, but uses credentials found at the given alias and credential store.- Parameters:
credentialStore
- the credential store (must not benull
)alias
- the alias within the store (must not benull
)- Returns:
- the new configuration
-
useKeyManagerCredential
public AuthenticationConfiguration useKeyManagerCredential(X509KeyManager keyManager)
Create a new configuration which is the same as this configuration, but which uses the given key manager to acquire the credential required for authentication.- Parameters:
keyManager
- the key manager to use- Returns:
- the new configuration
-
useLocalKerberosCredential
@Deprecated public AuthenticationConfiguration useLocalKerberosCredential(Oid[] mechanismOids)
Deprecated.can be ommited - kerberos based authentication mechanism obtains credential himselfCreate a new configuration which is the same as this configuration, but which uses local kerberos ticket cache to acquire the credential required for authentication.- Parameters:
mechanismOids
- array of oid's indicating the mechanisms over which the credential is to be acquired- Returns:
- the new configuration
- Since:
- 1.2.0
-
useCredentials
public AuthenticationConfiguration useCredentials(CredentialSource credentials)
Create a new configuration which is the same as this configuration, but which uses the given identity credentials to acquire the credential required for authentication.- Parameters:
credentials
- the credentials to use- Returns:
- the new configuration
-
useChoice
public AuthenticationConfiguration useChoice(BiPredicate<Class<? extends ChoiceCallback>,String> matchPredicate, String choice)
Create a new configuration which is the same as this configuration, but which uses the given choice if the given predicate evaluates totrue
.- Parameters:
matchPredicate
- the predicate that should be used to determine if a choice callback type and prompt are relevant for the given choicechoice
- the choice to use if the given predicate evaluates totrue
- Returns:
- the new configuration
-
useParameterSpec
public AuthenticationConfiguration useParameterSpec(AlgorithmParameterSpec parameterSpec)
Create a new configuration which is the same as this configuration, but which uses the given parameter specification.- Parameters:
parameterSpec
- the algorithm parameter specification to use- Returns:
- the new configuration
-
useTrustManager
public AuthenticationConfiguration useTrustManager(X509TrustManager trustManager)
Create a new configuration which is the same as this configuration, but which uses the given trust manager for trust verification.- Parameters:
trustManager
- the trust manager to use ornull
if the default trust manager should be used- Returns:
- the new configuration
-
useHost
@Deprecated public AuthenticationConfiguration useHost(String hostName)
Deprecated.This configuration is not supported by most providers and will be removed in a future release.Create a new configuration which is the same as this configuration, but which connects to a different host name.- Parameters:
hostName
- the host name to connect to- Returns:
- the new configuration
-
useProtocol
@Deprecated public AuthenticationConfiguration useProtocol(String protocol)
Deprecated.This configuration is not supported by most providers and will be removed in a future release.Create a new configuration which is the same as this configuration, but which specifies a different protocol to be used for outgoing connection.- Parameters:
protocol
- the protocol to be used for outgoing connection.- Returns:
- the new configuration
-
useSaslProtocol
public AuthenticationConfiguration useSaslProtocol(String saslProtocol)
Create a new configuration which is the same as this configuration, but which specifies a different protocol to be passed to the authentication mechanisms.- Parameters:
saslProtocol
- the protocol to pass to the authentication mechanisms.- Returns:
- the new configuration
-
useWebServices
public AuthenticationConfiguration useWebServices(Map<String,?> webservicesProperties)
-
usePort
@Deprecated public AuthenticationConfiguration usePort(int port)
Deprecated.This configuration is not supported by most providers and will be removed in a future release.Create a new configuration which is the same as this configuration, but which connects to a different port.- Parameters:
port
- the port to connect to, or -1 to not override the port- Returns:
- the new configuration
-
useForwardedIdentity
public AuthenticationConfiguration useForwardedIdentity(SecurityDomain securityDomain)
Create a new configuration which is the same as this configuration, but which forwards the authentication name and credentials from the current identity of the given security domain.- Parameters:
securityDomain
- the security domain- Returns:
- the new configuration
-
useForwardedAuthenticationIdentity
public AuthenticationConfiguration useForwardedAuthenticationIdentity(SecurityDomain securityDomain)
Create a new configuration which is the same as this configuration, but which forwards the authentication name from the current identity of the given security domain.- Parameters:
securityDomain
- the security domain- Returns:
- the new configuration
-
useForwardedAuthenticationCredentials
public AuthenticationConfiguration useForwardedAuthenticationCredentials(SecurityDomain securityDomain)
Create a new configuration which is the same as this configuration, but which forwards the authentication credentials from the current identity of the given security domain.- Parameters:
securityDomain
- the security domain- Returns:
- the new configuration
-
useForwardedAuthorizationIdentity
public AuthenticationConfiguration useForwardedAuthorizationIdentity(SecurityDomain securityDomain)
Create a new configuration which is the same as this configuration, but which forwards the authorization name from the current identity of the given security domain.- Parameters:
securityDomain
- the security domain- Returns:
- the new configuration
-
useProviders
public AuthenticationConfiguration useProviders(Supplier<Provider[]> providerSupplier)
Use the given security provider supplier to locate security implementations.- Parameters:
providerSupplier
- the provider supplier- Returns:
- the new configuration
-
useDefaultProviders
public AuthenticationConfiguration useDefaultProviders()
Use the default provider discovery behaviour of combining service loader discovered providers with the system default security providers when locating security implementations.- Returns:
- the new configuration
-
useProvidersFromClassLoader
public AuthenticationConfiguration useProvidersFromClassLoader(ClassLoader classLoader)
Use security providers from the given class loader.- Parameters:
classLoader
- the class loader to search for security providers- Returns:
- the new configuration
-
useSaslClientFactory
public AuthenticationConfiguration useSaslClientFactory(SaslClientFactory saslClientFactory)
Use a pre-existingSaslClientFactory
instead of discovery.- Parameters:
saslClientFactory
- the pre-existingSaslClientFactory
to use.- Returns:
- the new configuration.
-
useSaslClientFactory
public AuthenticationConfiguration useSaslClientFactory(Supplier<SaslClientFactory> saslClientFactory)
Use the given sasl client factory supplier to obtain theSaslClientFactory
to use.- Parameters:
saslClientFactory
- the sasl client factory supplier to use.- Returns:
- the new configuration.
-
useSaslClientFactoryFromProviders
public AuthenticationConfiguration useSaslClientFactoryFromProviders()
Use provider based discovery to load availableSaslClientFactory
implementations.- Returns:
- the new configuration.
-
useMechanismProperties
@Deprecated public AuthenticationConfiguration useMechanismProperties(Map<String,?> mechanismProperties)
Deprecated.Create a new configuration which is the same as this configuration, but which sets the properties that will be passed to theSaslClientFactory
when the mechanism is created. Existing properties defined on this authentication context will be retained unless overridden by new properties, any properties resulting with a value ofnull
will be removed.- Parameters:
mechanismProperties
- the properties to be passed to theSaslClientFactory
to create the mechanism.- Returns:
- the new configuration.
-
useSaslMechanismProperties
public AuthenticationConfiguration useSaslMechanismProperties(Map<String,?> mechanismProperties)
Create a new configuration which is the same as this configuration, but which sets the properties that will be passed to theSaslClientFactory
when the mechanism is created. Existing properties defined on this authentication context will be retained unless overridden by new properties, any properties resulting with a value ofnull
will be removed.- Parameters:
mechanismProperties
- the properties to be passed to theSaslClientFactory
to create the mechanism.- Returns:
- the new configuration.
-
useMechanismProperties
@Deprecated public AuthenticationConfiguration useMechanismProperties(Map<String,?> mechanismProperties, boolean exclusive)
Deprecated.Create a new configuration which is the same as this configuration, but which sets the properties that will be passed to theSaslClientFactory
when the mechanism is created. If exclusive the existing properties will be discarded and replaced with the new properties otherwise existing properties defined on this authentication context will be retained unless overridden by new properties, any properties resulting with a value ofnull
will be removed.- Parameters:
mechanismProperties
- the properties to be passed to theSaslClientFactory
to create the mechanism.exclusive
- should the provided properties be used exclusively or merged with the existing properties?- Returns:
- the new configuration.
-
useSaslMechanismProperties
public AuthenticationConfiguration useSaslMechanismProperties(Map<String,?> mechanismProperties, boolean exclusive)
Create a new configuration which is the same as this configuration, but which sets the properties that will be passed to theSaslClientFactory
when the mechanism is created. If exclusive the existing properties will be discarded and replaced with the new properties otherwise existing properties defined on this authentication context will be retained unless overridden by new properties, any properties resulting with a value ofnull
will be removed.- Parameters:
mechanismProperties
- the properties to be passed to theSaslClientFactory
to create the mechanism.exclusive
- should the provided properties be used exclusively or merged with the existing properties?- Returns:
- the new configuration.
-
useWebServicesProperties
public AuthenticationConfiguration useWebServicesProperties(Map<String,?> webServicesProperties)
Create a new configuration which is the same as this configuration, but which sets the properties that can be used by WebServices client.- Parameters:
webServicesProperties
- the properties that can be used by WS client.- Returns:
- the new configuration.
-
useKerberosSecurityFactory
@Deprecated public AuthenticationConfiguration useKerberosSecurityFactory(SecurityFactory<? extends Credential> kerberosSecurityFactory)
Deprecated.Create a new configuration which is the same as this configuration, but which uses the given kerberos security factory to acquire the GSS credential required for authentication.- Parameters:
kerberosSecurityFactory
- a reference to the kerberos security factory to be use- Returns:
- the new configuration
-
setSaslMechanismSelector
public AuthenticationConfiguration setSaslMechanismSelector(SaslMechanismSelector saslMechanismSelector)
Set the SASL mechanism selector for this authentication configuration.- Parameters:
saslMechanismSelector
- the SASL mechanism selector, ornull
to clear the current selector- Returns:
- the new configuration
-
useRealm
public AuthenticationConfiguration useRealm(String realm)
Create a new configuration which is the same as this configuration, but uses the given realm for authentication.- Parameters:
realm
- the realm to use, ornull
to accept the default realm always- Returns:
- the new configuration
-
useBearerTokenCredential
public AuthenticationConfiguration useBearerTokenCredential(BearerTokenCredential credential)
Create a new configuration which is the same as this configuration, but which uses the givenBearerTokenCredential
to authenticate.- Parameters:
credential
- the bearer token credential to use- Returns:
- the new configuration
-
withCapturedAccessControlContext
public AuthenticationConfiguration withCapturedAccessControlContext()
Create a new configuration which is the same as this configuration, but which captures the caller's access control context to be used in authentication decisions.- Returns:
- the new configuration
-
with
public AuthenticationConfiguration with(AuthenticationConfiguration other)
Create a new configuration which is the same as this configuration, but which adds or replaces every item in theother
configuration with that item, overwriting any corresponding such item in this configuration.- Parameters:
other
- the other authentication configuration- Returns:
- the merged authentication configuration
-
captureAuthorizationIdentity
public AuthenticationConfiguration captureAuthorizationIdentity()
Create a new configuration which is the same as this configuration, but which attempts to authorize to the principal from the current identity from the configured security domain.- Returns:
- the new configuration
-
getUserCallbackHandler
CallbackHandler getUserCallbackHandler()
-
getUserCallbackKinds
EnumSet<CallbackKind> getUserCallbackKinds()
-
getSaslClientFactory
private SaslClientFactory getSaslClientFactory()
-
createSaslClient
SaslClient createSaslClient(URI uri, Collection<String> serverMechanisms, UnaryOperator<SaslClientFactory> factoryOperator, SSLSession sslSession) throws SaslException
- Throws:
SaslException
-
createCallbackHandler
CallbackHandler createCallbackHandler()
-
equals
public boolean equals(Object obj)
Determine whether this configuration is equal to another object. Two configurations are equal if they apply the same items.
-
equals
public boolean equals(AuthenticationConfiguration other)
Determine whether this configuration is equal to another object. Two configurations are equal if they apply the same items.- Parameters:
other
- the other object- Returns:
true
if they are equal,false
otherwise
-
hashCode
public int hashCode()
Get the hash code of this authentication configuration.
-
sanitazeOnMutation
private void sanitazeOnMutation(int what)
-
getCapturedContext
AccessControlContext getCapturedContext()
-
-