public Vector getIdentityNames() throws JSchException{ Vector foo=new Vector(); synchronized(identities){ for(int i=0; i<identities.size(); i++){ Identity identity=(Identity)(identities.elementAt(i)); foo.addElement(identity.getName()); } } return foo; }
public void removeIdentity(String name) throws JSchException{ synchronized(identities){ for(int i=0; i<identities.size(); i++){ Identity identity=(Identity)(identities.elementAt(i)); if(!identity.getName().equals(name)) continue; identities.removeElement(identity); identity.clear(); break; } } }
/** * Lists names of identities included in the identityRepository. * * @return names of identities * @throws JSchException if identityReposory has problems. */ public List<String> getIdentityNames() throws JSchException { List<String> list = new ArrayList<>(); List<Identity> identities = identityRepository.getIdentities(); for (Identity identity : identities) { list.add(identity.getName()); } return list; }
/** * Lists names of identities included in the identityRepository. * * @return names of identities * * @throws JSchException if identityReposory has problems. */ public Vector getIdentityNames() throws JSchException{ Vector foo=new Vector(); Vector identities = identityRepository.getIdentities(); for(int i=0; i<identities.size(); i++){ Identity identity=(Identity)(identities.elementAt(i)); foo.addElement(identity.getName()); } return foo; }
/** * Lists names of identities included in the identityRepository. * * @return names of identities * * @throws JSchException if identityReposory has problems. */ public Vector getIdentityNames() throws JSchException{ Vector foo=new Vector(); Vector identities = identityRepository.getIdentities(); for(int i=0; i<identities.size(); i++){ Identity identity=(Identity)(identities.elementAt(i)); foo.addElement(identity.getName()); } return foo; }
/** * Lists names of identities included in the identityRepository. * * @return names of identities (as a vector of strings). * * @throws JSchException if identityReposory has problems. */ public Vector getIdentityNames() throws JSchException{ Vector foo=new Vector(); Vector identities = identityRepository.getIdentities(); for(int i=0; i<identities.size(); i++){ Identity identity=(Identity)(identities.elementAt(i)); foo.addElement(identity.getName()); } return foo; }
/** * @deprecated use #removeIdentity(Identity identity) */ public void removeIdentity(String name) throws JSchException{ Vector identities = identityRepository.getIdentities(); for(int i=0; i<identities.size(); i++){ Identity identity=(Identity)(identities.elementAt(i)); if(!identity.getName().equals(name)) continue; if(identityRepository instanceof LocalIdentityRepository){ ((LocalIdentityRepository)identityRepository).remove(identity); } else identityRepository.remove(identity.getPublicKeyBlob()); } }
/** * @deprecated use #removeIdentity(Identity identity) */ public void removeIdentity(String name) throws JSchException{ Vector identities = identityRepository.getIdentities(); for(int i=0; i<identities.size(); i++){ Identity identity=(Identity)(identities.elementAt(i)); if(!identity.getName().equals(name)) continue; if(identityRepository instanceof LocalIdentityRepository){ ((LocalIdentityRepository)identityRepository).remove(identity); } else identityRepository.remove(identity.getPublicKeyBlob()); } }
/** * Removes an identity by name. * (The name is the result of the {@link Identity#getName getName} * method of the Identity object.) * * This identity will not be used for future connections anymore. * (We also {@link Identity#clear clear} the identity, causing it * to forget its passphrase.) * @param name the name of the identity to remove. * @deprecated use #removeIdentity(Identity identity) */ public void removeIdentity(String name) throws JSchException{ Vector identities = identityRepository.getIdentities(); for(int i=0; i<identities.size(); i++){ Identity identity=(Identity)(identities.elementAt(i)); if(!identity.getName().equals(name)) continue; if(identityRepository instanceof LocalIdentityRepository){ ((LocalIdentityRepository)identityRepository).remove(identity); } else identityRepository.remove(identity.getPublicKeyBlob()); } }
List<String> getPublicKeys() throws Exception { JSch jSch = createDefaultJSch(FS.DETECTED); List<String> keys = new ArrayList<>(); for (Object o : jSch.getIdentityRepository().getIdentities()) { Identity i = (Identity) o; KeyPair keyPair = KeyPair.load(jSch, i.getName(), null); StringBuilder sb = new StringBuilder(); try (StringBuilderWriter sbw = new StringBuilderWriter(sb); OutputStream os = new WriterOutputStream(sbw, "UTF-8")) { keyPair.writePublicKey(os, keyPair.getPublicKeyComment()); } finally { keyPair.dispose(); } keys.add(sb.toString().trim()); } return keys; } }.getPublicKeys();
if(userinfo==null) throw new JSchException("USERAUTH fail"); if(identity.isEncrypted() && !userinfo.promptPassphrase("Passphrase for "+identity.getName())){ throw new JSchAuthCancelException("publickey");
continue; while(_identity.isEncrypted()){ if(!userinfo.promptPassphrase("Passphrase for "+_identity.getName())){ break;
continue; while(_identity.isEncrypted()){ if(!userinfo.promptPassphrase("Passphrase for "+_identity.getName())){ break;
continue; while(_identity.isEncrypted()){ if(!userinfo.promptPassphrase("Passphrase for "+_identity.getName())){ break;
continue; while(_identity.isEncrypted()){ if(!userinfo.promptPassphrase("Passphrase for "+_identity.getName())){ break;
if(userinfo==null) throw new JSchException("USERAUTH fail"); if(identity.isEncrypted() && !userinfo.promptPassphrase("Passphrase for "+identity.getName())){ throw new JSchAuthCancelException("publickey");
if(userinfo==null) throw new JSchException("USERAUTH fail"); if(identity.isEncrypted() && !userinfo.promptPassphrase("Passphrase for "+identity.getName())){ throw new JSchAuthCancelException("publickey");
if(userinfo==null) throw new JSchException("USERAUTH fail"); if(identity.isEncrypted() && !userinfo.promptPassphrase("Passphrase for "+identity.getName())){ throw new JSchAuthCancelException("publickey");
continue; while (_identity.isEncrypted()) { if (!userinfo.promptPassphrase("Passphrase for " + _identity.getName())) { break;
!userinfo.promptPassphrase("Passphrase for " + identity1.getName())) { throw new JSchAuthCancelException("publickey");