Search in sources :

Example 1 with GetAccessKeyInfoResponse

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

the class GetAccessKeyInfo method getKeyInfo.

// snippet-start:[sts.java2.get_access_key.main]
public static void getKeyInfo(StsClient stsClient, String accessKeyId) {
    try {
        GetAccessKeyInfoRequest accessRequest = GetAccessKeyInfoRequest.builder().accessKeyId(accessKeyId).build();
        GetAccessKeyInfoResponse accessResponse = stsClient.getAccessKeyInfo(accessRequest);
        System.out.println("The account associated with the access key is " + accessResponse.account());
    } catch (StsException e) {
        System.err.println(e.getMessage());
        System.exit(1);
    }
}
Also used : GetAccessKeyInfoResponse(software.amazon.awssdk.services.sts.model.GetAccessKeyInfoResponse) StsException(software.amazon.awssdk.services.sts.model.StsException) GetAccessKeyInfoRequest(software.amazon.awssdk.services.sts.model.GetAccessKeyInfoRequest)

Aggregations

GetAccessKeyInfoRequest (software.amazon.awssdk.services.sts.model.GetAccessKeyInfoRequest)1 GetAccessKeyInfoResponse (software.amazon.awssdk.services.sts.model.GetAccessKeyInfoResponse)1 StsException (software.amazon.awssdk.services.sts.model.StsException)1