Interface CurrentIdentityAssociation
This interface should be implemented by a CDI bean that provides a means of associating the current identity with the running thread.
-
Method Summary
Modifier and TypeMethodDescriptionstatic SecurityIdentitycurrent()io.smallrye.mutiny.Uni<SecurityIdentity>Gets the (potentially lazy) security identity wrapped in a Uni.Gets the current identity.voidsetIdentity(SecurityIdentity identity) Sets the current security identity for the thread.voidsetIdentity(io.smallrye.mutiny.Uni<SecurityIdentity> identity) Sets the current deferred security identity for the thread.
-
Method Details
-
setIdentity
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
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
AuthenticationFailedExceptionif 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
-
current
-