ServerConnManagerImpl mgr = new ServerConnManagerImpl();
endpointInternals.setServerConnManager(ep, mgr);
ListenContextImpl lc = new ListenContextImpl();
ep.enumerateListenEndpoints(lc);
ServerConnection conn = mgr.getServerConnection();
try {
InputStream in = new BufferedInputStream(conn.getInputStream());
OutputStream out = new BufferedOutputStream(conn.getOutputStream());
InboundRequestHandle handle = conn.processRequestData(in, out);
conn.checkPermissions(handle);
checkIntegrity(conn.checkConstraints(handle, constraints));
if (checker != null) {
checker.checkClientSubject(getClientSubject(conn, handle));
}
byte[] hash = calcHandshakeHash(received, sent);
byte[] clientHash = new byte[hash.length];
new DataInputStream(in).readFully(clientHash);
if (!Arrays.equals(clientHash, hash)) {
throw new DiscoveryProtocolException(
"handshake hash mismatch");
}
Plaintext.writeUnicastResponse(out, response, context);
out.flush();
} finally {
conn.close();
lc.getListenHandle().close();
}
}