Class KeyHelper

java.lang.Object
hudson.plugins.ec2.util.KeyHelper

public abstract class KeyHelper extends Object
Utility class to parse PEM.
  • Method Details

    • decodeKeyPair

      public static KeyPair decodeKeyPair(@NonNull String pem, @NonNull String password) throws IOException
      Decodes a PEM-encoded key pair into a KeyPair object. This method supports various types of PEM input such as encrypted private keys, public keys, and key pairs.
      Parameters:
      pem - The PEM-formatted string containing the key data.
      password - The password used to decrypt encrypted key pairs, if applicable. Can be null if no password is required.
      Returns:
      A KeyPair containing the public and private keys. If a public key is provided without a matching private key, the private key in the returned KeyPair will be null.
      Throws:
      IOException - If an error occurs during parsing or decryption of the PEM input.
      IllegalArgumentException - If the provided PEM input cannot be parsed or is of an unsupported type.
    • getSshAlgorithm

      public static String getSshAlgorithm(@NonNull PublicKey serverKey)
      Determines the SSH algorithm identifier corresponding to the given server public key. This method matches the key type to the appropriate SSH algorithm string. When an ECPublicKey is given, an NIST curse will be assumed.
      Parameters:
      serverKey - The server's PublicKey object for which the SSH algorithm identifier needs to be determined.
      Returns:
      A String representing the SSH algorithm identifier for the given server key, or null if the key type is unsupported or cannot be determined.
    • getFingerprint

      public static String getFingerprint(@NonNull PublicKey serverKey)
      Computes the MD5 fingerprint of the given server public key. The fingerprint is formatted as a colon-separated hexadecimal string.
      Parameters:
      serverKey - The server's PublicKey object for which the fingerprint needs to be computed.
      Returns:
      A String representing the MD5 fingerprint of the given server key in colon-separated hexadecimal format, or an empty string if an error occurs during computation.