test_class.declarator: UTF_8 = Charset.forName("UTF-8")
test_class.modifier: private static final
test_class.original_string: private static final Charset UTF_8 = Charset.forName("UTF-8");
test_class.type: Charset
test_class.var_name: UTF_8
test_class.declarator: GOOGLE_VERIFYING_PUBLIC_KEYS_JSON =
        "{\n"
            + "  \"keys\": [\n"
            + "    {\n"
            + "      \"base64\": \"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEPYnHwS8uegWAewQtlxizmLFynw"
            + "HcxRT1PK07cDA6/C4sXrVI1SzZCUx8U8S0LjMrT6ird/VW7be3Mz6t/srtRQ==\",\n"
            + "      \"keyId\": 1234\n"
            + "    },\n"
            + "  ],\n"
            + "}"
test_class.modifier: private static final
test_class.original_string: private static final String GOOGLE_VERIFYING_PUBLIC_KEYS_JSON =
        "{\n"
            + "  \"keys\": [\n"
            + "    {\n"
            + "      \"base64\": \"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEPYnHwS8uegWAewQtlxizmLFynw"
            + "HcxRT1PK07cDA6/C4sXrVI1SzZCUx8U8S0LjMrT6ird/VW7be3Mz6t/srtRQ==\",\n"
            + "      \"keyId\": 1234\n"
            + "    },\n"
            + "  ],\n"
            + "}";
test_class.type: String
test_class.var_name: GOOGLE_VERIFYING_PUBLIC_KEYS_JSON
test_class.declarator: GOOGLE_SIGNING_PRIVATE_KEY_PKCS8_BASE64 =
        "MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgZj/Dldxz8fvKVF5O"
            + "TeAtK6tY3G1McmvhMppe6ayW6GahRANCAAQ9icfBLy56BYB7BC2XGLOYsXKfAdzF"
            + "FPU8rTtwMDr8LixetUjVLNkJTHxTxLQuMytPqKt39Vbtt7czPq3+yu1F"
test_class.modifier: private static final
test_class.original_string: private static final String GOOGLE_SIGNING_PRIVATE_KEY_PKCS8_BASE64 =
        "MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgZj/Dldxz8fvKVF5O"
            + "TeAtK6tY3G1McmvhMppe6ayW6GahRANCAAQ9icfBLy56BYB7BC2XGLOYsXKfAdzF"
            + "FPU8rTtwMDr8LixetUjVLNkJTHxTxLQuMytPqKt39Vbtt7czPq3+yu1F";
test_class.type: String
test_class.var_name: GOOGLE_SIGNING_PRIVATE_KEY_PKCS8_BASE64
test_class.declarator: KEY_ID = 1234
test_class.modifier: private static final
test_class.original_string: private static final long KEY_ID = 1234;
test_class.type: long
test_class.var_name: KEY_ID
test_class.declarator: REWARD_HOST_AND_PATH = "https://publisher.com/blah?"
test_class.modifier: private static final
test_class.original_string: private static final String REWARD_HOST_AND_PATH = "https://publisher.com/blah?";
test_class.type: String
test_class.var_name: REWARD_HOST_AND_PATH
test_class.declarator: REWARD_QUERY = "foo1=bar1&foo2=bar2"
test_class.modifier: private static final
test_class.original_string: private static final String REWARD_QUERY = "foo1=bar1&foo2=bar2";
test_class.type: String
test_class.var_name: REWARD_QUERY
test_class.declarator: REWARD_URL = REWARD_HOST_AND_PATH + REWARD_QUERY
test_class.modifier: private static final
test_class.original_string: private static final String REWARD_URL = REWARD_HOST_AND_PATH + REWARD_QUERY;
test_class.type: String
test_class.var_name: REWARD_URL
test_class.declarator: ALTERNATE_PUBLIC_SIGNING_KEY =
        "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEU8E6JppGKFG40r5dDU1idHRN52NuwsemFzXZh1oUqh3bGUPgPioH+RoW"
            + "nmVSUQz1WfM2426w9f0GADuXzpUkcw=="
test_class.modifier: private static final
test_class.original_string: private static final String ALTERNATE_PUBLIC_SIGNING_KEY =
        "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEU8E6JppGKFG40r5dDU1idHRN52NuwsemFzXZh1oUqh3bGUPgPioH+RoW"
            + "nmVSUQz1WfM2426w9f0GADuXzpUkcw==";
test_class.type: String
test_class.var_name: ALTERNATE_PUBLIC_SIGNING_KEY
test_class.file: apps/rewardedads/src/test/java/com/google/crypto/tink/apps/rewardedads/RewardedAdsVerifierTest.java
test_class.identifier: RewardedAdsVerifierTest
test_case.body: @Test
    public void testShouldDecryptV1WhenFetchingSenderVerifyingKeys() throws Exception {
      RewardedAdsVerifier verifier =
          new RewardedAdsVerifier.Builder()
              .fetchVerifyingPublicKeysWith(
                  new KeysDownloader.Builder()
                      .setHttpTransport(
                          new MockHttpTransport.Builder()
                              .setLowLevelHttpResponse(
                                  new MockLowLevelHttpResponse()
                                      .setContent(GOOGLE_VERIFYING_PUBLIC_KEYS_JSON))
                              .build())
                      .setUrl("https://someUrl" /* unused */)
                      .build())
              .build();
  
      verifier.verify(signUrl(REWARD_URL, GOOGLE_SIGNING_PRIVATE_KEY_PKCS8_BASE64, KEY_ID));
    }
