Search in sources :

Example 1 with GetPolicyRequest

use of com.amazonaws.services.identitymanagement.model.GetPolicyRequest 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;
}
Also used : GetPolicyRequest(com.amazonaws.services.identitymanagement.model.GetPolicyRequest) GetPolicyResult(com.amazonaws.services.identitymanagement.model.GetPolicyResult)

Example 2 with GetPolicyRequest

use of com.amazonaws.services.identitymanagement.model.GetPolicyRequest 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());
}
Also used : GetPolicyRequest(com.amazonaws.services.identitymanagement.model.GetPolicyRequest) GetPolicyResult(com.amazonaws.services.identitymanagement.model.GetPolicyResult) AmazonIdentityManagement(com.amazonaws.services.identitymanagement.AmazonIdentityManagement)

Aggregations

GetPolicyRequest (com.amazonaws.services.identitymanagement.model.GetPolicyRequest)2 GetPolicyResult (com.amazonaws.services.identitymanagement.model.GetPolicyResult)2 AmazonIdentityManagement (com.amazonaws.services.identitymanagement.AmazonIdentityManagement)1