当前位置: 首页>>代码示例>>Java>>正文


Java AccessKeyMetadata类代码示例

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


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

示例1: main

import com.amazonaws.services.identitymanagement.model.AccessKeyMetadata; //导入依赖的package包/类
public static void main(String[] args) {

        final String USAGE =
            "To run this example, supply an IAM  username\n" +
            "Ex: ListAccessKeys <username>\n";

        if (args.length != 1) {
            System.out.println(USAGE);
            System.exit(1);
        }

        String username = args[0];

        final AmazonIdentityManagement iam =
            AmazonIdentityManagementClientBuilder.defaultClient();

        boolean done = false;
        ListAccessKeysRequest request = new ListAccessKeysRequest()
                .withUserName(username);

        while (!done) {

            ListAccessKeysResult response = iam.listAccessKeys(request);

            for (AccessKeyMetadata metadata :
                    response.getAccessKeyMetadata()) {
                System.out.format("Retrieved access key %s",
                        metadata.getAccessKeyId());
            }

            request.setMarker(response.getMarker());

            if (!response.getIsTruncated()) {
                done = true;
            }
        }
    }
 
开发者ID:awsdocs,项目名称:aws-doc-sdk-examples,代码行数:38,代码来源:ListAccessKeys.java

示例2: writeViolation

import com.amazonaws.services.identitymanagement.model.AccessKeyMetadata; //导入依赖的package包/类
void writeViolation(final String accountId, final AccessKeyMetadata accessKey) {
    log.info("Found user {} with expired access key {} in account {}", accessKey.getUserName(), accessKey.getAccessKeyId(), accountId);
    violationSink.put(
            new ViolationBuilder()
                    .withAccountId(accountId)
                    .withRegion(NoPasswordViolationWriter.NO_REGION)
                    .withEventId("check-access-key_" + accessKey.getAccessKeyId())
                    .withType(ACTIVE_KEY_TOO_OLD)
                    .withPluginFullyQualifiedClassName(KeyRotationJob.class)
                    .withMetaInfo(metaMap(accessKey))
                    .build());
}
 
开发者ID:zalando-stups,项目名称:fullstop,代码行数:13,代码来源:KeyRotationViolationWriter.java

示例3: metaMap

import com.amazonaws.services.identitymanagement.model.AccessKeyMetadata; //导入依赖的package包/类
private Map<?, ?> metaMap(final AccessKeyMetadata accessKey) {
    return ImmutableMap.builder()
            .put("access_key_id", accessKey.getAccessKeyId())
            .put("user_name", accessKey.getUserName())
            .put("access_key_created", accessKey.getCreateDate())
            .build();
}
 
开发者ID:zalando-stups,项目名称:fullstop,代码行数:8,代码来源:KeyRotationViolationWriter.java

示例4: setUp

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

示例5: activity

import com.amazonaws.services.identitymanagement.model.AccessKeyMetadata; //导入依赖的package包/类
private static Predicate<AccessKeyMetadata> activity(final String value) {
    return t -> value.equals(t.getStatus());
}
 
开发者ID:zalando-stups,项目名称:fullstop,代码行数:4,代码来源:AccessKeyMetadataPredicates.java

示例6: withDaysOlderThan

import com.amazonaws.services.identitymanagement.model.AccessKeyMetadata; //导入依赖的package包/类
private static Predicate<AccessKeyMetadata> withDaysOlderThan(final int days) {
    return t -> (t.getCreateDate().getTime() < LocalDate.now().minusDays(days).toDate().getTime());
}
 
开发者ID:zalando-stups,项目名称:fullstop,代码行数:4,代码来源:AccessKeyMetadataPredicates.java

示例7: isActiveAndOlderThanDays

import com.amazonaws.services.identitymanagement.model.AccessKeyMetadata; //导入依赖的package包/类
static Predicate<AccessKeyMetadata> isActiveAndOlderThanDays(final int days) {
    return IS_ACTIVE.and(withDaysOlderThan(days));
}
 
