//snippet-sourcedescription:[ListServerCertificates.java demonstrates how to list all server certificates associated with an AWS account.]
//snippet-keyword:[SDK for Java 2.0]
//snippet-keyword:[Code Sample]
//snippet-service:[iam]
//snippet-sourcetype:[full-example]
//snippet-sourcedate:[]
//snippet-sourceauthor:[soo-aws]
/*
 * Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 *
 *  http://aws.amazon.com/apache2.0
 *
 * or in the "license" file accompanying this file. This file is distributed
 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */
package com.example.iam;
// snippet-start:[iam.java2.list_server_certificates.complete]
// snippet-start:[iam.java2.list_server_certificates.import]
import software.amazon.awssdk.services.iam.model.ListServerCertificatesRequest;
import software.amazon.awssdk.services.iam.model.ListServerCertificatesResponse;
import software.amazon.awssdk.services.iam.model.ServerCertificateMetadata;

import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.iam.IamClient;
 
// snippet-end:[iam.java2.list_server_certificates.import]
/**
 * Lists all server certificates associated with an AWS account
 */
public class ListServerCertificates {
    public static void main(String[] args) {

        // snippet-start:[iam.java2.list_server_certificates.main]
        Region region = Region.AWS_GLOBAL;
        IamClient iam = IamClient.builder().region(region).build();

        boolean done = false;
        String new_marker = null;

        while(!done) {
        	ListServerCertificatesResponse response;

        	if (new_marker == null) {
                ListServerCertificatesRequest request =
                		ListServerCertificatesRequest.builder().build();
                response = iam.listServerCertificates(request);
        	}
        	else {
                ListServerCertificatesRequest request =
                		ListServerCertificatesRequest.builder()
                		.marker(new_marker).build();
                response = iam.listServerCertificates(request);
        	}

            for(ServerCertificateMetadata metadata :
                    response.serverCertificateMetadataList()) {
                System.out.printf("Retrieved server certificate %s",
                        metadata.serverCertificateName());
            }

            if(!response.isTruncated()) {
                done = true;
            }
            else {
            	new_marker = response.marker();
            }
        }
        // snippet-end:[iam.java2.list_server_certificates.main]
    }
}
 
// snippet-end:[iam.java2.list_server_certificates.complete]

@@ -288,16 +288,26 @@
 cedate:%5B
+03/02/2020
 %5D%0D%0A//sni
@@ -326,18 +326,23 @@
 uthor:%5Bs
-oo
+cmacdon
 -aws%5D%0D%0A/
@@ -361,18 +361,8 @@
 ght 
-2010-2019 
 Amaz
@@ -1081,16 +1081,80 @@
 mport%5D%0D%0A
+import software.amazon.awssdk.services.iam.model.IamException;%0D%0A
 import s
@@ -1385,18 +1385,16 @@
 adata;%0D%0A
-%0D%0A
 import s
@@ -1487,19 +1487,16 @@
 lient;%0D%0A
- %0D%0A
 // snipp
@@ -1547,16 +1547,18 @@
 mport%5D%0D%0A
+%0D%0A
 /**%0D%0A * 
@@ -1890,24 +1890,45 @@
 build();%0D%0A%0D%0A
+        try %7B%0D%0A%0D%0A    
         bool
@@ -1954,16 +1954,20 @@
         
+    
 String n
@@ -1968,18 +1968,17 @@
 ring new
-_m
+M
 arker = 
@@ -1994,16 +1994,20 @@
         
+    
 while(!d
@@ -2022,17 +2022,22 @@
         
-%09
+      
 ListServ
@@ -2084,18 +2084,20 @@
     
-%09
+    
 if (new
-_m
+M
 arke
@@ -2175,34 +2175,40 @@
                 
-%09%09
+        
 ListServerCertif
@@ -2318,21 +2318,14 @@
     
-%09%7D%0D%0A        %09
+    %7D 
 else
@@ -2401,18 +2401,24 @@
         
-%09%09
+        
 ListServ
@@ -2470,10 +2470,24 @@
     
-%09%09
+                
 .mar
@@ -2493,18 +2493,17 @@
 rker(new
-_m
+M
 arker).b
@@ -2584,17 +2584,20 @@
         
-%09
+    
 %7D%0D%0A%0D%0A   
@@ -2945,29 +2945,16 @@
        %7D
-%0D%0A           
  else %7B%0D
@@ -2970,14 +2970,16 @@
     
-%09new_m
+    newM
 arke
@@ -3020,32 +3020,198 @@
   %7D%0D%0A        %7D%0D%0A
+    %7D catch (IamException e) %7B%0D%0A        System.err.println(e.awsErrorDetails().errorMessage());%0D%0A        System.exit(1);%0D%0A    %7D%0D%0A        System.out.println(%22Done%22);%0D%0A
         // snipp
@@ -3274,11 +3274,8 @@
 %0A%7D%0D%0A
- %0D%0A
 // s

Update ListServerCertificates.java