in emr-user-role-mapper-s3storagebasedauthorizationmanager/src/main/java/com/amazonaws/emr/urm/hive/urmstoragebasedauthorizer/URMCredentialsRetriever.java [22:40]
AWSCredentials getCredentialsForUser(String userName) {
try {
//Create http-client to get user mapped role credentials
URI uri = URI.create(URM_ADDRESS_FOR_IMPERSONATION + userName);
URLConnection connection = uri.toURL().openConnection();
InputStream response = connection.getInputStream();
try (BufferedReader rd = new BufferedReader(new InputStreamReader(response))) {
StringBuilder responseString = new StringBuilder(); // or StringBuffer if Java version 5+
String line;
while ((line = rd.readLine()) != null) {
responseString.append(line);
responseString.append('\r');
}
return extractCredentialsFromResponse(responseString.toString());
}
} catch (Exception e) {
throw new RuntimeException(String.format("Caught exception [%s] while fetching user mapped role credentials for user %s.", e, userName), e);
}
}