Package org.vngx.jsch.exception

Examples of org.vngx.jsch.exception.JSchException


      subsystemRequest.setReply(_wantReply);
      subsystemRequest.request(_session, this);
    } catch(JSchException e) {
      throw e;
    } catch(Exception e) {
      throw new JSchException("Failed to start ChannelSubsystem", e);
    }
    if( _io.in != null ) {
      _thread = new Thread(this, "Subsystem for " + _session.getHost());
      _thread.setDaemon(_session.isDaemonThread());
      _thread.start();
View Full Code Here


    if( _decompressor != null ) {
      int paddingSize = buffer.buffer[4];
      _uncompressLen[0] = buffer.index - 5 - paddingSize;
      byte[] uncompressed = _decompressor.uncompress(buffer.buffer, 5, _uncompressLen);
      if( uncompressed == null ) {
        throw new JSchException("Failed to decompress packet data", SSH_DISCONNECT_COMPRESSION_ERROR);
      }
      buffer.buffer = uncompressed;
      buffer.index = 5 + _uncompressLen[0]// Index is set excluding setPadding
    }
View Full Code Here

   */
  private void startDiscard(Buffer buffer, int packetLength, int discard, String msg, int reasonCode) throws JSchException, IOException {
    // If the server-to-client cipher is not using cipher-block chaining mode
    // of operation, then the inbound SSH packet is corrupt and session should end
    if( !_readCipher.isCBC() ) {
      throw new JSchException("Inbound packet is corrupt: "+msg, reasonCode);
    }

    // Finish reading in the rest of the data from the Session's in stream
    // which needs to be discarded.
    MAC discardMac = packetLength != Packet.MAX_SIZE ? _readMac : null;
    discard -= buffer.index;
    while( discard > 0 ) {
      buffer.reset();
      int len = Math.min(discard, buffer.buffer.length);
      getByte(buffer.buffer, 0, len);
      if( discardMac != null ) {
        discardMac.update(buffer.buffer, 0, len);
      }
      discard -= len;
    }
    if( discardMac != null ) {
      discardMac.doFinal(buffer.buffer, 0);
    }
    throw new JSchException("Inbound packet is corrupt: "+msg, reasonCode);
  }
View Full Code Here

      // Generate inflater/deflater instances for compression
      initCompressor(proposal.getCompressionAlgCtoS());
      initDecompressor(proposal.getCompressionAlgStoC());
    } catch(Exception e) {
      throw new JSchException("Failed to initialize new keys", e);
    }
    kex.kexCompleted()// No longer in key exchange
  }
View Full Code Here

        (_session.isAuthenticated() && Compression.COMPRESSION_ZLIB_OPENSSH.equals(method)) ) {
      try {
        _compressor = AlgorithmManager.getManager().createAlgorithm(method, _session);
        _compressor.init(Compression.COMPRESS_MODE, _session.getConfig().getInteger(SessionConfig.COMPRESSION_LEVEL));
      } catch(Exception e) {
        throw new JSchException("Failed to initialize deflater, method: "+method, e);
      }
    }
  }
View Full Code Here

        (_session.isAuthenticated() && Compression.COMPRESSION_ZLIB_OPENSSH.equals(method)) ) {  // why only if authed?
      try {
        _decompressor = AlgorithmManager.getManager().createAlgorithm(method, _session);
        _decompressor.init(Compression.DECOMPRESS_MODE, 0);
      } catch(Exception e) {
        throw new JSchException("Failed to initialize inflater, method: "+method, e);
      }
    }
  }
View Full Code Here

    _host = host;
    _key = Util.copyOf(key, key.length)// Copy key for security
    if( keyType == null ) {
      _type = guessType(key);
      if( _type == KeyType.UNKNOWN ) {
        throw new JSchException("Failed to determine key type");
      }
    } else {
      _type = keyType;
    }
View Full Code Here

      PipedOutputStream pos = new PipedOutputStream();
      _io.setOutputStream(pos);
      _io.setInputStream(new PipedInputStream(pos, 32 * 1024))// TODO make pipe size configurable
      _io_in = _io.in;
      if( _io_in == null ) {
        throw new JSchException("Channel is down");
      }

      new RequestSftp().request(_session, this);
      _buffer = new Buffer(_remoteMaxPacketSize);
      _packet = new Packet(_buffer);

      // send SSH_FXP_INIT
      sendINIT();

      // receive SSH_FXP_VERSION
      readHeader();
      if( _header.length > MAX_MSG_LENGTH ) {
        throw new SftpException(SSH_FX_FAILURE, "Received message is too long: " + _header.length);
      }
      _serverVersion = _header.rid;  // Retrieve version from header

      if( _header.length > 0 ) {
        _extensions = new HashMap<String,String>();
        fill(_buffer, _header.length)// read in extension data
        byte[] extensionName, extensionData;
        while( _header.length > 0 ) {
          extensionName = _buffer.getString();
          extensionData = _buffer.getString();
          _header.length -= 4 + extensionName.length + 4 + extensionData.length;
          _extensions.put(Util.byte2str(extensionName), Util.byte2str(extensionData));
        }
      }

      // Set local current working directory and home directory after connecting
      _lcwd = new File(".").getCanonicalPath()// TODO Should be configurable location
      _home = Util.byte2str(_realpath(""), _fileEncoding);
      _cwd = _home;
    } catch(JSchException e) {
      throw e;
    } catch(Exception e) {
      throw new JSchException("Failed to start ChannelSftp", e);
    }
  }
View Full Code Here

  static PortWatcher getPort(Session session, String address, int localPort) throws JSchException {
    InetAddress addr;
    try {
      addr = InetAddress.getByName(address);
    } catch(UnknownHostException uhe) {
      throw new JSchException("PortForwardingL: invalid address " + address + " specified", uhe);
    }
    synchronized( PORT_WATCHER_POOL ) {
      for( PortWatcher p : PORT_WATCHER_POOL ) {
        if( p._session == session && p._localPort == localPort &&
          ((ANY_LOCAL != null && p._boundAddress.equals(ANY_LOCAL)) || p._boundAddress.equals(addr)) ) {
View Full Code Here

   * @return created port watcher instance
   * @throws JSchException
   */
  static PortWatcher addPort(Session session, String address, int localPort, String host, int remotePort, ServerSocketFactory ssf) throws JSchException {
    if( getPort(session, address, localPort) != null ) {
      throw new JSchException("PortForwardingL: local port " + address + ":" + localPort + " is already registered");
    }
    PortWatcher pw = new PortWatcher(session, address, localPort, host, remotePort, ssf);
    PORT_WATCHER_POOL.add(pw);
    return pw;
  }
View Full Code Here

TOP

Related Classes of org.vngx.jsch.exception.JSchException

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.