Interface JwtMac


  • @Immutable
    public interface JwtMac
    Interface for authenticating and verifying JWT with JWS MAC, as described in RFC 7519 and RFC 7515.

    Security guarantees: similar to Mac.

    • Method Detail

      • computeMacAndEncode

        java.lang.String computeMacAndEncode​(RawJwt token)
                                      throws java.security.GeneralSecurityException
        Computes a MAC, and encodes the JWT and the MAC in the JWS compact serialization format.
        Throws:
        java.security.GeneralSecurityException
      • verifyMacAndDecode

        VerifiedJwt verifyMacAndDecode​(java.lang.String compact,
                                       JwtValidator validator)
                                throws java.security.GeneralSecurityException
        Decodes and verifies a JWT in the JWS compact serialization format.

        The JWT is validated against the rules in validator. That is, every claim in validator must also be present in the JWT. For example, if validator contains an iss claim, the JWT must contain an identical claim. The JWT can contain claims that are NOT in the validator. However, if the JWT contains a list of audiences, the validator must also contain an audience in the list.

        If the JWT contains timestamp claims such as exp, iat or nbf, they will also be validated. validator allows to set a clock skew, to deal with small clock differences among different machines.

        Throws:
        java.security.GeneralSecurityException - when the signature of the token could not be verified, the token contains an invalid claim or header, the token has been expired or can't be used yet