List of usage examples for com.amazonaws.services.identitymanagement AmazonIdentityManagementClient getAccountSummary
@Override
public GetAccountSummaryResult getAccountSummary()
From source file:com.denismo.aws.iam.IAMPasswordValidator.java
License:Apache License
public boolean verifyIAMPassword(Entry user, String pw) throws LdapInvalidAttributeValueException, LdapAuthenticationException { boolean role = false; AWSCredentials creds;/*from ww w . j a v a 2 s . c o m*/ if (isRole(user)) { role = true; String[] parts = pw.split("\\|"); if (parts == null || parts.length < 3) throw new LdapAuthenticationException(); creds = new BasicSessionCredentials(parts[0], parts[1], parts[2]); } else { creds = new BasicAWSCredentials(user.get("accessKey").getString(), pw); } LOG.debug("Verifying {} {} with accessKey <hidden> and secretKey <hidden>", role ? "role" : "user", user.get("uid").getString()); AmazonIdentityManagementClient client = new AmazonIdentityManagementClient(creds); try { client.getAccountSummary(); } catch (AmazonClientException e) { System.err.println(e.getMessage()); return false; } finally { client.shutdown(); } return true; }
From source file:com.denismo.aws.iam.IAMSecretKeyValidator.java
License:Apache License
@Override public boolean verifyIAMPassword(Entry user, String pw) throws LdapInvalidAttributeValueException, LdapAuthenticationException { boolean role = false; AWSCredentials creds;/* w ww .j a v a 2s . c om*/ if (isRole(user)) { role = true; String[] parts = pw.split("\\|"); if (parts == null || parts.length < 3) throw new LdapAuthenticationException(); creds = new BasicSessionCredentials(parts[0], parts[1], parts[2]); } else { creds = new BasicAWSCredentials(user.get("accessKey").getString(), pw); } LOG.debug("Verifying {} {} with accessKey <hidden> and secretKey <hidden>", role ? "role" : "user", user.get("uid").getString()); AmazonIdentityManagementClient client = new AmazonIdentityManagementClient(creds); try { client.getAccountSummary(); } catch (AmazonClientException e) { System.err.println(e.getMessage()); return false; } finally { client.shutdown(); } return true; }