/** * @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()); } }
public String getSshSignatures(byte[] sign, List<Identity> identities) { StringBuilder ret = new StringBuilder(); for (Identity id : identities) { try { byte[] sig = id.getSignature(sign); if (sig != null) { ret.append(" ").append(printBase64Binary(sig)); } } catch (Exception t) { logger.log(Level.FINE, "Failed to add signature: " + t.getMessage()); } } return ret.toString(); }
public synchronized void add(Identity identity) { if (!identities.contains(identity)) { byte[] blob1 = identity.getPublicKeyBlob(); if (blob1 == null) { identities.add(identity); return; } for (Identity identity1 : identities) { byte[] blob2 = identity1.getPublicKeyBlob(); if (blob2 != null && Util.array_equals(blob1, blob2)) { if (!identity.isEncrypted() && identity1.isEncrypted()) { remove(blob2); } else { return; } } } identities.add(identity); } }
synchronized void remove(Identity identity) { if(identities.contains(identity)) { identities.removeElement(identity); identity.clear(); } else { remove(identity.getPublicKeyBlob()); } }
for(int i=0; i<identities.size(); i++){ Identity identity=(Identity)(identities.elementAt(i)); if(identity.getPublicKeyBlob()!=null) count++; for(int i=0; i<identities.size(); i++){ Identity identity=(Identity)(identities.elementAt(i)); byte[] pubkeyblob=identity.getPublicKeyBlob(); if(pubkeyblob==null) continue; for(int i=0; i<identities.size(); i++){ Identity _identity=(Identity)(identities.elementAt(i)); if(_identity.getPublicKeyBlob()==null) continue; if(!Util.array_equals(blob, _identity.getPublicKeyBlob())){ continue; if(_identity.isEncrypted()){ if(userinfo==null) continue; while(_identity.isEncrypted()){ if(!userinfo.promptPassphrase("Passphrase for "+_identity.getName())){ break; if(_identity.setPassphrase(passphrase)){ break; if(!_identity.isEncrypted()){
if (!identity.isEncrypted()) { throw new JSchException("unexpected passphrase"); if (!identity.setPassphrase(passphrase.getBytes())) { throw new JSchException("invalid passphrase"); if (!identity.setPassphrase(null)) { throw new JSchException("missing passphrase");
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; }
.map((identity) -> (Identity)identity) .forEach((i) -> { log.debug("Identity {} {}", i.getName(), i.getAlgName()); });
void add(Identity identity) { if (!keep_in_cache && !identity.isEncrypted() && (identity instanceof IdentityFile)) { try { ir.add(((IdentityFile) identity).getKeyPair().forSSHAgent()); } catch (JSchException e) { } } else cache.add(identity); }
/** * Removes the identity from identityRepository. * * @param identity the indentity to be removed. * * @throws JSchException if <code>identity</code> is invalid. */ public void removeIdentity(Identity identity) throws JSchException{ identityRepository.remove(identity.getPublicKeyBlob()); }
public synchronized void removeAll() { for (Identity identity1 : identities) { identity1.clear(); } identities.clear(); }
public void addIdentity(Identity identity, byte[] passphrase) throws JSchException{ if(passphrase!=null){ try{ byte[] goo=new byte[passphrase.length]; System.arraycopy(passphrase, 0, goo, 0, passphrase.length); passphrase=goo; identity.setPassphrase(passphrase); } finally{ Util.bzero(passphrase); } } synchronized(identities){ if(!identities.contains(identity)){ identities.addElement(identity); } } }
byte[] pubkeyblob=identity.getPublicKeyBlob(); buf.putString("publickey".getBytes()); buf.putByte((byte)0); buf.putString(identity.getAlgName().getBytes()); buf.putString(pubkeyblob); session.write(packet); if((identity.isEncrypted() && passphrase==null)){ if(userinfo==null) throw new JSchException("USERAUTH fail"); if(identity.isEncrypted() && !userinfo.promptPassphrase("Passphrase for "+identity.getName())){ throw new JSchAuthCancelException("publickey"); if(!identity.isEncrypted() || passphrase!=null){ if(identity.setPassphrase(passphrase)) break; if(identity.isEncrypted()) continue; if(pubkeyblob==null) pubkeyblob=identity.getPublicKeyBlob(); buf.putString("publickey".getBytes()); buf.putByte((byte)1); buf.putString(identity.getAlgName().getBytes()); buf.putString(pubkeyblob); System.arraycopy(sid, 0, tmp, 4, sidlen); System.arraycopy(buf.buffer, 5, tmp, 4+sidlen, buf.index-5); byte[] signature=identity.getSignature(tmp);
System.arraycopy(passphrase, 0, goo, 0, passphrase.length); passphrase = goo; identity.setPassphrase(passphrase); } finally { Util.bzero(passphrase); } else if (identity instanceof IdentityFile && !identity.isEncrypted()) { identityRepository.add(((IdentityFile) identity).getKeyPair().forSSHAgent()); } else {
synchronized void remove(Identity identity) { if(identities.contains(identity)) { identities.removeElement(identity); identity.clear(); } else { remove(identity.getPublicKeyBlob()); } }
/** * 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; }
void add(Identity identity) { if(!keep_in_cache && !identity.isEncrypted() && (identity instanceof IdentityFile)) { try { ir.add(((IdentityFile)identity).getKeyPair().forSSHAgent()); } catch(JSchException e){ // an exception will not be thrown. } } else cache.addElement(identity); } void check() {
/** * Removes the identity from identityRepository. * * @param identity the indentity to be removed. * * @throws JSchException if <code>identity</code> is invalid. */ public void removeIdentity(Identity identity) throws JSchException{ identityRepository.remove(identity.getPublicKeyBlob()); }
public synchronized void removeAll() { for(int i=0; i<identities.size(); i++) { Identity identity=(Identity)(identities.elementAt(i)); identity.clear(); } identities.removeAllElements(); }