Examples of JSchException


Examples of org.vngx.jsch.exception.JSchException

      _q = keypairgen.getQ();
      _ep = keypairgen.getEP();
      _eq = keypairgen.getEQ();
      _c = keypairgen.getC();
    } catch(Exception e) {
      throw new JSchException("Failed to generate KeyPairRSA: "+e, e);
    }
  }
View Full Code Here

Examples of org.vngx.jsch.exception.JSchException

      _prvKey = keypairgen.getX();
      _p = keypairgen.getP();
      _q = keypairgen.getQ();
      _g = keypairgen.getG();
    } catch(Exception e) {
      throw new JSchException("Failed to generate KeyPairDSA: "+e, e);
    }
  }
View Full Code Here

Examples of org.vngx.jsch.exception.JSchException

      sendRequests();
      new RequestShell().request(_session, this);
    } catch(JSchException e) {
      throw e;
    } catch(Exception e) {
      throw new JSchException("Failed to start ChannelShell", e);
    }

    if( _io.in != null ) {
      _thread = new Thread(this, "Shell for " + _session.getHost());
      _thread.setDaemon(_session.isDaemonThread());
View Full Code Here

Examples of org.vngx.jsch.exception.JSchException

        }
      }
    } catch(JSchException e) {
      throw e;
    } catch(Exception e) {
      throw new JSchException("Failed to load known hosts", e);
    } finally {
      if( hostsStream != null ) {
        try { hostsStream.close(); } catch(Exception e) { /* Ignore Error */ }
      }
    }
View Full Code Here

Examples of org.vngx.jsch.exception.JSchException

   * @param connectTimeout in milliseconds
   * @throws JSchException if any errors occur
   */
  public void connect(int connectTimeout) throws JSchException {
    if( isConnected() ) {
      throw new JSchException("Channel is already connected");
    } else if( !_session.isConnected() ) {
      throw new JSchException("Session is not connected");
    }
    _connectTimeout = connectTimeout;  // Set connection timeout
    try {
      Buffer buffer = new Buffer(100);
      Packet packet = new Packet(buffer);
      // send
      // byte   SSH_MSG_CHANNEL_OPEN(90)
      // string channel type         //
      // uint32 sender channel       // 0
      // uint32 initial window size  // 0x100000(65536)
      // uint32 maxmum packet size   // 0x4000(16384)
      packet.reset();
      buffer.putByte(SSH_MSG_CHANNEL_OPEN);
      buffer.putString(_type);
      buffer.putInt(_id);
      buffer.putInt(_localWindowSize);
      buffer.putInt(_localMaxPacketSize);
      _session.write(packet);

      int retry = 1000// Note: Max timeout is 50 seconds (1000 retries * 50ms sleep)
      long start = System.currentTimeMillis();
      while( _recipient == -1 && _session.isConnected() && retry-- > 0 ) {
        if( _connectTimeout > 0L && (System.currentTimeMillis() - start) > _connectTimeout ) {
          throw new JSchException("Failed to open channel: connection timeout after " + _connectTimeout + " ms");
        }
        try { Thread.sleep(50); } catch(Exception ee) { /* Ignore error. */ }
      }
      if( !_session.isConnected() ) {
        throw new JSchException("Failed to open channel: session is not connected");
      } else if( retry == 0 ) {
        throw new JSchException("Failed to open channel: no response");
      }

      /*
       * At the failure in opening the channel on the sshd,
       * 'SSH_MSG_CHANNEL_OPEN_FAILURE' will be sent from sshd and it will
       * be processed in Session#run().
       */
      if( isClosed() ) {
        throw new JSchException("Failed to open channel: "+_exitstatus);
      }
      _connected = true;
      start();
    } catch(JSchException je) {
      _connected = false;
      disconnect();
      throw je;
    } catch(Exception e) {
      _connected = false;
      disconnect();
      throw new JSchException("Failed to open channel "+getClass().getSimpleName()+": "+_exitstatus, e);
    }
  }
View Full Code Here

Examples of org.vngx.jsch.exception.JSchException

      _salt = Util.fromBase64(Util.str2byte(salt), 0, salt.length());
      _hashedHost = Util.fromBase64(Util.str2byte(hash), 0, hash.length());

      // If invalid salt/hash, then generate hash and salt for session
      if( _salt.length != 20 || _hashedHost.length != 20 ) {  // SHA-1 block size must be 20!
        throw new JSchException("Invalid format, salt/hashed host lengths are wrong size: "+_host);
      }
    } else {
      // Host is not yet hashed, so generate hash
      generateHash();
    }
View Full Code Here

Examples of org.vngx.jsch.exception.JSchException

        macsha1.update(hostBytes, 0, hostBytes.length);
        _hashedHost = new byte[macsha1.getBlockSize()];
        macsha1.doFinal(_hashedHost, 0);
      }
    } catch(Exception e) {
      throw new JSchException("Failed to create HashedHostKey: " + e, e);
    }

    // Update the host value to the proper hashed format
    StringBuilder buffer = new StringBuilder(2000);
    buffer.append(HASH_MAGIC).append(Util.byte2str(Util.toBase64(_salt, 0, _salt.length)));
View Full Code Here

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

Examples of org.vngx.jsch.exception.JSchException

    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

Examples of org.vngx.jsch.exception.JSchException

   */
  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
TOP
Copyright © 2018 www.massapi.com. 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.