Example usage for com.amazonaws.services.identitymanagement AmazonIdentityManagementClient listRoles

List of usage examples for com.amazonaws.services.identitymanagement AmazonIdentityManagementClient listRoles

Introduction

In this page you can find the example usage for com.amazonaws.services.identitymanagement AmazonIdentityManagementClient listRoles.

Prototype

@Override
    public ListRolesResult listRoles() 

Source Link

Usage

From source file:com.denismo.aws.iam.LDAPIAMPoller.java

License:Apache License

private void populateRolesFromIAM() {
    AmazonIdentityManagementClient client = new AmazonIdentityManagementClient(credentials);

    try {//from  ww w.  ja va 2  s  . co  m
        ListRolesResult res = client.listRoles();
        while (true) {
            for (Role role : res.getRoles()) {
                try {
                    Entry groupEntry = getOrCreateRoleGroup(role);
                    addRole(role, groupEntry);
                    LOG.info("Added role " + role.getRoleName() + " at " + rolesDN);
                } catch (Throwable e) {
                    LOG.error("Exception processing role " + role.getRoleName(), e);
                }
            }
            if (res.isTruncated()) {
                res = client.listRoles(new ListRolesRequest().withMarker(res.getMarker()));
            } else {
                break;
            }
        }
    } finally {
        client.shutdown();
    }
}