Search in sources :

Example 1 with KeyListEntry

use of software.amazon.awssdk.services.kms.model.KeyListEntry in project aws-doc-sdk-examples by awsdocs.

the class ListKeys method listAllKeys.

// snippet-start:[kms.java2_list_keys.main]
public static void listAllKeys(KmsClient kmsClient) {
    try {
        ListKeysRequest listKeysRequest = ListKeysRequest.builder().limit(15).build();
        ListKeysResponse keysResponse = kmsClient.listKeys(listKeysRequest);
        List<KeyListEntry> keyListEntries = keysResponse.keys();
        for (KeyListEntry key : keyListEntries) {
            System.out.println("The key ARN is: " + key.keyArn());
            System.out.println("The key Id is: " + key.keyId());
        }
    } catch (KmsException e) {
        System.err.println(e.getMessage());
        System.exit(1);
    }
}
Also used : KeyListEntry(software.amazon.awssdk.services.kms.model.KeyListEntry) KmsException(software.amazon.awssdk.services.kms.model.KmsException) ListKeysRequest(software.amazon.awssdk.services.kms.model.ListKeysRequest) ListKeysResponse(software.amazon.awssdk.services.kms.model.ListKeysResponse)

Aggregations

KeyListEntry (software.amazon.awssdk.services.kms.model.KeyListEntry)1 KmsException (software.amazon.awssdk.services.kms.model.KmsException)1 ListKeysRequest (software.amazon.awssdk.services.kms.model.ListKeysRequest)1 ListKeysResponse (software.amazon.awssdk.services.kms.model.ListKeysResponse)1