Package org.wildfly.security.auth.client
Class AuthenticationContext
java.lang.Object
org.wildfly.security.auth.client.AuthenticationContext
- All Implemented Interfaces:
org.wildfly.common.context.Contextual<AuthenticationContext>
public final class AuthenticationContext
extends Object
implements org.wildfly.common.context.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 org.wildfly.common.context.ContextManager<AuthenticationContext>Get the context manager for authentication contexts.org.wildfly.common.context.ContextManager<AuthenticationContext>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, org.wildfly.security.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, org.wildfly.security.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, org.wildfly.security.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(org.wildfly.common.function.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(org.wildfly.common.function.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, org.wildfly.security.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, org.wildfly.security.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
public AuthenticationContext withSsl(MatchRule rule, org.wildfly.security.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.- 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, org.wildfly.security.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, org.wildfly.security.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
public <T,P> T run(P parameter, org.wildfly.security.ParametricPrivilegedAction<T, P> action) 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, org.wildfly.security.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(org.wildfly.common.function.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
public <T,E extends Exception> T runAsSupplierEx(org.wildfly.common.function.ExceptionSupplier<T, E> action) throws ERun 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
- Specified by:
getInstanceContextManagerin interfaceorg.wildfly.common.context.Contextual<AuthenticationContext>
-
getContextManager
Get the context manager for authentication contexts.- Returns:
- the context manager for authentication contexts (not
null)
-