Class PeerIdentityContext


  • public abstract class PeerIdentityContext
    extends Object
    A peer identity context. The peer identity is relevant only to this context.
    Author:
    David M. Lloyd
    • Constructor Detail

      • PeerIdentityContext

        protected PeerIdentityContext()
        Construct a new instance.
    • 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, a ReauthenticationException 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 the PeerIdentity 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