streamReader.readString());
if (type != null) {
if (!implementsInterface(type, serviceIntfName)) {
// The service does not implement the requested interface
throw new IncompatibleRemoteServiceException(
"Blocked attempt to access interface '" + serviceIntfName
+ "', which is not implemented by '" + printTypeName(type)
+ "'; this is either misconfiguration or a hack attempt");
}
}
SerializationPolicy serializationPolicy = streamReader.getSerializationPolicy();
Class<?> serviceIntf;
try {
serviceIntf = getClassFromSerializedName(serviceIntfName, classLoader);
if (!RemoteService.class.isAssignableFrom(serviceIntf)) {
// The requested interface is not a RemoteService interface
throw new IncompatibleRemoteServiceException(
"Blocked attempt to access interface '"
+ printTypeName(serviceIntf)
+ "', which doesn't extend RemoteService; this is either misconfiguration or a hack attempt");
}
} catch (ClassNotFoundException e) {
throw new IncompatibleRemoteServiceException(
"Could not locate requested interface '" + serviceIntfName
+ "' in default classloader", e);
}
String serviceMethodName = streamReader.readString();
int paramCount = streamReader.readInt();
if (paramCount > streamReader.getNumberOfTokens()) {
throw new IncompatibleRemoteServiceException(
"Invalid number of parameters");
}
Class<?>[] parameterTypes = new Class[paramCount];
for (int i = 0; i < parameterTypes.length; i++) {
String paramClassName = maybeDeobfuscate(streamReader,
streamReader.readString());
try {
parameterTypes[i] = getClassFromSerializedName(paramClassName,
classLoader);
} catch (ClassNotFoundException e) {
throw new IncompatibleRemoteServiceException("Parameter " + i
+ " of is of an unknown type '" + paramClassName + "'", e);
}
}
try {
Method method = serviceIntf.getMethod(serviceMethodName, parameterTypes);
Object[] parameterValues = new Object[parameterTypes.length];
for (int i = 0; i < parameterValues.length; i++) {
parameterValues[i] = streamReader.deserializeValue(parameterTypes[i]);
}
return new RPCRequest(method, parameterValues, rpcToken,
serializationPolicy, streamReader.getFlags());
} catch (NoSuchMethodException e) {
throw new IncompatibleRemoteServiceException(
formatMethodNotFoundErrorMessage(serviceIntf, serviceMethodName,
parameterTypes));
}
} catch (SerializationException ex) {
throw new IncompatibleRemoteServiceException(ex.getMessage(), ex);
}
}