@Override public void setAuthenticated() { this.authed = true; encoder.setAuthenticated(); decoder.setAuthenticated(); }
private synchronized void ensureKexOngoing() throws TransportException { if (!isKexOngoing()) throw new TransportException(DisconnectReason.PROTOCOL_ERROR, "Key exchange packet received when key exchange was not ongoing"); }
public NegotiatedAlgorithms negotiate(Proposal other) throws TransportException { return new NegotiatedAlgorithms( firstMatch(this.getKeyExchangeAlgorithms(), other.getKeyExchangeAlgorithms()), firstMatch(this.getSignatureAlgorithms(), other.getSignatureAlgorithms()), firstMatch(this.getClient2ServerCipherAlgorithms(), other.getClient2ServerCipherAlgorithms()), firstMatch(this.getServer2ClientCipherAlgorithms(), other.getServer2ClientCipherAlgorithms()), firstMatch(this.getClient2ServerMACAlgorithms(), other.getClient2ServerMACAlgorithms()), firstMatch(this.getServer2ClientMACAlgorithms(), other.getServer2ClientMACAlgorithms()), firstMatch(this.getClient2ServerCompressionAlgorithms(), other.getClient2ServerCompressionAlgorithms()), firstMatch(this.getServer2ClientCompressionAlgorithms(), other.getServer2ClientCompressionAlgorithms()) ); }
/** * Sends SSH_MSG_KEXINIT and sets the {@link #kexInitSent} event. * * @throws TransportException */ private void sendKexInit() throws TransportException { log.debug("Sending SSH_MSG_KEXINIT"); clientProposal = new Proposal(transport.getConfig()); transport.write(clientProposal.getPacket()); kexInitSent.set(); }
private int decryptLength() throws TransportException { decryptBuffer(0, cipherSize); final int len; // Read packet length try { len = inputBuffer.readUInt32AsInt(); } catch (Buffer.BufferException be) { throw new TransportException(be); } checkPacketLength(len); return len; }
@Override public long sendUnimplemented() throws TransportException { final long seq = decoder.getSequenceNumber(); log.debug("Sending SSH_MSG_UNIMPLEMENTED for packet #{}", seq); return write(new SSHPacket(Message.UNIMPLEMENTED).putUInt32(seq)); }
@Override public TransportException chain(Throwable t) { if (t instanceof TransportException) return (TransportException) t; else return new TransportException(t); } };
/** * Returns advised number of bytes that should be made available in decoderBuffer before the method should be called * again. * * @return number of bytes needed before further decoding possible */ private int decode() throws SSHException { if (etm) { return decodeEtm(); } else { return decodeMte(); } }
@Override public void disconnect() { disconnect(DisconnectReason.BY_APPLICATION); }
@Override public void handle(Message msg, SSHPacket buf) throws SSHException { trans.sendUnimplemented(); }
@Override public void doKex() throws TransportException { kexer.startKex(true); }
/** * Add a {@link HostKeyVerifier} which will be invoked for verifying host key during connection establishment and * future key exchanges. * * @param verifier {@link HostKeyVerifier} instance */ public void addHostKeyVerifier(HostKeyVerifier verifier) { trans.addHostKeyVerifier(verifier); }
/** @return whether authenticated. */ public boolean isAuthenticated() { return trans.isAuthenticated(); }
@Override public void addHostKeyVerifier(HostKeyVerifier hkv) { kexer.addHostKeyVerifier(hkv); }
@Override public byte[] getSessionID() { return kexer.getSessionID(); }
public boolean isKexDone() { return kexer.isKexDone(); }
/** * Add a {@link AlgorithmsVerifier} which will be invoked for verifying negotiated algorithms. * * @param verifier {@link AlgorithmsVerifier} instance */ public void addAlgorithmsVerifier(AlgorithmsVerifier verifier) { trans.addAlgorithmsVerifier(verifier); }
@Override public void addAlgorithmsVerifier(AlgorithmsVerifier verifier) { kexer.addAlgorithmsVerifier(verifier); }
@SuppressWarnings("PMD.CompareObjectsWithEquals") private static void ensureReceivedMatchesExpected(Message got, Message expected) throws TransportException { if (got != expected) throw new TransportException(DisconnectReason.PROTOCOL_ERROR, "Was expecting " + expected); }
@Override public void disconnect(DisconnectReason reason) { disconnect(reason, ""); }