@Override
public void receiveRecord(RPCServerRequest rq) {
Logging.logMessage(Logging.LEVEL_DEBUG, this, "Dispatching request %s ...", rq.toString());
RPCHeader hdr = rq.getHeader();
if (hdr.getMessageType() != MessageType.RPC_REQUEST) {
rq.sendError(ErrorType.GARBAGE_ARGS, POSIX_ERROR_NONE,
"expected RPC request message type but got " +
hdr.getMessageType());
return;
}
RequestHeader rqHdr = hdr.getRequestHeader();
// check authentication
if (!rqHdr.hasAuthData() ||
!rqHdr.getAuthData().getAuthType().equals(AUTH_TYPE)) {
rq.sendError(ErrorType.AUTH_FAILED, POSIX_ERROR_NONE,
"only '"+AUTH_TYPE.toString()+"' is permitted");
return;
}
// check userCredentials
if (!rqHdr.hasUserCreds() ||
!rqHdr.getUserCreds().getUsername().equals(USER)) {
rq.sendError(ErrorType.AUTH_FAILED, POSIX_ERROR_NONE,
"expected request from user '" + USER + "' only");
return;
}
int interfaceId = hdr.getRequestHeader().getInterfaceId();
RequestHandler handler = handlers.get(interfaceId);
if (handler == null) {
rq.sendError(ErrorType.INVALID_PROC_ID, POSIX_ERROR_NONE,
"requested handler (#" + interfaceId +