@SuppressWarnings("static-access") @Test public void fetchIAMUsersTest() throws Exception { mockStatic(AmazonIdentityManagementClientBuilder.class); AmazonIdentityManagement iamClient = PowerMockito.mock(AmazonIdentityManagement.class); AmazonIdentityManagementClientBuilder amazonIdentityManagementClientBuilder = PowerMockito.mock(AmazonIdentityManagementClientBuilder.class); AWSStaticCredentialsProvider awsStaticCredentialsProvider = PowerMockito.mock(AWSStaticCredentialsProvider.class); PowerMockito.whenNew(AWSStaticCredentialsProvider.class).withAnyArguments().thenReturn(awsStaticCredentialsProvider); when(amazonIdentityManagementClientBuilder.standard()).thenReturn(amazonIdentityManagementClientBuilder); when(amazonIdentityManagementClientBuilder.withCredentials(anyObject())).thenReturn(amazonIdentityManagementClientBuilder); when(amazonIdentityManagementClientBuilder.withRegion(anyString())).thenReturn(amazonIdentityManagementClientBuilder); when(amazonIdentityManagementClientBuilder.build()).thenReturn(iamClient); ListUsersResult listUsersResult = new ListUsersResult(); List<User> users = new ArrayList<>(); User user = new User(); user.setUserName("name"); users.add(user); listUsersResult.setUsers(users); when(iamClient.listUsers(anyObject())).thenReturn(listUsersResult); ListAccessKeysResult listAccessKeysResult = new ListAccessKeysResult(); List<AccessKeyMetadata> accessKeyMetadataList = new ArrayList<>(); AccessKeyMetadata accessKeyMetadata = new AccessKeyMetadata(); accessKeyMetadata.setAccessKeyId("accessKeyId"); accessKeyMetadataList.add(accessKeyMetadata); listAccessKeysResult.setAccessKeyMetadata(accessKeyMetadataList ); when(iamClient.listAccessKeys(anyObject())).thenReturn(listAccessKeysResult); GetAccessKeyLastUsedResult getAccessKeyLastUsedResult = new GetAccessKeyLastUsedResult(); AccessKeyLastUsed accessKeyLastUsed = new AccessKeyLastUsed(); accessKeyLastUsed.setLastUsedDate(new Date()); getAccessKeyLastUsedResult.setAccessKeyLastUsed(accessKeyLastUsed ); when(iamClient.getAccessKeyLastUsed(anyObject())).thenReturn(getAccessKeyLastUsedResult); GetLoginProfileResult getLoginProfileResult = new GetLoginProfileResult(); LoginProfile loginProfile = new LoginProfile(); loginProfile.setCreateDate(new Date()); loginProfile.setPasswordResetRequired(false); getLoginProfileResult.setLoginProfile(loginProfile ); when(iamClient.getLoginProfile(anyObject())).thenReturn(getLoginProfileResult ); ListGroupsForUserResult listGroupsForUserResult = new ListGroupsForUserResult(); List<Group> groups = new ArrayList<>(); Group group = new Group(); group.setGroupName("groupName"); groups.add(group); listGroupsForUserResult.setGroups(groups ); when(iamClient.listGroupsForUser(anyObject())).thenReturn(listGroupsForUserResult ); ListMFADevicesResult listMFADevicesResult = new ListMFADevicesResult(); listMFADevicesResult.setMFADevices(new ArrayList<>());; when(iamClient.listMFADevices(anyObject())).thenReturn(listMFADevicesResult ); assertThat(inventoryUtil.fetchIAMUsers(new BasicSessionCredentials("awsAccessKey", "awsSecretKey", "sessionToken"), "account","accountName").size(), is(1)); listMFADevicesResult = new ListMFADevicesResult(); List<MFADevice> mfaDevices = new ArrayList<>(); mfaDevices.add(new MFADevice()); listMFADevicesResult.setMFADevices(mfaDevices); when(iamClient.listMFADevices(anyObject())).thenReturn(listMFADevicesResult ); assertThat(inventoryUtil.fetchIAMUsers(new BasicSessionCredentials("awsAccessKey", "awsSecretKey", "sessionToken"), "account","accountName").size(), is(1)); }
public static Map<String,List<UserVH>> fetchIAMUsers(BasicSessionCredentials temporaryCredentials,String accountId,String accountName) { String expPrefix = InventoryConstants.ERROR_PREFIX_CODE+accountId + "\",\"Message\": \"Exception in fetching info for resource in specific region\" ,\"type\": \"IAM\"" ; AmazonIdentityManagement iamClient = AmazonIdentityManagementClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(temporaryCredentials)).withRegion(InventoryConstants.REGION_US_WEST_2).build(); String marker = null; List<User> users = new ArrayList<>(); ListUsersResult rslt; do{ rslt = iamClient.listUsers(new ListUsersRequest().withMarker(marker)); users.addAll(rslt.getUsers()); marker = rslt.getMarker(); }while(marker!=null); List<UserVH> userList = new ArrayList<>(); Map<String,List<UserVH>> iamUsers = new HashMap<>(); iamUsers.put(accountId+delimiter+accountName, userList); users.parallelStream().forEach(user -> { UserVH userTemp = new UserVH(user); String userName = user.getUserName(); List<AccessKeyMetadata> accessKeys = iamClient.listAccessKeys(new ListAccessKeysRequest().withUserName(userName)).getAccessKeyMetadata(); List<AccessKeyMetadataVH> accessKeysTemp = new ArrayList<>(); userTemp.setAccessKeys(accessKeysTemp); try { if(!CollectionUtils.isEmpty(accessKeys)){ accessKeys.stream().forEach(accesskeyInfo -> { GetAccessKeyLastUsedResult accessKeyLastUsedResult = iamClient.getAccessKeyLastUsed(new GetAccessKeyLastUsedRequest().withAccessKeyId(accesskeyInfo.getAccessKeyId())); AccessKeyMetadataVH accessKeyVH = new AccessKeyMetadataVH(accesskeyInfo); accessKeysTemp.add(accessKeyVH); if(accessKeyLastUsedResult != null) { accessKeyVH.setLastUsedDate(accessKeyLastUsedResult.getAccessKeyLastUsed().getLastUsedDate()); } }); } } catch (Exception e){ log.warn(expPrefix+ InventoryConstants.ERROR_CAUSE +e.getMessage()+"\"}"); ErrorManageUtil.uploadError(accountId,"","IAM",e.getMessage()); } try{ LoginProfile logProf = iamClient.getLoginProfile(new GetLoginProfileRequest().withUserName(userName)).getLoginProfile(); userTemp.setPasswordCreationDate(logProf.getCreateDate()); userTemp.setPasswordResetRequired(logProf.isPasswordResetRequired()); }catch (Exception e) { } List<Group> groups = iamClient.listGroupsForUser(new ListGroupsForUserRequest().withUserName(userName)).getGroups(); List<String> groupsList = new ArrayList<>(); for(Group grp : groups){ groupsList.add(grp.getGroupName()); } userTemp.setGroups(groupsList); userTemp.setMfa(!iamClient.listMFADevices(new ListMFADevicesRequest().withUserName(userName)).getMFADevices().isEmpty()); synchronized (userList) { userList.add(userTemp); } }); log.debug(InventoryConstants.ACCOUNT + accountId +" Type : IAM User >> "+userList.size()); return iamUsers; }
InventoryUtil { public static Map<String,List<UserVH>> fetchIAMUsers(BasicSessionCredentials temporaryCredentials,String accountId,String accountName) { String expPrefix = InventoryConstants.ERROR_PREFIX_CODE+accountId + "\",\"Message\": \"Exception in fetching info for resource in specific region\" ,\"type\": \"IAM\"" ; AmazonIdentityManagement iamClient = AmazonIdentityManagementClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(temporaryCredentials)).withRegion(InventoryConstants.REGION_US_WEST_2).build(); String marker = null; List<User> users = new ArrayList<>(); ListUsersResult rslt; do{ rslt = iamClient.listUsers(new ListUsersRequest().withMarker(marker)); users.addAll(rslt.getUsers()); marker = rslt.getMarker(); }while(marker!=null); List<UserVH> userList = new ArrayList<>(); Map<String,List<UserVH>> iamUsers = new HashMap<>(); iamUsers.put(accountId+delimiter+accountName, userList); users.parallelStream().forEach(user -> { UserVH userTemp = new UserVH(user); String userName = user.getUserName(); List<AccessKeyMetadata> accessKeys = iamClient.listAccessKeys(new ListAccessKeysRequest().withUserName(userName)).getAccessKeyMetadata(); List<AccessKeyMetadataVH> accessKeysTemp = new ArrayList<>(); userTemp.setAccessKeys(accessKeysTemp); try { if(!CollectionUtils.isEmpty(accessKeys)){ accessKeys.stream().forEach(accesskeyInfo -> { GetAccessKeyLastUsedResult accessKeyLastUsedResult = iamClient.getAccessKeyLastUsed(new GetAccessKeyLastUsedRequest().withAccessKeyId(accesskeyInfo.getAccessKeyId())); AccessKeyMetadataVH accessKeyVH = new AccessKeyMetadataVH(accesskeyInfo); accessKeysTemp.add(accessKeyVH); if(accessKeyLastUsedResult != null) { accessKeyVH.setLastUsedDate(accessKeyLastUsedResult.getAccessKeyLastUsed().getLastUsedDate()); } }); } } catch (Exception e){ log.warn(expPrefix+ InventoryConstants.ERROR_CAUSE +e.getMessage()+"\"}"); ErrorManageUtil.uploadError(accountId,"","IAM",e.getMessage()); } try{ LoginProfile logProf = iamClient.getLoginProfile(new GetLoginProfileRequest().withUserName(userName)).getLoginProfile(); userTemp.setPasswordCreationDate(logProf.getCreateDate()); userTemp.setPasswordResetRequired(logProf.isPasswordResetRequired()); }catch (Exception e) { } List<Group> groups = iamClient.listGroupsForUser(new ListGroupsForUserRequest().withUserName(userName)).getGroups(); List<String> groupsList = new ArrayList<>(); for(Group grp : groups){ groupsList.add(grp.getGroupName()); } userTemp.setGroups(groupsList); userTemp.setMfa(!iamClient.listMFADevices(new ListMFADevicesRequest().withUserName(userName)).getMFADevices().isEmpty()); synchronized (userList) { userList.add(userTemp); } }); log.debug(InventoryConstants.ACCOUNT + accountId +" Type : IAM User >> "+userList.size()); return iamUsers; } }
InventoryUtil { public static Map<String,List<UserVH>> fetchIAMUsers(BasicSessionCredentials temporaryCredentials,String accountId,String accountName) { String expPrefix = InventoryConstants.ERROR_PREFIX_CODE+accountId + "\",\"Message\": \"Exception in fetching info for resource in specific region\" ,\"type\": \"IAM\"" ; AmazonIdentityManagement iamClient = AmazonIdentityManagementClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(temporaryCredentials)).withRegion(InventoryConstants.REGION_US_WEST_2).build(); String marker = null; List<User> users = new ArrayList<>(); ListUsersResult rslt; do{ rslt = iamClient.listUsers(new ListUsersRequest().withMarker(marker)); users.addAll(rslt.getUsers()); marker = rslt.getMarker(); }while(marker!=null); List<UserVH> userList = new ArrayList<>(); Map<String,List<UserVH>> iamUsers = new HashMap<>(); iamUsers.put(accountId+delimiter+accountName, userList); users.parallelStream().forEach(user -> { UserVH userTemp = new UserVH(user); String userName = user.getUserName(); List<AccessKeyMetadata> accessKeys = iamClient.listAccessKeys(new ListAccessKeysRequest().withUserName(userName)).getAccessKeyMetadata(); List<AccessKeyMetadataVH> accessKeysTemp = new ArrayList<>(); userTemp.setAccessKeys(accessKeysTemp); try { if(!CollectionUtils.isEmpty(accessKeys)){ accessKeys.stream().forEach(accesskeyInfo -> { GetAccessKeyLastUsedResult accessKeyLastUsedResult = iamClient.getAccessKeyLastUsed(new GetAccessKeyLastUsedRequest().withAccessKeyId(accesskeyInfo.getAccessKeyId())); AccessKeyMetadataVH accessKeyVH = new AccessKeyMetadataVH(accesskeyInfo); accessKeysTemp.add(accessKeyVH); if(accessKeyLastUsedResult != null) { accessKeyVH.setLastUsedDate(accessKeyLastUsedResult.getAccessKeyLastUsed().getLastUsedDate()); } }); } } catch (Exception e){ log.warn(expPrefix+ InventoryConstants.ERROR_CAUSE +e.getMessage()+"\"}"); ErrorManageUtil.uploadError(accountId,"","IAM",e.getMessage()); } try{ LoginProfile logProf = iamClient.getLoginProfile(new GetLoginProfileRequest().withUserName(userName)).getLoginProfile(); userTemp.setPasswordCreationDate(logProf.getCreateDate()); userTemp.setPasswordResetRequired(logProf.isPasswordResetRequired()); }catch (Exception e) { } List<Group> groups = iamClient.listGroupsForUser(new ListGroupsForUserRequest().withUserName(userName)).getGroups(); List<String> groupsList = new ArrayList<>(); for(Group grp : groups){ groupsList.add(grp.getGroupName()); } userTemp.setGroups(groupsList); userTemp.setMfa(!iamClient.listMFADevices(new ListMFADevicesRequest().withUserName(userName)).getMFADevices().isEmpty()); synchronized (userList) { userList.add(userTemp); } }); log.debug(InventoryConstants.ACCOUNT + accountId +" Type : IAM User >> "+userList.size()); return iamUsers; } private  InventoryUtil(); }
InventoryUtil { public static Map<String,List<UserVH>> fetchIAMUsers(BasicSessionCredentials temporaryCredentials,String accountId,String accountName) { String expPrefix = InventoryConstants.ERROR_PREFIX_CODE+accountId + "\",\"Message\": \"Exception in fetching info for resource in specific region\" ,\"type\": \"IAM\"" ; AmazonIdentityManagement iamClient = AmazonIdentityManagementClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(temporaryCredentials)).withRegion(InventoryConstants.REGION_US_WEST_2).build(); String marker = null; List<User> users = new ArrayList<>(); ListUsersResult rslt; do{ rslt = iamClient.listUsers(new ListUsersRequest().withMarker(marker)); users.addAll(rslt.getUsers()); marker = rslt.getMarker(); }while(marker!=null); List<UserVH> userList = new ArrayList<>(); Map<String,List<UserVH>> iamUsers = new HashMap<>(); iamUsers.put(accountId+delimiter+accountName, userList); users.parallelStream().forEach(user -> { UserVH userTemp = new UserVH(user); String userName = user.getUserName(); List<AccessKeyMetadata> accessKeys = iamClient.listAccessKeys(new ListAccessKeysRequest().withUserName(userName)).getAccessKeyMetadata(); List<AccessKeyMetadataVH> accessKeysTemp = new ArrayList<>(); userTemp.setAccessKeys(accessKeysTemp); try { if(!CollectionUtils.isEmpty(accessKeys)){ accessKeys.stream().forEach(accesskeyInfo -> { GetAccessKeyLastUsedResult accessKeyLastUsedResult = iamClient.getAccessKeyLastUsed(new GetAccessKeyLastUsedRequest().withAccessKeyId(accesskeyInfo.getAccessKeyId())); AccessKeyMetadataVH accessKeyVH = new AccessKeyMetadataVH(accesskeyInfo); accessKeysTemp.add(accessKeyVH); if(accessKeyLastUsedResult != null) { accessKeyVH.setLastUsedDate(accessKeyLastUsedResult.getAccessKeyLastUsed().getLastUsedDate()); } }); } } catch (Exception e){ log.warn(expPrefix+ InventoryConstants.ERROR_CAUSE +e.getMessage()+"\"}"); ErrorManageUtil.uploadError(accountId,"","IAM",e.getMessage()); } try{ LoginProfile logProf = iamClient.getLoginProfile(new GetLoginProfileRequest().withUserName(userName)).getLoginProfile(); userTemp.setPasswordCreationDate(logProf.getCreateDate()); userTemp.setPasswordResetRequired(logProf.isPasswordResetRequired()); }catch (Exception e) { } List<Group> groups = iamClient.listGroupsForUser(new ListGroupsForUserRequest().withUserName(userName)).getGroups(); List<String> groupsList = new ArrayList<>(); for(Group grp : groups){ groupsList.add(grp.getGroupName()); } userTemp.setGroups(groupsList); userTemp.setMfa(!iamClient.listMFADevices(new ListMFADevicesRequest().withUserName(userName)).getMFADevices().isEmpty()); synchronized (userList) { userList.add(userTemp); } }); log.debug(InventoryConstants.ACCOUNT + accountId +" Type : IAM User >> "+userList.size()); return iamUsers; } private  InventoryUtil(); static Map<String,List<Instance>> fetchInstances(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName,String ec2Filters); static Map<String,List<NetworkInterface>> fetchNetworkIntefaces(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<SecurityGroup>> fetchSecurityGroups(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<AutoScalingGroup>> fetchAsg(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<Stack>> fetchCloudFormationStack(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<DynamoVH>> fetchDynamoDBTables(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<EfsVH>> fetchEFSInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<Cluster>> fetchEMRInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<LambdaVH>> fetchLambdaInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<ClassicELBVH>> fetchClassicElbInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<LoadBalancerVH>> fetchElbInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<TargetGroupVH>> fetchTargetGroups(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<NatGateway>> fetchNATGatewayInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<DBClusterVH>> fetchRDSClusterInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<DBInstanceVH>> fetchRDSInstanceInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<BucketVH>> fetchS3Info(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<Subnet>> fetchSubnets(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<CheckVH>> fetchTrusterdAdvisorsChecks(BasicSessionCredentials temporaryCredentials,String accountId,String accountName ); static Map<String,List<RedshiftVH>> fetchRedshiftInfo(BasicSessionCredentials temporaryCredentials,String skipRegions,String accountId,String accountName); static Map<String,List<Volume>> fetchVolumetInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<Snapshot>> fetchSnapshots(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); @SuppressWarnings("rawtypes") static Map<String,List<VpcVH>> fetchVpcInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<RestApi>> fetchApiGateways(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<UserVH>> fetchIAMUsers(BasicSessionCredentials temporaryCredentials,String accountId,String accountName); static Map<String,List<Role>> fetchIAMRoles(BasicSessionCredentials temporaryCredentials,String accountId,String accountName); static Map<String,List<DBSnapshot>> fetchRDSDBSnapshots(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<KMSKeyVH>> fetchKMSKeys(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<CloudFrontVH>> fetchCloudFrontInfo(BasicSessionCredentials temporaryCredentials,String accountId,String accountName); static Map<String,List<EbsVH>> fetchEBSInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<PhdVH>> fetchPHDInfo(BasicSessionCredentials temporaryCredentials,String accountId,String accountName); static Map<String,List<SQSVH>> fetchSQSInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<SSLCertificateVH>> fetchACMCertficateInfo(BasicSessionCredentials temporaryCredentials, String skipRegions, String account, String accountName); static Map<String,List<IAMCertificateVH>> fetchIAMCertificateInfo(BasicSessionCredentials temporaryCredentials, String skipRegions, String account, String accountName); static Map<String,List<AccountVH>> fetchAccountsInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,
			String account, String accountName); static Map<String,List<GroupVH>> fetchIAMGroups(BasicSessionCredentials temporaryCredentials,String account, String accountName); static Map<String,List<Trail>> fetchCloudTrails(BasicSessionCredentials temporaryCredentials, String skipRegions,String account, String accountName); }
InventoryUtil { public static Map<String,List<UserVH>> fetchIAMUsers(BasicSessionCredentials temporaryCredentials,String accountId,String accountName) { String expPrefix = InventoryConstants.ERROR_PREFIX_CODE+accountId + "\",\"Message\": \"Exception in fetching info for resource in specific region\" ,\"type\": \"IAM\"" ; AmazonIdentityManagement iamClient = AmazonIdentityManagementClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(temporaryCredentials)).withRegion(InventoryConstants.REGION_US_WEST_2).build(); String marker = null; List<User> users = new ArrayList<>(); ListUsersResult rslt; do{ rslt = iamClient.listUsers(new ListUsersRequest().withMarker(marker)); users.addAll(rslt.getUsers()); marker = rslt.getMarker(); }while(marker!=null); List<UserVH> userList = new ArrayList<>(); Map<String,List<UserVH>> iamUsers = new HashMap<>(); iamUsers.put(accountId+delimiter+accountName, userList); users.parallelStream().forEach(user -> { UserVH userTemp = new UserVH(user); String userName = user.getUserName(); List<AccessKeyMetadata> accessKeys = iamClient.listAccessKeys(new ListAccessKeysRequest().withUserName(userName)).getAccessKeyMetadata(); List<AccessKeyMetadataVH> accessKeysTemp = new ArrayList<>(); userTemp.setAccessKeys(accessKeysTemp); try { if(!CollectionUtils.isEmpty(accessKeys)){ accessKeys.stream().forEach(accesskeyInfo -> { GetAccessKeyLastUsedResult accessKeyLastUsedResult = iamClient.getAccessKeyLastUsed(new GetAccessKeyLastUsedRequest().withAccessKeyId(accesskeyInfo.getAccessKeyId())); AccessKeyMetadataVH accessKeyVH = new AccessKeyMetadataVH(accesskeyInfo); accessKeysTemp.add(accessKeyVH); if(accessKeyLastUsedResult != null) { accessKeyVH.setLastUsedDate(accessKeyLastUsedResult.getAccessKeyLastUsed().getLastUsedDate()); } }); } } catch (Exception e){ log.warn(expPrefix+ InventoryConstants.ERROR_CAUSE +e.getMessage()+"\"}"); ErrorManageUtil.uploadError(accountId,"","IAM",e.getMessage()); } try{ LoginProfile logProf = iamClient.getLoginProfile(new GetLoginProfileRequest().withUserName(userName)).getLoginProfile(); userTemp.setPasswordCreationDate(logProf.getCreateDate()); userTemp.setPasswordResetRequired(logProf.isPasswordResetRequired()); }catch (Exception e) { } List<Group> groups = iamClient.listGroupsForUser(new ListGroupsForUserRequest().withUserName(userName)).getGroups(); List<String> groupsList = new ArrayList<>(); for(Group grp : groups){ groupsList.add(grp.getGroupName()); } userTemp.setGroups(groupsList); userTemp.setMfa(!iamClient.listMFADevices(new ListMFADevicesRequest().withUserName(userName)).getMFADevices().isEmpty()); synchronized (userList) { userList.add(userTemp); } }); log.debug(InventoryConstants.ACCOUNT + accountId +" Type : IAM User >> "+userList.size()); return iamUsers; } private  InventoryUtil(); static Map<String,List<Instance>> fetchInstances(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName,String ec2Filters); static Map<String,List<NetworkInterface>> fetchNetworkIntefaces(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<SecurityGroup>> fetchSecurityGroups(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<AutoScalingGroup>> fetchAsg(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<Stack>> fetchCloudFormationStack(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<DynamoVH>> fetchDynamoDBTables(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<EfsVH>> fetchEFSInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<Cluster>> fetchEMRInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<LambdaVH>> fetchLambdaInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<ClassicELBVH>> fetchClassicElbInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<LoadBalancerVH>> fetchElbInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<TargetGroupVH>> fetchTargetGroups(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<NatGateway>> fetchNATGatewayInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<DBClusterVH>> fetchRDSClusterInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<DBInstanceVH>> fetchRDSInstanceInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<BucketVH>> fetchS3Info(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<Subnet>> fetchSubnets(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<CheckVH>> fetchTrusterdAdvisorsChecks(BasicSessionCredentials temporaryCredentials,String accountId,String accountName ); static Map<String,List<RedshiftVH>> fetchRedshiftInfo(BasicSessionCredentials temporaryCredentials,String skipRegions,String accountId,String accountName); static Map<String,List<Volume>> fetchVolumetInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<Snapshot>> fetchSnapshots(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); @SuppressWarnings("rawtypes") static Map<String,List<VpcVH>> fetchVpcInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<RestApi>> fetchApiGateways(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<UserVH>> fetchIAMUsers(BasicSessionCredentials temporaryCredentials,String accountId,String accountName); static Map<String,List<Role>> fetchIAMRoles(BasicSessionCredentials temporaryCredentials,String accountId,String accountName); static Map<String,List<DBSnapshot>> fetchRDSDBSnapshots(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<KMSKeyVH>> fetchKMSKeys(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<CloudFrontVH>> fetchCloudFrontInfo(BasicSessionCredentials temporaryCredentials,String accountId,String accountName); static Map<String,List<EbsVH>> fetchEBSInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<PhdVH>> fetchPHDInfo(BasicSessionCredentials temporaryCredentials,String accountId,String accountName); static Map<String,List<SQSVH>> fetchSQSInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName); static Map<String,List<SSLCertificateVH>> fetchACMCertficateInfo(BasicSessionCredentials temporaryCredentials, String skipRegions, String account, String accountName); static Map<String,List<IAMCertificateVH>> fetchIAMCertificateInfo(BasicSessionCredentials temporaryCredentials, String skipRegions, String account, String accountName); static Map<String,List<AccountVH>> fetchAccountsInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,
			String account, String accountName); static Map<String,List<GroupVH>> fetchIAMGroups(BasicSessionCredentials temporaryCredentials,String account, String accountName); static Map<String,List<Trail>> fetchCloudTrails(BasicSessionCredentials temporaryCredentials, String skipRegions,String account, String accountName);  }