Class CompanionPublicKey

java.lang.Object
com.hierynomus.sshj.userauth.keyprovider.CompanionPublicKey

public class CompanionPublicKey extends Object
The public key - or certificate - provided alongside a private key for the OpenSSH key file providers (OpenSSHKeyFile and OpenSSHKeyV1KeyFile). It can be supplied next to the private key as a .pub / -cert.pub file, or explicitly as a string or a stream. When none was supplied, the providers fall back to the public key embedded in the private key file.

A parse failure is logged and otherwise ignored, again letting the provider fall back to the embedded public key.

  • Constructor Details

    • CompanionPublicKey

      public CompanionPublicKey()
  • Method Details

    • loadSiblingOf

      public void loadSiblingOf(File privateKeyLocation)
      Load the .pub / -cert.pub file that sits next to the given private key file, if any.
    • load

      public void load(File publicKey)
      Load the public key - or certificate - from the given, explicitly named file. Unlike loadSiblingOf(File), the file name is not constrained to the .pub / -cert.pub convention, so this also covers e.g. Pritunl-Zero style -cert00.pub, -cert01.pub multi-CA certificates, or do nothing when publicKey is null.
    • load

      public void load(String publicKey)
      Load the public key from the given string, or do nothing when it is null.
    • load

      public void load(Reader publicKey)
      Load the public key from the given stream, or do nothing when it is null.
    • isPresent

      public boolean isPresent()
    • getPublicKey

      public PublicKey getPublicKey()
    • getType

      public KeyType getType()