Class JsonWebTokenUtil


  • public final class JsonWebTokenUtil
    extends Object
    Builds/decodes a JSON Web Token (JWT) for a given subject and set of policies (represented as resource/action pairs). This allows you to ask the PDP for a number of claims and represent them in a JWT format. Within a service, you can simply return this token as a string.
    • Method Detail

      • createToken

        public static String createToken​(String subject,
                                         String audience,
                                         Collection<? extends AbstractAuthorizationRequest> ruleClaims)
        Creates a JSON Web Token (JWT) for the given subject, audience, and resource/action pairs.
        Parameters:
        subject - The subject for which the token will contain information
        audience - The audience to whom this token is intended
        ruleClaims - resource/action pairs for which the PDP will be asked for decisions or id requests for attributes
        Returns:
        A signed, compressed JWT token
      • parseLocalToken

        public static io.jsonwebtoken.Jws<io.jsonwebtoken.Claims> parseLocalToken​(String token)
        Decodes a JSON Web Token.
        Parameters:
        token - the token to decode
        Returns:
        the decoded token. See JJWT for usage details.