@Test public void testParseInstanceProfileCredentialsFromJsonWhenAccessSecretAndTokenPresent() { assertThat( InstanceProfileCredentialsProvider .parseJson( "{\"AccessKeyId\" : \"AAAAA\",\"SecretAccessKey\" : \"SSSSSSS\", \"Token\" : \"TTTTTTT\"}")) .containsEntry("accessKey", "AAAAA") .containsEntry("secretKey", "SSSSSSS") .containsEntry("sessionToken", "TTTTTTT"); }
static Map<String, String> parseJson(String in) { if (in == null) { return Collections.emptyMap(); } String noBraces = in.replace('{', ' ').replace('}', ' ').trim(); Map<String, String> builder = new LinkedHashMap<String, String>(); Matcher matcher = JSON_FIELDS.matcher(noBraces); while (matcher.find()) { String key = keyMap.get(matcher.group(1)); if (key != null) { builder.put(key, matcher.group(2)); } } return builder; }
InstanceProfileCredentialsProvider { static Map<String, String> parseJson(String in) { if (in == null) { return Collections.emptyMap(); } String noBraces = in.replace('{', ' ').replace('}', ' ').trim(); Map<String, String> builder = new LinkedHashMap<String, String>(); Matcher matcher = JSON_FIELDS.matcher(noBraces); while (matcher.find()) { String key = keyMap.get(matcher.group(1)); if (key != null) { builder.put(key, matcher.group(2)); } } return builder; } }
InstanceProfileCredentialsProvider { static Map<String, String> parseJson(String in) { if (in == null) { return Collections.emptyMap(); } String noBraces = in.replace('{', ' ').replace('}', ' ').trim(); Map<String, String> builder = new LinkedHashMap<String, String>(); Matcher matcher = JSON_FIELDS.matcher(noBraces); while (matcher.find()) { String key = keyMap.get(matcher.group(1)); if (key != null) { builder.put(key, matcher.group(2)); } } return builder; } InstanceProfileCredentialsProvider();  InstanceProfileCredentialsProvider(URI baseUri);  InstanceProfileCredentialsProvider(Provider<String> iipJsonProvider); }
InstanceProfileCredentialsProvider { static Map<String, String> parseJson(String in) { if (in == null) { return Collections.emptyMap(); } String noBraces = in.replace('{', ' ').replace('}', ' ').trim(); Map<String, String> builder = new LinkedHashMap<String, String>(); Matcher matcher = JSON_FIELDS.matcher(noBraces); while (matcher.find()) { String key = keyMap.get(matcher.group(1)); if (key != null) { builder.put(key, matcher.group(2)); } } return builder; } InstanceProfileCredentialsProvider();  InstanceProfileCredentialsProvider(URI baseUri);  InstanceProfileCredentialsProvider(Provider<String> iipJsonProvider); @Override String toString(); }
InstanceProfileCredentialsProvider { static Map<String, String> parseJson(String in) { if (in == null) { return Collections.emptyMap(); } String noBraces = in.replace('{', ' ').replace('}', ' ').trim(); Map<String, String> builder = new LinkedHashMap<String, String>(); Matcher matcher = JSON_FIELDS.matcher(noBraces); while (matcher.find()) { String key = keyMap.get(matcher.group(1)); if (key != null) { builder.put(key, matcher.group(2)); } } return builder; } InstanceProfileCredentialsProvider();  InstanceProfileCredentialsProvider(URI baseUri);  InstanceProfileCredentialsProvider(Provider<String> iipJsonProvider); @Override String toString();  }