Package com.sshtools.common.publickey
Class SshPrivateKeyFileFactory
java.lang.Object
com.sshtools.common.publickey.SshPrivateKeyFileFactory
Private key format factory used to decode private key files. This factory
currently supports SSHTools, OpenSSH and SSH1 encrypted private keys.
- Author:
- Lee David Painter
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidchangePassphrase(File keyFile, String passphrase, String newPassphrase) Take a file in any of the supported public key formats and convert to the requested format.static voidconvertFile(File keyFile, String passphrase, int toFormat, File toFile) Take a file in any of the supported public key formats and convert to the requested format.static SshPrivateKeyFilecreate(SshKeyPair pair) static SshPrivateKeyFilecreate(SshKeyPair pair, String passphrase) static SshPrivateKeyFilecreate(SshKeyPair pair, String passphrase, int format) static SshPrivateKeyFilecreate(SshKeyPair pair, String passphrase, String comment) static SshPrivateKeyFilecreate(SshKeyPair pair, String passphrase, String comment, int format) static voidcreateFile(SshKeyPair key, String passphrase, int format, File toFile) Take a SshPrivateKey and write it to a file.static voidcreateFile(SshKeyPair key, String passphrase, File toFile) static SshPrivateKeyFileparse(byte[] formattedkey) Parse formatted data and return a suitable SshPrivateKeyFile implementation.static SshPrivateKeyFilestatic SshPrivateKeyFileparse(InputStream in) Parse an InputStream and return a suitable SshPrivateKeyFile implementation.static SshPrivateKeyFile
-
Field Details
-
OPENSSH_FORMAT
public static final int OPENSSH_FORMAT- See Also:
-
OPENSSL_FORMAT
public static final int OPENSSL_FORMAT- See Also:
-
-
Constructor Details
-
SshPrivateKeyFileFactory
public SshPrivateKeyFileFactory()
-
-
Method Details
-
parse
Parse formatted data and return a suitable SshPrivateKeyFile implementation.- Parameters:
formattedkey-- Returns:
- SshPrivateKeyFile
- Throws:
IOException
-
parse
Parse an InputStream and return a suitable SshPrivateKeyFile implementation.- Parameters:
in-- Returns:
- SshPrivateKeyFile
- Throws:
IOException
-
create
- Throws:
IOException
-
create
- Throws:
IOException
-
create
public static SshPrivateKeyFile create(SshKeyPair pair, String passphrase, int format) throws IOException - Throws:
IOException
-
create
public static SshPrivateKeyFile create(SshKeyPair pair, String passphrase, String comment) throws IOException - Throws:
IOException
-
create
public static SshPrivateKeyFile create(SshKeyPair pair, String passphrase, String comment, int format) throws IOException - Throws:
IOException
-
createFile
- Throws:
IOException
-
createFile
public static void createFile(SshKeyPair key, String passphrase, int format, File toFile) throws IOException Take a SshPrivateKey and write it to a file.- Parameters:
key-comment-format-toFile-- Throws:
IOException
-
convertFile
public static void convertFile(File keyFile, String passphrase, int toFormat, File toFile) throws IOException, InvalidPassphraseException Take a file in any of the supported public key formats and convert to the requested format.- Parameters:
keyFile-toFormat-toFile-- Throws:
IOExceptionInvalidPassphraseException
-
changePassphrase
public static void changePassphrase(File keyFile, String passphrase, String newPassphrase) throws IOException, InvalidPassphraseException Take a file in any of the supported public key formats and convert to the requested format.- Parameters:
keyFile-toFormat-toFile-- Throws:
IOExceptionInvalidPassphraseException
-
parse
- Throws:
IOException
-
parse
- Throws:
IOException
-