in sdk/enclave/src/main/java/org/apache/teaclave/javasdk/enclave/agent/EnclaveAgent.java [85:115]
public void handle(HttpExchange exchange) throws IOException {
InputStream inputStream = exchange.getRequestBody();
byte[] payload = inputStream.readAllBytes();
inputStream.close();
SocketEnclaveInvocationContext context = null;
try {
context = (SocketEnclaveInvocationContext) SerializationHelper.deserialize(payload);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
switch (Objects.requireNonNull(context).getAgentServiceName()) {
case SocketEnclaveInvocationContext.SERVICE_LOADING:
writeBackResponse(exchange, service.loadService(context.getServiceHandler().getServiceInterfaceName()));
break;
case SocketEnclaveInvocationContext.SERVICE_UNLOADING:
writeBackResponse(exchange, service.unloadService(context.getServiceHandler()));
break;
case SocketEnclaveInvocationContext.METHOD_INVOCATION:
writeBackResponse(exchange, service.invokeMethod(context));
break;
case SocketEnclaveInvocationContext.REMOTE_ATTESTATION_GENERATE:
writeBackResponse(exchange, service.generateAttestationReport(context.getUserData()));
break;
case SocketEnclaveInvocationContext.ENCLAVE_DESTROY:
writeBackResponse(exchange, service.destroy());
break;
default:
}
}