开发者ID:zalando-stups,项目名称:fullstop,代码行数:4,代码来源:AccessKeyMetadataPredicates.java

示例8: expired

import com.amazonaws.services.identitymanagement.model.AccessKeyMetadata; //导入依赖的package包/类
private AccessKeyMetadata expired(final AccessKeyMetadata accessKeyMetadata) {
    accessKeyMetadata.setCreateDate(now().minusDays(31).toDate());
    return accessKeyMetadata;
}
 
开发者ID:zalando-stups,项目名称:fullstop,代码行数:5,代码来源:KeyRotationJobTest.java

示例9: upToDate

import com.amazonaws.services.identitymanagement.model.AccessKeyMetadata; //导入依赖的package包/类
private AccessKeyMetadata upToDate(final AccessKeyMetadata accessKeyMetadata) {
    accessKeyMetadata.setCreateDate(new Date());
    return accessKeyMetadata;
}
 
开发者ID:zalando-stups,项目名称:fullstop,代码行数:5,代码来源:KeyRotationJobTest.java

示例10: inactive

import com.amazonaws.services.identitymanagement.model.AccessKeyMetadata; //导入依赖的package包/类
private AccessKeyMetadata inactive(final AccessKeyMetadata accessKeyMetadata) {
    accessKeyMetadata.setStatus("Inactive");
    return accessKeyMetadata;
}
 
开发者ID:zalando-stups,项目名称:fullstop,代码行数:5,代码来源:KeyRotationJobTest.java

示例11: active

import com.amazonaws.services.identitymanagement.model.AccessKeyMetadata; //导入依赖的package包/类
private AccessKeyMetadata active(final AccessKeyMetadata accessKeyMetadata) {
    accessKeyMetadata.setStatus("Active");
    return accessKeyMetadata;
}
 
开发者ID:zalando-stups,项目名称:fullstop,代码行数:5,代码来源:KeyRotationJobTest.java

示例12: handle

import com.amazonaws.services.identitymanagement.model.AccessKeyMetadata; //导入依赖的package包/类
@Override
public void handle(String target,
                   Request baseRequest,
                   HttpServletRequest request,
                   HttpServletResponse response) {
    try {
        final Map<String, String[]> paramMap = request.getParameterMap();

        final AWSDatabase current = dbHolder.getCurrent();

        final long age = current.getAgeInMs();
        final float ageInSeconds = (float) age / 1000.0f;
        response.setHeader("Age", String.format("%.3f", ageInSeconds));
        response.setHeader("Cache-Control", String.format("public, max-age=%d", dbHolder.getCacheTimeInMs() / 1000));

        switch (target) {
            case "/ec2":
                handleComplexEC2(response, paramMap, current);
                break;
            case "/ec2/all":
                handleSimpleRequest(response, current.getEc2Instances());
                break;
            case "/rds/all":
                handleSimpleRequest(response, current.getRdsInstances());
                break;
            case "/ec2/sg":
                handleSimpleRequest(response, current.getEc2SGs());
                break;
            case "/iam": // backwards compatibility with documented feature
                final ArrayList<AccessKeyMetadata> justKeys = Lists.<AccessKeyMetadata>newArrayList();
                for (IAMUserWithKeys userWithKeys : current.getIamUsers())
                    justKeys.addAll(userWithKeys.getKeys());
                handleSimpleRequest(response, justKeys);
                break;
            case "/iam/users":
                handleSimpleRequest(response, current.getIamUsers());
                break;
            case "/dynamo":
                handleComplexDynamo(response, paramMap, current);
                break;
            case "/sqs":
                handleComplexSQS(response, paramMap, current);
                break;
            case "/elasticache/cluster":
                handleComplexElasticacheCluster(response, paramMap, current);
                break;
            default:
                response.setStatus(HttpServletResponse.SC_NOT_FOUND);
                break;
        }
    } finally {
        baseRequest.setHandled(true);
    }
}
 
开发者ID:airbnb,项目名称:billow,代码行数:55,代码来源:Handler.java


注:本文中的com.amazonaws.services.identitymanagement.model.AccessKeyMetadata类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。