if (logger.isDebugEnabled()) {
logger.debug(MessageFormat.format("Processing message {0}:{1}",
received.getClass().getName(), received));
}
if (received instanceof Request) {
Request request = (Request) received;
try {
if (request instanceof PublicKeyRequest) {
serverState.transit(SState.PUBLIC_KEY_SENT);
clientState.transit(CState.PUBLIC_KEY_RECEIVED);
}
if (request instanceof ExchSharedKeyRequest) {
serverState.transit(SState.SHARED_KEY_RECEIVED);
clientState.transit(CState.SHARED_KEY_EXCHANGED);
}
if (request instanceof SendTextRequest) {
// Do nothing now
serverState.verify(SState.SHARED_KEY_RECEIVED);
}
} catch (IllegalStateException e) {
send(request.respondError(Response.ERROR_NO_AUTHORIZED));
return;
}
send(request.respond());
}
if (received instanceof Response) {
// Update State Machine
Response resp = (Response) received;
try {