Package com.sshtools.common.publickey
Class OpenSSHPrivateKeyFile
java.lang.Object
com.sshtools.common.publickey.OpenSSHPrivateKeyFile
- All Implemented Interfaces:
SshPrivateKeyFile
-
Constructor Summary
ConstructorsConstructorDescriptionOpenSSHPrivateKeyFile(byte[] formattedkey) OpenSSHPrivateKeyFile(SshKeyPair pair, String passphrase, String comment) -
Method Summary
Modifier and TypeMethodDescriptionvoidchangePassphrase(String oldpassphrase, String newpassphrase) Change the passphrase of the key file.byte[]encryptKey(SshKeyPair pair, String passphrase) The private key comment (if any).byte[]Get the formatted keygetType()Get a description of the format type e.g.static booleanisFormatted(byte[] formattedkey) booleanDetermine if the private key file is protected by a passphrase.oidByteArrayToString(byte[] o) booleanMethod to determine whether the format supports changing of passphrases.Decode the private key using the users passphrase.
-
Constructor Details
-
OpenSSHPrivateKeyFile
- Throws:
IOException
-
OpenSSHPrivateKeyFile
- Throws:
IOException
-
OpenSSHPrivateKeyFile
public OpenSSHPrivateKeyFile()
-
-
Method Details
-
getComment
Description copied from interface:SshPrivateKeyFileThe private key comment (if any).- Specified by:
getCommentin interfaceSshPrivateKeyFile- Returns:
-
isPassphraseProtected
public boolean isPassphraseProtected()Description copied from interface:SshPrivateKeyFileDetermine if the private key file is protected by a passphrase.- Specified by:
isPassphraseProtectedin interfaceSshPrivateKeyFile- Returns:
- true if the key file is encrypted with a passphrase, otherwise false
-
getType
Description copied from interface:SshPrivateKeyFileGet a description of the format type e.g. "OpenSSH"- Specified by:
getTypein interfaceSshPrivateKeyFile- Returns:
- String
-
supportsPassphraseChange
public boolean supportsPassphraseChange()Description copied from interface:SshPrivateKeyFileMethod 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.- Specified by:
supportsPassphraseChangein interfaceSshPrivateKeyFile- Returns:
- boolean
-
toKeyPair
Description copied from interface:SshPrivateKeyFileDecode the private key using the users passphrase.- Specified by:
toKeyPairin interfaceSshPrivateKeyFile- Parameters:
passphrase- the users passphrase- Returns:
- the key pair stored in this private key file.
- Throws:
IOExceptionInvalidPassphraseException
-
oidByteArrayToString
-
encryptKey
- Throws:
IOException
-
changePassphrase
public void changePassphrase(String oldpassphrase, String newpassphrase) throws IOException, InvalidPassphraseException Description copied from interface:SshPrivateKeyFileChange the passphrase of the key file.- Specified by:
changePassphrasein interfaceSshPrivateKeyFile- Parameters:
oldpassphrase- the old passphrasenewpassphrase- the new passphrase- Throws:
IOExceptionInvalidPassphraseException
-
getFormattedKey
public byte[] getFormattedKey()Description copied from interface:SshPrivateKeyFileGet the formatted key- Specified by:
getFormattedKeyin interfaceSshPrivateKeyFile- Returns:
- byte[]
-
isFormatted
public static boolean isFormatted(byte[] formattedkey)
-