/** * Utility to create a client that may be used with this configuration. It * uses the DefaultProviderFactory, so if you want to custom how providers * are selected, do not use this method. * * @return client */ public SshClient createClient() { // Create the client using that configuration SshProvider provider = DefaultProviderFactory.getInstance().getProvider(this); return provider.createClient(this); }
/** * Get all discovered compression algorithms. This is determine by examining * all providers for their algorithms and producing a unique list. * * @return all compression algorithms */ public static String[] getAllCompression() { List comp = new ArrayList(); SshProvider[] providers = getAllProviders(); for (int i = 0; i < providers.length; i++) { try { List c = providers[i].getSupportedCompression(); addList(comp, c); } catch (UnsatisfiedLinkError ule) { System.out .println("WARNING: Provider requires a native library but it could not be found." + ule.getMessage()); } catch (Exception ex) { System.out.println("WARNING: Provider failed to load. " + ex.getMessage()); ex.printStackTrace(); } } return (String[]) comp.toArray(new String[0]); }
ClassLoader cl = getClassLoader(); try { for (Enumeration e = cl.getResources("sshapi-providers.properties"); e .hasMoreElements();) { try { addIfNotExist(providers, e); } catch (UnsatisfiedLinkError ule) { System.out
protected static final SshProvider loadFromProperties(URL resource) throws IOException { SshConfiguration.getLogger().log(Level.INFO, "Loading " + resource + "."); return loadFromProperties(loadProperties(resource)); }
static String getHTML() throws Exception { SshProvider[] providers = DefaultProviderFactory.getAllProviders(); Capability[] caps = DefaultProviderFactory.getAllCapabilties(); String[] ciphers = DefaultProviderFactory.getAllCiphers(); String[] key = DefaultProviderFactory.getAllKEX(); String[] mac = DefaultProviderFactory.getAllMAC(); String[] comp = DefaultProviderFactory.getAllCompression(); String[] pk = DefaultProviderFactory.getAllPublicKey(); String[][] strArrs = new String[][] { ciphers, key, mac, comp, pk };
SshProvider provider = loadFromProperties(System.getProperties()); if (provider != null && !provider.supportsConfiguration(null)) { throw new UnsupportedOperationException( ClassLoader cl = getClassLoader(); try { SshConfiguration.getLogger().log(Level.INFO, .getResources("sshapi-providers.properties"); e .hasMoreElements() && provider == null;) { SshProvider possibleProvider = loadFromProperties((URL) e .nextElement()); if (possibleProvider != null) {
/** * Get a provider given it's name. * * @param providerName * provider name * @return provider * @throws IllegalArgumentException * if no such provider is found */ public static SshProvider getProviderByName(String providerName) { SshProvider[] providers = getAllProviders(); for (int i = 0; i < providers.length; i++) { if (providers[i].getName().equals(providerName)) { return providers[i]; } } throw new IllegalArgumentException("No provider named " + providerName); }
if (!dependsOn.equals("")) { try { Class.forName(dependsOn, true, getClassLoader()); } catch (ClassNotFoundException cnfe) { SshConfiguration SshProvider provider = createProviderInstance(requestedProviderClassName); providerCache.put(requestedProviderClassName, provider); return provider;
private static void addIfNotExist(List providers, Enumeration e) throws IOException { SshProvider provider = loadFromProperties((URL) e.nextElement()); if (provider != null && !providers.contains(provider)) { providers.add(provider); } }
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; } }
SshProvider[] providers = DefaultProviderFactory.getAllProviders(); Capability[] caps = DefaultProviderFactory.getAllCapabilties(); String[] ciphers = DefaultProviderFactory.getAllCiphers(); String[] key = DefaultProviderFactory.getAllKEX(); String[] mac = DefaultProviderFactory.getAllMAC(); String[] comp = DefaultProviderFactory.getAllCompression(); String[] pk = DefaultProviderFactory.getAllPublicKey();
SshProvider provider = loadFromProperties(System.getProperties()); if (provider != null && !provider.supportsConfiguration(null)) { throw new UnsupportedOperationException( ClassLoader cl = getClassLoader(); try { SshConfiguration.getLogger().log(Level.INFO, .getResources("sshapi-providers.properties"); e .hasMoreElements() && provider == null;) { SshProvider possibleProvider = loadFromProperties((URL) e .nextElement()); if (possibleProvider != null) {
/** * Get a provider given it's name. * * @param providerName * provider name * @return provider * @throws IllegalArgumentException * if no such provider is found */ public static SshProvider getProviderByName(String providerName) { SshProvider[] providers = getAllProviders(); for (int i = 0; i < providers.length; i++) { if (providers[i].getName().equals(providerName)) { return providers[i]; } } throw new IllegalArgumentException("No provider named " + providerName); }
protected static final SshProvider loadFromProperties(URL resource) throws IOException { SshConfiguration.getLogger().log(Level.INFO, "Loading " + resource + "."); return loadFromProperties(loadProperties(resource)); }
if (!dependsOn.equals("")) { try { Class.forName(dependsOn, true, getClassLoader()); } catch (ClassNotFoundException cnfe) { SshConfiguration SshProvider provider = createProviderInstance(requestedProviderClassName); providerCache.put(requestedProviderClassName, provider); return provider;
private static void addIfNotExist(List providers, Enumeration e) throws IOException { SshProvider provider = loadFromProperties((URL) e.nextElement()); if (provider != null && !providers.contains(provider)) { providers.add(provider); } }
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; } }
/** * Get all discovered public key algorithms. This is determine by examining * all providers for their algorithms and producing a unique list. * * @return all public key algorithms */ public static String[] getAllPublicKey() { List pk = new ArrayList(); SshProvider[] providers = getAllProviders(); for (int i = 0; i < providers.length; i++) { try { List c = providers[i].getSupportedPublicKey(); addList(pk, c); } catch (UnsatisfiedLinkError ule) { System.out .println("WARNING: Provider requires a native library but it could not be found." + ule.getMessage()); } catch (Exception ex) { System.out.println("WARNING: Provider failed to load. " + ex.getMessage()); ex.printStackTrace(); } } return (String[]) pk.toArray(new String[0]); }
/** * Utility to create a client that may be used with this configuration. It * uses the DefaultProviderFactory, so if you want to custom how providers * are selected, do not use this method. * * @return client */ public SshClient createClient() { // Create the client using that configuration SshProvider provider = DefaultProviderFactory.getInstance().getProvider(this); return provider.createClient(this); }
/** * Get all discovered {@link Capability}. This is determine by examining all * providers for their capabilities and producing a unique list. * * @return all capabilities */ public static Capability[] getAllCapabilties() { List capabilties = new ArrayList(); SshProvider[] providers = getAllProviders(); for (int i = 0; i < providers.length; i++) { List c = providers[i].getCapabilities(); for (Iterator it = c.iterator(); it.hasNext();) { Capability cap = (Capability) it.next(); if (!capabilties.contains(cap)) { capabilties.add(cap); } } } return (Capability[]) capabilties.toArray(new Capability[0]); }