Package org.wildfly.security.auth.server
Class FlexibleIdentityAssociation
- java.lang.Object
-
- org.wildfly.security.auth.server.FlexibleIdentityAssociation
-
- All Implemented Interfaces:
Supplier<SecurityIdentity>
,Scoped
public final class FlexibleIdentityAssociation extends Object implements Scoped, Supplier<SecurityIdentity>
A flexible identity association which can have its current identity modified. Modifying the identity association will affect the current identity of any thread which is currently executing within the scope of this association.- Author:
- David M. Lloyd
- See Also:
SecurityIdentity.createFlexibleAssociation()
-
-
Field Summary
Fields Modifier and Type Field Description private SecurityDomain
securityDomain
private SecurityIdentity
securityIdentity
-
Constructor Summary
Constructors Constructor Description FlexibleIdentityAssociation(SecurityDomain securityDomain, SecurityIdentity securityIdentity)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SecurityIdentity
get()
Get the current associated identity.<T,U>
booleanrunAsBiPredicate(BiPredicate<T,U> action, T param1, U param2)
Run an action under this identity.<T,U>
voidrunAsConsumer(BiConsumer<T,U> action, T parameter1, U parameter2)
Run an action under this identity.<T,U,E extends Exception>
voidrunAsConsumerEx(org.wildfly.common.function.ExceptionBiConsumer<T,U,E> action, T parameter1, U parameter2)
Run an action under this identity.<T,U,E extends Exception>
booleanrunAsExBiPredicate(org.wildfly.common.function.ExceptionBiPredicate<T,U,E> action, T param1, U param2)
Run an action under this identity.<T,U,R>
RrunAsFunction(BiFunction<T,U,R> action, T parameter1, U parameter2)
Run an action under this identity.<T,U,R,E extends Exception>
RrunAsFunctionEx(org.wildfly.common.function.ExceptionBiFunction<T,U,R,E> action, T parameter1, U parameter2)
Run an action under this identity.<T> void
runAsObjIntConsumer(ObjIntConsumer<T> action, T parameter1, int parameter2)
Run an action under this identity.<T,E extends Exception>
voidrunAsObjIntConsumerEx(org.wildfly.common.function.ExceptionObjIntConsumer<T,E> action, T parameter1, int parameter2)
Run an action under this identity.void
setIdentity(SecurityIdentity securityIdentity)
Set the current associated identity.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.wildfly.security.auth.server.Scoped
runAs, runAs, runAsAction, runAsConsumer, runAsConsumerEx, runAsExceptionAction, runAsExIntFunction, runAsExLongFunction, runAsExPredicate, runAsFunction, runAsFunctionEx, runAsIntFunction, runAsLongFunction, runAsPredicate, runAsSupplier, runAsSupplierEx
-
-
-
-
Field Detail
-
securityDomain
private final SecurityDomain securityDomain
-
securityIdentity
private volatile SecurityIdentity securityIdentity
-
-
Constructor Detail
-
FlexibleIdentityAssociation
FlexibleIdentityAssociation(SecurityDomain securityDomain, SecurityIdentity securityIdentity)
-
-
Method Detail
-
setIdentity
public void setIdentity(SecurityIdentity securityIdentity)
Set the current associated identity.- Parameters:
securityIdentity
- the current associated identity (must not benull
)
-
get
public SecurityIdentity get()
Get the current associated identity.- Specified by:
get
in interfaceSupplier<SecurityIdentity>
- Returns:
- the current associated identity (not
null
)
-
runAsFunction
public <T,U,R> R runAsFunction(BiFunction<T,U,R> action, T parameter1, U parameter2)
Description copied from interface:Scoped
Run an action under this identity.- Specified by:
runAsFunction
in interfaceScoped
- Type Parameters:
T
- the action first parameter typeU
- the action second parameter typeR
- the action return type- Parameters:
action
- the action to runparameter1
- the first parameter to pass to the actionparameter2
- the second parameter to pass to the action- Returns:
- the action result (may be
null
)
-
runAsConsumer
public <T,U> void runAsConsumer(BiConsumer<T,U> action, T parameter1, U parameter2)
Description copied from interface:Scoped
Run an action under this identity.- Specified by:
runAsConsumer
in interfaceScoped
- Type Parameters:
T
- the action first parameter typeU
- the action second parameter type- Parameters:
action
- the action to runparameter1
- the first parameter to pass to the actionparameter2
- the second parameter to pass to the action
-
runAsObjIntConsumer
public <T> void runAsObjIntConsumer(ObjIntConsumer<T> action, T parameter1, int parameter2)
Description copied from interface:Scoped
Run an action under this identity.- Specified by:
runAsObjIntConsumer
in interfaceScoped
- Type Parameters:
T
- the action first parameter type- Parameters:
action
- the action to runparameter1
- the first parameter to pass to the actionparameter2
- the second parameter to pass to the action
-
runAsFunctionEx
public <T,U,R,E extends Exception> R runAsFunctionEx(org.wildfly.common.function.ExceptionBiFunction<T,U,R,E> action, T parameter1, U parameter2) throws E extends Exception
Description copied from interface:Scoped
Run an action under this identity.- Specified by:
runAsFunctionEx
in interfaceScoped
- Type Parameters:
T
- the action first parameter typeU
- the action second parameter typeR
- the action return typeE
- the action exception type- Parameters:
action
- the action to runparameter1
- the first parameter to pass to the actionparameter2
- the second parameter to pass to the action- Returns:
- the action result (may be
null
) - Throws:
E
- if the action throws this exceptionE extends Exception
-
runAsConsumerEx
public <T,U,E extends Exception> void runAsConsumerEx(org.wildfly.common.function.ExceptionBiConsumer<T,U,E> action, T parameter1, U parameter2) throws E extends Exception
Description copied from interface:Scoped
Run an action under this identity.- Specified by:
runAsConsumerEx
in interfaceScoped
- Type Parameters:
T
- the action first parameter typeU
- the action second parameter typeE
- the action exception type- Parameters:
action
- the action to runparameter1
- the first parameter to pass to the actionparameter2
- the second parameter to pass to the action- Throws:
E
- if the action throws this exceptionE extends Exception
-
runAsObjIntConsumerEx
public <T,E extends Exception> void runAsObjIntConsumerEx(org.wildfly.common.function.ExceptionObjIntConsumer<T,E> action, T parameter1, int parameter2) throws E extends Exception
Description copied from interface:Scoped
Run an action under this identity.- Specified by:
runAsObjIntConsumerEx
in interfaceScoped
- Type Parameters:
T
- the action first parameter typeE
- the action exception type- Parameters:
action
- the action to runparameter1
- the first parameter to pass to the actionparameter2
- the second parameter to pass to the action- Throws:
E
- if the action throws this exceptionE extends Exception
-
runAsBiPredicate
public <T,U> boolean runAsBiPredicate(BiPredicate<T,U> action, T param1, U param2)
Description copied from interface:Scoped
Run an action under this identity.- Specified by:
runAsBiPredicate
in interfaceScoped
- Type Parameters:
T
- the first parameter typeU
- the second parameter type- Parameters:
action
- the task to run (must not benull
)param1
- the first parameter to pass to the taskparam2
- the second parameter to pass to the task- Returns:
- the action return value
-
runAsExBiPredicate
public <T,U,E extends Exception> boolean runAsExBiPredicate(org.wildfly.common.function.ExceptionBiPredicate<T,U,E> action, T param1, U param2) throws E extends Exception
Description copied from interface:Scoped
Run an action under this identity.- Specified by:
runAsExBiPredicate
in interfaceScoped
- Type Parameters:
T
- the first parameter typeU
- the second parameter typeE
- the exception type- Parameters:
action
- the task to run (must not benull
)param1
- the first parameter to pass to the taskparam2
- the second parameter to pass to the task- Returns:
- the action return value
- Throws:
E
- if an exception occurs in the taskE extends Exception
-
-