test_class.file: java_src/src/test/java/com/google/crypto/tink/jwt/JwtHmacTest.java
test_class.identifier: JwtHmacTest
test_case.body: @Test
    public void verifyCompact_rfc7515TestVector_fixedClock_success() throws Exception {
      String key =
          "AyM1SysPpbyDfgZld3umj1qzKObwVMkoqQ-EstJQLr_T-1qS0gZH75aKtMN3Yj0iPS4hcgUuTwjAzZr1Z9CAow";
      // The sample token has expired since 2011-03-22T18:43:00Z.
      String compact =
          "eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9."
              + "eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ."
              + "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk";
  
      String algo = "HS256";
      SecretKey secretKey = new SecretKeySpec(Base64.urlSafeDecode(key), "HMAC");
      JwtHmac mac = new JwtHmac(algo, secretKey);
  
      // One minute earlier than the expiration time of the sample token.
      String instant = "2011-03-22T18:42:00Z";
      Clock clock = Clock.fixed(Instant.parse(instant), ZoneOffset.UTC);
      JwtValidator validator = new JwtValidator.Builder().setClock(clock).build();
  
      Jwt token = mac.verifyCompact(compact, validator);
  
      assertThat(token.getAlgorithm()).isEqualTo(algo);
      assertThat(token.getType()).isEqualTo("JWT");
      assertThat(token.getIssuer()).isEqualTo("joe");
      boolean value = (boolean) token.getClaim("http://example.com/is_root");
  
      assertThat(value).isTrue();
    }
test_case.class_method_signature: JwtHmacTest.verifyCompact_rfc7515TestVector_fixedClock_success()
test_case.full_signature: @Test public void verifyCompact_rfc7515TestVector_fixedClock_success()
test_case.identifier: verifyCompact_rfc7515TestVector_fixedClock_success
test_case.invocations: urlSafeDecode fixed parse build setClock verifyCompact isEqualTo assertThat getAlgorithm isEqualTo assertThat getType isEqualTo assertThat getIssuer getClaim isTrue assertThat
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void verifyCompact_rfc7515TestVector_fixedClock_success()
focal_class.declarator: ASCII = Charset.forName("US-ASCII")
focal_class.modifier: private static final
focal_class.original_string: private static final Charset ASCII = Charset.forName("US-ASCII");
focal_class.type: Charset
focal_class.var_name: ASCII
focal_class.declarator: MIN_KEY_SIZE_IN_BYTES = 32
focal_class.modifier: private static final
focal_class.original_string: private static final int MIN_KEY_SIZE_IN_BYTES = 32;
focal_class.type: int
focal_class.var_name: MIN_KEY_SIZE_IN_BYTES
focal_class.declarator: mac
focal_class.modifier: @SuppressWarnings("Immutable") // We do not mutate the mac.
    private final
focal_class.original_string: @SuppressWarnings("Immutable") // We do not mutate the mac.
    private final Mac mac;
focal_class.type: Mac
focal_class.var_name: mac
focal_class.declarator: algo
focal_class.modifier: private final
focal_class.original_string: private final String algo;
focal_class.type: String
focal_class.var_name: algo
focal_class.file: java_src/src/main/java/com/google/crypto/tink/jwt/JwtHmac.java
focal_class.identifier: JwtHmac
focal_class.interfaces: implements JwtMac
focal_class.class_method_signature: JwtHmac.JwtHmac(String algo, java.security.Key key)
focal_class.full_signature: public  JwtHmac(String algo, java.security.Key key)
focal_class.identifier: JwtHmac
focal_class.modifiers: public
focal_class.parameters: (String algo, java.security.Key key)
focal_class.signature:  JwtHmac(String algo, java.security.Key key)
focal_class.class_method_signature: JwtHmac.createCompact(ToBeSignedJwt token)
focal_class.full_signature: @Override public String createCompact(ToBeSignedJwt token)
focal_class.identifier: createCompact
focal_class.modifiers: @Override public
focal_class.parameters: (ToBeSignedJwt token)
focal_class.return: String
focal_class.signature: String createCompact(ToBeSignedJwt token)
focal_class.class_method_signature: JwtHmac.verifyCompact(String compact, JwtValidator validator)
focal_class.full_signature: @Override public Jwt verifyCompact(String compact, JwtValidator validator)
focal_class.identifier: verifyCompact
focal_class.modifiers: @Override public
focal_class.parameters: (String compact, JwtValidator validator)
focal_class.return: Jwt
focal_class.signature: Jwt verifyCompact(String compact, JwtValidator validator)
focal_class.class_method_signature: JwtHmac.getHmacAlgo(String algo)
focal_class.full_signature: private static String getHmacAlgo(String algo)
focal_class.identifier: getHmacAlgo
focal_class.modifiers: private static
focal_class.parameters: (String algo)
focal_class.return: String
focal_class.signature: String getHmacAlgo(String algo)
focal_method.body: @Override
    public Jwt verifyCompact(String compact, JwtValidator validator) throws GeneralSecurityException {
      String[] parts = compact.split("\\.", -1);
      if (parts.length != 3) {
        throw new JwtInvalidException(
            "only tokens in JWS compact serialization format are supported");
      }
  
      String input = parts[0] + "." + parts[1];
      byte[] expectedTag = Base64.urlSafeDecode(parts[2]);
      mac.verifyMac(expectedTag, input.getBytes(ASCII));
  
      ToBeSignedJwt token = new ToBeSignedJwt.Builder(input).build();
      return validator.validate(this.algo, token);
    }
focal_method.class_method_signature: JwtHmac.verifyCompact(String compact, JwtValidator validator)
focal_method.full_signature: @Override public Jwt verifyCompact(String compact, JwtValidator validator)
focal_method.identifier: verifyCompact
focal_method.invocations: split urlSafeDecode verifyMac getBytes build validate
focal_method.modifiers: @Override public
focal_method.parameters: (String compact, JwtValidator validator)
focal_method.return: Jwt
focal_method.signature: Jwt verifyCompact(String compact, JwtValidator validator)