diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ReferenceManifestRepository.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ReferenceManifestRepository.java index 8bad5f02..ecf941df 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ReferenceManifestRepository.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ReferenceManifestRepository.java @@ -17,6 +17,7 @@ import java.util.UUID; public interface ReferenceManifestRepository extends JpaRepository { ReferenceManifest findByHexDecHash(String hexDecHash); + ReferenceManifest findByEventLogHash(String eventLogHash); ReferenceManifest findByBase64Hash(String base64Hash); ReferenceManifest findByHexDecHashAndRimType(String hexDecHash, String rimType); @Query(value = "SELECT * FROM ReferenceManifest WHERE platformManufacturer = ?1 AND platformModel = ?2 AND rimType = 'Base'", nativeQuery = true) diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/SupplyChainValidationSummaryRepository.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/SupplyChainValidationSummaryRepository.java index 94131b5d..a8306057 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/SupplyChainValidationSummaryRepository.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/SupplyChainValidationSummaryRepository.java @@ -9,6 +9,5 @@ import java.util.UUID; @Repository public interface SupplyChainValidationSummaryRepository extends JpaRepository { - SupplyChainValidationSummary findByDevice(String device); SupplyChainValidationSummary findByDevice(Device device); } diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/Device.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/Device.java index 14b8592a..ff6e7c0f 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/Device.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/Device.java @@ -114,8 +114,8 @@ public class Device extends AbstractEntity { public String toString() { return String.format("Device Name: %s%nStatus: %s%nSummary: %s%n", - name, healthStatus.getStatus(), - supplyChainValidationStatus.toString()); + name, (healthStatus == null ? "N/A" : healthStatus.getStatus()), + (supplyChainValidationStatus == null ? "N/A" : supplyChainValidationStatus.toString())); } @Override diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/SupplyChainValidationService.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/SupplyChainValidationService.java index 0040a754..7f17908c 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/SupplyChainValidationService.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/SupplyChainValidationService.java @@ -11,10 +11,7 @@ import hirs.attestationca.persist.entity.manager.ReferenceDigestValueRepository; import hirs.attestationca.persist.entity.manager.ReferenceManifestRepository; import hirs.attestationca.persist.entity.manager.SupplyChainValidationRepository; import hirs.attestationca.persist.entity.manager.SupplyChainValidationSummaryRepository; -import hirs.attestationca.persist.entity.userdefined.Device; -import hirs.attestationca.persist.entity.userdefined.PolicySettings; -import hirs.attestationca.persist.entity.userdefined.SupplyChainValidation; -import hirs.attestationca.persist.entity.userdefined.SupplyChainValidationSummary; +import hirs.attestationca.persist.entity.userdefined.*; import hirs.attestationca.persist.entity.userdefined.certificate.ComponentResult; import hirs.attestationca.persist.entity.userdefined.certificate.EndorsementCredential; import hirs.attestationca.persist.entity.userdefined.certificate.PlatformCredential; @@ -29,6 +26,7 @@ import lombok.extern.log4j.Log4j2; import org.apache.logging.log4j.Level; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.yaml.snakeyaml.events.Event; import java.security.KeyStore; import java.util.ArrayList; @@ -322,8 +320,11 @@ public class SupplyChainValidationService { + "could be found for %s", deviceName)); } else { - eventLog = (EventLogMeasurements) referenceManifestRepository - .findByHexDecHash(sRim.getEventLogHash()); + ReferenceManifest manifest = referenceManifestRepository + .findByEventLogHash(sRim.getEventLogHash()); + if (manifest instanceof EventLogMeasurements) { + eventLog = (EventLogMeasurements)manifest; + } } if (eventLog == null) { fwStatus = new AppraisalStatus(FAIL,