/** * @param str Determine if URL can be handled by a registered protocol * @return True if known URL */ public static boolean isURL(final String str) { if(StringUtils.isNotBlank(str)) { for(Scheme scheme : Scheme.values()) { if(scheme.equals(Scheme.file)) { continue; } if(str.startsWith(scheme + "://")) { return true; } } } return false; } }
public HostKeyCallback create(final Controller c, final Protocol protocol) { if(Scheme.sftp.equals(protocol.getScheme())) { try { if(null == constructor) { constructor = ConstructorUtils.getMatchingAccessibleConstructor(clazz, c.getClass()); } if(null == constructor) { log.warn(String.format("No matching constructor for parameter %s", c.getClass())); // Call default constructor for disabled implementations return clazz.newInstance(); } return constructor.newInstance(c); } catch(InstantiationException | InvocationTargetException | IllegalAccessException e) { log.error(String.format("Failure loading callback class %s. %s", clazz, e.getMessage())); return new DisabledHostKeyCallback(); } } return new DisabledHostKeyCallback(); }
@Override public boolean equals(Object o) { if(this == o) { return true; } if(!(o instanceof Protocol)) { return false; } Protocol protocol = (Protocol) o; if(this.getIdentifier() != null ? !this.getIdentifier().equals(protocol.getIdentifier()) : protocol.getIdentifier() != null) { return false; } if(this.getScheme() != null ? !this.getScheme().equals(protocol.getScheme()) : protocol.getScheme() != null) { return false; } if(this.getProvider() != null ? !this.getProvider().equals(protocol.getProvider()) : protocol.getProvider() != null) { return false; } return true; }
@Override public boolean equals(Object o) { if(this == o) { return true; } if(!(o instanceof Protocol)) { return false; } Protocol protocol = (Protocol) o; if(this.getIdentifier() != null ? !this.getIdentifier().equals(protocol.getIdentifier()) : protocol.getIdentifier() != null) { return false; } if(this.getScheme() != null ? !this.getScheme().equals(protocol.getScheme()) : protocol.getScheme() != null) { return false; } if(this.getContext() != null ? !this.getContext().equals(protocol.getContext()) : protocol.getContext() != null) { return false; } if(this.getAuthorization() != null ? !this.getAuthorization().equals(protocol.getAuthorization()) : protocol.getAuthorization() != null) { return false; } if(this.getProvider() != null ? !this.getProvider().equals(protocol.getProvider()) : protocol.getProvider() != null) { return false; } if(this.getDefaultHostname() != null ? !this.getDefaultHostname().equals(protocol.getDefaultHostname()) : protocol.getDefaultHostname() != null) { return false; } return true; }