Class 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 Detail

      • JWTCallerPrincipal

        public JWTCallerPrincipal​(String rawToken,
                                  String tokenType)
        Create a JWTCallerPrincipal with the caller's name
        Parameters:
        rawToken - - raw token value
        tokenType - - token type
    • Method Detail

      • getName

        public String getName()
        Note that this method is not guaranteed to return the unique principal name as documented in the JsonWebToken.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. Use JsonWebToken.getSubject() to get a unique subject value or JsonWebToken.getClaim(String) to get a 'upn' claim whose value is a unique identifier.
        Specified by:
        getName in interface org.eclipse.microprofile.jwt.JsonWebToken
        Specified by:
        getName in interface Principal
      • getClaimNames

        public Set<String> getClaimNames()
        Specified by:
        getClaimNames in interface org.eclipse.microprofile.jwt.JsonWebToken
      • getClaim

        public <T> T getClaim​(String claimName)
        Specified by:
        getClaim in interface org.eclipse.microprofile.jwt.JsonWebToken
      • getClaimValue

        protected abstract Object getClaimValue​(String claimName)
      • 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)