本文整理汇总了Java中com.amazonaws.services.identitymanagement.model.User类的典型用法代码示例。如果您正苦于以下问题:Java User类的具体用法?Java User怎么用?Java User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
User类属于com.amazonaws.services.identitymanagement.model包,在下文中一共展示了User类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createEvaluations
import com.amazonaws.services.identitymanagement.model.User; //导入依赖的package包/类
/**
*
* @param allMFANotEnabledUsers
* @return List<Evaluation> returns list of Evaluation objects.
*/
private List<Evaluation> createEvaluations(List<User> allMFANotEnabledUsers) {
List<Evaluation> evaluations = new ArrayList<>();
if ( allMFANotEnabledUsers == null || allMFANotEnabledUsers.size() > 0 ) {
for(User user: allMFANotEnabledUsers) {
String userName = user.getUserName();
Evaluation evaluation = new Evaluation();
evaluation.setComplianceResourceId(userName);
evaluation.setComplianceResourceType(COMPLIANCE_RESOURCE_TYPE);
evaluation.setComplianceType(ComplianceType.NON_COMPLIANT);
evaluation.setOrderingTimestamp(new Date());
evaluations.add(evaluation);
}
}
System.out.println("INFO : Number of evaluations : " + evaluations.size());
return evaluations;
}
开发者ID:code4innerpeace,项目名称:AWSConfig,代码行数:28,代码来源:MFANotEnabledUsers.java
示例2: getAllMFANotEnabledUsers
import com.amazonaws.services.identitymanagement.model.User; //导入依赖的package包/类
/**
* Returns all Iam users for whom MFA is not enabled.
* @param allIamUsers
* @return List<User> :- return all Iam users whose MFA is not enabled.
*/
public List<User> getAllMFANotEnabledUsers(List<User> allIamUsers) {
List<User> allMFANotEnabledUsers = new ArrayList<>();
if ( allIamUsers != null || allIamUsers.size() > 0 ) {
for ( User user: allIamUsers) {
if (! isMFAEnabled(user)) {
allMFANotEnabledUsers.add(user);
}
}
}
System.out.println("INFO : Number of MFA Not Enabled Users : " + allMFANotEnabledUsers.size());
System.out.println("INFO : All MFA Not Enabled Users : " + allMFANotEnabledUsers);
return allMFANotEnabledUsers;
}
开发者ID:code4innerpeace,项目名称:AWSConfig,代码行数:22,代码来源:IamUtilsImpl.java
示例3: isMFAEnabled
import com.amazonaws.services.identitymanagement.model.User; //导入依赖的package包/类
/**
* Checks if user MFA is enabled or not.
* @param user
* @return returns true, if MFA is enabled for the user.
*/
public Boolean isMFAEnabled(User user) throws AmazonClientException {
Boolean mfaDeviceEnabled = false;
try {
if ( user != null ) {
ListMFADevicesRequest listMFADevicesRequest = new ListMFADevicesRequest(user.getUserName());
ListMFADevicesResult listMFADevicesResult = this.iamClient.listMFADevices(listMFADevicesRequest);
if ( listMFADevicesResult.getMFADevices().size() > 0) {
mfaDeviceEnabled = true;
}
}
}catch(AmazonClientException e) {
System.out.println("ERROR : Fetching list of MFA Devices.");
e.printStackTrace();
throw e;
}
//System.out.println("INFO : MFA enabled for the user? " + mfaDeviceEnabled);
return mfaDeviceEnabled;
}
开发者ID:code4innerpeace,项目名称:AWSConfig,代码行数:27,代码来源:IamUtilsImpl.java
示例4: setup
import com.amazonaws.services.identitymanagement.model.User; //导入依赖的package包/类
@Before
public void setup() {
iamUtilsImpl = new IamUtilsImpl();
allIamUsers = new ArrayList<>();
User user1 = new User();
user1.setUserName("VASVijay1");
User user2 = new User();
user2.setUserName("VASVijay2");
MFADevice mfaDevice1 = new MFADevice();
mfaDevice1.setUserName(user2.getUserName());
User user3 = new User();
user3.setUserName("[email protected]");
MFADevice mfaDevice2 = new MFADevice();
mfaDevice2.setUserName(user3.getUserName());
allIamUsers.addAll(Arrays.asList(user1,user2,user3));
}
开发者ID:code4innerpeace,项目名称:AWSConfig,代码行数:24,代码来源:IamUtilsImplTest.java
示例5: main
import com.amazonaws.services.identitymanagement.model.User; //导入依赖的package包/类
public static void main(String[] args) {
final AmazonIdentityManagement iam =
AmazonIdentityManagementClientBuilder.defaultClient();
boolean done = false;
ListUsersRequest request = new ListUsersRequest();
while(!done) {
ListUsersResult response = iam.listUsers(request);
for(User user : response.getUsers()) {
System.out.format("Retrieved user %s", user.getUserName());
}
request.setMarker(response.getMarker());
if(!response.getIsTruncated()) {
done = true;
}
}
}
开发者ID:awsdocs,项目名称:aws-doc-sdk-examples,代码行数:23,代码来源:ListUsers.java
示例6: createServiceInstanceBinding
import com.amazonaws.services.identitymanagement.model.User; //导入依赖的package包/类
public ServiceInstanceBinding createServiceInstanceBinding(String bindingId, ServiceInstance serviceInstance,
String serviceId, String planId, String appGuid) {
User user = iam.createUserForBinding(bindingId);
AccessKey accessKey = iam.createAccessKey(user);
// TODO create password and add to credentials
iam.addUserToGroup(user, iam.getGroupNameForInstance(serviceInstance.getId()));
String bucketName = s3.getBucketNameForInstance(serviceInstance.getId());
Map<String, Object> credentials = new HashMap<String, Object>();
credentials.put("bucket", bucketName);
credentials.put("username", user.getUserName());
credentials.put("access_key_id", accessKey.getAccessKeyId());
credentials.put("secret_access_key", accessKey.getSecretAccessKey());
credentials.put("host", AMAZON_S3_HOST);
credentials.put("uri", this.generateUri(accessKey.getAccessKeyId(), accessKey.getSecretAccessKey(), bucketName));
return new ServiceInstanceBinding(bindingId, serviceInstance.getId(), credentials, null, appGuid);
}
开发者ID:cloudfoundry-community,项目名称:s3-cf-service-broker,代码行数:17,代码来源:BasicPlan.java
示例7: beforeEachTestRuns
import com.amazonaws.services.identitymanagement.model.User; //导入依赖的package包/类
@Before
public void beforeEachTestRuns() {
monitor = createMock(MonitorStackEvents.class);
cfnRepository = createMock(CloudFormRepository.class);
vpcRepository = createMock(VpcRepository.class);
ELBRepository elbRepository = createMock(ELBRepository.class);
cloudRepository = createStrictMock(CloudRepository.class);
notificationSender = createStrictMock(NotificationSender.class);
identityProvider = createStrictMock(IdentityProvider.class);
user = new User("path", "userName", "userId", "arn", new Date());
aws = new AwsFacade(monitor, cfnRepository, vpcRepository, elbRepository, cloudRepository, notificationSender,
identityProvider);
}
开发者ID:cartwrightian,项目名称:cfnassist,代码行数:17,代码来源:TestAwsFacadeCreatesStacks.java
示例8: getAllIamUsers
import com.amazonaws.services.identitymanagement.model.User; //导入依赖的package包/类
/**
* This method returns all Iam users.
* @return List<User> returns all Iam users.
* @throws AmazonClientException
*/
public List<User> getAllIamUsers() throws AmazonClientException {
String marker = null;
List<User> allIamUsers = new ArrayList<>();
try {
// Fetch all iam users.
while(true) {
ListUsersRequest listUsersRequest = new ListUsersRequest();
listUsersRequest.setMarker(marker);
ListUsersResult listUsersResult = this.iamClient.listUsers(listUsersRequest);
allIamUsers.addAll(listUsersResult.getUsers());
// Check the listUsersResult is truncated. This method returns users in batches of 100.
if ( listUsersResult.isTruncated() ) {
marker = listUsersResult.getMarker();
} else {
break;
}
}
} catch(AmazonClientException e) {
System.out.println("ERROR : fetching all iam users");
e.printStackTrace();
throw e;
}
List<String> allIamUsersName = allIamUsers.stream().map(e -> e.getUserName()).collect(Collectors.toList());
System.out.println("INFO : Number of Iam users : " + allIamUsers.size());
System.out.println("INFO : Iam users : " + allIamUsersName);
return allIamUsers;
}
开发者ID:code4innerpeace,项目名称:AWSConfig,代码行数:41,代码来源:IamUtilsImpl.java
示例9: testGetAllIamUsers
import com.amazonaws.services.identitymanagement.model.User; //导入依赖的package包/类
@Test
public void testGetAllIamUsers() {
IamUtilsImpl iamUtilsImpl = mock(IamUtilsImpl.class);
when(iamUtilsImpl.getAllIamUsers()).thenReturn(allIamUsers);
List<User> output = iamUtilsImpl.getAllIamUsers();
assertEquals(3, output.size());
}
开发者ID:code4innerpeace,项目名称:AWSConfig,代码行数:9,代码来源:IamUtilsImplTest.java
示例10: testGetAllMFANotEnabledUsers
import com.amazonaws.services.identitymanagement.model.User; //导入依赖的package包/类
@Test
public void testGetAllMFANotEnabledUsers() {
// Not sure how to test this method. 'getAllMFANotEnabledUsers' method calls 'isMFAEnabled',
// which inturn uses AWS api. So mocking below.
IamUtilsImpl iamUtilsImpl = mock(IamUtilsImpl.class);
when(iamUtilsImpl.getAllMFANotEnabledUsers(allIamUsers)).thenReturn(Arrays.asList(user3));
List<User> allMFANotEnabledUsers = iamUtilsImpl.getAllMFANotEnabledUsers(allIamUsers);
assertEquals(1,allMFANotEnabledUsers.size());
}
开发者ID:code4innerpeace,项目名称:AWSConfig,代码行数:10,代码来源:IamUtilsImplTest.java
示例11: setUp
import com.amazonaws.services.identitymanagement.model.User; //导入依赖的package包/类
@Before
public void setUp() {
mockIAMDataSource = mock(IdentityManagementDataSource.class);
mockViolationWriter = mock(KeyRotationViolationWriter.class);
mockAccountIdSupplier = mock(AccountIdSupplier.class);
when(mockAccountIdSupplier.get()).thenReturn(newHashSet("account01", "account02"));
when(mockIAMDataSource.getUsers(eq("account01"))).thenReturn(singletonList(new User()));
when(mockIAMDataSource.getUsers(eq("account02"))).thenReturn(asList(new User(), new User()));
when(mockIAMDataSource.getAccessKeys(eq("account01"), any())).thenReturn(asList(
upToDate(active(new AccessKeyMetadata())),
expired(active(new AccessKeyMetadata())),
expired(inactive(new AccessKeyMetadata()))));
when(mockIAMDataSource.getAccessKeys(eq("account02"), any())).thenReturn(singletonList(upToDate(inactive(new AccessKeyMetadata()))));
}
开发者ID:zalando-stups,项目名称:fullstop,代码行数:15,代码来源:KeyRotationJobTest.java
示例12: getObject_instanceWithTagsConfiguredWithCustomResourceResolverAndCustomRegion_mapWithTagsReturned
import com.amazonaws.services.identitymanagement.model.User; //导入依赖的package包/类
@Test
public void getObject_instanceWithTagsConfiguredWithCustomResourceResolverAndCustomRegion_mapWithTagsReturned() throws Exception {
//Arrange
AmazonRDS amazonRds = mock(AmazonRDS.class);
ResourceIdResolver resourceIdResolver = mock(ResourceIdResolver.class);
AmazonIdentityManagement amazonIdentityManagement = mock(AmazonIdentityManagement.class);
AmazonRdsDataSourceUserTagsFactoryBean factoryBean = new AmazonRdsDataSourceUserTagsFactoryBean(amazonRds, "test", amazonIdentityManagement);
factoryBean.setResourceIdResolver(resourceIdResolver);
factoryBean.setRegion(Region.getRegion(Regions.EU_WEST_1));
when(resourceIdResolver.resolveToPhysicalResourceId("test")).thenReturn("stack-test");
when(amazonIdentityManagement.getUser()).thenReturn(new GetUserResult().withUser(new User("/", "aemruli", "123456789012", "arn:aws:iam::1234567890:user/aemruli", new Date())));
when(amazonRds.listTagsForResource(new ListTagsForResourceRequest().withResourceName("arn:aws:rds:eu-west-1:1234567890:db:stack-test"))).thenReturn(new ListTagsForResourceResult().withTagList(
new Tag().withKey("key1").withValue("value1"),
new Tag().withKey("key2").withValue("value2")
));
//Act
factoryBean.afterPropertiesSet();
Map<String, String> userTagMap = factoryBean.getObject();
//Assert
assertEquals("value1", userTagMap.get("key1"));
assertEquals("value2", userTagMap.get("key2"));
}
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:26,代码来源:AmazonRdsDataSourceUserTagsFactoryBeanTest.java
示例13: getObject_instanceWithOutTags_emptyMapReturned
import com.amazonaws.services.identitymanagement.model.User; //导入依赖的package包/类
@Test
public void getObject_instanceWithOutTags_emptyMapReturned() throws Exception {
//Arrange
AmazonRDS amazonRds = mock(AmazonRDS.class);
ResourceIdResolver resourceIdResolver = mock(ResourceIdResolver.class);
AmazonIdentityManagement amazonIdentityManagement = mock(AmazonIdentityManagement.class);
AmazonRdsDataSourceUserTagsFactoryBean factoryBean = new AmazonRdsDataSourceUserTagsFactoryBean(amazonRds, "test", amazonIdentityManagement);
factoryBean.setResourceIdResolver(resourceIdResolver);
factoryBean.setResourceIdResolver(resourceIdResolver);
factoryBean.setRegion(Region.getRegion(Regions.EU_WEST_1));
when(resourceIdResolver.resolveToPhysicalResourceId("test")).thenReturn("stack-test");
when(amazonIdentityManagement.getUser()).thenReturn(new GetUserResult().withUser(new User("/", "aemruli", "123456789012", "arn:aws:iam::1234567890:user/aemruli", new Date())));
when(amazonRds.listTagsForResource(new ListTagsForResourceRequest().withResourceName("arn:aws:rds:eu-west-1:1234567890:db:stack-test"))).thenReturn(new ListTagsForResourceResult());
//Act
factoryBean.afterPropertiesSet();
Map<String, String> userTagMap = factoryBean.getObject();
//Assert
assertTrue(userTagMap.isEmpty());
}
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:23,代码来源:AmazonRdsDataSourceUserTagsFactoryBeanTest.java
示例14: getObject_instanceWithTagsAndNoResourceIdResolverAndDefaultRegion_mapWithTagsReturned
import com.amazonaws.services.identitymanagement.model.User; //导入依赖的package包/类
@Test
public void getObject_instanceWithTagsAndNoResourceIdResolverAndDefaultRegion_mapWithTagsReturned() throws Exception {
//Arrange
AmazonRDS amazonRds = mock(AmazonRDS.class);
AmazonIdentityManagement amazonIdentityManagement = mock(AmazonIdentityManagement.class);
AmazonRdsDataSourceUserTagsFactoryBean factoryBean = new AmazonRdsDataSourceUserTagsFactoryBean(amazonRds, "test", amazonIdentityManagement);
when(amazonIdentityManagement.getUser()).thenReturn(new GetUserResult().withUser(new User("/", "aemruli", "123456789012", "arn:aws:iam::1234567890:user/aemruli", new Date())));
when(amazonRds.listTagsForResource(new ListTagsForResourceRequest().withResourceName("arn:aws:rds:us-west-2:1234567890:db:test"))).thenReturn(new ListTagsForResourceResult().withTagList(
new Tag().withKey("key1").withValue("value1"),
new Tag().withKey("key2").withValue("value2")
));
//Act
factoryBean.afterPropertiesSet();
Map<String, String> userTagMap = factoryBean.getObject();
//Assert
assertEquals("value1", userTagMap.get("key1"));
assertEquals("value2", userTagMap.get("key2"));
}
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:24,代码来源:AmazonRdsDataSourceUserTagsFactoryBeanTest.java
示例15: parseInternal_userTagsDefined_createsUserTagBeanDefinition
import com.amazonaws.services.identitymanagement.model.User; //导入依赖的package包/类
@Test
public void parseInternal_userTagsDefined_createsUserTagBeanDefinition() throws Exception {
//Arrange
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
BeanDefinitionBuilder beanDefinitionBuilder = BeanDefinitionBuilder.rootBeanDefinition(Mockito.class);
beanDefinitionBuilder.setFactoryMethod("mock");
beanDefinitionBuilder.addConstructorArgValue(AmazonRDS.class);
beanFactory.registerBeanDefinition(AmazonWebserviceClientConfigurationUtils.getBeanName(AmazonRDSClient.class.getName()), beanDefinitionBuilder.getBeanDefinition());
BeanDefinitionBuilder identityBuilder = BeanDefinitionBuilder.rootBeanDefinition(Mockito.class);
identityBuilder.setFactoryMethod("mock");
identityBuilder.addConstructorArgValue(AmazonIdentityManagement.class);
beanFactory.registerBeanDefinition(AmazonWebserviceClientConfigurationUtils.getBeanName(AmazonIdentityManagement.class.getName()), identityBuilder.getBeanDefinition());
XmlBeanDefinitionReader xmlBeanDefinitionReader = new XmlBeanDefinitionReader(beanFactory);
xmlBeanDefinitionReader.loadBeanDefinitions(new ClassPathResource(getClass().getSimpleName() + "-userTags.xml", getClass()));
AmazonRDS client = beanFactory.getBean(AmazonWebserviceClientConfigurationUtils.getBeanName(AmazonRDSClient.class.getName()), AmazonRDS.class);
AmazonIdentityManagement amazonIdentityManagement = beanFactory.getBean(AmazonWebserviceClientConfigurationUtils.getBeanName(AmazonIdentityManagement.class.getName()), AmazonIdentityManagement.class);
when(amazonIdentityManagement.getUser()).thenReturn(new GetUserResult().withUser(new User("/", "aemruli", "123456789012", "arn:aws:iam::1234567890:user/aemruli", new Date())));
when(client.listTagsForResource(new ListTagsForResourceRequest().withResourceName("arn:aws:rds:us-west-2:1234567890:db:test"))).thenReturn(new ListTagsForResourceResult().withTagList(
new Tag().withKey("key1").withValue("value2")
));
//Act
Map<?, ?> dsTags = beanFactory.getBean("dsTags", Map.class);
//Assert
assertEquals("value2", dsTags.get("key1"));
}
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:34,代码来源:AmazonRdsDataSourceBeanDefinitionParserTest.java
示例16: toIamUsers
import com.amazonaws.services.identitymanagement.model.User; //导入依赖的package包/类
public List<AbstractResource<?>> toIamUsers(List<User> users, String accountId, DateTime dt) {
List<AbstractResource<?>> resources = new ArrayList<>();
for (User user : users) {
IamUser iamUser = new IamUser();
conf(iamUser, accountId, dt);
iamUser.setResource(user);
resources.add(iamUser);
}
log.debug("{} users found via api and converted to IamUser", resources.size());
return resources;
}
开发者ID:veyronfei,项目名称:clouck,代码行数:12,代码来源:IamConverter.java
示例17: CFNAssistNotification
import com.amazonaws.services.identitymanagement.model.User; //导入依赖的package包/类
public CFNAssistNotification(String stackName, String stackStatus, User user) {
this.stackName = stackName;
this.stackStatus = stackStatus;
if (user!=null) {
this.userId = user.getUserId();
this.setUserName(user.getUserName());
}
}
开发者ID:cartwrightian,项目名称:cfnassist,代码行数:9,代码来源:CFNAssistNotification.java
示例18: getUserId
import com.amazonaws.services.identitymanagement.model.User; //导入依赖的package包/类
public User getUserId() {
logger.debug("Get current user");
try {
GetUserResult result = iamClient.getUser();
User user = result.getUser();
logger.info("Fetched current user: " + user);
return user;
}
catch(AmazonServiceException exception) {
logger.warn("Unable to fetch current user: " + exception.toString());
return null;
}
}
开发者ID:cartwrightian,项目名称:cfnassist,代码行数:14,代码来源:IdentityProvider.java
示例19: beforeEachTestRuns
import com.amazonaws.services.identitymanagement.model.User; //导入依赖的package包/类
@Before
public void beforeEachTestRuns() {
monitor = createMock(MonitorStackEvents.class);
cfnRepository = createMock(CloudFormRepository.class);
VpcRepository vpcRepository = createMock(VpcRepository.class);
elbRepository = createMock(ELBRepository.class);
CloudRepository cloudRepository = createStrictMock(CloudRepository.class);
notificationSender = createStrictMock(NotificationSender.class);
identityProvider = createStrictMock(IdentityProvider.class);
user = new User("path", "userName", "userId", "arn", new Date());
aws = new AwsFacade(monitor, cfnRepository, vpcRepository, elbRepository, cloudRepository, notificationSender, identityProvider);
}
开发者ID:cartwrightian,项目名称:cfnassist,代码行数:15,代码来源:TestAWSFacadeDeleteStacks.java
示例20: beforeEachTestRuns
import com.amazonaws.services.identitymanagement.model.User; //导入依赖的package包/类
@Before
public void beforeEachTestRuns() throws IOException {
monitor = createMock(MonitorStackEvents.class);
cfnRepository = createMock(CloudFormRepository.class);
vpcRepository = createStrictMock(VpcRepository.class);
ELBRepository elbRepository = createMock(ELBRepository.class);
cloudRepository = createStrictMock(CloudRepository.class);
notificationSender = createStrictMock(NotificationSender.class);
identityProvider = createStrictMock(IdentityProvider.class);
user = new User("path", "userName", "userId", "arn", new Date());
aws = new AwsFacade(monitor, cfnRepository, vpcRepository, elbRepository, cloudRepository, notificationSender, identityProvider);
deleteFile(THIRD_FILE);
}
开发者ID:cartwrightian,项目名称:cfnassist,代码行数:16,代码来源:TestAwsFacadeDeltaApplicationAndRollbacks.java
注:本文中的com.amazonaws.services.identitymanagement.model.User类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论