test_class.file: java_src/src/test/java/com/google/crypto/tink/jwt/JwtValidatorTest.java
test_class.identifier: JwtValidatorTest
test_case.body: @Test
    public void validate_wrongSubject_shouldThrow() throws Exception {
      ToBeSignedJwt token =
          new ToBeSignedJwt.Builder().setAlgorithm("HS256").setSubject("blah").build();
      JwtValidator validator = new JwtValidator.Builder().setSubject("123").build();
  
      assertThrows(JwtInvalidException.class, () -> validator.validate("HS256", token));
    }
test_case.class_method_signature: JwtValidatorTest.validate_wrongSubject_shouldThrow()
test_case.full_signature: @Test public void validate_wrongSubject_shouldThrow()
test_case.identifier: validate_wrongSubject_shouldThrow
test_case.invocations: build setSubject setAlgorithm build setSubject assertThrows validate
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void validate_wrongSubject_shouldThrow()
focal_class.declarator: MAX_CLOCK_SKEW = Duration.ofMinutes(10)
focal_class.modifier: private static final
focal_class.original_string: private static final Duration MAX_CLOCK_SKEW = Duration.ofMinutes(10);
focal_class.type: Duration
focal_class.var_name: MAX_CLOCK_SKEW
focal_class.declarator: header
focal_class.modifier: @SuppressWarnings("Immutable") // We do not mutate the header.
    private final
focal_class.original_string: @SuppressWarnings("Immutable") // We do not mutate the header.
    private final JSONObject header;
focal_class.type: JSONObject
focal_class.var_name: header
focal_class.declarator: payload
focal_class.modifier: @SuppressWarnings("Immutable") // We do not mutate the payload.
    private final
focal_class.original_string: @SuppressWarnings("Immutable") // We do not mutate the payload.
    private final JSONObject payload;
focal_class.type: JSONObject
focal_class.var_name: payload
focal_class.declarator: clock
focal_class.modifier: @SuppressWarnings("Immutable") // We do not mutate the clock.
    private final
focal_class.original_string: @SuppressWarnings("Immutable") // We do not mutate the clock.
    private final Clock clock;
