Esempio n. 1
0
  @Test
  public void shouldFailWhenPacketLengthTooLarge() throws Exception {
    dataout.writeInt(Integer.MAX_VALUE);
    dataout.flush();

    try {
      reader.readPacket();
      fail("Should have failed to read packet of size " + Integer.MAX_VALUE);
    } catch (SSHException e) {
      e.printStackTrace();
      // success; indicated packet size was too large
    }
  }
Esempio n. 2
0
  public void die(Exception ex) {
    close.lock();
    try {
      if (!close.isSet()) {

        log.error("Dying because - {}", ex);

        final SSHException causeOfDeath = SSHException.chainer.chain(ex);

        disconnectListener.notifyDisconnect(
            causeOfDeath.getDisconnectReason(), causeOfDeath.getMessage());

        ErrorDeliveryUtil.alertEvents(causeOfDeath, close, serviceAccept);
        kexer.notifyError(causeOfDeath);
        getService().notifyError(causeOfDeath);
        setService(nullService);

        { // Perhaps can send disconnect packet to server
          final boolean didNotReceiveDisconnect = msg != Message.DISCONNECT;
          final boolean gotRequiredInfo =
              causeOfDeath.getDisconnectReason() != DisconnectReason.UNKNOWN;
          if (didNotReceiveDisconnect && gotRequiredInfo)
            sendDisconnect(causeOfDeath.getDisconnectReason(), causeOfDeath.getMessage());
        }

        finishOff();

        close.set();
      }
    } finally {
      close.unlock();
    }
  }
Esempio n. 3
0
 @Override
 public void notifyError(SSHException error) {
   log.debug("Notified of {}", error.toString());
 }