protected Credentials parse(final InputStream in) throws IOException {
        final JsonReader reader = new JsonReader(new InputStreamReader(in, StandardCharsets.UTF_8));
        reader.beginObject();
        String key = null;
        String secret = null;
        String token = null;
        Date expiration = null;
        while(reader.hasNext()) {
            final String name = reader.nextName();
            final String value = reader.nextString();
            switch(name) {
                case "AccessKeyId":
                    key = value;
                    break;
                case "SecretAccessKey":
                    secret = value;
                    break;
                case "Token":
                    token = value;
                    break;
                case "Expiration":
                    try {
                        expiration = new ISO8601DateFormatter().parse(value);
                    }
                    catch(InvalidDateException e) {
                        log.warn(String.format("Failure %s parsing %s", e, value));
                    }
                    break;
            }
        }
        reader.endObject();
        return new Credentials().withTokens(new TemporaryAccessTokens(key, secret, token, expiration != null ? expiration.getTime() : -1L));
    }
@Test
    public void testParse() throws Exception {
        final Credentials c = new AWSSessionCredentialsRetriever(new DisabledX509TrustManager(), new DefaultX509KeyManager(),
                "http://169.254.169.254/latest/meta-data/iam/security-credentials/s3access")
                .parse(IOUtils.toInputStream("{\n" +
                        "  \"Code\" : \"Success\",\n" +
                        "  \"LastUpdated\" : \"2012-04-26T16:39:16Z\",\n" +
                        "  \"Type\" : \"AWS-HMAC\",\n" +
                        "  \"AccessKeyId\" : \"AKIAIOSFODNN7EXAMPLE\",\n" +
                        "  \"SecretAccessKey\" : \"wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY\",\n" +
                        "  \"Token\" : \"token\",\n" +
                        "  \"Expiration\" : \"2012-04-27T22:39:16Z\"\n" +
                        "}", Charset.defaultCharset()));
        assertEquals("AKIAIOSFODNN7EXAMPLE", c.getTokens().getAccessKeyId());
        assertEquals("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", c.getTokens().getSecretAccessKey());
        assertEquals("token", c.getTokens().getSessionToken());
        assertEquals(1335566356000L, c.getTokens().getExpiryInMilliseconds(), 0L);
    }