use of com.jcraft.jsch.Identity 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.Identity in project artisynth_core by artisynth.
the class SimpleIdentityRepository method remove.
public synchronized boolean remove(Identity id) {
if (id == null)
return false;
for (Identity identity : identities) {
if (id.equals(identity)) {
identities.removeElement(id);
// erase private key
id.clear();
return true;
}
}
return false;
}
use of com.jcraft.jsch.Identity 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