Search in sources :

Example 1 with DefaultSessionFactory

use of com.helger.jsch.session.DefaultSessionFactory in project ph-web by phax.

the class ConnectionTest method getKeyboardInteractiveAuthenticatingSessionFactory.

private ISessionFactory getKeyboardInteractiveAuthenticatingSessionFactory(final String password) {
    final DefaultSessionFactory defaultSessionFactory = new DefaultSessionFactory(username, hostname, port);
    defaultSessionFactory.setConfig("PreferredAuthentications", "keyboard-interactive");
    defaultSessionFactory.setUserInfo(new MockUserInfo(password));
    return defaultSessionFactory;
}
Also used : DefaultSessionFactory(com.helger.jsch.session.DefaultSessionFactory)

Example 2 with DefaultSessionFactory

use of com.helger.jsch.session.DefaultSessionFactory in project ph-web by phax.

the class AbstractScpTestBase method initializeClass.

@BeforeClass
public static void initializeClass() {
    try (final InputStream inputStream = ClassLoader.getSystemResourceAsStream("configuration.properties")) {
        Assume.assumeNotNull(inputStream);
        s_aProperties = new NonBlockingProperties();
        s_aProperties.load(inputStream);
    } catch (final IOException e) {
        LOGGER.warn("cant find properties file (tests will be skipped): " + e.getMessage());
        s_aProperties = null;
        return;
    }
    final String knownHosts = s_aProperties.getProperty("ssh.knownHosts");
    final String privateKey = s_aProperties.getProperty("ssh.privateKey");
    s_sScpPath = s_aProperties.getProperty("scp.out.test.scpPath");
    s_sFileSystemPath = s_aProperties.getProperty("scp.out.test.filesystemPath");
    final String username = s_aProperties.getProperty("scp.out.test.username");
    final String hostname = "localhost";
    final int port = Integer.parseInt(s_aProperties.getProperty("scp.out.test.port"));
    final DefaultSessionFactory defaultSessionFactory = new DefaultSessionFactory(username, hostname, port);
    try {
        defaultSessionFactory.setKnownHosts(knownHosts);
        defaultSessionFactory.setIdentityFromPrivateKey(privateKey);
    } catch (final JSchException e) {
        Assume.assumeNoException(e);
    }
    s_aSessionFactory = defaultSessionFactory;
}
Also used : NonBlockingProperties(com.helger.commons.lang.NonBlockingProperties) JSchException(com.jcraft.jsch.JSchException) DefaultSessionFactory(com.helger.jsch.session.DefaultSessionFactory) InputStream(java.io.InputStream) IOException(java.io.IOException) BeforeClass(org.junit.BeforeClass)

Example 3 with DefaultSessionFactory

use of com.helger.jsch.session.DefaultSessionFactory in project ph-web by phax.

the class TunnelConnectionTest method initializeClass.

@BeforeClass
public static void initializeClass() {
    try (final InputStream inputStream = ClassLoader.getSystemResourceAsStream("configuration.properties")) {
        Assume.assumeNotNull(inputStream);
        properties = new NonBlockingProperties();
        properties.load(inputStream);
    } catch (final IOException e) {
        LOGGER.warn("cant find properties file (tests will be skipped)", e);
        properties = null;
        return;
    }
    final String knownHosts = properties.getProperty("ssh.knownHosts");
    final String privateKey = properties.getProperty("ssh.privateKey");
    final String username = properties.getProperty("scp.out.test.username");
    final String hostname = "localhost";
    final int port = Integer.parseInt(properties.getProperty("scp.out.test.port"));
    final DefaultSessionFactory defaultSessionFactory = new DefaultSessionFactory(username, hostname, port);
    try {
        defaultSessionFactory.setKnownHosts(knownHosts);
        defaultSessionFactory.setIdentityFromPrivateKey(privateKey);
    } catch (final JSchException e) {
        LOGGER.error("Failed to configure default session, skipping tests", e);
        Assume.assumeNoException(e);
    }
    sessionFactory = defaultSessionFactory;
}
Also used : NonBlockingProperties(com.helger.commons.lang.NonBlockingProperties) JSchException(com.jcraft.jsch.JSchException) DefaultSessionFactory(com.helger.jsch.session.DefaultSessionFactory) InputStream(java.io.InputStream) IOException(java.io.IOException) BeforeClass(org.junit.BeforeClass)

Example 4 with DefaultSessionFactory

use of com.helger.jsch.session.DefaultSessionFactory in project ph-web by phax.

the class ConnectionTest method _getPasswordAuthenticatingSessionFactory.

private ISessionFactory _getPasswordAuthenticatingSessionFactory(final String password) {
    final DefaultSessionFactory defaultSessionFactory = new DefaultSessionFactory(username, hostname, port);
    defaultSessionFactory.setConfig("PreferredAuthentications", "password");
    defaultSessionFactory.setPassword(password);
    return defaultSessionFactory;
}
Also used : DefaultSessionFactory(com.helger.jsch.session.DefaultSessionFactory)

Example 5 with DefaultSessionFactory

use of com.helger.jsch.session.DefaultSessionFactory in project ph-web by phax.

the class CommandRunnerTest method initializeClass.

@BeforeClass
public static void initializeClass() {
    try (final InputStream inputStream = ClassLoader.getSystemResourceAsStream("configuration.properties")) {
        Assume.assumeNotNull(inputStream);
        properties = new NonBlockingProperties();
        properties.load(inputStream);
    } catch (final IOException e) {
        LOGGER.warn("cant find properties file (tests will be skipped)", e);
        properties = null;
        return;
    }
    final String knownHosts = properties.getProperty("ssh.knownHosts");
    final String privateKey = properties.getProperty("ssh.privateKey");
    final String username = properties.getProperty("scp.out.test.username");
    final String hostname = "localhost";
    final int port = Integer.parseInt(properties.getProperty("scp.out.test.port"));
    final DefaultSessionFactory defaultSessionFactory = new DefaultSessionFactory(username, hostname, port);
    try {
        defaultSessionFactory.setKnownHosts(knownHosts);
        defaultSessionFactory.setIdentityFromPrivateKey(privateKey);
    } catch (final JSchException e) {
        Assume.assumeNoException(e);
    }
    sessionFactory = defaultSessionFactory;
}
Also used : NonBlockingProperties(com.helger.commons.lang.NonBlockingProperties) JSchException(com.jcraft.jsch.JSchException) DefaultSessionFactory(com.helger.jsch.session.DefaultSessionFactory) InputStream(java.io.InputStream) IOException(java.io.IOException) BeforeClass(org.junit.BeforeClass)

Aggregations

DefaultSessionFactory (com.helger.jsch.session.DefaultSessionFactory)7 JSchException (com.jcraft.jsch.JSchException)5 NonBlockingProperties (com.helger.commons.lang.NonBlockingProperties)4 IOException (java.io.IOException)4 InputStream (java.io.InputStream)4 BeforeClass (org.junit.BeforeClass)4 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1