Package org.wildfly.security.auth.client
Class AuthenticationContext
java.lang.Object
org.wildfly.security.auth.client.AuthenticationContext
- All Implemented Interfaces:
Contextual<AuthenticationContext>
public final class AuthenticationContext
extends Object
implements Contextual<AuthenticationContext>
A set of rules and authentication configurations to use with a client for establishing a connection.
- Author:
- David M. Lloyd
-
Method Summary
Modifier and TypeMethodDescriptionstatic AuthenticationContextGet the current thread's captured authentication context.static AuthenticationContextempty()Get a new, empty authentication context.static ContextManager<AuthenticationContext>Get the context manager for authentication contexts.Get the context manager for this object.replacing(int idx, MatchRule rule, AuthenticationConfiguration configuration) Get a new authentication context which is the same as this one, but which replaces the rule and configuration at the given index with the given rule and configuration.replacingSslContext(int idx, MatchRule rule, SecurityFactory<SSLContext> sslContext) Get a new authentication context which is the same as this one, but which replaces the rule and SSL context at the given index with the given rule and SSL context.<T> Trun(PrivilegedAction<T> action) Run a privileged action with this authentication context associated for the duration of the task.<T> Trun(PrivilegedExceptionAction<T> action) Run a privileged action with this authentication context associated for the duration of the task.<T,P> T run(P parameter, ParametricPrivilegedAction<T, P> action) Run a privileged action with this authentication context associated for the duration of the task.<T,P> T run(P parameter, ParametricPrivilegedExceptionAction<T, P> action) Run a privileged action with this authentication context associated for the duration of the task.<T> voidrunAsObjIntConsumer(ObjIntConsumer<T> action, T parameter1, int parameter2) Run a privileged action with this authentication context associated for the duration of the task.<T,E extends Exception>
voidrunAsObjIntConsumerEx(ExceptionObjIntConsumer<T, E> action, T parameter1, int parameter2) Run a privileged action with this authentication context associated for the duration of the task.<T> TrunAsSupplier(Supplier<T> action) Run a privileged action with this authentication context associated for the duration of the task.<T,E extends Exception>
TrunAsSupplierEx(ExceptionSupplier<T, E> action) Run a privileged action with this authentication context associated for the duration of the task.with(int idx, MatchRule rule, AuthenticationConfiguration configuration) Get a new authentication context which is the same as this one, but which includes the given rule and configuration inserted at the position of its list indicated by theidxparameter.with(AuthenticationContext other) Get a new authentication context which is the same as this one, but which includes the rules, configurations and SSL contexts of the given context at the end of its list.with(MatchRule rule, AuthenticationConfiguration configuration) Get a new authentication context which is the same as this one, but which includes the given rule and configuration at the end of its list.without(int idx) Get a new authentication context which is the same as this one, but without the rule and configuration at the index indicated by theidxparameter.withoutSsl(int idx) Get a new authentication context which is the same as this one, but without the rule and configuration at the index indicated by theidxparameter.withSsl(int idx, MatchRule rule, SecurityFactory<SSLContext> sslContext) Get a new authentication context which is the same as this one, but which includes the given rule and SSL context inserted at the position of its list indicated by theidxparameter.withSsl(MatchRule rule, SecurityFactory<SSLContext> sslContext) Get a new authentication context which is the same as this one, but which includes the given rule and SSL context at the end of its SSL context list.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.wildfly.common.context.Contextual
run, runAction, runBiConsumer, runBiFunction, runBiPredicate, runCallable, runConsumer, runExBiConsumer, runExBiFunction, runExBiPredicate, runExceptionAction, runExConsumer, runExFunction, runExIntFunction, runExLongFunction, runExPredicate, runFunction, runIntFunction, runLongFunction, runPredicate
-
Method Details
-
empty
Get a new, empty authentication context.- Returns:
- the new authentication context
-
captureCurrent
Get the current thread's captured authentication context.- Returns:
- the current thread's captured authentication context
-
with
Get a new authentication context which is the same as this one, but which includes the given rule and configuration at the end of its list.- Parameters:
rule- the rule to matchconfiguration- the configuration to select when the rule matches- Returns:
- the combined authentication context
-
withSsl
Get a new authentication context which is the same as this one, but which includes the given rule and SSL context at the end of its SSL context list.- Parameters:
rule- the rule to matchsslContext- the SSL context to select when the rule matches- Returns:
- the combined authentication context
-
with
Get a new authentication context which is the same as this one, but which includes the rules, configurations and SSL contexts of the given context at the end of its list.- Parameters:
other- the other authentication context- Returns:
- the combined authentication context
-
with
public AuthenticationContext with(int idx, MatchRule rule, AuthenticationConfiguration configuration) throws IndexOutOfBoundsException Get a new authentication context which is the same as this one, but which includes the given rule and configuration inserted at the position of its list indicated by theidxparameter.- Parameters:
idx- the index at which insertion should be donerule- the rule to matchconfiguration- the configuration to select when the rule matches- Returns:
- the combined authentication context
- Throws:
IndexOutOfBoundsException- if the index is out of bounds
-
withSsl
public AuthenticationContext withSsl(int idx, MatchRule rule, SecurityFactory<SSLContext> sslContext) throws IndexOutOfBoundsException Get a new authentication context which is the same as this one, but which includes the given rule and SSL context inserted at the position of its list indicated by theidxparameter.- Parameters:
idx- the index at which insertion should be donerule- the rule to matchsslContext- the SSL context to select when the rule matches- Returns:
- the combined authentication context
- Throws:
IndexOutOfBoundsException- if the index is out of bounds
-
replacing
public AuthenticationContext replacing(int idx, MatchRule rule, AuthenticationConfiguration configuration) throws IndexOutOfBoundsException Get a new authentication context which is the same as this one, but which replaces the rule and configuration at the given index with the given rule and configuration.- Parameters:
idx- the index at which insertion should be donerule- the rule to matchconfiguration- the configuration to select when the rule matches- Returns:
- the combined authentication context
- Throws:
IndexOutOfBoundsException- if the index is out of bounds
-
replacingSslContext
public AuthenticationContext replacingSslContext(int idx, MatchRule rule, SecurityFactory<SSLContext> sslContext) throws IndexOutOfBoundsException Get a new authentication context which is the same as this one, but which replaces the rule and SSL context at the given index with the given rule and SSL context.- Parameters:
idx- the index at which insertion should be donerule- the rule to matchsslContext- the SSL context to select when the rule matches- Returns:
- the combined authentication context
- Throws:
IndexOutOfBoundsException- if the index is out of bounds
-
without
Get a new authentication context which is the same as this one, but without the rule and configuration at the index indicated by theidxparameter.- Parameters:
idx- the index at which removal should be done- Returns:
- the modified authentication context
- Throws:
IndexOutOfBoundsException- if the index is out of bounds
-
withoutSsl
Get a new authentication context which is the same as this one, but without the rule and configuration at the index indicated by theidxparameter.- Parameters:
idx- the index at which removal should be done- Returns:
- the modified authentication context
- Throws:
IndexOutOfBoundsException- if the index is out of bounds
-
run
Run a privileged action with this authentication context associated for the duration of the task.- Type Parameters:
T- the action return type- Parameters:
action- the action to run under association- Returns:
- the action return value
-
run
Run a privileged action with this authentication context associated for the duration of the task.- Type Parameters:
T- the action return type- Parameters:
action- the action to run under association- Returns:
- the action return value
- Throws:
PrivilegedActionException- if the action throws an exception
-
run
Run a privileged action with this authentication context associated for the duration of the task.- Type Parameters:
T- the action return typeP- the action parameter type- Parameters:
parameter- the parameter to pass to the actionaction- the action to run under association- Returns:
- the action return value
-
run
public <T,P> T run(P parameter, ParametricPrivilegedExceptionAction<T, P> action) throws PrivilegedActionExceptionRun a privileged action with this authentication context associated for the duration of the task.- Type Parameters:
T- the action return typeP- the action parameter type- Parameters:
parameter- the parameter to pass to the actionaction- the action to run under association- Returns:
- the action return value
- Throws:
PrivilegedActionException- if the action throws an exception
-
runAsObjIntConsumer
Run a privileged action with this authentication context associated for the duration of the task.- Type Parameters:
T- the action first parameter type- Parameters:
parameter1- the first parameter to pass to the actionparameter2- the second parameter to pass to the actionaction- the action to run
-
runAsSupplier
Run a privileged action with this authentication context associated for the duration of the task.- Type Parameters:
T- the action return type- Parameters:
action- the action to run- Returns:
- the action result (may be
null)
-
runAsObjIntConsumerEx
public <T,E extends Exception> void runAsObjIntConsumerEx(ExceptionObjIntConsumer<T, E> action, T parameter1, int parameter2) throws ERun a privileged action with this authentication context associated for the duration of the task.- Type Parameters:
T- the action first parameter typeE- the action exception type- Parameters:
parameter1- the first parameter to pass to the actionparameter2- the second parameter to pass to the actionaction- the action to run- Throws:
E- if the action throws this exception
-
runAsSupplierEx
Run a privileged action with this authentication context associated for the duration of the task.- Type Parameters:
T- the action return typeE- the action exception type- Parameters:
action- the action to run- Returns:
- the action result (may be
null) - Throws:
E- if the action throws this exception
-
getInstanceContextManager
Description copied from interface:ContextualGet the context manager for this object. The implementation of this method normally should return a constant instance.- Specified by:
getInstanceContextManagerin interfaceContextual<AuthenticationContext>- Returns:
- the context manager (must not be
null)
-
getContextManager
Get the context manager for authentication contexts.- Returns:
- the context manager for authentication contexts (not
null)
-