test_case.class_method_signature: RewardedAdsVerifierTest.testShouldDecryptV1WhenFetchingSenderVerifyingKeys()
test_case.full_signature: @Test public void testShouldDecryptV1WhenFetchingSenderVerifyingKeys()
test_case.identifier: testShouldDecryptV1WhenFetchingSenderVerifyingKeys
test_case.invocations: build fetchVerifyingPublicKeysWith build setUrl setHttpTransport build setLowLevelHttpResponse setContent verify signUrl
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testShouldDecryptV1WhenFetchingSenderVerifyingKeys()
focal_class.declarator: UTF_8 = Charset.forName("UTF-8")
focal_class.modifier: private static final
focal_class.original_string: private static final Charset UTF_8 = Charset.forName("UTF-8");
focal_class.type: Charset
focal_class.var_name: UTF_8
focal_class.declarator: DEFAULT_HTTP_TRANSPORT =
        new NetHttpTransport.Builder().build()
focal_class.modifier: private static final
focal_class.original_string: private static final NetHttpTransport DEFAULT_HTTP_TRANSPORT =
        new NetHttpTransport.Builder().build();
focal_class.type: NetHttpTransport
focal_class.var_name: DEFAULT_HTTP_TRANSPORT
focal_class.declarator: DEFAULT_BACKGROUND_EXECUTOR = Executors.newCachedThreadPool()
focal_class.modifier: private static final
focal_class.original_string: private static final Executor DEFAULT_BACKGROUND_EXECUTOR = Executors.newCachedThreadPool();
focal_class.type: Executor
focal_class.var_name: DEFAULT_BACKGROUND_EXECUTOR
focal_class.declarator: verifyingPublicKeysProviders
focal_class.modifier: private final
focal_class.original_string: private final List<VerifyingPublicKeysProvider> verifyingPublicKeysProviders;
focal_class.type: List<VerifyingPublicKeysProvider>
focal_class.var_name: verifyingPublicKeysProviders
focal_class.declarator: SIGNATURE_PARAM_NAME = "signature="
focal_class.modifier: public static final
focal_class.original_string: public static final String SIGNATURE_PARAM_NAME = "signature=";
focal_class.type: String
focal_class.var_name: SIGNATURE_PARAM_NAME
focal_class.declarator: KEY_ID_PARAM_NAME = "key_id="
focal_class.modifier: public static final
focal_class.original_string: public static final String KEY_ID_PARAM_NAME = "key_id=";
focal_class.type: String
focal_class.var_name: KEY_ID_PARAM_NAME
focal_class.declarator: PUBLIC_KEYS_URL_PROD =
        "https://www.gstatic.com/admob/reward/verifier-keys.json"
focal_class.modifier: public static final
focal_class.original_string: public static final String PUBLIC_KEYS_URL_PROD =
        "https://www.gstatic.com/admob/reward/verifier-keys.json";
focal_class.type: String
focal_class.var_name: PUBLIC_KEYS_URL_PROD
focal_class.declarator: PUBLIC_KEYS_URL_TEST =
        "https://www.gstatic.com/admob/reward/verifier-keys-test.json"
focal_class.modifier: public static final
focal_class.original_string: public static final String PUBLIC_KEYS_URL_TEST =
        "https://www.gstatic.com/admob/reward/verifier-keys-test.json";
focal_class.type: String
focal_class.var_name: PUBLIC_KEYS_URL_TEST
focal_class.declarator: KEYS_DOWNLOADER_INSTANCE_PROD =
        new KeysDownloader(DEFAULT_BACKGROUND_EXECUTOR, DEFAULT_HTTP_TRANSPORT, PUBLIC_KEYS_URL_PROD)
focal_class.modifier: public static final
focal_class.original_string: public static final KeysDownloader KEYS_DOWNLOADER_INSTANCE_PROD =
        new KeysDownloader(DEFAULT_BACKGROUND_EXECUTOR, DEFAULT_HTTP_TRANSPORT, PUBLIC_KEYS_URL_PROD);
focal_class.type: KeysDownloader
focal_class.var_name: KEYS_DOWNLOADER_INSTANCE_PROD
focal_class.declarator: KEYS_DOWNLOADER_INSTANCE_TEST =
        new KeysDownloader(DEFAULT_BACKGROUND_EXECUTOR, DEFAULT_HTTP_TRANSPORT, PUBLIC_KEYS_URL_TEST)
