Package org.wildfly.security.auth.client
Class PeerIdentity
java.lang.Object
org.wildfly.security.auth.client.PeerIdentity
A peer's authenticated identity.
- Author:
- David M. Lloyd
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classThe opaque configuration to apply to a peer identity. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedPeerIdentity(PeerIdentity.Configuration configuration, Principal peerPrincipal) Construct a new instance. -
Method Summary
Modifier and TypeMethodDescriptionorg.wildfly.security.authz.Attributes.EntrygetPeerAttribute(String key) Get a specific attribute value for the peer identity.org.wildfly.security.authz.AttributesGet the attribute set for the peer identity.protected final PeerIdentityContextGet the peer identity context for this identity.Get the peer principal.Get the peer identity roles.booleanhasPeerRole(String roleName) Determine whether the peer identity has a given role name.booleanDetermine if the peer identity context of this identity is the same as that of the given identity.protected voidPerform an optional post-association action, called after association with the current thread has completed.protected voidPerform an optional pre-association action, called before association with the current thread.voidRun an action under this identity.<T> TrunAs(PrivilegedAction<T> action) Run an action under this identity.<T> TrunAs(PrivilegedExceptionAction<T> action) Run an action under this identity.<T> TRun an action under this identity.<T,P> T runAs(P parameter, org.wildfly.security.ParametricPrivilegedAction<T, P> action) Run an action under this identity.<T,P> T runAs(P parameter, org.wildfly.security.ParametricPrivilegedExceptionAction<T, P> action) Run an action under this identity.static voidrunAsAll(Runnable runnable, PeerIdentity... identities) Run an action under a series of identities.static <T> TrunAsAll(PrivilegedAction<T> privilegedAction, PeerIdentity... identities) Run an action under a series of identities.static <T> TrunAsAll(PrivilegedExceptionAction<T> privilegedAction, PeerIdentity... identities) Run an action under a series of identities.static <T> TrunAsAll(Callable<T> callable, PeerIdentity... identities) Run an action under a series of identities.static <T,P> T runAsAll(P parameter, org.wildfly.security.ParametricPrivilegedAction<T, P> privilegedAction, PeerIdentity... identities) Run an action under a series of identities.static <T,P> T runAsAll(P parameter, org.wildfly.security.ParametricPrivilegedExceptionAction<T, P> privilegedAction, PeerIdentity... identities) Run an action under a series of identities.static <T> voidrunAsAllConsumer(T parameter, Consumer<T> privilegedAction, PeerIdentity... identities) Run an action under a series of identities.static <T,U> void runAsAllConsumer(T parameter1, U parameter2, BiConsumer<T, U> privilegedAction, PeerIdentity... identities) Run an action under a series of identities.static <R,T> R runAsAllFunction(T parameter, Function<T, R> privilegedAction, PeerIdentity... identities) Run an action under a series of identities.static <T,U, R> R runAsAllFunction(T parameter1, U parameter2, BiFunction<T, U, R> privilegedAction, PeerIdentity... identities) Run an action under a series of identities.static <T> voidrunAsAllObjIntConsumer(T parameter1, int parameter2, ObjIntConsumer<T> privilegedAction, PeerIdentity... identities) Run an action under a series of identities.static <T> TrunAsAllSupplier(Supplier<T> action, PeerIdentity... identities) Run an action under a series of identities.<T> voidrunAsConsumer(T parameter, Consumer<T> action) Run an action under this identity.<T,U> void runAsConsumer(T parameter1, U parameter2, BiConsumer<T, U> action) Run an action under this identity.<T,R> R runAsFunction(T parameter, Function<T, R> action) Run an action under this identity.<T,U, R> R runAsFunction(T parameter1, U parameter2, BiFunction<T, U, R> action) Run an action under this identity.<T> TrunAsSupplier(Supplier<T> supplier) Run an action under this identity.
-
Constructor Details
-
PeerIdentity
Construct a new instance.- Parameters:
configuration- the opaque configuration (must not benull)peerPrincipal- the peer principal (must not benull)
-
-
Method Details
-
preAssociate
protected void preAssociate()Perform an optional pre-association action, called before association with the current thread. -
postAssociate
protected void postAssociate()Perform an optional post-association action, called after association with the current thread has completed. -
isSamePeerIdentityContext
Determine if the peer identity context of this identity is the same as that of the given identity.- Parameters:
other- the other peer identity- Returns:
trueif the identities share a context,falseotherwise
-
runAs
Run an action under this identity.- Parameters:
runnable- the action to run
-
runAs
Run an action under this identity.- Type Parameters:
T- the action return type- Parameters:
callable- the action to run- Returns:
- the action result (may be
null) - Throws:
PrivilegedActionException- if the action failsException
-
runAs
Run an action under this identity.- Type Parameters:
T- the action return type- Parameters:
action- the action to run- Returns:
- the action result (may be
null)
-
runAs
Run an action under this identity.- Type Parameters:
T- the action return type- Parameters:
action- the action to run- Returns:
- the action result (may be
null) - Throws:
PrivilegedActionException- if the action fails
-
runAs
public <T,P> T runAs(P parameter, org.wildfly.security.ParametricPrivilegedAction<T, P> action) Run an action under this identity.- Type Parameters:
T- the action return typeP- the action parameter type- Parameters:
parameter- the parameter to pass to the actionaction- the action to run- Returns:
- the action result (may be
null)
-
runAs
public <T,P> T runAs(P parameter, org.wildfly.security.ParametricPrivilegedExceptionAction<T, P> action) throws PrivilegedActionExceptionRun an action under this identity.- Type Parameters:
T- the action return typeP- the action parameter type- Parameters:
parameter- the parameter to pass to the actionaction- the action to run- Returns:
- the action result (may be
null) - Throws:
PrivilegedActionException- if the action fails
-
runAsFunction
Run an action under this identity.- Type Parameters:
T- the action parameter typeR- the action return type- Parameters:
parameter- the parameter to pass to the actionaction- the action to run- Returns:
- the action result (may be
null)
-
runAsFunction
Run an action under this identity.- Type Parameters:
T- the action first parameter typeU- the action second parameter typeR- the action return type- Parameters:
parameter1- the first parameter to pass to the actionparameter2- the second parameter to pass to the actionaction- the action to run- Returns:
- the action result (may be
null)
-
runAsConsumer
Run an action under this identity.- Type Parameters:
T- the action parameter type- Parameters:
parameter- the parameter to pass to the actionaction- the action to run
-
runAsConsumer
Run an action under this identity.- Type Parameters:
T- the action first parameter typeU- the action second 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 an action under this identity.- Type Parameters:
T- the action return type- Parameters:
supplier- the action to run- Returns:
- the action result (may be
null) - Throws:
PrivilegedActionException- if the action failsException
-
runAsAll
Run an action under a series of identities.- Parameters:
runnable- the action to runidentities- the identities to use
-
runAsAll
Run an action under a series of identities.- Type Parameters:
T- the action return type- Parameters:
callable- the action to runidentities- the identities to use- Throws:
Exception
-
runAsAll
Run an action under a series of identities.- Type Parameters:
T- the action return type- Parameters:
privilegedAction- the action to runidentities- the identities to use
-
runAsAll
public static <T> T runAsAll(PrivilegedExceptionAction<T> privilegedAction, PeerIdentity... identities) throws PrivilegedActionException Run an action under a series of identities.- Type Parameters:
T- the action return type- Parameters:
privilegedAction- the action to runidentities- the identities to use- Throws:
PrivilegedActionException- if the action throws an exception
-
runAsAll
public static <T,P> T runAsAll(P parameter, org.wildfly.security.ParametricPrivilegedAction<T, P> privilegedAction, PeerIdentity... identities) Run an action under a series of identities.- Type Parameters:
T- the action return typeP- the action parameter type- Parameters:
parameter- the parameter to pass to the actionprivilegedAction- the action to runidentities- the identities to use
-
runAsAll
public static <T,P> T runAsAll(P parameter, org.wildfly.security.ParametricPrivilegedExceptionAction<T, P> privilegedAction, PeerIdentity... identities) throws PrivilegedActionExceptionRun an action under a series of identities.- Type Parameters:
T- the action return typeP- the action parameter type- Parameters:
parameter- the parameter to pass to the actionprivilegedAction- the action to runidentities- the identities to use- Throws:
PrivilegedActionException- if the action throws an exception
-
runAsAllFunction
public static <R,T> R runAsAllFunction(T parameter, Function<T, R> privilegedAction, PeerIdentity... identities) Run an action under a series of identities.- Type Parameters:
R- the action return typeT- the action parameter type- Parameters:
parameter- the parameter to pass to the actionprivilegedAction- the action to runidentities- the identities to use
-
runAsAllFunction
public static <T,U, R runAsAllFunctionR> (T parameter1, U parameter2, BiFunction<T, U, R> privilegedAction, PeerIdentity... identities) Run an action under a series of identities.- Type Parameters:
T- the action first parameter typeU- the action second parameter typeR- the action return type- Parameters:
parameter1- the first parameter to pass to the actionparameter2- the second parameter to pass to the actionprivilegedAction- the action to runidentities- the identities to use
-
runAsAllConsumer
public static <T> void runAsAllConsumer(T parameter, Consumer<T> privilegedAction, PeerIdentity... identities) Run an action under a series of identities.- Type Parameters:
T- the action parameter type- Parameters:
parameter- the parameter to pass to the actionprivilegedAction- the action to runidentities- the identities to use
-
runAsAllConsumer
public static <T,U> void runAsAllConsumer(T parameter1, U parameter2, BiConsumer<T, U> privilegedAction, PeerIdentity... identities) Run an action under a series of identities.- Type Parameters:
T- the action first parameter typeU- the action second parameter type- Parameters:
parameter1- the first parameter to pass to the actionparameter2- the second parameter to pass to the actionprivilegedAction- the action to runidentities- the identities to use
-
runAsAllObjIntConsumer
public static <T> void runAsAllObjIntConsumer(T parameter1, int parameter2, ObjIntConsumer<T> privilegedAction, PeerIdentity... identities) Run an action under a series of identities.- 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 actionprivilegedAction- the action to runidentities- the identities to use
-
runAsAllSupplier
Run an action under a series of identities.- Type Parameters:
T- the action return type- Parameters:
action- the action to runidentities- the identities to use
-
getPeerPrincipal
Get the peer principal.- Returns:
- the peer principal (not
null)
-
getPeerRoles
Get the peer identity roles. The default implementation returns an empty set.- Returns:
- the peer identity role set (not
null)
-
hasPeerRole
Determine whether the peer identity has a given role name. The default implementation returnsfalse.- Parameters:
roleName- the role name- Returns:
trueif the peer identity has the role,falseotherwise
-
getPeerAttributes
public org.wildfly.security.authz.Attributes getPeerAttributes()Get the attribute set for the peer identity. The default implementation returns an empty attributes set.- Returns:
- the peer identity attributes
-
getPeerAttribute
Get a specific attribute value for the peer identity. The default implementation returnsnull.- Parameters:
key- the attribute name- Returns:
- the attribute value entry, or
nullif there is no matching entry
-
getPeerIdentityContext
Get the peer identity context for this identity.- Returns:
- the peer identity context for this identity (not
null)
-