public static void main(String[] args) { final String USAGE = "To run this example, supply a certificate name\n" + "Ex: GetServerCertificate <certificate-name>\n"; if (args.length != 1) { System.out.println(USAGE); System.exit(1); } String cert_name = args[0]; final AmazonIdentityManagement iam = AmazonIdentityManagementClientBuilder.defaultClient(); GetServerCertificateRequest request = new GetServerCertificateRequest() .withServerCertificateName(cert_name); GetServerCertificateResult response = iam.getServerCertificate(request); System.out.format("Successfully retrieved certificate with body %s", response.getServerCertificate().getCertificateBody()); }
/** * Checks if the server certificate is present. * * @param name The server certificate name * @return If present */ public boolean isServerCertificatePresent(final String name) { try { client.getServerCertificate(new GetServerCertificateRequest().withServerCertificateName(name)); return true; } catch (final NoSuchEntityException nsee) { return false; } }
/** * Gets the ARN for the specified server certificate name. * * @param name The server certificate name * @return ARN */ public Optional<String> getServerCertificateArn(final String name) { try { final GetServerCertificateResult serverCertificateResult = client.getServerCertificate(new GetServerCertificateRequest().withServerCertificateName(name)); return Optional.of(serverCertificateResult.getServerCertificate().getServerCertificateMetadata().getArn()); } catch (final NoSuchEntityException nsee) { return Optional.empty(); } }
/** * Gets the ID for the specified server certificate name. * * @param name The server certificate name * @return ID */ public Optional<String> getServerCertificateId(final String name) { try { final GetServerCertificateResult serverCertificateResult = client.getServerCertificate(new GetServerCertificateRequest().withServerCertificateName(name)); return Optional.of(serverCertificateResult.getServerCertificate() .getServerCertificateMetadata().getServerCertificateId()); } catch (final NoSuchEntityException nsee) { return Optional.empty(); } }
public ServerCertificate getServerCert(String serverCertName) { logger.info("get server cert, name={}", serverCertName); return iam.getServerCertificate(new GetServerCertificateRequest(serverCertName)).getServerCertificate(); }