public String getType() { return key.getType(); }
public HostKey[] getHostKey(String host, String type){ synchronized(pool){ int count=0; for(int i=0; i<pool.size(); i++){ HostKey hk=(HostKey)pool.elementAt(i); if(hk.type==HostKey.UNKNOWN) continue; if(host==null || (hk.isMatched(host) && (type==null || hk.getType().equals(type)))){ count++; } } if(count==0)return null; HostKey[] foo=new HostKey[count]; int j=0; for(int i=0; i<pool.size(); i++){ HostKey hk=(HostKey)pool.elementAt(i); if(hk.type==HostKey.UNKNOWN) continue; if(host==null || (hk.isMatched(host) && (type==null || hk.getType().equals(type)))){ foo[j++]=hk; } } return foo; } } public void remove(String host, String type){
public HostKey[] getHostKey(String host, String type) { synchronized (pool) { List<HostKey> v = new ArrayList<>(); for (HostKey hk : pool) { if (hk.type == HostKey.UNKNOWN) continue; if (host == null || (hk.isMatched(host) && (type == null || hk.getType().equals(type)))) { v.add(hk); } } HostKey[] foo = new HostKey[v.size()]; for (int i = 0; i < v.size(); i++) { foo[i] = v.get(i); } if (host != null && host.startsWith("[") && host.indexOf("]:") > 1) { HostKey[] tmp = getHostKey(host.substring(1, host.indexOf("]:")), type); if (tmp.length > 0) { HostKey[] bar = new HostKey[foo.length + tmp.length]; System.arraycopy(foo, 0, bar, 0, foo.length); System.arraycopy(tmp, 0, bar, foo.length, tmp.length); foo = bar; } } return foo; } }
void dump(OutputStream out) throws IOException { try{ HostKey hk; synchronized(pool){ for(int i=0; i<pool.size(); i++){ hk=(HostKey)(pool.elementAt(i)); //hk.dump(out); String host=hk.getHost(); String type=hk.getType(); if(type.equals("UNKNOWN")){ out.write(host.getBytes()); out.write(cr); continue; } out.write(host.getBytes()); out.write(space); out.write(type.getBytes()); out.write(space); out.write(hk.getKey().getBytes()); out.write(cr); } } } catch(Exception e){ System.err.println(e); } } private int getType(byte[] key){
public HostKey[] getHostKey(String host, String type){ synchronized(pool){ java.util.ArrayList v = new java.util.ArrayList(); for(int i=0; i<pool.size(); i++){ HostKey hk=(HostKey)pool.elementAt(i); if(hk.type==HostKey.UNKNOWN) continue; if(host==null || (hk.isMatched(host) && (type==null || hk.getType().equals(type)))){ v.add(hk); } } HostKey[] foo = new HostKey[v.size()]; for(int i=0; i<v.size(); i++){ foo[i] = (HostKey)v.get(i); } if(host != null && host.startsWith("[") && host.indexOf("]:")>1){ HostKey[] tmp = getHostKey(host.substring(1, host.indexOf("]:")), type); if(tmp.length > 0){ HostKey[] bar = new HostKey[foo.length + tmp.length]; System.arraycopy(foo, 0, bar, 0, foo.length); System.arraycopy(tmp, 0, bar, foo.length, tmp.length); foo = bar; } } return foo; } } public void remove(String host, String type){
public HostKey[] getHostKey(String host, String type){ synchronized(pool){ java.util.ArrayList v = new java.util.ArrayList(); for(int i=0; i<pool.size(); i++){ HostKey hk=(HostKey)pool.elementAt(i); if(hk.type==HostKey.UNKNOWN) continue; if(host==null || (hk.isMatched(host) && (type==null || hk.getType().equals(type)))){ v.add(hk); } } HostKey[] foo = new HostKey[v.size()]; for(int i=0; i<v.size(); i++){ foo[i] = (HostKey)v.get(i); } if(host != null && host.startsWith("[") && host.indexOf("]:")>1){ HostKey[] tmp = getHostKey(host.substring(1, host.indexOf("]:")), type); if(tmp.length > 0){ HostKey[] bar = new HostKey[foo.length + tmp.length]; System.arraycopy(foo, 0, bar, 0, foo.length); System.arraycopy(tmp, 0, bar, foo.length, tmp.length); foo = bar; } } return foo; } } public void remove(String host, String type){
public HostKey[] getHostKey(String host, String type){ synchronized(pool){ java.util.ArrayList v = new java.util.ArrayList(); for(int i=0; i<pool.size(); i++){ HostKey hk=(HostKey)pool.elementAt(i); if(hk.type==HostKey.UNKNOWN) continue; if(host==null || (hk.isMatched(host) && (type==null || hk.getType().equals(type)))){ v.add(hk); } } HostKey[] foo = new HostKey[v.size()]; for(int i=0; i<v.size(); i++){ foo[i] = (HostKey)v.get(i); } if(host != null && host.startsWith("[") && host.indexOf("]:")>1){ HostKey[] tmp = getHostKey(host.substring(1, host.indexOf("]:")), type); if(tmp.length > 0){ HostKey[] bar = new HostKey[foo.length + tmp.length]; System.arraycopy(foo, 0, bar, 0, foo.length); System.arraycopy(tmp, 0, bar, foo.length, tmp.length); foo = bar; } } return foo; } } public void remove(String host, String type){
String type=hk.getType(); String comment = hk.getComment(); if(type.equals("UNKNOWN")){
public void remove(String host, String type, byte[] key){ boolean sync=false; synchronized(pool){ for(int i=0; i<pool.size(); i++){ HostKey hk=(HostKey)(pool.elementAt(i)); if(host==null || (hk.isMatched(host) && (type==null || (hk.getType().equals(type) && (key==null || Util.array_equals(key, hk.key)))))){ String hosts=hk.getHost(); if(hosts.equals(host) || ((hk instanceof HashedHostKey) && ((HashedHostKey)hk).isHashed())){ pool.removeElement(hk); } else{ hk.host=deleteSubString(hosts, host); } sync=true; } } } if(sync){ try{sync();}catch(Exception e){}; } }
String type=hk.getType(); String comment = hk.getComment(); if(type.equals("UNKNOWN")){
String type=hk.getType(); String comment = hk.getComment(); if(type.equals("UNKNOWN")){
String marker = hk.getMarker(); String host = hk.getHost(); String type = hk.getType(); String comment = hk.getComment(); if (type.equals("UNKNOWN")) {
public void remove(String host, String type, byte[] key){ boolean sync=false; synchronized(pool){ for(int i=0; i<pool.size(); i++){ HostKey hk=(HostKey)(pool.elementAt(i)); if(host==null || (hk.isMatched(host) && (type==null || (hk.getType().equals(type) && (key==null || Util.array_equals(key, hk.key)))))){ String hosts=hk.getHost(); if(hosts.equals(host) || ((hk instanceof HashedHostKey) && ((HashedHostKey)hk).isHashed())){ pool.removeElement(hk); } else{ hk.host=deleteSubString(hosts, host); } sync=true; } } } if(sync){ try{sync();}catch(Exception e){}; } }
public void remove(String host, String type, byte[] key){ boolean sync=false; synchronized(pool){ for(int i=0; i<pool.size(); i++){ HostKey hk=(HostKey)(pool.elementAt(i)); if(host==null || (hk.isMatched(host) && (type==null || (hk.getType().equals(type) && (key==null || Util.array_equals(key, hk.key)))))){ String hosts=hk.getHost(); if(hosts.equals(host) || ((hk instanceof HashedHostKey) && ((HashedHostKey)hk).isHashed())){ pool.removeElement(hk); } else{ hk.host=deleteSubString(hosts, host); } sync=true; } } } if(sync){ try{sync();}catch(Exception e){}; } }
public void remove(String host, String type, byte[] key){ boolean sync=false; synchronized(pool){ for(int i=0; i<pool.size(); i++){ HostKey hk=(HostKey)(pool.elementAt(i)); if(host==null || (hk.isMatched(host) && (type==null || (hk.getType().equals(type) && (key==null || Util.array_equals(key, hk.key)))))){ String hosts=hk.getHost(); if(hosts.equals(host) || ((hk instanceof HashedHostKey) && ((HashedHostKey)hk).isHashed())){ pool.removeElement(hk); } else{ hk.host=deleteSubString(hosts, host); } sync=true; } } } if(sync){ try{sync();}catch(Exception e){}; } }
public void remove(String host, String type, byte[] key) { boolean sync = false; synchronized (pool) { for (int i = 0; i < pool.size(); i++) { HostKey hk = pool.get(i); if (host == null || (hk.isMatched(host) && (type == null || (hk.getType().equals(type) && (key == null || Util.array_equals(key, hk.key)))))) { String hosts = hk.getHost(); if (hosts.equals(host) || ((hk instanceof HashedHostKey) && ((HashedHostKey) hk).isHashed())) { pool.remove(hk); } else { hk.host = deleteSubString(hosts, host); } sync = true; } } } if (sync) { try { sync(); } catch (Exception e) { } ; } }
log.debug("Host keys in {}", hkr.getKnownHostsRepositoryID()); for (HostKey hk : hks) { log.trace("Loaded host key {} {} {}", hk.getHost(), hk.getType(), hk.getFingerPrint(jsch));
KnownHostEntry knownHostEntry = new KnownHostEntry( hostKey.getHost(), hostKey.getType(), hostKey.getKey() ); getKnownHostsProvider().addKnownHost( knownHostEntry );
KnownHostEntry knownHostEntry = new KnownHostEntry( hostKey.getHost(), hostKey.getType(), hostKey.getKey() ); getKnownHostsProvider().addKnownHost( knownHostEntry );