Class SSHFTPPublicKey

java.lang.Object
com.enterprisedt.net.ftp.ssh.SSHFTPPublicKey

public class SSHFTPPublicKey extends Object
Represents an SSH public key. This class may be used to obtain information about a public key. It has methods for accessing the name of the algorithm, the bit length, the key data, the fingerprint, as well as a method for writing the key to a stream in either OpenSSH or IETF SECSH format.
Author:
Hans Andersen
  • Field Details

    • OPENSSH_FORMAT

      public static final int OPENSSH_FORMAT
      Specifies the OpenSSH format.
      See Also:
    • IETF_SECSH_FORMAT

      public static final int IETF_SECSH_FORMAT
      Specifies the IETF SECSH format.
      See Also:
  • Method Details

    • getAlgorithmName

      public String getAlgorithmName()
      Returns the name of the algorithm (either DSA or RSA).
      Returns:
      Returns the name of the algorithm (either DSA or RSA).
    • getBitLength

      public int getBitLength()
      Returns the bit-length of the key.
      Returns:
      Returns the bit-length of the key.
    • getKeyData

      public byte[] getKeyData()
      Returns the raw data of the key.
      Returns:
      Returns the raw data of the key.
    • getFingerprint

      public String getFingerprint()
      Returns the finger-print of the key.
      Returns:
      Returns the finger-print of the key.
    • equals

      public boolean equals(Object obj)
      Indicates whether some other object is "equal to" this one.
      Overrides:
      equals in class Object
      Returns:
      trueinvalid input: '<'/code if this object is the same as the obj argument; falseinvalid input: '<'/code otherwise.
    • hashCode

      public int hashCode()
      Returns a hash code value for the object.
      Overrides:
      hashCode in class Object
      Returns:
      a hash code value for this object.
    • write

      public int write(OutputStream outStr, int formatCode) throws SSHFTPException, IOException
      Writes a printable representation of the key to the given stream. This method writes a printable representation of the key to the given stream. The format in which it is written is determined by the format parameter and should be either OPENSSH_FORMAT or IETF_SECSH_FORMAT. The stream is not closed.
      Parameters:
      outStr - OutputStream to which to write the key.
      formatCode - Format to use (either OPENSSH_FORMAT or IETF_SECSH_FORMAT).
      Returns:
      The number of bytes written.
      Throws:
      SSHFTPException - Thrown if the format-code is not OPENSSH_FORMAT or IETF_SECSH_FORMAT.
      IOException - Thrown if there was an error while writing to the stream.