focal_class.type: Clock
focal_class.var_name: clock
focal_class.declarator: clockSkew
focal_class.modifier: private final
focal_class.original_string: private final Duration clockSkew;
focal_class.type: Duration
focal_class.var_name: clockSkew
focal_class.file: java_src/src/main/java/com/google/crypto/tink/jwt/JwtValidator.java
focal_class.identifier: JwtValidator
focal_class.class_method_signature: JwtValidator.JwtValidator(Builder builder)
focal_class.full_signature: private  JwtValidator(Builder builder)
focal_class.identifier: JwtValidator
focal_class.modifiers: private
focal_class.parameters: (Builder builder)
focal_class.signature:  JwtValidator(Builder builder)
focal_class.class_method_signature: JwtValidator.getHeader(String name)
focal_class.full_signature: private String getHeader(String name)
focal_class.identifier: getHeader
focal_class.modifiers: private
focal_class.parameters: (String name)
focal_class.return: String
focal_class.signature: String getHeader(String name)
focal_class.class_method_signature: JwtValidator.getClaim(String name)
focal_class.full_signature: private Object getClaim(String name)
focal_class.identifier: getClaim
focal_class.modifiers: private
focal_class.parameters: (String name)
focal_class.return: Object
focal_class.signature: Object getClaim(String name)
focal_class.class_method_signature: JwtValidator.getClock()
focal_class.full_signature:  Clock getClock()
focal_class.identifier: getClock
focal_class.parameters: ()
focal_class.return: Clock
focal_class.signature: Clock getClock()
focal_class.class_method_signature: JwtValidator.getClockSkew()
focal_class.full_signature:  Duration getClockSkew()
focal_class.identifier: getClockSkew
focal_class.parameters: ()
focal_class.return: Duration
focal_class.signature: Duration getClockSkew()
focal_class.class_method_signature: JwtValidator.validate(String algorithm, ToBeSignedJwt target)
focal_class.full_signature:  Jwt validate(String algorithm, ToBeSignedJwt target)
focal_class.identifier: validate
focal_class.parameters: (String algorithm, ToBeSignedJwt target)
focal_class.return: Jwt
focal_class.signature: Jwt validate(String algorithm, ToBeSignedJwt target)
focal_class.class_method_signature: JwtValidator.validateTimestampClaims(ToBeSignedJwt target)
focal_class.full_signature: private void validateTimestampClaims(ToBeSignedJwt target)
focal_class.identifier: validateTimestampClaims
focal_class.modifiers: private
focal_class.parameters: (ToBeSignedJwt target)
focal_class.return: void
focal_class.signature: void validateTimestampClaims(ToBeSignedJwt target)
focal_method.body: Jwt validate(String algorithm, ToBeSignedJwt target)
        throws InvalidAlgorithmParameterException, JwtExpiredException, JwtNotBeforeException,
            JwtInvalidException {
      validateTimestampClaims(target);
  
      if (!target.getAlgorithm().equals(algorithm)) {
        throw new InvalidAlgorithmParameterException(
            String.format(
                "invalid algorithm; expected %s, got %s", algorithm, target.getAlgorithm()));
      }
  
      @SuppressWarnings("unchecked") // keys() returns Iterator, not Iterator<String>
      Iterator<String> headerIterator = this.header.keys();
      while (headerIterator.hasNext()) {
        String name = headerIterator.next();
        if (name.equals(JwtNames.HEADER_ALGORITHM)) {
          continue;
        }
        String value = target.getHeader(name);
        if (value == null || !value.equals(this.getHeader(name))) {
          throw new JwtInvalidException(
              String.format(
                  "invalid JWT; expected header '%s' with value %s, but got %s",
                  name, value, this.getHeader(name)));
        }
      }
  
      @SuppressWarnings("unchecked") // keys() returns Iterator, not Iterator<String>
      Iterator<String> payloadIterator = this.payload.keys();
      while (payloadIterator.hasNext()) {
        String name = payloadIterator.next();
        if (name.equals(JwtNames.CLAIM_AUDIENCE)) {
          // This is checked below.
          continue;
        }
        Object value = target.getClaim(name);
        if (value == null || !value.equals(this.getClaim(name))) {
          throw new JwtInvalidException(
              String.format(
                  "invalid JWT; expected claim '%s' with value %s, but got %s",
                  name, value, this.getClaim(name)));
        }
      }
  
      // Check that the validator's audience is in the list of claimed audiences.
      List<String> audiences = target.getAudiences();
      String audience = (String) this.getClaim(JwtNames.CLAIM_AUDIENCE);
      if ((audiences == null && audience != null)
          || (audiences != null && !audiences.contains(audience))) {
        throw new JwtInvalidException(
            String.format(
                "invalid JWT; cannot find the expected audience %s in claimed audiences %s",
                audience, audiences));
      }
  
      return new Jwt(target.getHeader(), target.getPayload(), this.clock, this.clockSkew);
    }
focal_method.class_method_signature: JwtValidator.validate(String algorithm, ToBeSignedJwt target)
focal_method.full_signature:  Jwt validate(String algorithm, ToBeSignedJwt target)
focal_method.identifier: validate
focal_method.invocations: validateTimestampClaims equals getAlgorithm format getAlgorithm keys hasNext next equals getHeader equals getHeader format getHeader keys hasNext next equals getClaim equals getClaim format getClaim getAudiences getClaim contains format getHeader getPayload
focal_method.parameters: (String algorithm, ToBeSignedJwt target)
focal_method.return: Jwt
focal_method.signature: Jwt validate(String algorithm, ToBeSignedJwt target)