use of com.jcraft.jsch.IdentityRepository in project dbeaver by serge-rider.
the class SSHUtils method isKeyEncrypted.
public static boolean isKeyEncrypted(String privKeyPath) {
// Check whether this key is encrypted
if (privKeyPath != null) {
// Determine whether public key is encrypted
try {
JSch testSch = new JSch();
testSch.addIdentity(privKeyPath);
IdentityRepository ir = testSch.getIdentityRepository();
List<Identity> identities = ir.getIdentities();
for (Identity identity : identities) {
if (identity.isEncrypted()) {
return true;
}
}
} catch (JSchException e) {
// Something went wrong
log.debug("Can't check private key encryption: " + e.getMessage());
}
}
return false;
}
use of com.jcraft.jsch.IdentityRepository in project dbeaver by dbeaver.
the class SSHUtils method isKeyEncrypted.
public static boolean isKeyEncrypted(String privKeyPath) {
// Check whether this key is encrypted
if (privKeyPath != null) {
// Determine whether public key is encrypted
try {
JSch testSch = new JSch();
testSch.addIdentity(privKeyPath);
IdentityRepository ir = testSch.getIdentityRepository();
List<Identity> identities = ir.getIdentities();
for (Identity identity : identities) {
if (identity.isEncrypted()) {
return true;
}
}
} catch (JSchException e) {
// Something went wrong
log.debug("Can't check private key encryption: " + e.getMessage());
}
}
return false;
}
Aggregations