Package io.smallrye.jwt.auth.principal
Class JWTCallerPrincipal
- java.lang.Object
-
- io.smallrye.jwt.auth.principal.JWTCallerPrincipal
-
- All Implemented Interfaces:
Principal,org.eclipse.microprofile.jwt.JsonWebToken
- Direct Known Subclasses:
DefaultJWTCallerPrincipal
public abstract class JWTCallerPrincipal extends Object implements org.eclipse.microprofile.jwt.JsonWebToken
An abstract CallerPrincipal implementation that provides access to the JWT claims that are required by the microprofile token.
-
-
Constructor Summary
Constructors Constructor Description JWTCallerPrincipal(String rawToken, String tokenType)Create a JWTCallerPrincipal with the caller's name
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract Collection<String>doGetClaimNames()<T> TgetClaim(String claimName)Set<String>getClaimNames()protected org.eclipse.microprofile.jwt.ClaimsgetClaimType(String claimName)protected abstract ObjectgetClaimValue(String claimName)StringgetName()Note that this method is not guaranteed to return the unique principal name as documented in theJsonWebToken.getName()if the "upn" claim is not available but the next fallback claim, the "preferred_username" claim is.booleanimplies(Subject subject)StringtoString()StringtoString(boolean showAll)TODO: showAll is ignored and currently assumed trueprotected jakarta.json.JsonValuewrapClaimValue(Object value)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
-
-
-
Method Detail
-
getName
public String getName()
Note that this method is not guaranteed to return the unique principal name as documented in theJsonWebToken.getName()if the "upn" claim is not available but the next fallback claim, the "preferred_username" claim is. This is due to the fact that a standard OpenId Connect "preferred_username" claim value is not guaranteed to be unique. UseJsonWebToken.getSubject()to get a unique subject value orJsonWebToken.getClaim(String)to get a 'upn' claim whose value is a unique identifier.
-
getClaimNames
public Set<String> getClaimNames()
- Specified by:
getClaimNamesin interfaceorg.eclipse.microprofile.jwt.JsonWebToken
-
doGetClaimNames
protected abstract Collection<String> doGetClaimNames()
-
getClaim
public <T> T getClaim(String claimName)
- Specified by:
getClaimin interfaceorg.eclipse.microprofile.jwt.JsonWebToken
-
toString
public String toString()
-
toString
public String toString(boolean showAll)
TODO: showAll is ignored and currently assumed true- Parameters:
showAll- - should all claims associated with the JWT be displayed or should only those defined in the JsonWebToken interface be displayed.- Returns:
- JWTCallerPrincipal string view
-
wrapClaimValue
protected jakarta.json.JsonValue wrapClaimValue(Object value)
-
getClaimType
protected org.eclipse.microprofile.jwt.Claims getClaimType(String claimName)
-
-