private void updateIdentity(final JSch jsch, File identity) { if (identity.isFile()) { try { jsch.removeIdentity(identity.getAbsolutePath()); jsch.addIdentity(identity.getAbsolutePath(), passphrase); } catch (JSchException e) { // Pretend file didn't exist } } } }
public void removeAllIdentity() throws JSchException{ synchronized(identities){ Vector foo=getIdentityNames(); for(int i=0; i<foo.size(); i++){ String name=((String)foo.elementAt(i)); removeIdentity(name); } } }
jsch.removeIdentity(identity); jsch.addIdentity(identity, null);