Class AuthResult
java.lang.Object
org.apache.juneau.rest.server.auth.AuthResult
Immutable value type returned by
Authenticator.authenticate(jakarta.servlet.http.HttpServletRequest) on success.
Carries the resolved Principal and the set of roles associated with the authenticated subject.
The role set may be empty when no role claims are available (the principal is still valid).
See Also:
- Since:
- 10.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumControls how anAuthResultmerges with results accumulated earlier in an authenticator chain. -
Method Summary
Modifier and TypeMethodDescriptiongetMode()Returns the merge mode for this result.Returns the authenticated principal.getRoles()Returns the unmodifiable set of roles granted to this principal.static AuthResultCreates anAuthResultwith the specified principal and roles usingAuthResult.MergeMode.ADDmode.static AuthResultCreates anAuthResultwith the specified principal and role set usingAuthResult.MergeMode.ADDmode.static AuthResultstatic AuthResultofRoles(Collection<String> roles) static AuthResultCreates anAuthResultthatreplacesany accumulated identity and roles.static AuthResultCreates anAuthResultthatreplacesany accumulated identity and roles.
-
Method Details
-
of
Creates anAuthResultwith the specified principal and roles usingAuthResult.MergeMode.ADDmode.- Parameters:
principal- The authenticated principal. Must not benull .roles- The roles granted to this principal. May be empty.- Returns:
- A new
AuthResult.
-
of
Creates anAuthResultwith the specified principal and role set usingAuthResult.MergeMode.ADDmode.- Parameters:
principal- The authenticated principal. Must not benull .roles- The roles granted to this principal. May benull or empty.- Returns:
- A new
AuthResult.
-
ofRoles
Creates a roles-onlyAuthResult(AuthResult.MergeMode.ADDmode,null principal).Use this to contribute additional roles without supplying a principal — the accumulated/inherited principal is kept. This replaces the need for a separate roles-only authenticator type.
- Parameters:
roles- The roles to contribute. May be empty.- Returns:
- A new
AuthResult.
-
ofRoles
- Parameters:
roles- The roles to contribute. May benull or empty.- Returns:
- A new
AuthResult.
-
replacing
Creates anAuthResultthatreplacesany accumulated identity and roles.- Parameters:
principal- The authenticated principal. Must not benull .roles- The roles granted to this principal. May be empty.- Returns:
- A new
AuthResult.
-
replacing
Creates anAuthResultthatreplacesany accumulated identity and roles.- Parameters:
principal- The authenticated principal. Must not benull .roles- The roles granted to this principal. May benull or empty.- Returns:
- A new
AuthResult.
-
getPrincipal
Returns the authenticated principal.- Returns:
- The authenticated principal. May be
null for a roles-only (AuthResult.MergeMode.ADD) result.
-
getMode
Returns the merge mode for this result.- Returns:
- The merge mode. Never
null . - Since:
- 10.0.0
-
getRoles
Returns the unmodifiable set of roles granted to this principal.- Returns:
- The role set. Never
null ; may be empty.
-