focal_class.modifier: public static final
focal_class.original_string: public static final KeysDownloader KEYS_DOWNLOADER_INSTANCE_TEST =
        new KeysDownloader(DEFAULT_BACKGROUND_EXECUTOR, DEFAULT_HTTP_TRANSPORT, PUBLIC_KEYS_URL_TEST);
focal_class.type: KeysDownloader
focal_class.var_name: KEYS_DOWNLOADER_INSTANCE_TEST
focal_class.file: apps/rewardedads/src/main/java/com/google/crypto/tink/apps/rewardedads/RewardedAdsVerifier.java
focal_class.identifier: RewardedAdsVerifier
focal_class.class_method_signature: RewardedAdsVerifier.RewardedAdsVerifier(List<VerifyingPublicKeysProvider> verifyingPublicKeysProviders)
focal_class.full_signature:   RewardedAdsVerifier(List<VerifyingPublicKeysProvider> verifyingPublicKeysProviders)
focal_class.identifier: RewardedAdsVerifier
focal_class.parameters: (List<VerifyingPublicKeysProvider> verifyingPublicKeysProviders)
focal_class.signature:  RewardedAdsVerifier(List<VerifyingPublicKeysProvider> verifyingPublicKeysProviders)
focal_class.class_method_signature: RewardedAdsVerifier.RewardedAdsVerifier(Builder builder)
focal_class.full_signature: private  RewardedAdsVerifier(Builder builder)
focal_class.identifier: RewardedAdsVerifier
focal_class.modifiers: private
focal_class.parameters: (Builder builder)
focal_class.signature:  RewardedAdsVerifier(Builder builder)
focal_class.class_method_signature: RewardedAdsVerifier.verify(String rewardUrl)
focal_class.full_signature: public void verify(String rewardUrl)
focal_class.identifier: verify
focal_class.modifiers: public
focal_class.parameters: (String rewardUrl)
focal_class.return: void
focal_class.signature: void verify(String rewardUrl)
focal_class.class_method_signature: RewardedAdsVerifier.verify(final byte[] tbs, long keyId, final byte[] signature)
focal_class.full_signature: private void verify(final byte[] tbs, long keyId, final byte[] signature)
focal_class.identifier: verify
focal_class.modifiers: private
focal_class.parameters: (final byte[] tbs, long keyId, final byte[] signature)
focal_class.return: void
focal_class.signature: void verify(final byte[] tbs, long keyId, final byte[] signature)
focal_class.class_method_signature: RewardedAdsVerifier.parsePublicKeysJson(String publicKeysJson)
focal_class.full_signature: private static Map<Long, ECPublicKey> parsePublicKeysJson(String publicKeysJson)
focal_class.identifier: parsePublicKeysJson
focal_class.modifiers: private static
focal_class.parameters: (String publicKeysJson)
focal_class.return: Map<Long, ECPublicKey>
focal_class.signature: Map<Long, ECPublicKey> parsePublicKeysJson(String publicKeysJson)
focal_method.body: public void verify(String rewardUrl) throws GeneralSecurityException {
      URI uri;
      try {
        uri = new URI(rewardUrl);
      } catch (URISyntaxException ex) {
        throw new GeneralSecurityException(ex);
      }
      String queryString = uri.getQuery();
      int i = queryString.indexOf(SIGNATURE_PARAM_NAME);
      if (i <= 0 || queryString.charAt(i - 1) != '&') {
        throw new GeneralSecurityException(
            "signature and key id must be the last two query parameters");
      }
      byte[] tbsData =
          queryString.substring(0, i - 1 /* i - 1 instead of i because of & */).getBytes(UTF_8);
  
      String sigAndKeyId = queryString.substring(i);
      i = sigAndKeyId.indexOf(KEY_ID_PARAM_NAME);
      if (i == -1 || sigAndKeyId.charAt(i - 1) != '&') {
        throw new GeneralSecurityException(
            "signature and key id must be the last two query parameters");
      }
      String sig =
          sigAndKeyId.substring(
              SIGNATURE_PARAM_NAME.length(), i - 1 /* i - 1 instead of i because of & */);
  
      // We don't have to check that keyId is the last parameter, because the long conversion would
      // fail anyway if there's any trailing data.
      try {
        long keyId = Long.parseLong(sigAndKeyId.substring(i + KEY_ID_PARAM_NAME.length()));
        verify(tbsData, keyId, Base64.urlSafeDecode(sig));
      } catch (NumberFormatException ex) {
        throw new GeneralSecurityException("key_id must be a long");
      }
    }
focal_method.class_method_signature: RewardedAdsVerifier.verify(String rewardUrl)
focal_method.full_signature: public void verify(String rewardUrl)
focal_method.identifier: verify
focal_method.invocations: getQuery indexOf charAt getBytes substring substring indexOf charAt substring length parseLong substring length verify urlSafeDecode
focal_method.modifiers: public
focal_method.parameters: (String rewardUrl)
focal_method.return: void
focal_method.signature: void verify(String rewardUrl)