public void handleMessage(final Connection connection, final InputStream dataStream)
     throws IOException {
   final int cmd = readUnsignedByte(dataStream);
   if (cmd != Protocol.AUTH) {
     log.warnf(
         "Received unrecognized greeting code 0x%02x from %s",
         Integer.valueOf(cmd), connection.getPeerAddress());
     connection.close();
     return;
   }
   final int version = StreamUtils.readUnsignedByte(dataStream);
   if (version < 1) {
     log.warnf("Received connection with invalid version from %s", connection.getPeerAddress());
     connection.close();
     return;
   }
   final byte[] authCode = new byte[16];
   StreamUtils.readFully(dataStream, authCode);
   final ManagedProcess process = processController.getServerByAuthCode(authCode);
   if (process == null) {
     log.warnf(
         "Received connection with unknown credentials from %s", connection.getPeerAddress());
     StreamUtils.safeClose(connection);
     return;
   }
   log.tracef("Received authentic connection from %s", connection.getPeerAddress());
   connection.setMessageHandler(
       new ConnectedMessageHandler(processController, process.isInitial()));
   processController.addManagedConnection(connection);
   dataStream.close();
 }
 public void handleFailure(final Connection connection, final IOException e)
     throws IOException {
   log.tracef(e, "Received failure of connection");
   connection.close();
 }
 public void handleFailure(final Connection connection, final IOException e) throws IOException {
   log.tracef(e, "Received failure of connection");
   processController.removeManagedConnection(connection);
   connection.close();
 }