diff --git a/pom.xml b/pom.xml index 1ba9023b..a2274d9b 100644 --- a/pom.xml +++ b/pom.xml @@ -285,6 +285,9 @@ org.apache.maven.plugins maven-surefire-plugin 3.2.5 + + -XX:+EnableDynamicAgentLoading + org.sonatype.plugins diff --git a/src/main/java/com/uid2/shared/secure/AttestationClientException.java b/src/main/java/com/uid2/shared/secure/AttestationClientException.java index ce43f61f..15096125 100644 --- a/src/main/java/com/uid2/shared/secure/AttestationClientException.java +++ b/src/main/java/com/uid2/shared/secure/AttestationClientException.java @@ -1,7 +1,12 @@ package com.uid2.shared.secure; -public class AttestationClientException extends AttestationException -{ +import lombok.Getter; + +@Getter +public class AttestationClientException extends AttestationException { + // This exception should be used when the error is as a result of invalid or bad data from the caller. + // It will result in a return code in the 400s + private final AttestationFailure attestationFailure; public AttestationClientException(Throwable cause) { @@ -14,7 +19,4 @@ public AttestationClientException(String message, AttestationFailure attestation this.attestationFailure = attestationFailure; } - public AttestationFailure getAttestationFailure() { - return this.attestationFailure; - } } diff --git a/src/main/java/com/uid2/shared/secure/AttestationException.java b/src/main/java/com/uid2/shared/secure/AttestationException.java index e6aa0077..175f0d8c 100644 --- a/src/main/java/com/uid2/shared/secure/AttestationException.java +++ b/src/main/java/com/uid2/shared/secure/AttestationException.java @@ -1,6 +1,10 @@ package com.uid2.shared.secure; public class AttestationException extends Exception { + // Used to indicate an error in the processing of Attestation due to internal server errors + // It will result in a response code of 500. + // If the error is as a result in invalid input from the caller, use the AttestationClientException + private final boolean isClientError; public boolean IsClientError() { diff --git a/src/main/java/com/uid2/shared/secure/AttestationResult.java b/src/main/java/com/uid2/shared/secure/AttestationResult.java index 2e3f239d..c4ee89ba 100644 --- a/src/main/java/com/uid2/shared/secure/AttestationResult.java +++ b/src/main/java/com/uid2/shared/secure/AttestationResult.java @@ -16,7 +16,7 @@ public AttestationResult(AttestationFailure reasonToFail) { } public AttestationResult(AttestationClientException exception) { - this.failure = AttestationFailure.UNKNOWN; + this.failure = exception.getAttestationFailure(); this.publicKey = null; this.enclaveId = "Failed attestation, enclave Id unknown"; this.attestationClientException = exception; diff --git a/src/main/java/com/uid2/shared/secure/BadFormatException.java b/src/main/java/com/uid2/shared/secure/BadFormatException.java deleted file mode 100644 index 731dd5df..00000000 --- a/src/main/java/com/uid2/shared/secure/BadFormatException.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.uid2.shared.secure; - -public class BadFormatException extends Exception { - public BadFormatException(Throwable cause) { - super(cause); - } - public BadFormatException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/src/main/java/com/uid2/shared/secure/NitroCoreAttestationService.java b/src/main/java/com/uid2/shared/secure/NitroCoreAttestationService.java index 5488d176..700379c9 100644 --- a/src/main/java/com/uid2/shared/secure/NitroCoreAttestationService.java +++ b/src/main/java/com/uid2/shared/secure/NitroCoreAttestationService.java @@ -20,7 +20,7 @@ public class NitroCoreAttestationService implements ICoreAttestationService { private final String attestationUrl; - private Set allowedEnclaveIds; + private final Set allowedEnclaveIds; private final ICertificateProvider certificateProvider; private static final Logger LOGGER = LoggerFactory.getLogger(NitroCoreAttestationService.class); @@ -37,6 +37,8 @@ public void attest(byte[] attestationRequest, byte[] publicKey, Handler