Package org.wildfly.security.auth.client
Class PeerIdentityContext
- java.lang.Object
-
- org.wildfly.security.auth.client.PeerIdentityContext
-
public abstract class PeerIdentityContext extends Object
A peer identity context. The peer identity is relevant only to this context.- Author:
- David M. Lloyd
-
-
Field Summary
Fields Modifier and Type Field Description private ThreadLocal<PeerIdentity>
currentIdentity
-
Constructor Summary
Constructors Modifier Constructor Description protected
PeerIdentityContext()
Construct a new instance.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract PeerIdentity
authenticate(AuthenticationConfiguration authenticationConfiguration)
Authenticate a new peer identity.protected <I> I
constructIdentity(Function<PeerIdentity.Configuration,I> constructFunction)
Construct a new peer identity.(package private) PeerIdentity
getAndSetPeerIdentity(PeerIdentity newIdentity)
PeerIdentity
getCurrentIdentity()
Get the currently set peer identity for this context.boolean
owns(PeerIdentity identity)
Determine whether this context owns the given identity.(package private) void
setPeerIdentity(PeerIdentity newIdentity)
-
-
-
Field Detail
-
currentIdentity
private final ThreadLocal<PeerIdentity> currentIdentity
-
-
Method Detail
-
getCurrentIdentity
public PeerIdentity getCurrentIdentity()
Get the currently set peer identity for this context.- Returns:
- the currently set peer identity for this context, or
null
if no identity is set
-
authenticate
public abstract PeerIdentity authenticate(AuthenticationConfiguration authenticationConfiguration) throws AuthenticationException
Authenticate a new peer identity. The authentication operation may be deferred if the backend cannot perform authentications on demand. If so, and the authentication fails, aReauthenticationException
may be thrown at a later time.- Parameters:
authenticationConfiguration
- the authentication configuration to use- Returns:
- the peer identity
- Throws:
AuthenticationException
- if an immediate authentication error occurs
-
constructIdentity
protected final <I> I constructIdentity(Function<PeerIdentity.Configuration,I> constructFunction)
Construct a new peer identity. The given function uses the opaque one-time configuration object to construct the identity, which must be passed as-is to the constructor of thePeerIdentity
class. This object must not be retained or made available after the identity is constructed; such misuse may result in an exception or undefined behavior.- Parameters:
constructFunction
- a function that, when applied, constructs a new peer identity- Returns:
- the constructed peer identity
-
owns
public final boolean owns(PeerIdentity identity)
Determine whether this context owns the given identity.- Parameters:
identity
- the identity- Returns:
true
if this context owns the identity,false
otherwise
-
getAndSetPeerIdentity
final PeerIdentity getAndSetPeerIdentity(PeerIdentity newIdentity)
-
setPeerIdentity
void setPeerIdentity(PeerIdentity newIdentity)
-
-