Example usage for com.amazonaws.services.ec2.model ImportKeyPairResult getKeyFingerprint

List of usage examples for com.amazonaws.services.ec2.model ImportKeyPairResult getKeyFingerprint

Introduction

In this page you can find the example usage for com.amazonaws.services.ec2.model ImportKeyPairResult getKeyFingerprint.

Prototype


public String getKeyFingerprint() 

Source Link

Document

The MD5 public key fingerprint as specified in section 4 of RFC 4716.

Usage

From source file:com.axemblr.provisionr.amazon.activities.EnsureKeyPairExists.java

License:Apache License

private void importPoolPublicKeyPair(AmazonEC2 client, String keyName, String publicKey) {
    ImportKeyPairResult result = client
            .importKeyPair(new ImportKeyPairRequest().withKeyName(keyName).withPublicKeyMaterial(publicKey));
    LOG.info("<< Created remote key with fingerprint {}", result.getKeyFingerprint());
}

From source file:org.occiware.clouddriver.IAM.KeyPairOperation.java

License:Apache License

/**
 * Import key pair to AWS./* ww  w  . j av a  2 s. co  m*/
 * @param keyPair a keypair data object with a public key and a name set..
 * @throws KeyPairOperationException Exception when aws exception when importing a new key pair.
 */
public void importKeyPair(KeyPairDO keyPair) throws KeyPairOperationException {

    String keyPairName = keyPair.getKeyPairName();
    String encodedPublicKey = keyPair.getPublicKey(); // Base 64 encoded, DER

    if (keyPairName == null) {
        throw new KeyPairOperationException("The keyPair name must be provided for operation import KeyPair.");
    }
    if (encodedPublicKey == null) {
        throw new KeyPairOperationException(
                "The keyPair public key encoded base 64, DER must be provided for operation importKeyPair.");
    }
    try {
        ImportKeyPairResult result = ec2Client.getClientInstance()
                .importKeyPair(new ImportKeyPairRequest(keyPairName, encodedPublicKey));
        keyPair.setKeyPairName(result.getKeyName());
        keyPair.setFingerPrintPublicKey(result.getKeyFingerprint());
        ec2Client.getClientInstance().shutdown();
    } catch (AmazonServiceException ase) {
        logger.error("Exception thrown from aws : " + ase.getErrorCode() + " --> " + ase.getErrorMessage());
        throw new KeyPairOperationException(ase);
    } catch (AmazonClientException ace) {
        logger.error("Exception thrown from aws : " + ace.getMessage());
        throw new KeyPairOperationException(ace);
    } finally {
        ec2Client.getClientInstance().shutdown();
    }
}