Package com.sshtools.j2ssh.session

Examples of com.sshtools.j2ssh.session.SessionChannelClient


    {
        if( log.isInfoEnabled() ) log.info( connectionInfo + " - Opening new ShellChannel" );

        try
        {
            SessionChannelClient sessionChannelClient = sshClient.openSessionChannel();
            ShellChannel shellChannel = new VT100ShellChannel( this, sessionChannelClient );

            // Generate a channelId for the channel and add it to the local map.
            String channelId = String.valueOf( nextChannelId++ );
            shellChannel.setChannelId( channelId );
View Full Code Here


                        + "authentication is required", jobExecutionContext);
            } else if(result==AuthenticationProtocolState.COMPLETE) {
                log.info("ssh client authentication is complete...");
            }

            SessionChannelClient session = sshClient.openSessionChannel();
            log.info("ssh session successfully opened...");
            session.requestPseudoTerminal("vt100", 80, 25, 0, 0, "");
            session.startShell();
            session.getOutputStream().write(shellCmd.getBytes());

            InputStream in = session.getInputStream();
            byte buffer[] = new byte[255];
            int read;
            String executionResult = "";
            while((read = in.read(buffer)) > 0) {
                String out = new String(buffer, 0, read);
View Full Code Here

        int result = ssh.authenticate(pwd);

        if(result == AuthenticationProtocolState.COMPLETE)
        {
            SessionChannelClient session = ssh.openSessionChannel();

            if(!session.requestPseudoTerminal("vt100", 80, 24, 0, 0, ""))
            {
                Log.debug("ERROR: Could not open terminal");
            }

            if(session.startShell())
            {
                out = new BufferedOutputStream(session.getOutputStream());
                in = new BufferedInputStream(session.getInputStream());
                err = new BufferedInputStream(session.getStderrInputStream());

                //session.getState().waitForState(ChannelState.CHANNEL_CLOSED);
            }
            else
            {
View Full Code Here

                        + "authentication is required", jobExecutionContext);
            } else if(result==AuthenticationProtocolState.COMPLETE) {
                log.info("ssh client authentication is complete...");
            }
            GFacUtils.updateApplicationJobStatus(jobExecutionContext, jobId, ApplicationJobStatus.SUBMITTED);
            SessionChannelClient session = sshClient.openSessionChannel();
            log.info("ssh session successfully opened...");
            session.requestPseudoTerminal("vt100", 80, 25, 0, 0, "");
            session.startShell();
           
            GFacUtils.updateApplicationJobStatus(jobExecutionContext, jobId, ApplicationJobStatus.EXECUTING);
            session.getOutputStream().write(shellCmd.getBytes());

            InputStream in = session.getInputStream();
            byte buffer[] = new byte[255];
            int read;
            String executionResult = "";
            while((read = in.read(buffer)) > 0) {
                String out = new String(buffer, 0, read);
View Full Code Here

                        + "authentication is required");
            } else if(result==AuthenticationProtocolState.COMPLETE) {
                log.info("ssh client authentication is complete...");
            }
            GFacUtils.updateApplicationJobStatus(jobExecutionContext, jobId, ApplicationJobStatus.SUBMITTED);
            SessionChannelClient session = sshClient.openSessionChannel();
            log.info("ssh session successfully opened...");
            session.requestPseudoTerminal("vt100", 80, 25, 0, 0, "");
            session.startShell();
           
            GFacUtils.updateApplicationJobStatus(jobExecutionContext, jobId, ApplicationJobStatus.EXECUTING);
            session.getOutputStream().write(shellCmd.getBytes());

            InputStream in = session.getInputStream();
            byte buffer[] = new byte[255];
            int read;
            String executionResult = "";
            while((read = in.read(buffer)) > 0) {
                String out = new String(buffer, 0, read);
View Full Code Here

                        + "authentication is required", jobExecutionContext);
            } else if(result==AuthenticationProtocolState.COMPLETE) {
                log.info("ssh client authentication is complete...");
            }
            GFacUtils.updateApplicationJobStatus(jobExecutionContext, jobId, ApplicationJobStatus.SUBMITTED);
            SessionChannelClient session = sshClient.openSessionChannel();
            log.info("ssh session successfully opened...");
            session.requestPseudoTerminal("vt100", 80, 25, 0, 0, "");
            session.startShell();
           
            GFacUtils.updateApplicationJobStatus(jobExecutionContext, jobId, ApplicationJobStatus.EXECUTING);
            session.getOutputStream().write(shellCmd.getBytes());

            InputStream in = session.getInputStream();
            byte buffer[] = new byte[255];
            int read;
            String executionResult = "";
            while((read = in.read(buffer)) > 0) {
                String out = new String(buffer, 0, read);
View Full Code Here

        ChannelEventListener eventListener) throws IOException {
        if (authenticationState != AuthenticationProtocolState.COMPLETE) {
            throw new SshException("Authentication has not been completed!");
        }

        SessionChannelClient session = new SessionChannelClient();
        session.addEventListener(activeChannelListener);

        if (!connection.openChannel(session, eventListener)) {
            throw new SshException("The server refused to open a session");
        }
View Full Code Here

     * @throws IOException
     * @throws SshException
     */
    public SftpSubsystemClient openSftpChannel(
        ChannelEventListener eventListener) throws IOException {
        SessionChannelClient session = openSessionChannel(eventListener);
        SftpSubsystemClient sftp = new SftpSubsystemClient();

        if (!openChannel(sftp)) {
            throw new SshException("The SFTP subsystem failed to start");
        }
View Full Code Here

      // Try the authentication
      int result = ssh.authenticate(pk);
      // Evaluate the result
      if (result == AuthenticationProtocolState.COMPLETE) {
        // The connection is authenticated we can now do some real work!
        SessionChannelClient session = ssh.openSessionChannel();
        if(!session.requestPseudoTerminal("vt100", 80, 24, 0, 0, ""))
          System.out.println("Failed to allocate a pseudo terminal");
        if(session.startShell()) {
          InputStream in = session.getInputStream();
          OutputStream out = session.getOutputStream();
          IOStreamConnector input =
              new IOStreamConnector(System.in, session.getOutputStream());
          IOStreamConnector output =
              new IOStreamConnector(session.getInputStream(), System.out);
          output.getState().waitForState(IOStreamConnectorState.CLOSED);
        } else
          System.out.println("Failed to start the users shell");
        ssh.disconnect();
      }
View Full Code Here

      // Try the authentication
      int result = ssh.authenticate(kbi);
      // Evaluate the result
      if (result == AuthenticationProtocolState.COMPLETE) {
        // The connection is authenticated we can now do some real work!
        SessionChannelClient session = ssh.openSessionChannel();
        if(!session.requestPseudoTerminal("vt100", 80, 24, 0, 0, ""))
          System.out.println("Failed to allocate a pseudo terminal");
        if(session.startShell()) {
          IOStreamConnector input =
              new IOStreamConnector(System.in, session.getOutputStream());
          IOStreamConnector output =
              new IOStreamConnector(session.getInputStream(), System.out);
          output.getState().waitForState(IOStreamConnectorState.CLOSED);
        }else
          System.out.println("Failed to start the users shell");
        ssh.disconnect();
      }
View Full Code Here

TOP

Related Classes of com.sshtools.j2ssh.session.SessionChannelClient

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.