Package com.sshtools.common.publickey
Interface SshPrivateKeyFile
- All Known Implementing Classes:
OpenSSHPrivateKeyFile
public interface SshPrivateKeyFile
Interface which all private key formats must implement to provide decoding
and decryption of the private key into a suitable format for the API.
- Author:
- Lee David Painter
-
Method Summary
Modifier and TypeMethodDescriptionvoidchangePassphrase(String oldpassphrase, String newpassprase) Change the passphrase of the key file.The private key comment (if any).byte[]Get the formatted keygetType()Get a description of the format type e.g.booleanDetermine if the private key file is protected by a passphrase.booleanMethod to determine whether the format supports changing of passphrases.Decode the private key using the users passphrase.
-
Method Details
-
isPassphraseProtected
boolean isPassphraseProtected()Determine if the private key file is protected by a passphrase.- Returns:
- true if the key file is encrypted with a passphrase, otherwise false
- Throws:
IOException
-
toKeyPair
Decode the private key using the users passphrase.- Parameters:
passphrase- the users passphrase- Returns:
- the key pair stored in this private key file.
- Throws:
IOExceptionInvalidPassphraseException
-
supportsPassphraseChange
boolean supportsPassphraseChange()Method to determine whether the format supports changing of passphrases. This typically would indicate that the format is read-only and that keys cannot be saved into this format.- Returns:
- boolean
-
getType
String getType()Get a description of the format type e.g. "OpenSSH"- Returns:
- String
-
changePassphrase
void changePassphrase(String oldpassphrase, String newpassprase) throws IOException, InvalidPassphraseException Change the passphrase of the key file.- Parameters:
oldpassphrase- the old passphrasenewpassprase- the new passphrase- Throws:
IOExceptionInvalidPassphraseException
-
getFormattedKey
Get the formatted key- Returns:
- byte[]
- Throws:
IOException
-
getComment
String getComment()The private key comment (if any).- Returns:
-