private void checkFirstConnection() { if (!firstConnection) { SshConfiguration.getLogger().log( Level.WARN, "JSch does not fully support per connection configuration. This second client's configuration " + "may interfere with the first's."); firstConnection = true; } }
public void doSupportsConfiguration(SshConfiguration configuration) { try { Class.forName("ch.ethz.ssh2.Connection", false, getClass().getClassLoader()); } catch (ClassNotFoundException cnfe) { SshConfiguration.getLogger().log(Level.INFO, "Could not find Ganymed class ch.ethz.ssh2.Connection."); throw new UnsupportedOperationException("Ganymed is not on the CLASSPATH"); } if (configuration != null && configuration.getProtocolVersion() == SshConfiguration.SSH1_ONLY) { SshConfiguration.getLogger().log(Level.INFO, "Ganymed does not support SSH1, not usable."); throw new UnsupportedOperationException("SSH1 is not supported."); } }
public void log(int level, String message) { net.sf.sshapi.Logger logger = SshConfiguration.getLogger(); Level sshapiLevel = Level.ERROR; switch (level) { case Logger.DEBUG: sshapiLevel = Level.DEBUG; break; case Logger.INFO: sshapiLevel = Level.INFO; break; case Logger.WARN: sshapiLevel = Level.WARN; break; default: sshapiLevel = Level.ERROR; break; } logger.log(sshapiLevel, message); }
public SshHostKey[] getKeys() { List keys = new ArrayList(); // Ewwwww :( try { Field field = knownHosts.getClass().getDeclaredField("publicKeys"); field.setAccessible(true); LinkedList publickeys = (LinkedList) field.get(knownHosts); addKeys(keys, publickeys); } catch (Exception e) { SshConfiguration.getLogger().log(Level.ERROR, "Failed to get host keys.", e); } return (SshHostKey[]) keys.toArray(new SshHostKey[0]); }
public SshHostKey[] getKeysForHost(String host, String type) { SshHostKey[] keys = getKeys(); List hostKeys = new ArrayList(); try { Method m = knownHosts.getClass().getDeclaredMethod("hostnameMatches", new Class[] { String[].class, String.class }); m.setAccessible(true); for (int i = 0; i < keys.length; i++) { if (type.equals(keys[i].getType()) && ((Boolean) m.invoke(knownHosts, new Object[] { ((GanymedHostKey) keys[i]).hosts, host })).booleanValue()) { hostKeys.add(keys[i]); } } } catch (Exception e) { SshConfiguration.getLogger().log(Level.ERROR, "Error locating host keys.", e); } return (SshHostKey[]) hostKeys.toArray(new SshHostKey[0]); }
private void checkForBanner() { try { Field amF = connection.getClass().getDeclaredField("am"); amF.setAccessible(true); AuthenticationManager am = (AuthenticationManager) amF .get(connection); Field bannerF = am.getClass().getDeclaredField("banner"); bannerF.setAccessible(true); String banner = (String) bannerF.get(am); if (banner != null && !banner.equals("") && getConfiguration().getBannerHandler() != null) { getConfiguration().getBannerHandler().banner(banner); } } catch (Exception e) { SshConfiguration.getLogger().log(Level.ERROR, "Failed to access banner", e); } }
private void addKeys(List keys, Collection publickeys) throws NoSuchFieldException, IllegalAccessException, IOException { Field field; for (Iterator e = publickeys.iterator(); e.hasNext();) { Object knownHostEntry = e.next(); field = knownHostEntry.getClass().getDeclaredField("key"); field.setAccessible(true); Object key = field.get(knownHostEntry); field = knownHostEntry.getClass().getDeclaredField("patterns"); field.setAccessible(true); String[] patterns = (String[]) field.get(knownHostEntry); String type = null; byte[] keyBytes = null; if (key instanceof RSAPublicKey) { type = SshConfiguration.PUBLIC_KEY_SSHRSA; keyBytes = RSASHA1Verify.encodeSSHRSAPublicKey((RSAPublicKey) key); } else if (key instanceof DSAPublicKey) { type = SshConfiguration.PUBLIC_KEY_SSHDSA; keyBytes = DSASHA1Verify.encodeSSHDSAPublicKey((DSAPublicKey) key); } else { SshConfiguration.getLogger().log(Level.WARN, "Unsupported key format " + key); continue; } keys.add(new GanymedHostKey(type, keyBytes, patterns)); } }
SshConfiguration .getLogger() .log(Level.WARN, "The provider " + requestedProviderClassName return provider; } catch (NoClassDefFoundError ncdfe) { SshConfiguration.getLogger().log( Level.WARN, "Could not load provider " + requestedProviderClassName + ". Probably cause by a missing dependency."); } catch (Exception e) { SshConfiguration.getLogger().log( Level.WARN, "Could not load provider " + requestedProviderClassName
SshConfiguration .getLogger() .log(Level.WARN, "The provider " + requestedProviderClassName return provider; } catch (NoClassDefFoundError ncdfe) { SshConfiguration.getLogger().log( Level.WARN, "Could not load provider " + requestedProviderClassName + ". Probably cause by a missing dependency."); } catch (Exception e) { SshConfiguration.getLogger().log( Level.WARN, "Could not load provider " + requestedProviderClassName
protected static final SshProvider loadFromProperties(URL resource) throws IOException { SshConfiguration.getLogger().log(Level.INFO, "Loading " + resource + "."); return loadFromProperties(loadProperties(resource)); }
protected static final SshProvider loadFromProperties(URL resource) throws IOException { SshConfiguration.getLogger().log(Level.INFO, "Loading " + resource + "."); return loadFromProperties(loadProperties(resource)); }
protected static final SshProvider createProviderInstance(String className) throws InstantiationException, IllegalAccessException, ClassNotFoundException { try { SshConfiguration.getLogger().log(Level.INFO, "Attempting to load provider " + className + "."); SshProvider provider = (SshProvider) (Class.forName(className, true, getClassLoader()).newInstance()); SshConfiguration.getLogger().log(Level.INFO, "Provider " + className + " loaded."); return provider; } catch (InstantiationException ie) { if (ie.getCause() != null && ie.getCause() instanceof ClassNotFoundException) { throw ((ClassNotFoundException) ie.getCause()); } throw ie; } }
protected static final SshProvider createProviderInstance(String className) throws InstantiationException, IllegalAccessException, ClassNotFoundException { try { SshConfiguration.getLogger().log(Level.INFO, "Attempting to load provider " + className + "."); SshProvider provider = (SshProvider) (Class.forName(className, true, getClassLoader()).newInstance()); SshConfiguration.getLogger().log(Level.INFO, "Provider " + className + " loaded."); return provider; } catch (InstantiationException ie) { if (ie.getCause() != null && ie.getCause() instanceof ClassNotFoundException) { throw ((ClassNotFoundException) ie.getCause()); } throw ie; } }
ClassLoader cl = getClassLoader(); try { SshConfiguration.getLogger().log(Level.INFO, "Looking for sshapi-providers.properties resources."); for (Enumeration e = cl if (possibleProvider .supportsConfiguration(configuration)) { SshConfiguration.getLogger().log(Level.INFO, "Provider supports configuration."); provider = possibleProvider; } else { SshConfiguration.getLogger().log(Level.INFO, "Provider DOES NOT support configuration.");
ClassLoader cl = getClassLoader(); try { SshConfiguration.getLogger().log(Level.INFO, "Looking for sshapi-providers.properties resources."); for (Enumeration e = cl if (possibleProvider .supportsConfiguration(configuration)) { SshConfiguration.getLogger().log(Level.INFO, "Provider supports configuration."); provider = possibleProvider; } else { SshConfiguration.getLogger().log(Level.INFO, "Provider DOES NOT support configuration.");
break; } else if (ret == SshLibrary.ssh_scp_request_types.SSH_SCP_REQUEST_WARNING) { LibsshClient.LOG.log(Level.WARN, library.ssh_scp_request_get_warning(scp)); } else if (ret == SshLibrary.ssh_scp_request_types.SSH_SCP_REQUEST_ENDDIR) { System.out.println("Leaving dir"); : destinationFile); LOG.log(Level.WARN, "MODE not implemented"); fireFileTransferStarted(remoteFilePath, destinationFile.getPath(), size);
String command = "scp -p " + (localfile.isDirectory() ? "-d " : "") + "-t " + (recursive ? "-r " : "") + (verbose ? "-v " : "") + remotePath; SshConfiguration.getLogger().log(Level.INFO, "Executing command '" + command + "'"); SshStreamChannel cmd = sshClient.createCommand(command); try {
public SshPrivateKeyFile create(SshKeyPair pair, int format, char[] passphrase, String comment) throws SshException { if (!Util.nullOrTrimmedBlank(comment)) { SshConfiguration.getLogger().log(Level.WARN, "JSch doesn't support comments in private key files, ignoring comment '" + comment + "'");
cwl.kexAlgorithms = (String[]) l.toArray(new String[l.size()]); } catch (Exception e) { SshConfiguration.getLogger().log(Level.ERROR, "Could not set key exchange.", e);