com.jcraft.jsch.SocketFactory Java Examples

The following examples show how to use com.jcraft.jsch.SocketFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SFTPEnvironmentTest.java    From sftp-fs with Apache License 2.0 6 votes vote down vote up
@Test
public void testInitializeSessionFull() throws IOException, JSchException {
    SFTPEnvironment env = new SFTPEnvironment();
    initializeFully(env);

    Session session = mock(Session.class);
    env.initialize(session);

    verify(session).setProxy((Proxy) env.get("proxy"));
    verify(session).setUserInfo((UserInfo) env.get("userInfo"));
    verify(session).setPassword(new String((char[]) env.get("password")));
    verify(session).setConfig((Properties) env.get("config"));
    verify(session).setSocketFactory((SocketFactory) env.get("socketFactory"));
    verify(session).setTimeout((int) env.get("timeOut"));
    verify(session).setClientVersion((String) env.get("clientVersion"));
    verify(session).setHostKeyAlias((String) env.get("hostKeyAlias"));
    verify(session).setServerAliveInterval((int) env.get("serverAliveInterval"));
    verify(session).setServerAliveCountMax((int) env.get("serverAliveCountMax"));
    verifyNoMoreInteractions(session);
}
 
Example #2
Source File: SshProxy.java    From jsch-extension with MIT License 5 votes vote down vote up
public void connect( SocketFactory socketFactory, String host, int port, int timeout ) throws Exception {
    logger.debug( "connecting session" );
    session.connect();

    channel = session.getStreamForwarder( host, port );
    inputStream = channel.getInputStream();
    outputStream = channel.getOutputStream();

    channel.connect( timeout );
}
 
Example #3
Source File: SftpStreamProxy.java    From commons-vfs with Apache License 2.0 5 votes vote down vote up
@Override
public void connect(final SocketFactory socketFactory, final String targetHost, final int targetPort,
        final int timeout) throws Exception {
    session = SftpClientFactory.createConnection(proxyHost, proxyPort, proxyUser.toCharArray(),
            proxyPassword.toCharArray(), proxyOptions);
    channel = (ChannelExec) session.openChannel("exec");
    channel.setCommand(String.format(commandFormat, targetHost, targetPort));
    channel.connect(timeout);
}
 
Example #4
Source File: SFTPEnvironment.java    From sftp-fs with Apache License 2.0 2 votes vote down vote up
/**
 * Stores the socket factory to use.
 *
 * @param factory The socket factory to use.
 * @return This object.
 */
public SFTPEnvironment withSocketFactory(SocketFactory factory) {
    put(SOCKET_FACTORY, factory);
    return this;
}