Java 类com.amazonaws.services.identitymanagement.model.ListRolePoliciesRequest 实例源码

项目:fullstop    文件:PolicyProviderImpl.java   
private Set<String> fetchInlinePolicyNames(String roleName, AmazonIdentityManagementClient iamClient) {
    return Optional.of(new ListRolePoliciesRequest().withRoleName(roleName))
            .map(iamClient::listRolePolicies)
            .map(ListRolePoliciesResult::getPolicyNames)
            .map(nameList -> nameList.stream().collect(toSet()))
            .orElseGet(Collections::emptySet);
}
项目:aws-sdk-java-resources    文件:RoleImpl.java   
@Override
public RolePolicyCollection getPolicies(ListRolePoliciesRequest request) {
    ResourceCollectionImpl result = resource.getCollection("Policies",
            request);

    if (result == null) return null;
    return new RolePolicyCollectionImpl(result);
}
项目:cloudbreak    文件:AwsSetup.java   
private void validateInstanceProfileCreation(AwsCredentialView awsCredentialView) {
    GetRoleRequest roleRequest = new GetRoleRequest();
    String roleName = awsCredentialView.getRoleArn().split("/")[1];
    LOGGER.info("Start validate {} role for S3 access.", roleName);
    roleRequest.withRoleName(roleName);
    AmazonIdentityManagement client = awsClient.createAmazonIdentityManagement(awsCredentialView);
    try {
        ListRolePoliciesRequest listRolePoliciesRequest = new ListRolePoliciesRequest();
        listRolePoliciesRequest.setRoleName(roleName);
        ListRolePoliciesResult listRolePoliciesResult = client.listRolePolicies(listRolePoliciesRequest);
        for (String s : listRolePoliciesResult.getPolicyNames()) {
            if (checkIamOrS3Statement(roleName, client, s)) {
                LOGGER.info("Validation successful for s3 or iam access.");
                return;
            }
        }
        ListAttachedRolePoliciesRequest listAttachedRolePoliciesRequest = new ListAttachedRolePoliciesRequest();
        listAttachedRolePoliciesRequest.setRoleName(roleName);
        ListAttachedRolePoliciesResult listAttachedRolePoliciesResult = client.listAttachedRolePolicies(listAttachedRolePoliciesRequest);
        for (AttachedPolicy attachedPolicy : listAttachedRolePoliciesResult.getAttachedPolicies()) {
            if (checkIamOrS3Access(client, attachedPolicy)) {
                LOGGER.info("Validation successful for s3 or iam access.");
                return;
            }
        }
    } catch (AmazonServiceException ase) {
        if (ase.getStatusCode() == UNAUTHORIZED) {
            String policyMEssage = "Could not get policies on the role because the arn role do not have enough permission: %s";
            LOGGER.info(String.format(policyMEssage, ase.getErrorMessage()));
            throw new CloudConnectorException(String.format(policyMEssage, ase.getErrorMessage()));
        } else {
            LOGGER.info(ase.getMessage());
            throw new CloudConnectorException(ase.getErrorMessage());
        }
    } catch (Exception e) {
        LOGGER.info(e.getMessage());
        throw new CloudConnectorException(e.getMessage());
    }
    LOGGER.info("Could not get policies on the role because the arn role do not have enough permission.");
    throw new CloudConnectorException("Could not get policies on the role because the arn role do not have enough permission.");
}
项目:aws-sdk-java-resources    文件:Role.java   
/**
 * Retrieves the Policies collection referenced by this resource.
 */
RolePolicyCollection getPolicies(ListRolePoliciesRequest request);