Package net.schmizz.sshj.connection

Examples of net.schmizz.sshj.connection.ConnectionException


        try {
            final int dataTypeCode = buf.readUInt32AsInt();
            if (dataTypeCode == 1)
                receiveInto(err, buf);
            else
                throw new ConnectionException(DisconnectReason.PROTOCOL_ERROR,
                                              "Bad extended data type = " + dataTypeCode);
        } catch (Buffer.BufferException be) {
            throw new ConnectionException(be);
        }
    }
View Full Code Here


        final String reqType;
        try {
            reqType = buf.readString();
            buf.readBoolean(); // We don't care about the 'want-reply' value
        } catch (Buffer.BufferException be) {
            throw new ConnectionException(be);
        }
        log.info("Got chan request for `{}`", reqType);
        handleRequest(reqType, buf);
    }
View Full Code Here

            throws ConnectionException {
        final int howMuch;
        try {
            howMuch = buf.readUInt32AsInt();
        } catch (Buffer.BufferException be) {
            throw new ConnectionException(be);
        }
        log.info("Received window adjustment for {} bytes", howMuch);
        rwin.expand(howMuch);
    }
View Full Code Here

        close.set();
    }

    protected void gotExtendedData(SSHPacket buf)
            throws ConnectionException, TransportException {
        throw new ConnectionException(DisconnectReason.PROTOCOL_ERROR,
                                      "Extended data not supported on " + type + " channel");
    }
View Full Code Here

            throws ConnectionException, TransportException {
        final int len;
        try {
            len = buf.readUInt32AsInt();
        } catch (Buffer.BufferException be) {
            throw new ConnectionException(be);
        }
        if (len < 0 || len > getLocalMaxPacketSize() || len > buf.available())
            throw new ConnectionException(DisconnectReason.PROTOCOL_ERROR, "Bad item length: " + len);
        if (log.isTraceEnabled())
            log.trace("IN #{}: {}", id, ByteArrayUtils.printHex(buf.array(), buf.rpos(), len));
        stream.receive(buf.array(), buf.rpos(), len);
    }
View Full Code Here

            final Event<ConnectionException> responseEvent = chanReqResponseEvents.poll();
            if (responseEvent != null) {
                if (success)
                    responseEvent.set();
                else
                    responseEvent.deliverError(new ConnectionException("Request failed"));
            } else
                throw new ConnectionException(DisconnectReason.PROTOCOL_ERROR,
                        "Received response to channel request when none was requested");
        }
    }
View Full Code Here

   public void testPropateConvertsAuthException() {
      ssh.propagate(new UserAuthException(""), "");
   }

   public void testExceptionClassesRetry() {
      assert ssh.shouldRetry(new ConnectionException("Read timed out", new SSHException("Read timed out",
            new SocketTimeoutException("Read timed out"))));
      assert ssh.shouldRetry(new SFTPException("Failure!"));
      assert ssh.shouldRetry(new SocketTimeoutException("connect timed out"));
      assert ssh.shouldRetry(new TransportException("socket closed"));
      assert ssh.shouldRetry(new ConnectionException("problem"));
      assert ssh.shouldRetry(new ConnectException("Connection refused"));
      assert !ssh.shouldRetry(new IOException("channel %s is not open", new NullPointerException()));
   }
View Full Code Here

   public void testDontThrowIOExceptionOnClear() throws Exception {
      SshjSshClient ssh1 = createClient();
      SSHClient ssh = createMock(SSHClient.class);
      expect(ssh.isConnected()).andReturn(true);
      ssh.disconnect();
      expectLastCall().andThrow(new ConnectionException("disconnected"));
      replay(ssh);
      ssh1.sshClientConnection.ssh = ssh;
      ssh1.sshClientConnection.clear();
      verify(ssh);
   }
View Full Code Here

   public void testRetriesLoggedAtInfoWithCount() throws Exception {
      SSHClientConnection mockConnection = createMock(SSHClientConnection.class);
      net.schmizz.sshj.SSHClient mockClient = createMock(net.schmizz.sshj.SSHClient.class);

      mockConnection.clear(); expectLastCall();
      mockConnection.create(); expectLastCall().andThrow(new ConnectionException("test1"));
      mockConnection.clear(); expectLastCall();
      //currently does two clears, one on failure (above) and one on next iteration (below)
      mockConnection.clear(); expectLastCall();
      mockConnection.create(); expectLastCall().andReturn(mockClient);
      replay(mockConnection);
View Full Code Here

   public void testPropateConvertsAuthException() {
      ssh.propagate(new UserAuthException(""), "");
   }

   public void testExceptionClassesRetry() {
      assert ssh.shouldRetry(new ConnectionException("Read timed out", new SSHException("Read timed out",
            new SocketTimeoutException("Read timed out"))));
      assert ssh.shouldRetry(new SFTPException("Failure!"));
      assert ssh.shouldRetry(new SocketTimeoutException("connect timed out"));
      assert ssh.shouldRetry(new TransportException("socket closed"));
      assert ssh.shouldRetry(new ConnectionException("problem"));
      assert ssh.shouldRetry(new ConnectException("Connection refused"));
      assert !ssh.shouldRetry(new IOException("channel %s is not open", new NullPointerException()));
   }
View Full Code Here

TOP

Related Classes of net.schmizz.sshj.connection.ConnectionException

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.