org.apache.sshd.common.Session Java Examples

The following examples show how to use org.apache.sshd.common.Session. 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: SshRequestLogListener.java    From artifactory_ssh_proxy with Apache License 2.0 5 votes vote down vote up
@Override
public void sessionCreated(Session session) {
    // this may not be called if the listener is created after the session
    // has been created
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("session " + session.toString() + "gets started.");
    }
}
 
Example #2
Source File: SshRequestLogListener.java    From artifactory_ssh_proxy with Apache License 2.0 5 votes vote down vote up
@Override
public void sessionClosed(Session session) {
    for (SshRequestInfo request : sshRequestList) {
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("logging the ssh request info " + request.toString());
        }
        requestLog.log(request);
    }
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("session" + session.toString() + " closed.");
    }
}
 
Example #3
Source File: LocalForwardingFilter.java    From artifactory_ssh_proxy with Apache License 2.0 5 votes vote down vote up
@Override
public boolean canConnect(SshdSocketAddress socketAddress, Session session) {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Connect forwarding requested from {} for {}", socketAddress, session);
    }

    // we don't want to allow forwards to just anywhere, we only allow them to the artifactory host.
    int sp = socketAddress.getPort();
    if (sp != toPort) {
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Denying forwarding requested from {} for {} tohost {} toPort {}", socketAddress, session,
                            toHost, Integer.valueOf(toPort));
        }

        return false;
    }

    String spHost = socketAddress.getHostName().toLowerCase();
    if (!toHost.equals(spHost)) {
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Denying forwarding requested from {} for {} tohost {} toPort {}", socketAddress, session,
                            toHost, Integer.valueOf(toPort));
        }

        return false;
    }

    return true;
}
 
Example #4
Source File: DenyingForwardingFilter.java    From artifactory_ssh_proxy with Apache License 2.0 5 votes vote down vote up
@Override
public boolean canForwardX11(Session session) {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("X11 forwarding requested for {}", session);
    }

    return false;
}
 
Example #5
Source File: DenyingForwardingFilter.java    From artifactory_ssh_proxy with Apache License 2.0 5 votes vote down vote up
@Override
public boolean canListen(SshdSocketAddress socketAddress, Session session) {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Listen forwarding requested from {} for {}", socketAddress, session);
    }

    return false;
}
 
Example #6
Source File: DenyingForwardingFilter.java    From artifactory_ssh_proxy with Apache License 2.0 5 votes vote down vote up
@Override
public boolean canConnect(SshdSocketAddress socketAddress, Session session) {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Connect forwarding requested from {} for {}", socketAddress, session);
    }

    return false;
}
 
Example #7
Source File: DenyingForwardingFilter.java    From artifactory_ssh_proxy with Apache License 2.0 5 votes vote down vote up
@Override
public boolean canForwardAgent(Session session) {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Agent forwarding requested for {}", session);
    }

    return false;
}
 
Example #8
Source File: ScpCommandSessionListener.java    From artifactory_ssh_proxy with Apache License 2.0 5 votes vote down vote up
@Override
public void sessionClosed(Session session) {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Session is closed. Try to interrupt the downloading thread if it is still blocked.");
    }

    if (null != this.threadRunningScpCommand) {
        this.threadRunningScpCommand.interrupt();
    }
}
 
Example #9
Source File: TestForwardingFilters.java    From artifactory_ssh_proxy with Apache License 2.0 5 votes vote down vote up
/**
 * not a test.
 * 
 * @param filter
 */
@Test(enabled = false)
public static void testDenyFilter(ForwardingFilter filter) {
    Session session = Mockito.mock(Session.class);
    SshdSocketAddress address = Mockito.mock(SshdSocketAddress.class);

    Assert.assertFalse(filter.canForwardAgent(session));
    Assert.assertFalse(filter.canForwardX11(session));
    Assert.assertFalse(filter.canListen(address, session));
    Assert.assertFalse(filter.canConnect(address, session));
}
 
Example #10
Source File: TestForwardingFilters.java    From artifactory_ssh_proxy with Apache License 2.0 5 votes vote down vote up
/**
 * not a test.
 * 
 * @param filter
 */
@SuppressWarnings("boxing")
@Test(enabled = false)
public static void testLocalForwardFilter(ForwardingFilter filter, String hostname, int port, boolean expected) {
    Session session = Mockito.mock(Session.class);
    SshdSocketAddress address = Mockito.mock(SshdSocketAddress.class);
    Mockito.when(address.getHostName()).thenReturn(hostname);
    Mockito.when(address.getPort()).thenReturn(port);

    Assert.assertFalse(filter.canForwardAgent(session));
    Assert.assertFalse(filter.canForwardX11(session));
    Assert.assertFalse(filter.canListen(address, session));
    Assert.assertEquals(filter.canConnect(address, session), expected);
}
 
Example #11
Source File: AbstractSftpProviderTestCase.java    From commons-vfs with Apache License 2.0 5 votes vote down vote up
/**
 * Accepts only the known test user.
 */
@Override
public FileSystemView createFileSystemView(final Session session) throws IOException {
    final String userName = session.getUsername();
    if (!DEFAULT_USER.equals(userName)) {
        return null;
    }
    return new TestFileSystemView(AbstractVfsTestCase.getTestDirectory(), userName);
}
 
Example #12
Source File: ArtifactoryFileSystemFactory.java    From artifactory_ssh_proxy with Apache License 2.0 4 votes vote down vote up
/**
 * Create the appropriate user file system view.
 */
@Override
public FileSystemView createFileSystemView(final Session session) {
    final String userName = session.getUsername();
    return new ArtifactoryFileSystemView(afInfo, userName, isCaseInsensitive(), artifactoryAuthorizer);
}
 
Example #13
Source File: SshRequestLogListener.java    From artifactory_ssh_proxy with Apache License 2.0 4 votes vote down vote up
@Override
public void sessionEvent(Session session, Event event) {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("session " + session.toString() + " Event: " + event.toString());
    }
}
 
Example #14
Source File: ScpCommandSessionListener.java    From artifactory_ssh_proxy with Apache License 2.0 4 votes vote down vote up
@Override
public void sessionCreated(Session session) {
}
 
Example #15
Source File: ScpCommandSessionListener.java    From artifactory_ssh_proxy with Apache License 2.0 4 votes vote down vote up
@Override
public void sessionEvent(Session session, Event event) {
}