@Test public void testParse() throws Exception { final Credentials c = new AWSSessionCredentialsRetriever(new DisabledX509TrustManager(), new DefaultX509KeyManager(), new DisabledTranscriptListener(), "http: .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.getUsername()); assertEquals("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", c.getPassword()); assertEquals("token", c.getToken()); }
protected Credentials parse(final InputStream in) throws BackgroundException { try { final JsonReader reader = new JsonReader(new InputStreamReader(in, StandardCharsets.UTF_8)); reader.beginObject(); String key = null; String secret = null; String token = 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; } } reader.endObject(); final Credentials credentials = new Credentials(key, secret); if(StringUtils.isNotBlank(token)) { credentials.setToken(token); } return credentials; } catch(MalformedJsonException e) { throw new InteroperabilityException("Invalid JSON response", e); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } }
AWSSessionCredentialsRetriever { protected Credentials parse(final InputStream in) throws BackgroundException { try { final JsonReader reader = new JsonReader(new InputStreamReader(in, StandardCharsets.UTF_8)); reader.beginObject(); String key = null; String secret = null; String token = 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; } } reader.endObject(); final Credentials credentials = new Credentials(key, secret); if(StringUtils.isNotBlank(token)) { credentials.setToken(token); } return credentials; } catch(MalformedJsonException e) { throw new InteroperabilityException("Invalid JSON response", e); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } }
AWSSessionCredentialsRetriever { protected Credentials parse(final InputStream in) throws BackgroundException { try { final JsonReader reader = new JsonReader(new InputStreamReader(in, StandardCharsets.UTF_8)); reader.beginObject(); String key = null; String secret = null; String token = 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; } } reader.endObject(); final Credentials credentials = new Credentials(key, secret); if(StringUtils.isNotBlank(token)) { credentials.setToken(token); } return credentials; } catch(MalformedJsonException e) { throw new InteroperabilityException("Invalid JSON response", e); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } AWSSessionCredentialsRetriever(final X509TrustManager trust, final X509KeyManager key, final TranscriptListener transcript, final String url);  AWSSessionCredentialsRetriever(final X509TrustManager trust, final X509KeyManager key, final ProtocolFactory factory, final TranscriptListener transcript, final String url); }
AWSSessionCredentialsRetriever { protected Credentials parse(final InputStream in) throws BackgroundException { try { final JsonReader reader = new JsonReader(new InputStreamReader(in, StandardCharsets.UTF_8)); reader.beginObject(); String key = null; String secret = null; String token = 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; } } reader.endObject(); final Credentials credentials = new Credentials(key, secret); if(StringUtils.isNotBlank(token)) { credentials.setToken(token); } return credentials; } catch(MalformedJsonException e) { throw new InteroperabilityException("Invalid JSON response", e); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } AWSSessionCredentialsRetriever(final X509TrustManager trust, final X509KeyManager key, final TranscriptListener transcript, final String url);  AWSSessionCredentialsRetriever(final X509TrustManager trust, final X509KeyManager key, final ProtocolFactory factory, final TranscriptListener transcript, final String url); Credentials get(); String getUrl(); }
AWSSessionCredentialsRetriever { protected Credentials parse(final InputStream in) throws BackgroundException { try { final JsonReader reader = new JsonReader(new InputStreamReader(in, StandardCharsets.UTF_8)); reader.beginObject(); String key = null; String secret = null; String token = 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; } } reader.endObject(); final Credentials credentials = new Credentials(key, secret); if(StringUtils.isNotBlank(token)) { credentials.setToken(token); } return credentials; } catch(MalformedJsonException e) { throw new InteroperabilityException("Invalid JSON response", e); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } AWSSessionCredentialsRetriever(final X509TrustManager trust, final X509KeyManager key, final TranscriptListener transcript, final String url);  AWSSessionCredentialsRetriever(final X509TrustManager trust, final X509KeyManager key, final ProtocolFactory factory, final TranscriptListener transcript, final String url); Credentials get(); String getUrl();  }