in sdk/host/src/main/java/org/apache/teaclave/javasdk/host/EnclaveFactory.java [71:108]
public static Enclave create(EnclaveType type) throws EnclaveCreatingException {
// create an enclave with specific enclave type.
try (MetricTraceContext trace = new MetricTraceContext(MetricTraceContext.LogPrefix.METRIC_LOG_ENCLAVE_CREATING_PATTERN)) {
Enclave enclave;
switch (type) {
case MOCK_IN_JVM:
enclave = new MockInJvmEnclave();
break;
case MOCK_IN_SVM:
enclave = new MockInSvmEnclave();
break;
case TEE_SDK:
// TEE_SDK only support hardware mode, not support simulate mode.
if (EnclaveConfigure.getInstance().isEnclaveDebuggable()) {
enclave = new TeeSdkEnclave(EnclaveDebug.DEBUG);
} else {
enclave = new TeeSdkEnclave(EnclaveDebug.RELEASE);
}
break;
case EMBEDDED_LIB_OS:
// EMBEDDED_LIB_OS only support hardware mode, not support simulate mode.
if (EmbeddedLibOSEnclaveConfigure.getInstance().isEnclaveDebuggable()) {
enclave = EmbeddedLibOSEnclave.getEmbeddedLibOSEnclaveInstance(EnclaveDebug.DEBUG);
} else {
enclave = EmbeddedLibOSEnclave.getEmbeddedLibOSEnclaveInstance(EnclaveDebug.RELEASE);
}
break;
case NONE:
default:
throw new EnclaveCreatingException("enclave type: " + type + " is not supported.");
}
trace.setEnclaveInfo(enclave.getEnclaveInfo());
EnclaveInfoManager.getEnclaveInfoManagerInstance().addEnclave(enclave);
return enclave;
} catch (IOException | MetricTraceLogWriteException e) {
throw new EnclaveCreatingException(e);
}
}