Esempio n. 1
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. 2
0
 private void gotFailure(SSHPacket buf) throws UserAuthException, TransportException {
   allowed.clear();
   allowed.addAll(Arrays.<String>asList(buf.readString().split(",")));
   partialSuccess |= buf.readBoolean();
   if (allowed.contains(currentMethod.getName()) && currentMethod.shouldRetry())
     currentMethod.request();
   else {
     saveException(currentMethod.getName() + " auth failed");
     result.set(false);
   }
 }
Esempio n. 3
0
 private void gotServiceAccept() throws TransportException {
   serviceAccept.lock();
   try {
     if (!serviceAccept.hasWaiters())
       throw new TransportException(
           DisconnectReason.PROTOCOL_ERROR,
           "Got a service accept notification when none was awaited");
     serviceAccept.set();
   } finally {
     serviceAccept.unlock();
   }
 }
Esempio n. 4
0
 @Override
 public void disconnect(DisconnectReason reason, String message) {
   close.lock();
   try {
     if (isRunning()) {
       disconnectListener.notifyDisconnect(reason, message);
       getService().notifyError(new TransportException(reason, "Disconnected"));
       sendDisconnect(reason, message);
       finishOff();
       close.set();
     }
   } finally {
     close.unlock();
   }
 }
Esempio n. 5
0
 private void gotSuccess() {
   trans.setAuthenticated(); // So it can put delayed compression into force if applicable
   trans.setService(nextService); // We aren't in charge anymore, next service is
   result.set(true);
 }