use of com.amazonaws.services.identitymanagement.model.GetPolicyResult in project cloudbreak by hortonworks.
the class AwsSetup method checkIamOrS3Access.
private boolean checkIamOrS3Access(AmazonIdentityManagement client, AttachedPolicy attachedPolicy) {
GetPolicyRequest getRolePolicyRequest = new GetPolicyRequest();
getRolePolicyRequest.setPolicyArn(attachedPolicy.getPolicyArn());
GetPolicyResult policy = client.getPolicy(getRolePolicyRequest);
if (policy.getPolicy().getArn().toLowerCase().contains("iam")) {
LOGGER.info("Role has policy for iam resources: {}.", policy.getPolicy().getArn());
return true;
}
return false;
}
use of com.amazonaws.services.identitymanagement.model.GetPolicyResult in project aws-doc-sdk-examples by awsdocs.
the class GetPolicy method main.
public static void main(String[] args) {
final String USAGE = "To run this example, supply a policy arn\n" + "Ex: GetPolicy <policy-arn>\n";
if (args.length != 1) {
System.out.println(USAGE);
System.exit(1);
}
String policy_arn = args[0];
final AmazonIdentityManagement iam = AmazonIdentityManagementClientBuilder.defaultClient();
GetPolicyRequest request = new GetPolicyRequest().withPolicyArn(policy_arn);
GetPolicyResult response = iam.getPolicy(request);
System.out.format("Successfully retrieved policy %s", response.getPolicy().getPolicyName());
}
Aggregations