• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java GetUserResult类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中com.amazonaws.services.identitymanagement.model.GetUserResult的典型用法代码示例。如果您正苦于以下问题:Java GetUserResult类的具体用法?Java GetUserResult怎么用?Java GetUserResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

GetUserResult类属于com.amazonaws.services.identitymanagement.model包,在下文中一共展示了GetUserResult类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getAccountId

点赞 2

import com.amazonaws.services.identitymanagement.model.GetUserResult; //导入依赖的package包/类
/**
 * Via the default provider chain (i.e., global keys for this Jenkins instance),  return the account ID for the
 * currently authenticated user.
 * @param proxyHost hostname of the proxy to use (if any)
 * @param proxyPort port of the proxy to use (if any)
 * @return 12-digit account id
 */
public static String getAccountId(String proxyHost, int proxyPort) {

    String arn = "";
    try {
        ClientConfiguration clientCfg = new ClientConfiguration();
        if (proxyHost != null && proxyPort > 0 ) {
            clientCfg.setProxyHost(proxyHost);
            clientCfg.setProxyPort(proxyPort);
        }
        AmazonIdentityManagementClient iam = new AmazonIdentityManagementClient(clientCfg);
        GetUserResult user = iam.getUser();
        arn = user.getUser().getArn();
    } catch (AmazonServiceException e) {
        if (e.getErrorCode().compareTo("AccessDenied") == 0) {
            String msg = e.getMessage();
            int arnIdx = msg.indexOf("arn:aws");
            if (arnIdx != -1) {
                int arnSpace = msg.indexOf(" ", arnIdx);
                arn = msg.substring(arnIdx, arnSpace);
            }
        }
    }

    String accountId = arn.split(":")[ARN_ACCOUNT_ID_INDEX];
    return accountId;
}
 

开发者ID:awslabs,
项目名称:aws-codedeploy-plugin,
代码行数:34,
代码来源:AWSClients.java

示例2: getObject_instanceWithTagsConfiguredWithCustomResourceResolverAndCustomRegion_mapWithTagsReturned

点赞 2

import com.amazonaws.services.identitymanagement.model.GetUserResult; //导入依赖的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

示例3: getObject_instanceWithOutTags_emptyMapReturned

点赞 2

import com.amazonaws.services.identitymanagement.model.GetUserResult; //导入依赖的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

示例4: getObject_instanceWithTagsAndNoResourceIdResolverAndDefaultRegion_mapWithTagsReturned

点赞 2

import com.amazonaws.services.identitymanagement.model.GetUserResult; //导入依赖的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

示例5: parseInternal_userTagsDefined_createsUserTagBeanDefinition

点赞 2

import com.amazonaws.services.identitymanagement.model.GetUserResult; //导入依赖的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

示例6: findUserId

点赞 2

import com.amazonaws.services.identitymanagement.model.GetUserResult; //导入依赖的package包/类
@Override
public String findUserId(String accessKeyId, String secretAccessKey) {
    AmazonIdentityManagement iam = findClient(accessKeyId, secretAccessKey);

    GetUserResult res = iam.getUser();

    return res.getUser().getArn().split(":")[4];
}
 

开发者ID:veyronfei,
项目名称:clouck,
代码行数:9,
代码来源:IamWrapperImpl.java

示例7: getUserId

点赞 2

import com.amazonaws.services.identitymanagement.model.GetUserResult; //导入依赖的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

示例8: load

点赞 2

import com.amazonaws.services.identitymanagement.model.GetUserResult; //导入依赖的package包/类
@Override
public boolean load(GetUserRequest request, ResultCapture<GetUserResult>
        extractor) {

    return resource.load(request, extractor);
}
 

开发者ID:awslabs,
项目名称:aws-sdk-java-resources,
代码行数:7,
代码来源:UserImpl.java

示例9: parseInternal_customRdsInstance_createsRdsBeanAndUserTagsWithCustomRdsInstance

点赞 2

import com.amazonaws.services.identitymanagement.model.GetUserResult; //导入依赖的package包/类
@Test
public void parseInternal_customRdsInstance_createsRdsBeanAndUserTagsWithCustomRdsInstance() throws Exception {

    //Arrange
    DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();

    XmlBeanDefinitionReader xmlBeanDefinitionReader = new XmlBeanDefinitionReader(beanFactory);
    xmlBeanDefinitionReader.loadBeanDefinitions(new ClassPathResource(getClass().getSimpleName() + "-customRdsInstance.xml", getClass()));

    AmazonRDS clientMock = beanFactory.getBean("amazonRds", AmazonRDS.class);

    when(clientMock.describeDBInstances(new DescribeDBInstancesRequest().withDBInstanceIdentifier("test"))).thenReturn(
            new DescribeDBInstancesResult().
                    withDBInstances(new DBInstance().
                            withDBInstanceStatus("available").
                            withDBName("test").
                            withDBInstanceIdentifier("test").
                            withEngine("mysql").
                            withMasterUsername("admin").
                            withEndpoint(new Endpoint().
                                    withAddress("localhost").
                                    withPort(3306)
                            ).withReadReplicaDBInstanceIdentifiers("read1")
                    )
    );

    AmazonIdentityManagement amazonIdentityManagement = beanFactory.getBean("myIdentityService", AmazonIdentityManagement.class);

    when(amazonIdentityManagement.getUser()).thenReturn(new GetUserResult().withUser(new User("/", "aemruli", "123456789012", "arn:aws:iam::1234567890:user/aemruli", new Date())));
    when(clientMock.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);
    DataSource dataSource = beanFactory.getBean(DataSource.class);

    //Assert
    assertEquals("value2", dsTags.get("key1"));
    assertTrue(dataSource instanceof org.apache.tomcat.jdbc.pool.DataSource);
}
 

开发者ID:spring-cloud,
项目名称:spring-cloud-aws,
代码行数:42,
代码来源:AmazonRdsDataSourceBeanDefinitionParserTest.java

示例10: load

点赞 1

import com.amazonaws.services.identitymanagement.model.GetUserResult; //导入依赖的package包/类
/**
 * Makes a call to the service to load this resource's attributes if they
 * are not loaded yet, and use a ResultCapture to retrieve the low-level
 * client response
 * The following request parameters will be populated from the data of this
 * <code>User</code> resource, and any conflicting parameter value set in
 * the request will be overridden:
 * <ul>
 *   <li>
 *     <b><code>UserName</code></b>
 *         - mapped from the <code>Name</code> identifier.
 *   </li>
 * </ul>
 *
 * <p>
 *
 * @return Returns {@code true} if the resource is not yet loaded when this
 *         method was invoked, which indicates that a service call has been
 *         made to retrieve the attributes.
 * @see GetUserRequest
 */
boolean load(GetUserRequest request, ResultCapture<GetUserResult> extractor)
        ;
 

开发者ID:awslabs,
项目名称:aws-sdk-java-resources,
代码行数:24,
代码来源:User.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)