Interface CurrentIdentityAssociation


  • public interface CurrentIdentityAssociation
    A class that maintains the current identity association.

    This interface should be implemented by a CDI bean that provides a means of associating the current identity with the running thread.

    • Method Detail

      • setIdentity

        void setIdentity​(SecurityIdentity identity)
        Sets the current security identity for the thread.

        It is the responsibility of the implementation/runtime to clear the identity at the appropriate time.

        In general this will be achieved by using a request scoped bean to manage the identity so it is scoped to the current request.

        Parameters:
        identity - The new identity
      • setIdentity

        void setIdentity​(io.smallrye.mutiny.Uni<SecurityIdentity> identity)
        Sets the current deferred security identity for the thread. This is a Uni that will resolve to the logged in user.

        Note that as Uni is lazy in some circumstances authentication will only be attempted if the Uni is subscribed to.

        It is the responsibility of the implementation/runtime to clear the identity at the appropriate time.

        In general this will be achieved by using a request scoped bean to manage the identity so it is scoped to the current request.

        Parameters:
        identity - The new identity
      • getIdentity

        SecurityIdentity getIdentity()
        Gets the current identity. This method must not return null, but must return a representation of the anonymous identity if there is no current logged in user.

        If a deferred identity has been set this may throw AuthenticationFailedException if authentication fails when the Uni is resolved.

        Returns:
        The current security identity
      • getDeferredIdentity

        io.smallrye.mutiny.Uni<SecurityIdentity> getDeferredIdentity()
        Gets the (potentially lazy) security identity wrapped in a Uni.

        Note that as Uni is lazy in some circumstances authentication will not actually be attempted until the Uni is subscribed to.

        If there is no logged in user the Uni will resolve to the anonymous identity.

        Returns:
        the current security identity