@Override public synchronized void setService(Service service) { if (service == null) service = nullService; log.debug("Setting active service to {}", service.getName()); this.service = service; }
@Override public void reqService(Service service) throws TransportException { serviceAccept.lock(); try { serviceAccept.clear(); sendServiceRequest(service.getName()); serviceAccept.await(timeoutMs, TimeUnit.MILLISECONDS); setService(service); } finally { serviceAccept.unlock(); } }
/** * This is where all incoming packets are handled. If they pertain to the transport layer, they * are handled here; otherwise they are delegated to the active service instance if any via {@link * Service#handle}. * * <p>Even among the transport layer specific packets, key exchange packets are delegated to * {@link KeyExchanger#handle}. * * <p>This method is called in the context of the {@link #reader} thread via {@link * Decoder#received} when a full packet has been decoded. * * @param msg the message identifer * @param buf buffer containg rest of the packet * @throws SSHException if an error occurs during handling (unrecoverable) */ @Override public void handle(Message msg, SSHPacket buf) throws SSHException { this.msg = msg; log.trace("Received packet {}", msg); if (msg.geq(50)) // not a transport layer packet service.handle(msg, buf); else if (msg.in(20, 21) || msg.in(30, 49)) // kex packet kexer.handle(msg, buf); else switch (msg) { case DISCONNECT: { gotDisconnect(buf); break; } case IGNORE: { log.debug("Received SSH_MSG_IGNORE"); break; } case UNIMPLEMENTED: { gotUnimplemented(buf); break; } case DEBUG: { gotDebug(buf); break; } case SERVICE_ACCEPT: { gotServiceAccept(); break; } case USERAUTH_BANNER: { log.debug("Received USERAUTH_BANNER"); break; } default: sendUnimplemented(); } }
@Override public String getNextServiceName() { return nextService.getName(); }