use of com.amazonaws.services.securitytoken.model.DecodeAuthorizationMessageResult in project cloudbreak by hortonworks.
the class AwsEncodedAuthorizationFailureMessageDecoder method getResultMessage.
private String getResultMessage(AwsCredentialView credentialView, String region, String encodedMessage) {
AmazonSecurityTokenServiceClient awsSts = awsClient.createSecurityTokenService(credentialView, region);
DecodeAuthorizationMessageRequest decodeAuthorizationMessageRequest = new DecodeAuthorizationMessageRequest().withEncodedMessage(encodedMessage);
DecodeAuthorizationMessageResult decodeAuthorizationMessageResult = awsSts.decodeAuthorizationMessage(decodeAuthorizationMessageRequest);
String decodedMessage = decodeAuthorizationMessageResult.getDecodedMessage();
Json authorizationError = new Json(decodedMessage);
String action = authorizationError.getValue("context.action");
String resource = authorizationError.getValue("context.resource");
return String.format("Your AWS credential is not authorized to perform action %s on resource %s. " + "Please contact your system administrator to update your AWS policy.", action, resource);
}
Aggregations