From 4dd6de148265a9a271c65aee282d7c9b58db8d6a Mon Sep 17 00:00:00 2001 From: Cyrus <24922493+cyrus-dev@users.noreply.github.com> Date: Mon, 11 Mar 2024 20:46:51 -0400 Subject: [PATCH 01/18] Initial push. Minor changes that'll update the details page --- .../userdefined/certificate/ComponentResult.java | 4 +++- .../page/params/CertificateDetailsPageParams.java | 2 ++ .../webapp/WEB-INF/jsp/certificate-details.jsp | 15 +++++++++++---- .../webapp/WEB-INF/jsp/validation-reports.jsp | 1 + 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/ComponentResult.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/ComponentResult.java index db82b9ce4..3db685d7e 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/ComponentResult.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/ComponentResult.java @@ -15,6 +15,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Objects; +import java.util.UUID; /** * A component result is a DO to hold the status of a component validation status. This will @@ -45,7 +46,8 @@ public class ComponentResult extends ArchivableEntity { @Setter private boolean failedValidation; private String certificateType; - + @Setter + private UUID deviceInfo; private String issuerDN; private String certificateSerialNumber; private String boardSerialNumber; diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/params/CertificateDetailsPageParams.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/params/CertificateDetailsPageParams.java index c4c073821..7df3d2b26 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/params/CertificateDetailsPageParams.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/params/CertificateDetailsPageParams.java @@ -17,6 +17,7 @@ public class CertificateDetailsPageParams implements PageParams { private String id; private String type; + private String sessionId; /** * Constructor to set ID Certificate Details URL parameters. @@ -33,6 +34,7 @@ public CertificateDetailsPageParams(final String id) { public CertificateDetailsPageParams() { id = null; type = null; + sessionId = null; } /** diff --git a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/certificate-details.jsp b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/certificate-details.jsp index 93a49c3b3..3d8b3a959 100644 --- a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/certificate-details.jsp +++ b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/certificate-details.jsp @@ -26,10 +26,17 @@ - Platform Certificate - - - + + + Platform Certificate + + + + + + Platform Component Comparison + + Issued Attestation Certificates diff --git a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/validation-reports.jsp b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/validation-reports.jsp index f74fdbe8c..bf9bde4b2 100644 --- a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/validation-reports.jsp +++ b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/validation-reports.jsp @@ -185,6 +185,7 @@ var curValidation = full.validations[i]; var curResult = curValidation.validationResult; var curMessage = curValidation.message; + var session = full.provisionSessionId; if (curValidation.validationType === validation_type) { var unknownStatus = ''; From 06c0766b0b3a0a241e2a828f16cb1eabeed6f6fe Mon Sep 17 00:00:00 2001 From: Cyrus <24922493+cyrus-dev@users.noreply.github.com> Date: Wed, 13 Mar 2024 14:41:54 -0400 Subject: [PATCH 02/18] initial push to add a new page for component comparison --- .../hirs/attestationca/portal/page/Page.java | 4 ++ .../ComponentComparisonPageController.java | 55 +++++++++++++++++++ .../WEB-INF/jsp/certificate-details.jsp | 2 + 3 files changed, 61 insertions(+) create mode 100644 HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/Page.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/Page.java index 0c0a6a393..d366bae09 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/Page.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/Page.java @@ -40,6 +40,10 @@ public enum Page { * Non-menu page to display certificate. Reachable from all certificate pages. */ CERTIFICATE_DETAILS("Certificate Details", "", null, true, false, null, null), + /** + * Non-menu page to display certificate. Reachable from all certificate pages. + */ + COMPONENT_COMPARISON("Component Comparison", "", null, true, false, null, null), /** * Page to display registered devices. */ diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java new file mode 100644 index 000000000..3a5f58a8f --- /dev/null +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java @@ -0,0 +1,55 @@ +package hirs.attestationca.portal.page.controllers; + +import hirs.attestationca.persist.entity.manager.CertificateRepository; +import hirs.attestationca.persist.entity.manager.ComponentAttributeRepository; +import hirs.attestationca.persist.entity.manager.ComponentResultRepository; +import hirs.attestationca.portal.page.Page; +import hirs.attestationca.portal.page.PageController; +import hirs.attestationca.portal.page.PageMessages; +import hirs.attestationca.portal.page.params.NoPageParams; +import lombok.extern.log4j.Log4j2; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.servlet.ModelAndView; + +@Log4j2 +@Controller +@RequestMapping("/HIRS_AttestationCAPortal/portal/component-validation") +public class ComponentComparisonPageController extends PageController { + + private final CertificateRepository certificateRepository; + private final ComponentResultRepository componentResultRepository; + private final ComponentAttributeRepository componentAttributeRepository; + @Autowired + public ComponentComparisonPageController(final CertificateRepository certificateRepository, final ComponentResultRepository componentResultRepository, final ComponentAttributeRepository componentAttributeRepository) { + super(Page.COMPONENT_COMPARISON); + this.certificateRepository = certificateRepository; + this.componentResultRepository = componentResultRepository; + this.componentAttributeRepository = componentAttributeRepository; + } + + /** + * Returns the path for the view and the data model for the page. + * + * @param params The object to map url parameters into. + * @param model The data model for the request. Can contain data from + * redirect. + * @return the path for the view and data model for the page. + */ + @Override + @RequestMapping + public ModelAndView initPage(final NoPageParams params, final Model model) { + // get the basic information to render the page + ModelAndView mav = getBaseModelAndView(); + PageMessages messages = new PageMessages(); + + mav.addObject(MESSAGES_ATTRIBUTE, messages); + mav.addObject(INITIAL_DATA, data); + + return mav; + } +} + + diff --git a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/certificate-details.jsp b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/certificate-details.jsp index 3d8b3a959..c69728f11 100644 --- a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/certificate-details.jsp +++ b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/certificate-details.jsp @@ -34,6 +34,8 @@ + + Platform Component Comparison From 04023c5ed2180c3fb2ef4bcd7b8ad307dff0f78f Mon Sep 17 00:00:00 2001 From: Cyrus <24922493+cyrus-dev@users.noreply.github.com> Date: Fri, 15 Mar 2024 20:18:15 -0400 Subject: [PATCH 03/18] Updated some more code, commiting to merge in updates from main that are needed for this branch --- .../entity/manager/CertificateRepository.java | 1 + .../manager/ComponentInfoRepository.java | 6 + .../ComponentComparisonPageController.java | 107 +++++++++++++++++- .../params/CertificateDetailsPageParams.java | 3 +- .../WEB-INF/jsp/component-comparison.jsp | 83 ++++++++++++++ 5 files changed, 195 insertions(+), 5 deletions(-) create mode 100644 HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/CertificateRepository.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/CertificateRepository.java index 900a30a64..e39c42815 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/CertificateRepository.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/CertificateRepository.java @@ -25,6 +25,7 @@ public interface CertificateRepository extends JpaRepository List findByType(String dType); @Query(value = "SELECT * FROM Certificate where serialNumber = ?1 AND DTYPE = ?2", nativeQuery = true) Certificate findBySerialNumber(BigInteger serialNumber, String dType); + Certificate findByPlatformSerialAndSerialNumber(String platformSerial, BigInteger serialNumber); @Query(value = "SELECT * FROM Certificate where platformSerial = ?1 AND DTYPE = 'PlatformCredential'", nativeQuery = true) List byBoardSerialNumber(String boardSerialNumber); @Query(value = "SELECT * FROM Certificate where holderSerialNumber = ?1 AND DTYPE = 'PlatformCredential'", nativeQuery = true) diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ComponentInfoRepository.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ComponentInfoRepository.java index 67fec4f09..e84fd2b0e 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ComponentInfoRepository.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ComponentInfoRepository.java @@ -13,6 +13,12 @@ public interface ComponentInfoRepository extends JpaRepository findByDeviceName(String deviceName); + /** + * Query that retrieves device components by device name and order them + * @param deviceName string for the host name + * @return a list of device components + */ + List findByDeviceNameOrderByDeviceNameAsc(String deviceName); /** * Query that retrieves device components by device name and diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java index 3a5f58a8f..78811eadd 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java @@ -2,11 +2,16 @@ import hirs.attestationca.persist.entity.manager.CertificateRepository; import hirs.attestationca.persist.entity.manager.ComponentAttributeRepository; +import hirs.attestationca.persist.entity.manager.ComponentInfoRepository; import hirs.attestationca.persist.entity.manager.ComponentResultRepository; +import hirs.attestationca.persist.entity.userdefined.certificate.ComponentResult; +import hirs.attestationca.persist.entity.userdefined.certificate.PlatformCredential; +import hirs.attestationca.persist.entity.userdefined.certificate.attributes.ComponentAttributeResult; +import hirs.attestationca.persist.util.PciIds; import hirs.attestationca.portal.page.Page; import hirs.attestationca.portal.page.PageController; import hirs.attestationca.portal.page.PageMessages; -import hirs.attestationca.portal.page.params.NoPageParams; +import hirs.attestationca.portal.page.params.CertificateDetailsPageParams; import lombok.extern.log4j.Log4j2; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -14,19 +19,31 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; +import java.io.IOException; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.UUID; + @Log4j2 @Controller @RequestMapping("/HIRS_AttestationCAPortal/portal/component-validation") -public class ComponentComparisonPageController extends PageController { +public class ComponentComparisonPageController extends PageController { private final CertificateRepository certificateRepository; private final ComponentResultRepository componentResultRepository; + private final ComponentInfoRepository componentInfoRepository; private final ComponentAttributeRepository componentAttributeRepository; @Autowired - public ComponentComparisonPageController(final CertificateRepository certificateRepository, final ComponentResultRepository componentResultRepository, final ComponentAttributeRepository componentAttributeRepository) { + public ComponentComparisonPageController(final CertificateRepository certificateRepository, + final ComponentResultRepository componentResultRepository, + final ComponentInfoRepository componentInfoRepository, + final ComponentAttributeRepository componentAttributeRepository) { super(Page.COMPONENT_COMPARISON); this.certificateRepository = certificateRepository; this.componentResultRepository = componentResultRepository; + this.componentInfoRepository = componentInfoRepository; this.componentAttributeRepository = componentAttributeRepository; } @@ -40,16 +57,98 @@ public ComponentComparisonPageController(final CertificateRepository certificate */ @Override @RequestMapping - public ModelAndView initPage(final NoPageParams params, final Model model) { + public ModelAndView initPage(final CertificateDetailsPageParams params, final Model model) { // get the basic information to render the page ModelAndView mav = getBaseModelAndView(); PageMessages messages = new PageMessages(); + // Map with the certificate information + HashMap data = new HashMap<>(); mav.addObject(MESSAGES_ATTRIBUTE, messages); mav.addObject(INITIAL_DATA, data); + // Check if parameters were set + if (params.getId() == null) { + String typeError = "ID was not provided"; + messages.addError(typeError); + log.debug(typeError); + mav.addObject(MESSAGES_ATTRIBUTE, messages); + } else { + try { + UUID uuid = UUID.fromString(params.getId()); + data.putAll(getPlatformComponentInformation(uuid, params.getDeviceName(), + certificateRepository, componentResultRepository, + componentInfoRepository, + componentAttributeRepository)); + } catch (IllegalArgumentException iaEx) { + String uuidError = "Failed to parse ID from: " + params.getId(); + messages.addError(uuidError); + log.error(uuidError, iaEx); + } catch (IOException ioEx) { + log.error(ioEx); + } catch (Exception ex) { + log.error(ex); + } + + if (data.isEmpty()) { + String notFoundMessage = "Unable to find RIM with ID: " + params.getId(); + messages.addError(notFoundMessage); + log.warn(notFoundMessage); + mav.addObject(MESSAGES_ATTRIBUTE, messages); + } else { + mav.addObject(INITIAL_DATA, data); + } + } return mav; } + + /** + * Compiles and returns Platform Certificate component information. + * + * @param uuid ID for the certificate. + * @param certificateRepository the certificate manager for retrieving certs. + * @return a hash map with the endorsement certificate information. + * @throws IOException when parsing the certificate + * @throws IllegalArgumentException invalid argument on parsing the certificate + */ + public static HashMap getPlatformComponentInformation( + final UUID sessionId, final String deviceName, + final CertificateRepository certificateRepository, + final ComponentResultRepository componentResultRepository, + final ComponentInfoRepository componentInfoRepository, + final ComponentAttributeRepository componentAttributeRepository) + throws IllegalArgumentException, IOException { + HashMap data = new HashMap<>(); + List componentResults = new ArrayList<>(); + List attributeResults = componentAttributeRepository.findByProvisionSessionId(sessionId); + if (!attributeResults.isEmpty()) { + List tempIdList = new ArrayList<>(); + attributeResults.stream().forEach((dbObject) -> { + if (!tempIdList.contains(dbObject.getComponentId())) { + tempIdList.add(dbObject.getComponentId()); + } + }); + componentResults.addAll(componentResultRepository.findAllById(tempIdList)); + PlatformCredential platformCredential = certificateRepository.findByPlatformSerialAndSerialNumber(componentResults.get(0).getBoardSerialNumber(), BigInteger.valueOf(Long.parseLong(componentResults.get(0).getCertificateSerialNumber())); + + if (platformCredential != null) { + data.put("certificateId", platformCredential.getId()); + data.put("certificateSerialNumber", platformCredential.getSerialNumber()); + data.put("platformManufacturer", platformCredential.getManufacturer()); + data.put("platformModel", platformCredential.getModel()); + } + if (PciIds.DB.isReady()) { + componentResults = PciIds.translateResults(componentResults); + } + data.put("componentResults", componentResults); + data.put("componentInfos", componentInfoRepository.findByDeviceNameOrderByDeviceNameAsc(deviceName)); + } else { + String notFoundMessage = "Unable to find Platform Certificate " + + "with ID: " + uuid; + log.error(notFoundMessage); + } + return data; + } } diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/params/CertificateDetailsPageParams.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/params/CertificateDetailsPageParams.java index 7df3d2b26..da800b5f1 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/params/CertificateDetailsPageParams.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/params/CertificateDetailsPageParams.java @@ -18,6 +18,7 @@ public class CertificateDetailsPageParams implements PageParams { private String id; private String type; private String sessionId; + private String deviceName; /** * Constructor to set ID Certificate Details URL parameters. @@ -35,6 +36,7 @@ public CertificateDetailsPageParams() { id = null; type = null; sessionId = null; + deviceName = null; } /** @@ -57,5 +59,4 @@ public String toString() { + "type: " + type + "}"; } - } diff --git a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp new file mode 100644 index 000000000..f6529330c --- /dev/null +++ b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp @@ -0,0 +1,83 @@ +<%@page contentType="text/html" pageEncoding="UTF-8"%> + +<%-- JSP TAGS --%> +<%@taglib prefix="c" uri="jakarta.tags.core" %> +<%@taglib prefix="spring" uri="http://www.springframework.org/tags"%> +<%@taglib prefix="form" uri="http://www.springframework.org/tags/form"%> +<%@taglib prefix="fn" uri="jakarta.tags.functions"%> +<%@taglib prefix="my" tagdir="/WEB-INF/tags"%> + +<%--CONTENT--%> + + + + + + + + + Platform Component Failure Comparison + + +
+
+
+
Support Component Objects
+
+ +
Device: ${initialData.hostName} +
+
+ +
Platform Certificate: ${initialData.certificateFileName} +
+
+
+
+
+
+
+
Client Log
+ + + +
+
+
Failed Event Digest:
+
+
+ PCR Index: ${lEvent.getPcrIndex()}
+ Digest: ${lEvent.getEventDigestStr()}
+ Event Content: ${lEvent.getEventContentStr()} +
+
+
+
+
+ Expected Events from RIM DB:
+ ${lEvent.getEventTypeString()} +
+
+ + + + +
+
PCR Index: ${event.getPcrIndex()}
+
Digest: ${event.getEventDigestStr()}
+
Event Content: ${event.getEventContentStr()}
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
\ No newline at end of file From e0de63aa030d97b40913ec3b6acf1354dd3a3cab Mon Sep 17 00:00:00 2001 From: Cyrus <24922493+cyrus-dev@users.noreply.github.com> Date: Mon, 18 Mar 2024 13:11:41 -0400 Subject: [PATCH 04/18] Fixed parameter for the controller --- .../controllers/ComponentComparisonPageController.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java index 78811eadd..06f686734 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java @@ -129,7 +129,9 @@ public static HashMap getPlatformComponentInformation( } }); componentResults.addAll(componentResultRepository.findAllById(tempIdList)); - PlatformCredential platformCredential = certificateRepository.findByPlatformSerialAndSerialNumber(componentResults.get(0).getBoardSerialNumber(), BigInteger.valueOf(Long.parseLong(componentResults.get(0).getCertificateSerialNumber())); + PlatformCredential platformCredential = (PlatformCredential) certificateRepository + .findByPlatformSerialAndSerialNumber(componentResults.get(0).getBoardSerialNumber(), + BigInteger.valueOf(Long.parseLong(componentResults.get(0).getCertificateSerialNumber()))); if (platformCredential != null) { data.put("certificateId", platformCredential.getId()); @@ -143,8 +145,8 @@ public static HashMap getPlatformComponentInformation( data.put("componentResults", componentResults); data.put("componentInfos", componentInfoRepository.findByDeviceNameOrderByDeviceNameAsc(deviceName)); } else { - String notFoundMessage = "Unable to find Platform Certificate " - + "with ID: " + uuid; + String notFoundMessage = "No components attribute comparison found " + + "with ID: " + sessionId; log.error(notFoundMessage); } return data; From 32b10260fdec3b53f51042cf65c5ecb113f40a68 Mon Sep 17 00:00:00 2001 From: Cyrus <24922493+cyrus-dev@users.noreply.github.com> Date: Mon, 18 Mar 2024 14:57:05 -0400 Subject: [PATCH 05/18] Updated how the platform certificate is accessed --- .../entity/manager/CertificateRepository.java | 1 - .../manager/PlatformCertificateRepository.java | 2 ++ .../ComponentComparisonPageController.java | 15 ++++++++------- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/CertificateRepository.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/CertificateRepository.java index e39c42815..900a30a64 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/CertificateRepository.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/CertificateRepository.java @@ -25,7 +25,6 @@ public interface CertificateRepository extends JpaRepository List findByType(String dType); @Query(value = "SELECT * FROM Certificate where serialNumber = ?1 AND DTYPE = ?2", nativeQuery = true) Certificate findBySerialNumber(BigInteger serialNumber, String dType); - Certificate findByPlatformSerialAndSerialNumber(String platformSerial, BigInteger serialNumber); @Query(value = "SELECT * FROM Certificate where platformSerial = ?1 AND DTYPE = 'PlatformCredential'", nativeQuery = true) List byBoardSerialNumber(String boardSerialNumber); @Query(value = "SELECT * FROM Certificate where holderSerialNumber = ?1 AND DTYPE = 'PlatformCredential'", nativeQuery = true) diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/PlatformCertificateRepository.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/PlatformCertificateRepository.java index 690d82ca4..fb5803643 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/PlatformCertificateRepository.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/PlatformCertificateRepository.java @@ -6,6 +6,7 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; +import java.math.BigInteger; import java.util.List; import java.util.UUID; @@ -15,4 +16,5 @@ public interface PlatformCertificateRepository extends JpaRepository findByArchiveFlag(boolean archiveFlag); Page findByArchiveFlag(boolean archiveFlag, Pageable pageable); List findByDeviceId(UUID deviceId); + PlatformCredential findByPlatformSerialAndSerialNumber(String platformSerial, BigInteger serialNumber); } diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java index 06f686734..1a10d7520 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java @@ -4,6 +4,7 @@ import hirs.attestationca.persist.entity.manager.ComponentAttributeRepository; import hirs.attestationca.persist.entity.manager.ComponentInfoRepository; import hirs.attestationca.persist.entity.manager.ComponentResultRepository; +import hirs.attestationca.persist.entity.manager.PlatformCertificateRepository; import hirs.attestationca.persist.entity.userdefined.certificate.ComponentResult; import hirs.attestationca.persist.entity.userdefined.certificate.PlatformCredential; import hirs.attestationca.persist.entity.userdefined.certificate.attributes.ComponentAttributeResult; @@ -28,20 +29,20 @@ @Log4j2 @Controller -@RequestMapping("/HIRS_AttestationCAPortal/portal/component-validation") +@RequestMapping("/HIRS_AttestationCAPortal/portal/component-comparison") public class ComponentComparisonPageController extends PageController { - private final CertificateRepository certificateRepository; + private final PlatformCertificateRepository platformCertificateRepository; private final ComponentResultRepository componentResultRepository; private final ComponentInfoRepository componentInfoRepository; private final ComponentAttributeRepository componentAttributeRepository; @Autowired - public ComponentComparisonPageController(final CertificateRepository certificateRepository, + public ComponentComparisonPageController(final PlatformCertificateRepository platformCertificateRepository, final ComponentResultRepository componentResultRepository, final ComponentInfoRepository componentInfoRepository, final ComponentAttributeRepository componentAttributeRepository) { super(Page.COMPONENT_COMPARISON); - this.certificateRepository = certificateRepository; + this.platformCertificateRepository = platformCertificateRepository; this.componentResultRepository = componentResultRepository; this.componentInfoRepository = componentInfoRepository; this.componentAttributeRepository = componentAttributeRepository; @@ -76,7 +77,7 @@ public ModelAndView initPage(final CertificateDetailsPageParams params, final Mo try { UUID uuid = UUID.fromString(params.getId()); data.putAll(getPlatformComponentInformation(uuid, params.getDeviceName(), - certificateRepository, componentResultRepository, + platformCertificateRepository, componentResultRepository, componentInfoRepository, componentAttributeRepository)); } catch (IllegalArgumentException iaEx) { @@ -113,7 +114,7 @@ public ModelAndView initPage(final CertificateDetailsPageParams params, final Mo */ public static HashMap getPlatformComponentInformation( final UUID sessionId, final String deviceName, - final CertificateRepository certificateRepository, + final PlatformCertificateRepository platformCertificateRepository, final ComponentResultRepository componentResultRepository, final ComponentInfoRepository componentInfoRepository, final ComponentAttributeRepository componentAttributeRepository) @@ -129,7 +130,7 @@ public static HashMap getPlatformComponentInformation( } }); componentResults.addAll(componentResultRepository.findAllById(tempIdList)); - PlatformCredential platformCredential = (PlatformCredential) certificateRepository + PlatformCredential platformCredential = platformCertificateRepository .findByPlatformSerialAndSerialNumber(componentResults.get(0).getBoardSerialNumber(), BigInteger.valueOf(Long.parseLong(componentResults.get(0).getCertificateSerialNumber()))); From a0c2b227f04aff67ad5d34a3ad654bb01c8c38f5 Mon Sep 17 00:00:00 2001 From: Cyrus <24922493+cyrus-dev@users.noreply.github.com> Date: Tue, 19 Mar 2024 08:35:19 -0400 Subject: [PATCH 06/18] Updated certain parameters to easily identify and pull information from the DB for the component comparison page --- .../entity/manager/ComponentAttributeRepository.java | 2 +- .../entity/userdefined/SupplyChainValidationSummary.java | 8 ++++++-- .../certificate/attributes/ComponentAttributeResult.java | 3 ++- .../persist/service/SupplyChainValidationService.java | 4 ++-- .../attestationca/persist/service/ValidationService.java | 2 +- .../validation/CertificateAttributeScvValidator.java | 2 +- .../persist/validation/CredentialValidator.java | 2 +- .../controllers/ComponentComparisonPageController.java | 7 +++---- .../src/main/webapp/WEB-INF/jsp/component-comparison.jsp | 9 +++++---- .../src/main/webapp/WEB-INF/jsp/error.jsp | 4 ++-- .../src/main/webapp/WEB-INF/jsp/validation-reports.jsp | 8 ++++++-- 11 files changed, 30 insertions(+), 21 deletions(-) diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ComponentAttributeRepository.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ComponentAttributeRepository.java index bfa101174..544506d43 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ComponentAttributeRepository.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ComponentAttributeRepository.java @@ -20,7 +20,7 @@ public interface ComponentAttributeRepository extends JpaRepository findByProvisionSessionId(UUID provisionSessionId); + List findByProvisionSessionId(String provisionSessionId); /** * Query to look up Attribute Results based on the component id and the session id. diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/SupplyChainValidationSummary.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/SupplyChainValidationSummary.java index 8793fe37e..b2020d12e 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/SupplyChainValidationSummary.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/SupplyChainValidationSummary.java @@ -60,7 +60,9 @@ public class SupplyChainValidationSummary extends ArchivableEntity { private final Set validations; @Column - private UUID provisionSessionId; + private String provisionSessionId; + @Column + private String deviceName; /** * Default constructor necessary for Hibernate. @@ -70,6 +72,7 @@ protected SupplyChainValidationSummary() { overallValidationResult = AppraisalStatus.Status.FAIL; validations = Collections.emptySet(); this.message = Strings.EMPTY; + this.deviceName = Strings.EMPTY; } /** @@ -190,9 +193,10 @@ public static SupplyChainValidationSummary.Selector select( */ public SupplyChainValidationSummary(final Device device, final Collection validations, - final UUID provisionSessionId) { + final String provisionSessionId) { this(device, validations); this.provisionSessionId = provisionSessionId; + this.deviceName = this.device.getName(); } /** diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/attributes/ComponentAttributeResult.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/attributes/ComponentAttributeResult.java index 79b0ad528..12b19d2bd 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/attributes/ComponentAttributeResult.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/attributes/ComponentAttributeResult.java @@ -6,6 +6,7 @@ import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; +import org.hibernate.annotations.JdbcTypeCode; import java.util.UUID; @@ -21,7 +22,7 @@ public class ComponentAttributeResult extends ArchivableEntity { private UUID componentId; @Setter - private UUID provisionSessionId; + private String provisionSessionId; private String expectedValue; private String actualValue; 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 d9c667064..929867478 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 @@ -55,7 +55,7 @@ public class SupplyChainValidationService { private CertificateRepository certificateRepository; private SupplyChainValidationRepository supplyChainValidationRepository; private SupplyChainValidationSummaryRepository supplyChainValidationSummaryRepository; - private UUID provisionSessionId; + private String provisionSessionId; /** * Constructor. @@ -109,7 +109,7 @@ public SupplyChainValidationSummary validateSupplyChain(final EndorsementCredent final Device device, final List componentInfos) { boolean acceptExpiredCerts = getPolicySettings().isExpiredCertificateValidationEnabled(); - provisionSessionId = UUID.randomUUID(); + provisionSessionId = UUID.randomUUID().toString(); PlatformCredential baseCredential = null; SupplyChainValidation platformScv = null; SupplyChainValidation basePlatformScv = null; diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/ValidationService.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/ValidationService.java index 84b229f00..fa22c2d06 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/ValidationService.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/ValidationService.java @@ -109,7 +109,7 @@ public static SupplyChainValidation evaluatePCAttributesStatus( final ComponentResultRepository componentResultRepository, final ComponentAttributeRepository componentAttributeRepository, final List componentInfos, - final UUID provisionSessionId) { + final String provisionSessionId) { final SupplyChainValidation.ValidationType validationType = SupplyChainValidation.ValidationType.PLATFORM_CREDENTIAL_ATTRIBUTES; diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/CertificateAttributeScvValidator.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/CertificateAttributeScvValidator.java index 2fdf50be8..b296f32e9 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/CertificateAttributeScvValidator.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/CertificateAttributeScvValidator.java @@ -208,7 +208,7 @@ public static AppraisalStatus validatePlatformCredentialAttributesV2p0( final ComponentResultRepository componentResultRepository, final ComponentAttributeRepository componentAttributeRepository, final List componentInfos, - final UUID provisionSessionId) { + final String provisionSessionId) { boolean passesValidation = true; StringBuilder resultMessage = new StringBuilder(); diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/CredentialValidator.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/CredentialValidator.java index 5917e1308..3337f8fc9 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/CredentialValidator.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/CredentialValidator.java @@ -177,7 +177,7 @@ public static AppraisalStatus validatePlatformCredentialAttributes( final ComponentResultRepository componentResultRepository, final ComponentAttributeRepository componentAttributeRepository, final List componentInfos, - final UUID provisionSessionId) { + final String provisionSessionId) { final String baseErrorMessage = "Can't validate platform credential attributes without "; String message; if (platformCredential == null) { diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java index 1a10d7520..27225e04e 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java @@ -1,6 +1,5 @@ package hirs.attestationca.portal.page.controllers; -import hirs.attestationca.persist.entity.manager.CertificateRepository; import hirs.attestationca.persist.entity.manager.ComponentAttributeRepository; import hirs.attestationca.persist.entity.manager.ComponentInfoRepository; import hirs.attestationca.persist.entity.manager.ComponentResultRepository; @@ -68,14 +67,14 @@ public ModelAndView initPage(final CertificateDetailsPageParams params, final Mo mav.addObject(MESSAGES_ATTRIBUTE, messages); mav.addObject(INITIAL_DATA, data); // Check if parameters were set - if (params.getId() == null) { + if (params.getSessionId() == null) { String typeError = "ID was not provided"; messages.addError(typeError); log.debug(typeError); mav.addObject(MESSAGES_ATTRIBUTE, messages); } else { try { - UUID uuid = UUID.fromString(params.getId()); + String uuid = params.getSessionId(); data.putAll(getPlatformComponentInformation(uuid, params.getDeviceName(), platformCertificateRepository, componentResultRepository, componentInfoRepository, @@ -113,7 +112,7 @@ public ModelAndView initPage(final CertificateDetailsPageParams params, final Mo * @throws IllegalArgumentException invalid argument on parsing the certificate */ public static HashMap getPlatformComponentInformation( - final UUID sessionId, final String deviceName, + final String sessionId, final String deviceName, final PlatformCertificateRepository platformCertificateRepository, final ComponentResultRepository componentResultRepository, final ComponentInfoRepository componentInfoRepository, diff --git a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp index f6529330c..78d957cc4 100644 --- a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp +++ b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp @@ -13,10 +13,11 @@ - - - - Platform Component Failure Comparison + Platform Component Failure Comparison + + + +
diff --git a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/error.jsp b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/error.jsp index 88bb88771..47771d782 100644 --- a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/error.jsp +++ b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/error.jsp @@ -9,7 +9,7 @@ Error - 404 - +
Exception Message:
+
from URL ->
\ No newline at end of file diff --git a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/validation-reports.jsp b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/validation-reports.jsp index bf9bde4b2..022068c75 100644 --- a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/validation-reports.jsp +++ b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/validation-reports.jsp @@ -185,7 +185,7 @@ var curValidation = full.validations[i]; var curResult = curValidation.validationResult; var curMessage = curValidation.message; - var session = full.provisionSessionId; + var deviceName = full.deviceName if (curValidation.validationType === validation_type) { var unknownStatus = ''; @@ -209,12 +209,16 @@ switch (validation_type) { case "PLATFORM_CREDENTIAL": - case "PLATFORM_CREDENTIAL_ATTRIBUTES": case "ENDORSEMENT_CREDENTIAL": html += ''; break; + case "PLATFORM_CREDENTIAL_ATTRIBUTES": + html += ''; + break; } } From e0ce4b2f052100ddd31c7390e3a985f2347daf80 Mon Sep 17 00:00:00 2001 From: Cyrus <24922493+cyrus-dev@users.noreply.github.com> Date: Tue, 19 Mar 2024 10:59:01 -0400 Subject: [PATCH 07/18] This update fixes the passing of parameters from the validation page to the new comparison page. --- .../manager/ComponentInfoRepository.java | 3 +- .../SupplyChainValidationSummary.java | 2 + .../SupplyChainCredentialValidatorTest.java | 98 +++++++++---------- .../ComponentComparisonPageController.java | 34 ++++--- .../WEB-INF/jsp/component-comparison.jsp | 11 ++- .../webapp/WEB-INF/jsp/validation-reports.jsp | 17 ++-- 6 files changed, 93 insertions(+), 72 deletions(-) diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ComponentInfoRepository.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ComponentInfoRepository.java index e84fd2b0e..fccf3d61c 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ComponentInfoRepository.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ComponentInfoRepository.java @@ -15,10 +15,11 @@ public interface ComponentInfoRepository extends JpaRepository findByDeviceName(String deviceName); /** * Query that retrieves device components by device name and order them + * by component class * @param deviceName string for the host name * @return a list of device components */ - List findByDeviceNameOrderByDeviceNameAsc(String deviceName); + List findByDeviceNameOrderByComponentClassAsc(String deviceName); /** * Query that retrieves device components by device name and diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/SupplyChainValidationSummary.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/SupplyChainValidationSummary.java index b2020d12e..d3b5eda76 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/SupplyChainValidationSummary.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/SupplyChainValidationSummary.java @@ -59,8 +59,10 @@ public class SupplyChainValidationSummary extends ArchivableEntity { targetEntity = SupplyChainValidation.class, orphanRemoval = true) private final Set validations; + @Getter @Column private String provisionSessionId; + @Getter @Column private String deviceName; diff --git a/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/validation/SupplyChainCredentialValidatorTest.java b/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/validation/SupplyChainCredentialValidatorTest.java index 8570c0678..1c66cb135 100644 --- a/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/validation/SupplyChainCredentialValidatorTest.java +++ b/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/validation/SupplyChainCredentialValidatorTest.java @@ -345,7 +345,7 @@ public final void validateIntelPlatformCredentialAttributes() AppraisalStatus result = CredentialValidator.validatePlatformCredentialAttributes(pc, deviceInfoReport, ec, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.PASS, result.getAppStatus()); assertEquals(SupplyChainCredentialValidator.PLATFORM_ATTRIBUTES_VALID, result.getMessage()); @@ -377,7 +377,7 @@ public final void validatePlatformCredentialWithDeviceBaseboard() AppraisalStatus result = CredentialValidator.validatePlatformCredentialAttributes(pc, deviceInfoReport, ec, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.PASS, result.getAppStatus()); assertEquals(SupplyChainCredentialValidator.PLATFORM_ATTRIBUTES_VALID, result.getMessage()); @@ -408,7 +408,7 @@ public final void validatePlatformCredentialWithDeviceChassis() AppraisalStatus result = CredentialValidator.validatePlatformCredentialAttributes(pc, deviceInfoReport, ec, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.PASS, result.getAppStatus()); assertEquals(SupplyChainCredentialValidator.PLATFORM_ATTRIBUTES_VALID, result.getMessage()); @@ -441,7 +441,7 @@ public final void validatePlatformCredentialWithDeviceSystemSerialNumber() AppraisalStatus result = CredentialValidator.validatePlatformCredentialAttributes(pc, deviceInfoReport, ec, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.PASS, result.getAppStatus()); assertEquals(SupplyChainCredentialValidator.PLATFORM_ATTRIBUTES_VALID, result.getMessage()); @@ -473,7 +473,7 @@ public final void validatePlatformCredentialCombinedWithChassisSerialNumbersMatc AppraisalStatus result = CredentialValidator.validatePlatformCredentialAttributes(pc, deviceInfoReport, ec, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.PASS, result.getAppStatus()); assertEquals(SupplyChainCredentialValidator.PLATFORM_ATTRIBUTES_VALID, result.getMessage()); @@ -504,7 +504,7 @@ public final void validatePlatformCredentialCombinedWithBaseboardSerialNumbersMa AppraisalStatus result = CredentialValidator.validatePlatformCredentialAttributes(pc, deviceInfoReport, ec, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.PASS, result.getAppStatus()); assertEquals(SupplyChainCredentialValidator.PLATFORM_ATTRIBUTES_VALID, result.getMessage()); @@ -535,7 +535,7 @@ public final void validatePlatformCredentialCombinedWithSystemSerialNumbersMatch AppraisalStatus result = CredentialValidator.validatePlatformCredentialAttributes(pc, deviceInfoReport, ec, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.PASS, result.getAppStatus()); assertEquals(SupplyChainCredentialValidator.PLATFORM_ATTRIBUTES_VALID, result.getMessage()); @@ -570,7 +570,7 @@ public final void validatePlatformCredentialWithNoDeviceSerialNumbers() AppraisalStatus result = CredentialValidator.validatePlatformCredentialAttributes( pc, deviceInfoReport, ec, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.FAIL, result.getAppStatus()); assertEquals(expectedMessage, result.getMessage()); } @@ -603,7 +603,7 @@ public final void validatePlatformCredentialCombinedWithNoMatchedDeviceSerialNum AppraisalStatus result = CredentialValidator.validatePlatformCredentialAttributes( pc, deviceInfoReport, ec, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.FAIL, result.getAppStatus()); assertEquals(expectedMessage, result.getMessage()); } @@ -984,7 +984,7 @@ public final void verifyPlatformCredentialNullDeviceInfoReport() AppraisalStatus result = CredentialValidator.validatePlatformCredentialAttributes(pc, null, ec, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.FAIL, result.getAppStatus()); assertEquals(expectedMessage, result.getMessage()); } @@ -1241,7 +1241,7 @@ public final void testValidatePlatformCredentialAttributesV2p0NoComponentsPass() AppraisalStatus appraisalStatus = CertificateAttributeScvValidator .validatePlatformCredentialAttributesV2p0(platformCredential, deviceInfoReport, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.PASS, appraisalStatus.getAppStatus()); assertEquals(SupplyChainCredentialValidator.PLATFORM_ATTRIBUTES_VALID, @@ -1261,7 +1261,7 @@ public final void testValidatePlatformCredentialAttributesV2p0WithComponentsPass AppraisalStatus appraisalStatus = CertificateAttributeScvValidator .validatePlatformCredentialAttributesV2p0(platformCredential, deviceInfoReport, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.PASS, appraisalStatus.getAppStatus()); assertEquals(SupplyChainCredentialValidator.PLATFORM_ATTRIBUTES_VALID, appraisalStatus.getMessage()); @@ -1283,7 +1283,7 @@ public final void testValPCAttributesV2p0WithComponentsPassPlatformSerialWithSys AppraisalStatus appraisalStatus = CertificateAttributeScvValidator .validatePlatformCredentialAttributesV2p0(platformCredential, deviceInfoReport, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.PASS, appraisalStatus.getAppStatus()); assertEquals(SupplyChainCredentialValidator.PLATFORM_ATTRIBUTES_VALID, appraisalStatus.getMessage()); @@ -1307,7 +1307,7 @@ public final void testValPCAttributesV2p0WithComponentsPassPlatformSerialWithSys AppraisalStatus appraisalStatus = CertificateAttributeScvValidator .validatePlatformCredentialAttributesV2p0(platformCredential, deviceInfoReport, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.FAIL, appraisalStatus.getAppStatus()); } @@ -1324,7 +1324,7 @@ public final void testValidatePlatformCredentialAttributesV2p0RequiredFieldsNull AppraisalStatus result = CertificateAttributeScvValidator .validatePlatformCredentialAttributesV2p0(platformCredential, deviceInfoReport, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.PASS, result.getAppStatus()); assertEquals(SupplyChainCredentialValidator.PLATFORM_ATTRIBUTES_VALID, result.getMessage()); @@ -1332,7 +1332,7 @@ public final void testValidatePlatformCredentialAttributesV2p0RequiredFieldsNull result = CertificateAttributeScvValidator .validatePlatformCredentialAttributesV2p0(platformCredential, deviceInfoReport, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.FAIL, result.getAppStatus()); assertEquals("Platform manufacturer did not match\n", result.getMessage()); @@ -1340,7 +1340,7 @@ public final void testValidatePlatformCredentialAttributesV2p0RequiredFieldsNull result = CertificateAttributeScvValidator .validatePlatformCredentialAttributesV2p0(platformCredential, deviceInfoReport, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.PASS, result.getAppStatus()); assertEquals(SupplyChainCredentialValidator.PLATFORM_ATTRIBUTES_VALID, result.getMessage()); @@ -1348,7 +1348,7 @@ public final void testValidatePlatformCredentialAttributesV2p0RequiredFieldsNull result = CertificateAttributeScvValidator .validatePlatformCredentialAttributesV2p0(platformCredential, deviceInfoReport, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(result.getAppStatus(), AppraisalStatus.Status.FAIL); assertEquals(result.getMessage(), "Platform model did not match\n"); @@ -1356,7 +1356,7 @@ public final void testValidatePlatformCredentialAttributesV2p0RequiredFieldsNull result = CertificateAttributeScvValidator .validatePlatformCredentialAttributesV2p0(platformCredential, deviceInfoReport, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.PASS, result.getAppStatus()); assertEquals(SupplyChainCredentialValidator.PLATFORM_ATTRIBUTES_VALID, result.getMessage()); @@ -1364,13 +1364,13 @@ public final void testValidatePlatformCredentialAttributesV2p0RequiredFieldsNull result = CertificateAttributeScvValidator .validatePlatformCredentialAttributesV2p0(platformCredential, deviceInfoReport, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.PASS, result.getAppStatus()); platformCredential = setupMatchingPlatformCredential(deviceInfoReport); result = CertificateAttributeScvValidator .validatePlatformCredentialAttributesV2p0(platformCredential, deviceInfoReport, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.PASS, result.getAppStatus()); assertEquals(SupplyChainCredentialValidator.PLATFORM_ATTRIBUTES_VALID, result.getMessage()); @@ -1378,7 +1378,7 @@ public final void testValidatePlatformCredentialAttributesV2p0RequiredFieldsNull result = CertificateAttributeScvValidator .validatePlatformCredentialAttributesV2p0(platformCredential, deviceInfoReport, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.PASS, result.getAppStatus()); assertEquals(SupplyChainCredentialValidator.PLATFORM_ATTRIBUTES_VALID, result.getMessage()); @@ -1387,7 +1387,7 @@ public final void testValidatePlatformCredentialAttributesV2p0RequiredFieldsNull result = CertificateAttributeScvValidator .validatePlatformCredentialAttributesV2p0(platformCredential, deviceInfoReport, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.PASS, result.getAppStatus()); assertEquals(SupplyChainCredentialValidator.PLATFORM_ATTRIBUTES_VALID, result.getMessage()); @@ -1398,7 +1398,7 @@ public final void testValidatePlatformCredentialAttributesV2p0RequiredFieldsNull result = CertificateAttributeScvValidator .validatePlatformCredentialAttributesV2p0(platformCredential, deviceInfoReport, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.FAIL, result.getAppStatus()); assertEquals("Component manufacturer is empty\n", result.getMessage()); @@ -1406,7 +1406,7 @@ public final void testValidatePlatformCredentialAttributesV2p0RequiredFieldsNull result = CertificateAttributeScvValidator .validatePlatformCredentialAttributesV2p0(platformCredential, deviceInfoReport, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.PASS, result.getAppStatus()); assertEquals(SupplyChainCredentialValidator.PLATFORM_ATTRIBUTES_VALID, result.getMessage()); @@ -1416,7 +1416,7 @@ public final void testValidatePlatformCredentialAttributesV2p0RequiredFieldsNull result = CertificateAttributeScvValidator .validatePlatformCredentialAttributesV2p0(platformCredential, deviceInfoReport, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.FAIL, result.getAppStatus()); assertEquals("Component model is empty\n", result.getMessage()); @@ -1436,7 +1436,7 @@ public final void testValidatePlatformCredentialAttributesV2p0RequiredFieldsEmpt AppraisalStatus result = CertificateAttributeScvValidator .validatePlatformCredentialAttributesV2p0(platformCredential, deviceInfoReport, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.PASS, result.getAppStatus()); assertEquals(SupplyChainCredentialValidator.PLATFORM_ATTRIBUTES_VALID, result.getMessage()); @@ -1444,7 +1444,7 @@ public final void testValidatePlatformCredentialAttributesV2p0RequiredFieldsEmpt result = CertificateAttributeScvValidator .validatePlatformCredentialAttributesV2p0(platformCredential, deviceInfoReport, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.FAIL, result.getAppStatus()); assertEquals("Platform manufacturer did not match\n", result.getMessage()); @@ -1452,7 +1452,7 @@ public final void testValidatePlatformCredentialAttributesV2p0RequiredFieldsEmpt result = CertificateAttributeScvValidator .validatePlatformCredentialAttributesV2p0(platformCredential, deviceInfoReport, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.PASS, result.getAppStatus()); assertEquals(SupplyChainCredentialValidator.PLATFORM_ATTRIBUTES_VALID, result.getMessage()); @@ -1460,7 +1460,7 @@ public final void testValidatePlatformCredentialAttributesV2p0RequiredFieldsEmpt result = CertificateAttributeScvValidator .validatePlatformCredentialAttributesV2p0(platformCredential, deviceInfoReport, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.FAIL, result.getAppStatus()); assertEquals("Platform model did not match\n", result.getMessage()); @@ -1468,7 +1468,7 @@ public final void testValidatePlatformCredentialAttributesV2p0RequiredFieldsEmpt result = CertificateAttributeScvValidator .validatePlatformCredentialAttributesV2p0(platformCredential, deviceInfoReport, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.PASS, result.getAppStatus()); assertEquals(SupplyChainCredentialValidator.PLATFORM_ATTRIBUTES_VALID, result.getMessage()); @@ -1476,7 +1476,7 @@ public final void testValidatePlatformCredentialAttributesV2p0RequiredFieldsEmpt result = CertificateAttributeScvValidator .validatePlatformCredentialAttributesV2p0(platformCredential, deviceInfoReport, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.FAIL, result.getAppStatus()); assertEquals("Platform serial did not match\n", result.getMessage()); @@ -1484,7 +1484,7 @@ public final void testValidatePlatformCredentialAttributesV2p0RequiredFieldsEmpt result = CertificateAttributeScvValidator .validatePlatformCredentialAttributesV2p0(platformCredential, deviceInfoReport, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.PASS, result.getAppStatus()); assertEquals(SupplyChainCredentialValidator.PLATFORM_ATTRIBUTES_VALID, result.getMessage()); @@ -1492,7 +1492,7 @@ public final void testValidatePlatformCredentialAttributesV2p0RequiredFieldsEmpt result = CertificateAttributeScvValidator .validatePlatformCredentialAttributesV2p0(platformCredential, deviceInfoReport, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.FAIL, result.getAppStatus()); assertEquals("Platform version did not match\n", result.getMessage()); @@ -1500,7 +1500,7 @@ public final void testValidatePlatformCredentialAttributesV2p0RequiredFieldsEmpt result = CertificateAttributeScvValidator .validatePlatformCredentialAttributesV2p0(platformCredential, deviceInfoReport, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.PASS, result.getAppStatus()); assertEquals(SupplyChainCredentialValidator.PLATFORM_ATTRIBUTES_VALID, result.getMessage()); @@ -1511,7 +1511,7 @@ public final void testValidatePlatformCredentialAttributesV2p0RequiredFieldsEmpt result = CertificateAttributeScvValidator .validatePlatformCredentialAttributesV2p0(platformCredential, deviceInfoReport, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.FAIL, result.getAppStatus()); assertEquals("Component manufacturer is empty\n" + "There are unmatched components:\n" @@ -1523,7 +1523,7 @@ public final void testValidatePlatformCredentialAttributesV2p0RequiredFieldsEmpt result = CertificateAttributeScvValidator .validatePlatformCredentialAttributesV2p0(platformCredential, deviceInfoReport, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.PASS, result.getAppStatus()); assertEquals(SupplyChainCredentialValidator.PLATFORM_ATTRIBUTES_VALID, result.getMessage()); @@ -1533,7 +1533,7 @@ public final void testValidatePlatformCredentialAttributesV2p0RequiredFieldsEmpt result = CertificateAttributeScvValidator .validatePlatformCredentialAttributesV2p0(platformCredential, deviceInfoReport, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.FAIL, result.getAppStatus()); assertEquals("Component model is empty\n", result.getMessage()); } @@ -1552,7 +1552,7 @@ public final void testValidatePlatformCredentialAttributesV2p0MissingComponentIn AppraisalStatus result = CertificateAttributeScvValidator .validatePlatformCredentialAttributesV2p0(platformCredential, deviceInfoReport, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.PASS, result.getAppStatus()); assertEquals(SupplyChainCredentialValidator.PLATFORM_ATTRIBUTES_VALID, result.getMessage()); @@ -1574,7 +1574,7 @@ public final void testValidatePlatformCredentialAttributesV2p0MissingComponentIn result = CertificateAttributeScvValidator .validatePlatformCredentialAttributesV2p0(platformCredential, deviceInfoReport, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.FAIL, result.getAppStatus()); assertEquals("There are unmatched components:\n" + "Manufacturer=ACME, Model=TNT, Serial=2, Revision=1.1;\n", @@ -1600,7 +1600,7 @@ public final void testValidatePlatformCredentialAttributesV2p0ExtraComponentInDe AppraisalStatus result = CertificateAttributeScvValidator .validatePlatformCredentialAttributesV2p0(platformCredential, deviceInfoReport, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.PASS, result.getAppStatus()); assertEquals(SupplyChainCredentialValidator.PLATFORM_ATTRIBUTES_VALID, result.getMessage()); @@ -1608,7 +1608,7 @@ public final void testValidatePlatformCredentialAttributesV2p0ExtraComponentInDe result = CertificateAttributeScvValidator .validatePlatformCredentialAttributesV2p0(platformCredential, deviceInfoReport, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.PASS, result.getAppStatus()); assertEquals(SupplyChainCredentialValidator.PLATFORM_ATTRIBUTES_VALID, result.getMessage()); @@ -1628,7 +1628,7 @@ public final void testValidatePlatformCredentialAttributesV2p0RequiredComponentF AppraisalStatus result = CertificateAttributeScvValidator .validatePlatformCredentialAttributesV2p0(platformCredential, deviceInfoReport, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.PASS, result.getAppStatus()); assertEquals(SupplyChainCredentialValidator.PLATFORM_ATTRIBUTES_VALID, result.getMessage()); @@ -1641,7 +1641,7 @@ public final void testValidatePlatformCredentialAttributesV2p0RequiredComponentF result = CertificateAttributeScvValidator .validatePlatformCredentialAttributesV2p0(platformCredential, deviceInfoReport, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.FAIL, result.getAppStatus()); assertEquals("Component manufacturer is empty\n" + "There are unmatched components:\n" @@ -1653,7 +1653,7 @@ public final void testValidatePlatformCredentialAttributesV2p0RequiredComponentF result = CertificateAttributeScvValidator .validatePlatformCredentialAttributesV2p0(platformCredential, deviceInfoReport, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.PASS, result.getAppStatus()); assertEquals(SupplyChainCredentialValidator.PLATFORM_ATTRIBUTES_VALID, result.getMessage()); @@ -1665,7 +1665,7 @@ public final void testValidatePlatformCredentialAttributesV2p0RequiredComponentF result = CertificateAttributeScvValidator .validatePlatformCredentialAttributesV2p0(platformCredential, deviceInfoReport, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.FAIL, result.getAppStatus()); assertEquals("Component model is empty\n", result.getMessage()); } @@ -1695,7 +1695,7 @@ public final void testValidatePlatformCredentialAttributesV2p0RequiredComponentN AppraisalStatus result = CertificateAttributeScvValidator .validatePlatformCredentialAttributesV2p0(platformCredential, deviceInfoReport, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.PASS, result.getAppStatus()); assertEquals(SupplyChainCredentialValidator.PLATFORM_ATTRIBUTES_VALID, result.getMessage()); @@ -1726,7 +1726,7 @@ public final void testValidatePlatformCredentialAttributesV2p0RequiredComponentN AppraisalStatus result = CertificateAttributeScvValidator .validatePlatformCredentialAttributesV2p0(platformCredential, deviceInfoReport, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.PASS, result.getAppStatus()); assertEquals(SupplyChainCredentialValidator.PLATFORM_ATTRIBUTES_VALID, result.getMessage()); @@ -1759,7 +1759,7 @@ public final void testValPlatCredentialAttributesV2p0RequiredComponentNoSerialOr AppraisalStatus result = CertificateAttributeScvValidator .validatePlatformCredentialAttributesV2p0(platformCredential, deviceInfoReport, null, null, - Collections.emptyList(), UUID.randomUUID()); + Collections.emptyList(), UUID.randomUUID().toString()); assertEquals(AppraisalStatus.Status.PASS, result.getAppStatus()); assertEquals(SupplyChainCredentialValidator.PLATFORM_ATTRIBUTES_VALID, result.getMessage()); diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java index 27225e04e..a4c222e0e 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java @@ -120,30 +120,40 @@ public static HashMap getPlatformComponentInformation( throws IllegalArgumentException, IOException { HashMap data = new HashMap<>(); List componentResults = new ArrayList<>(); - List attributeResults = componentAttributeRepository.findByProvisionSessionId(sessionId); + PlatformCredential platformCredential = null; + List attributeResults = componentAttributeRepository + .findByProvisionSessionId(sessionId); if (!attributeResults.isEmpty()) { - List tempIdList = new ArrayList<>(); - attributeResults.stream().forEach((dbObject) -> { - if (!tempIdList.contains(dbObject.getComponentId())) { - tempIdList.add(dbObject.getComponentId()); - } - }); - componentResults.addAll(componentResultRepository.findAllById(tempIdList)); - PlatformCredential platformCredential = platformCertificateRepository - .findByPlatformSerialAndSerialNumber(componentResults.get(0).getBoardSerialNumber(), - BigInteger.valueOf(Long.parseLong(componentResults.get(0).getCertificateSerialNumber()))); + ComponentResult componentResult = componentResultRepository.findById(attributeResults.get(0).getComponentId()).get(); + platformCredential = platformCertificateRepository + .findByPlatformSerialAndSerialNumber(componentResult.getBoardSerialNumber(), + BigInteger.valueOf(Long.parseLong( + componentResult.getCertificateSerialNumber()))); if (platformCredential != null) { data.put("certificateId", platformCredential.getId()); data.put("certificateSerialNumber", platformCredential.getSerialNumber()); data.put("platformManufacturer", platformCredential.getManufacturer()); data.put("platformModel", platformCredential.getModel()); + } else { + log.error("Can't find platform certificate " + + componentResults.get(0).getBoardSerialNumber()); + return data; } + List tempIdList = new ArrayList<>(); + attributeResults.stream().forEach((dbObject) -> { + if (!tempIdList.contains(dbObject.getComponentId())) { + tempIdList.add(dbObject.getComponentId()); + } + }); + componentResultRepository + .findByBoardSerialNumber(platformCredential.getPlatformSerial()); if (PciIds.DB.isReady()) { componentResults = PciIds.translateResults(componentResults); } data.put("componentResults", componentResults); - data.put("componentInfos", componentInfoRepository.findByDeviceNameOrderByDeviceNameAsc(deviceName)); + data.put("componentInfos", componentInfoRepository + .findByDeviceNameOrderByComponentClassAsc(deviceName)); } else { String notFoundMessage = "No components attribute comparison found " + "with ID: " + sessionId; diff --git a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp index 78d957cc4..4466765f8 100644 --- a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp +++ b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp @@ -47,9 +47,14 @@
Failed Event Digest:
- PCR Index: ${lEvent.getPcrIndex()}
- Digest: ${lEvent.getEventDigestStr()}
- Event Content: ${lEvent.getEventContentStr()} + Manufacturer: ${componentResult.getManufacturer()}
+ Model: ${componentResult.getModel()}
+ + Serial Number: ${component.getSerialNumber()}
+
+ + Revision: ${component.getRevisionNumber()}
+
diff --git a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/validation-reports.jsp b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/validation-reports.jsp index 022068c75..e5a48284b 100644 --- a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/validation-reports.jsp +++ b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/validation-reports.jsp @@ -208,17 +208,20 @@ } switch (validation_type) { - case "PLATFORM_CREDENTIAL": case "ENDORSEMENT_CREDENTIAL": + case "PLATFORM_CREDENTIAL": + case "PLATFORM_CREDENTIAL_ATTRIBUTES": + if (curMessage.includes("attributes")) { + html += ''; + break; + } else { html += ''; - break; - case "PLATFORM_CREDENTIAL_ATTRIBUTES": - html += ''; - break; + break; + } } } From 5a4d2e92afd1a79ccde4d3b220b6bb683cdc854c Mon Sep 17 00:00:00 2001 From: Cyrus <24922493+cyrus-dev@users.noreply.github.com> Date: Tue, 19 Mar 2024 20:19:26 -0400 Subject: [PATCH 08/18] The changes upaded the comparison page --- .../ComponentComparisonPageController.java | 6 ++-- .../WEB-INF/jsp/component-comparison.jsp | 32 +++++++------------ 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java index a4c222e0e..919e43a2f 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java @@ -65,7 +65,6 @@ public ModelAndView initPage(final CertificateDetailsPageParams params, final Mo HashMap data = new HashMap<>(); mav.addObject(MESSAGES_ATTRIBUTE, messages); - mav.addObject(INITIAL_DATA, data); // Check if parameters were set if (params.getSessionId() == null) { String typeError = "ID was not provided"; @@ -123,6 +122,8 @@ public static HashMap getPlatformComponentInformation( PlatformCredential platformCredential = null; List attributeResults = componentAttributeRepository .findByProvisionSessionId(sessionId); + + data.put("deviceName", deviceName); if (!attributeResults.isEmpty()) { ComponentResult componentResult = componentResultRepository.findById(attributeResults.get(0).getComponentId()).get(); platformCredential = platformCertificateRepository @@ -132,6 +133,7 @@ public static HashMap getPlatformComponentInformation( if (platformCredential != null) { data.put("certificateId", platformCredential.getId()); + data.put("boardNumber", platformCredential.getPlatformSerial()); data.put("certificateSerialNumber", platformCredential.getSerialNumber()); data.put("platformManufacturer", platformCredential.getManufacturer()); data.put("platformModel", platformCredential.getModel()); @@ -146,7 +148,7 @@ public static HashMap getPlatformComponentInformation( tempIdList.add(dbObject.getComponentId()); } }); - componentResultRepository + componentResults = componentResultRepository .findByBoardSerialNumber(platformCredential.getPlatformSerial()); if (PciIds.DB.isReady()) { componentResults = PciIds.translateResults(componentResults); diff --git a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp index 4466765f8..d40b65325 100644 --- a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp +++ b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp @@ -25,12 +25,12 @@
Support Component Objects
- -
Device: ${initialData.hostName} + +
Device: ${initialData.deviceName}
-
@@ -38,7 +38,7 @@
-
Client Log
+
Certificate Component
@@ -49,12 +49,8 @@
Manufacturer: ${componentResult.getManufacturer()}
Model: ${componentResult.getModel()}
- - Serial Number: ${component.getSerialNumber()}
-
- - Revision: ${component.getRevisionNumber()}
-
+ Serial Number: ${componentResult.getSerialNumber()}
+ Revision: ${componentResult.getRevisionNumber()}
@@ -64,17 +60,11 @@ ${lEvent.getEventTypeString()}
- - - - -
-
PCR Index: ${event.getPcrIndex()}
-
Digest: ${event.getEventDigestStr()}
-
Event Content: ${event.getEventContentStr()}
-
-
-
+ + Manufacturer: ${componentInfos.getComponentManufacturer()}
+ Model: ${componentInfos.getComponentModel()}
+ Serial Number: ${componentInfos.getComponentSerial()}
+ Revision: ${componentInfos.getComponentRevision()}
From 6308dad6eed12f937e373908de1c505a6b00fa02 Mon Sep 17 00:00:00 2001 From: Cyrus <24922493+cyrus-dev@users.noreply.github.com> Date: Wed, 20 Mar 2024 21:06:32 -0400 Subject: [PATCH 09/18] Continued formating of the jsp --- .../ComponentComparisonPageController.java | 4 + .../WEB-INF/jsp/component-comparison.jsp | 95 +++++++++---------- 2 files changed, 47 insertions(+), 52 deletions(-) diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java index 919e43a2f..b69381eb1 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java @@ -7,6 +7,7 @@ import hirs.attestationca.persist.entity.userdefined.certificate.ComponentResult; import hirs.attestationca.persist.entity.userdefined.certificate.PlatformCredential; import hirs.attestationca.persist.entity.userdefined.certificate.attributes.ComponentAttributeResult; +import hirs.attestationca.persist.entity.userdefined.info.ComponentInfo; import hirs.attestationca.persist.util.PciIds; import hirs.attestationca.portal.page.Page; import hirs.attestationca.portal.page.PageController; @@ -153,9 +154,12 @@ public static HashMap getPlatformComponentInformation( if (PciIds.DB.isReady()) { componentResults = PciIds.translateResults(componentResults); } + List componentInfos = componentInfoRepository + .findByDeviceNameOrderByComponentClassAsc(deviceName); data.put("componentResults", componentResults); data.put("componentInfos", componentInfoRepository .findByDeviceNameOrderByComponentClassAsc(deviceName)); + data.put("totalSize", Math.max(componentResults.size(), componentInfos.size())); } else { String notFoundMessage = "No components attribute comparison found " + "with ID: " + sessionId; diff --git a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp index d40b65325..978c8d22a 100644 --- a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp +++ b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp @@ -22,58 +22,49 @@
-
-
Support Component Objects
-
- -
Device: ${initialData.deviceName} -
-
- -
Platform Certificate: ${initialData.boardNumber} -
-
-
-
-
-
-
-
Certificate Component
- - - -
-
-
Failed Event Digest:
-
-
- Manufacturer: ${componentResult.getManufacturer()}
- Model: ${componentResult.getModel()}
- Serial Number: ${componentResult.getSerialNumber()}
- Revision: ${componentResult.getRevisionNumber()}
-
-
-
-
-
- Expected Events from RIM DB:
- ${lEvent.getEventTypeString()} -
-
- - Manufacturer: ${componentInfos.getComponentManufacturer()}
- Model: ${componentInfos.getComponentModel()}
- Serial Number: ${componentInfos.getComponentSerial()}
- Revision: ${componentInfos.getComponentRevision()}
-
-
-
- -
-
-
-
+
+
Support Component Objects
+
+ +
Device: ${initialData.deviceName}
+
+ +
Platform Certificate:  + + ${initialData.boardNumber} + +
+
+
+
+
+
+
+
Certificate Component
+
+
+
Device Components
+
+
+ +
+ Manufacturer: ${componentResults.get(i).getManufacturer()}
+ Model: ${componentResults.get(i).getModel()}
+ Serial Number: ${componentResults.get(i).getSerialNumber()}
+ Revision: ${componentResults.get(i).getRevisionNumber()}
+
+
+ Manufacturer: ${componentInfos.get(i).getComponentManufacturer()}
+ Model: ${componentInfos.get(i).getComponentModel()}
+ Serial Number: ${componentInfos.get(i).getComponentSerial()}
+ Revision: ${componentInfos.get(i).getComponentRevision()}
+
+
+
+
+
-
+
+
\ No newline at end of file From d907c910c745f9a187a53e67b5eff8d404742b4a Mon Sep 17 00:00:00 2001 From: Cyrus <24922493+cyrus-dev@users.noreply.github.com> Date: Thu, 21 Mar 2024 12:51:56 -0400 Subject: [PATCH 10/18] Updated the comparison page, the layout is now looking better. --- .../manager/ComponentResultRepository.java | 7 +++ .../userdefined/info/ComponentInfo.java | 2 + .../attestationca/persist/util/PciIds.java | 35 ++++++++++++ .../CertificatePageController.java | 8 ++- .../ComponentComparisonPageController.java | 12 ++-- .../WEB-INF/jsp/component-comparison.jsp | 56 ++++++++++++------- 6 files changed, 92 insertions(+), 28 deletions(-) diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ComponentResultRepository.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ComponentResultRepository.java index ab4ae5920..277d5fc58 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ComponentResultRepository.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ComponentResultRepository.java @@ -17,6 +17,13 @@ public interface ComponentResultRepository extends JpaRepository findByBoardSerialNumber(String boardSerialNumber); + /** + * Query based on the device serial number. + * @param boardSerialNumber variable holding the device serial number + * @return a list of component result. + */ + List findByBoardSerialNumberOrderByComponentClassValueAsc(String boardSerialNumber); + /** * Query based on certificate serial number and device serial number. * @param certificateSerialNumber certificate specific serial number diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/info/ComponentInfo.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/info/ComponentInfo.java index 1e9e9c7ba..6db4f6f82 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/info/ComponentInfo.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/info/ComponentInfo.java @@ -10,6 +10,7 @@ import jakarta.xml.bind.annotation.XmlElement; import lombok.AccessLevel; import lombok.Getter; +import lombok.Setter; import lombok.NoArgsConstructor; import lombok.extern.log4j.Log4j2; import org.apache.commons.lang3.StringUtils; @@ -23,6 +24,7 @@ @Log4j2 @Entity @Getter +@Setter @NoArgsConstructor(access = AccessLevel.PROTECTED) @DiscriminatorColumn(name = "componentTypeEnum", discriminatorType = DiscriminatorType.STRING) public class ComponentInfo extends ArchivableEntity { diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/util/PciIds.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/util/PciIds.java index f2c682a34..1efeb3775 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/util/PciIds.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/util/PciIds.java @@ -8,6 +8,7 @@ import hirs.attestationca.persist.entity.userdefined.certificate.attributes.ComponentClass; import hirs.attestationca.persist.entity.userdefined.certificate.attributes.ComponentIdentifier; import hirs.attestationca.persist.entity.userdefined.certificate.attributes.V2.ComponentIdentifierV2; +import hirs.attestationca.persist.entity.userdefined.info.ComponentInfo; import lombok.AccessLevel; import lombok.NoArgsConstructor; @@ -135,6 +136,23 @@ public static List translateResults(final List return newList; } + /** + * Iterate through all components and translate PCI hardware IDs as necessary. It will only + * translate ComponentInfo objects as it relies on Component Class information. + * @param componentInfos List of ComponentInfos. + * @return the translated list of ComponentInfos. + */ + public static List translateDeviceComponentInfo(final List componentInfos) { + List newList = new ArrayList<>(); + if (componentInfos != null && !componentInfos.isEmpty()) { + for (final ComponentInfo componentInfo : componentInfos) { + newList.add(translateDeviceComponentInfo(componentInfo)); + } + } + + return newList; + } + /** * Translate Vendor and Device IDs, if found, in ComponentIdentifierV2 objects. * It will only translate ID values, any other value will pass through. @@ -188,6 +206,23 @@ public static ComponentResult translateResult(final ComponentResult componentRes return newComponent; } + /** + * Translate Vendor and Device IDs, if found, in ComponentInfo objects. + * It will only translate ID values, any other value will pass through. + * @param componentInfo ComponentInfo object. + * @return the translated ComponentInfo object. + */ + public static ComponentInfo translateDeviceComponentInfo(final ComponentInfo componentInfo) { + ComponentInfo newComponent = null; + if (componentInfo != null) { + newComponent = componentInfo; + newComponent.setComponentManufacturer(translateVendor(componentInfo.getComponentManufacturer())); + newComponent.setComponentModel(translateDevice(componentInfo.getComponentManufacturer(), + componentInfo.getComponentModel())); + } + return newComponent; + } + /** * Look up the vendor name from the PCI IDs list, if the input string contains an ID. * If any part of this fails, return the original manufacturer value. diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/CertificatePageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/CertificatePageController.java index 4b3f00d39..256334eac 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/CertificatePageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/CertificatePageController.java @@ -211,7 +211,7 @@ public DataTableResponse getTableData( log.debug("Handling list request: " + input); // attempt to get the column property based on the order index. - String orderColumnName = input.getOrderColumnName(); + String orderColumnName = input.getOrderColumnName();//input.getSearch(); log.debug("Ordering on column: " + orderColumnName); // check that the alert is not archived and that it is in the specified report @@ -274,7 +274,8 @@ public void modify(final CriteriaQuery criteriaQuery) { return new DataTableResponse<>(records, input); } else if (certificateType.equals(ENDORSEMENTCREDENTIAL)) { FilteredRecordsList records = new FilteredRecordsList<>(); - org.springframework.data.domain.Page pagedResult = this.endorsementCredentialRepository.findByArchiveFlag(false, paging); + org.springframework.data.domain.Page pagedResult + = this.endorsementCredentialRepository.findByArchiveFlag(false, paging); if (pagedResult.hasContent()) { records.addAll(pagedResult.getContent()); @@ -289,7 +290,8 @@ public void modify(final CriteriaQuery criteriaQuery) { return new DataTableResponse<>(records, input); } else if (certificateType.equals(TRUSTCHAIN)) { FilteredRecordsList records = new FilteredRecordsList<>(); - org.springframework.data.domain.Page pagedResult = this.caCredentialRepository.findByArchiveFlag(false, paging); + org.springframework.data.domain.Page pagedResult + = this.caCredentialRepository.findByArchiveFlag(false, paging); if (pagedResult.hasContent()) { records.addAll(pagedResult.getContent()); diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java index b69381eb1..c0b7970f2 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java @@ -150,15 +150,17 @@ public static HashMap getPlatformComponentInformation( } }); componentResults = componentResultRepository - .findByBoardSerialNumber(platformCredential.getPlatformSerial()); + .findByBoardSerialNumberOrderByComponentClassValueAsc( + platformCredential.getPlatformSerial()); + List componentInfos = componentInfoRepository + .findByDeviceNameOrderByComponentClassAsc(deviceName); if (PciIds.DB.isReady()) { componentResults = PciIds.translateResults(componentResults); + componentInfos = PciIds.translateDeviceComponentInfo(componentInfos); } - List componentInfos = componentInfoRepository - .findByDeviceNameOrderByComponentClassAsc(deviceName); + data.put("componentResults", componentResults); - data.put("componentInfos", componentInfoRepository - .findByDeviceNameOrderByComponentClassAsc(deviceName)); + data.put("componentInfos", componentInfos); data.put("totalSize", Math.max(componentResults.size(), componentInfos.size())); } else { String notFoundMessage = "No components attribute comparison found " diff --git a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp index 978c8d22a..bff274754 100644 --- a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp +++ b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp @@ -23,7 +23,7 @@
-
Support Component Objects
+
Platform Information
Device: ${initialData.deviceName} @@ -39,28 +39,44 @@

-
-
-
Certificate Component
-
-
-
Device Components
-
-
- -
- Manufacturer: ${componentResults.get(i).getManufacturer()}
- Model: ${componentResults.get(i).getModel()}
- Serial Number: ${componentResults.get(i).getSerialNumber()}
- Revision: ${componentResults.get(i).getRevisionNumber()}
+ +
+
+
+
Certificate Component
+ +
+ +
+ Manufacturer: ${componentResult.getManufacturer()}
+ Model: ${componentResult.getModel()}
+ Serial Number: ${componentResult.getSerialNumber()}
+ Revision: ${componentResult.getRevisionNumber()}
+
+
+
+
+
Device Components
+
- Manufacturer: ${componentInfos.get(i).getComponentManufacturer()}
- Model: ${componentInfos.get(i).getComponentModel()}
- Serial Number: ${componentInfos.get(i).getComponentSerial()}
- Revision: ${componentInfos.get(i).getComponentRevision()}
+ +
+ Manufacturer: ${componentInfo.getComponentManufacturer()}
+ Model: ${componentInfo.getComponentModel()}
+ Serial Number: ${componentInfo.getComponentSerial()}
+ Revision: ${componentInfo.getComponentRevision()}
+
+
- +
From 29ef08e5e9f1af29d2acb6b5c7a16c6d9656e8eb Mon Sep 17 00:00:00 2001 From: Cyrus <24922493+cyrus-dev@users.noreply.github.com> Date: Thu, 21 Mar 2024 15:59:22 -0400 Subject: [PATCH 11/18] These changes highlight matched and unmatched --- .../attributes/ComponentAttributeResult.java | 4 + .../userdefined/info/ComponentInfo.java | 2 + .../CertificateAttributeScvValidator.java | 41 +++++----- .../ComponentComparisonPageController.java | 74 +++++++++++++++---- .../WEB-INF/jsp/component-comparison.jsp | 24 +++++- 5 files changed, 104 insertions(+), 41 deletions(-) diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/attributes/ComponentAttributeResult.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/attributes/ComponentAttributeResult.java index 12b19d2bd..a689e6a94 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/attributes/ComponentAttributeResult.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/attributes/ComponentAttributeResult.java @@ -21,6 +21,7 @@ public class ComponentAttributeResult extends ArchivableEntity { private UUID componentId; + private UUID deviceComponentId; @Setter private String provisionSessionId; private String expectedValue; @@ -29,13 +30,16 @@ public class ComponentAttributeResult extends ArchivableEntity { /** * Default constructor that populates the expected and actual values. * @param componentId id associated with component result + * @param deviceComponentId id associated with the device component * @param expectedValue platform certificate value * @param actualValue paccor value from the device */ public ComponentAttributeResult(final UUID componentId, + final UUID deviceComponentId, final String expectedValue, final String actualValue) { this.componentId = componentId; + this.deviceComponentId = deviceComponentId; this.expectedValue = expectedValue; this.actualValue = actualValue; } diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/info/ComponentInfo.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/info/ComponentInfo.java index 6db4f6f82..a4545ec79 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/info/ComponentInfo.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/info/ComponentInfo.java @@ -55,6 +55,8 @@ public class ComponentInfo extends ArchivableEntity { @XmlElement @Column private String componentClass; + @Column + private String componentClassStr; /** * Base constructor for children. diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/CertificateAttributeScvValidator.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/CertificateAttributeScvValidator.java index b296f32e9..40d6542f8 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/CertificateAttributeScvValidator.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/CertificateAttributeScvValidator.java @@ -337,6 +337,7 @@ public static AppraisalStatus validatePlatformCredentialAttributesV2p0( remainingComponentResults.add(componentResult); } } + List failedComponents = new ArrayList<>(); if (!remainingComponentResults.isEmpty()) { // continue down the options, move to a different method. // create component class mapping to component info @@ -369,23 +370,23 @@ public static AppraisalStatus validatePlatformCredentialAttributesV2p0( componentAttributeResult.setProvisionSessionId(provisionSessionId); componentAttributeRepository.save(componentAttributeResult); fieldValidation &= componentAttributeResult.checkMatchedStatus(); + if (!componentAttributeResult.checkMatchedStatus()) { + numOfAttributes++; + failedComponents.add(componentAttributeResult.getComponentId()); + } } - numOfAttributes = attributeResults.size(); } StringBuilder additionalInfo = new StringBuilder(); - if (!remainingComponentResults.isEmpty()) { - resultMessage.append(String.format("There are %d components not matched%n", - remainingComponentResults.size())); - resultMessage.append(String.format("\twith %d total attributes mismatched.", - numOfAttributes)); - } - passesValidation &= fieldValidation; if (passesValidation) { return new AppraisalStatus(PASS, PLATFORM_ATTRIBUTES_VALID); } else { + resultMessage.append(String.format("There are %d components not matched%n", + failedComponents.size())); + resultMessage.append(String.format("\twith %d total attributes mismatched.", + numOfAttributes)); return new AppraisalStatus(FAIL, resultMessage.toString(), additionalInfo.toString()); } } @@ -402,25 +403,17 @@ private static List generateComponentResults( final ComponentResult componentResult) { // there are instances of components with the same class (ie hard disks, memory) List attributeResults = new ArrayList<>(); - if (!componentInfo.getComponentManufacturer().equals(componentResult.getManufacturer())) { - attributeResults.add(new ComponentAttributeResult(componentResult.getId(), - componentResult.getManufacturer(), componentInfo.getComponentManufacturer())); - } + attributeResults.add(new ComponentAttributeResult(componentResult.getId(), componentInfo.getId(), + componentResult.getManufacturer(), componentInfo.getComponentManufacturer())); - if (!componentInfo.getComponentModel().equals(componentResult.getModel())) { - attributeResults.add(new ComponentAttributeResult(componentResult.getId(), - componentResult.getModel(), componentInfo.getComponentModel())); - } + attributeResults.add(new ComponentAttributeResult(componentResult.getId(), componentInfo.getId(), + componentResult.getModel(), componentInfo.getComponentModel())); - if (!componentInfo.getComponentSerial().equals(componentResult.getSerialNumber())) { - attributeResults.add(new ComponentAttributeResult(componentResult.getId(), - componentResult.getSerialNumber(), componentInfo.getComponentSerial())); - } + attributeResults.add(new ComponentAttributeResult(componentResult.getId(), componentInfo.getId(), + componentResult.getSerialNumber(), componentInfo.getComponentSerial())); - if (!componentInfo.getComponentRevision().equals(componentResult.getRevisionNumber())) { - attributeResults.add(new ComponentAttributeResult(componentResult.getId(), - componentResult.getRevisionNumber(), componentInfo.getComponentRevision())); - } + attributeResults.add(new ComponentAttributeResult(componentResult.getId(), componentInfo.getId(), + componentResult.getRevisionNumber(), componentInfo.getComponentRevision())); return attributeResults; } diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java index c0b7970f2..2907c4160 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java @@ -7,12 +7,14 @@ import hirs.attestationca.persist.entity.userdefined.certificate.ComponentResult; import hirs.attestationca.persist.entity.userdefined.certificate.PlatformCredential; import hirs.attestationca.persist.entity.userdefined.certificate.attributes.ComponentAttributeResult; +import hirs.attestationca.persist.entity.userdefined.certificate.attributes.ComponentClass; import hirs.attestationca.persist.entity.userdefined.info.ComponentInfo; import hirs.attestationca.persist.util.PciIds; import hirs.attestationca.portal.page.Page; import hirs.attestationca.portal.page.PageController; import hirs.attestationca.portal.page.PageMessages; import hirs.attestationca.portal.page.params.CertificateDetailsPageParams; +import hirs.utils.xjc.Link; import lombok.extern.log4j.Log4j2; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -24,6 +26,7 @@ import java.math.BigInteger; import java.util.ArrayList; import java.util.HashMap; +import java.util.LinkedList; import java.util.List; import java.util.UUID; @@ -143,25 +146,52 @@ public static HashMap getPlatformComponentInformation( + componentResults.get(0).getBoardSerialNumber()); return data; } - List tempIdList = new ArrayList<>(); - attributeResults.stream().forEach((dbObject) -> { - if (!tempIdList.contains(dbObject.getComponentId())) { - tempIdList.add(dbObject.getComponentId()); + + List matchedResults = new LinkedList<>(); + List matchedDeviceComps = new LinkedList<>(); + List mismatchedResults = new LinkedList<>(); + List mismatchedDeviceComps = new LinkedList<>(); + for(ComponentAttributeResult dbObject : attributeResults) { + if (dbObject.checkMatchedStatus()) { + matchedResults.add(componentResultRepository.getReferenceById(dbObject.getComponentId())); + matchedDeviceComps.add(componentInfoRepository.getReferenceById(dbObject.getDeviceComponentId())); + } else { + mismatchedResults.add(componentResultRepository.getReferenceById(dbObject.getComponentId())); + mismatchedDeviceComps.add(componentInfoRepository.getReferenceById(dbObject.getDeviceComponentId())); } - }); - componentResults = componentResultRepository - .findByBoardSerialNumberOrderByComponentClassValueAsc( - platformCredential.getPlatformSerial()); - List componentInfos = componentInfoRepository - .findByDeviceNameOrderByComponentClassAsc(deviceName); + } + +// componentResults.clear(); +// List componentInfos = componentInfoRepository +// .findByDeviceNameOrderByComponentClassAsc(deviceName); +// // find the ones that aren't matched or unmatched +// for (ComponentResult dbResult : componentResultRepository +// .findByBoardSerialNumberOrderByComponentClassValueAsc( +// platformCredential.getPlatformSerial())) { +// for (ComponentResult matched : matchedResults) { +// if (dbResult.getId().equals(matched.getId())) { +// +// } +// } +// } if (PciIds.DB.isReady()) { - componentResults = PciIds.translateResults(componentResults); - componentInfos = PciIds.translateDeviceComponentInfo(componentInfos); +// componentResults = PciIds.translateResults(componentResults); +// componentInfos = PciIds.translateDeviceComponentInfo(componentInfos); + matchedResults = PciIds.translateResults(matchedResults); + matchedDeviceComps = PciIds.translateDeviceComponentInfo(matchedDeviceComps); + mismatchedResults = PciIds.translateResults(mismatchedResults); + mismatchedDeviceComps = PciIds.translateDeviceComponentInfo(mismatchedDeviceComps); } - data.put("componentResults", componentResults); - data.put("componentInfos", componentInfos); - data.put("totalSize", Math.max(componentResults.size(), componentInfos.size())); + matchedDeviceComps = translateComponentClass(matchedDeviceComps); + mismatchedDeviceComps = translateComponentClass(mismatchedDeviceComps); + + data.put("componentResults", matchedResults); + data.put("componentInfos", matchedDeviceComps); + data.put("misMatchedComponentResults", mismatchedResults); + data.put("misMatchedComponentInfos", mismatchedDeviceComps); +// data.put("notFoundResults", ); +// data.put("notFoundComponentInfs", ); } else { String notFoundMessage = "No components attribute comparison found " + "with ID: " + sessionId; @@ -169,6 +199,20 @@ public static HashMap getPlatformComponentInformation( } return data; } + + private static List translateComponentClass(final List componentInfos) { + List tempList = new ArrayList<>(); + ComponentInfo componentInfo; + ComponentClass componentClass; + for (ComponentInfo info : componentInfos) { + componentInfo = info; + componentClass = new ComponentClass("TCG", info.getComponentClass()); + componentInfo.setComponentClassStr(componentClass.toString()); + tempList.add(componentInfo); + } + + return tempList; + } } diff --git a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp index bff274754..8c01bb5ce 100644 --- a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp +++ b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp @@ -54,7 +54,17 @@
-
+
+ Component Class: ${componentResult.getComponentClassStr()}
+ Manufacturer: ${componentResult.getManufacturer()}
+ Model: ${componentResult.getModel()}
+ Serial Number: ${componentResult.getSerialNumber()}
+ Revision: ${componentResult.getRevisionNumber()}
+
+ + +
+ Component Class: ${componentResult.getComponentClassStr()}
Manufacturer: ${componentResult.getManufacturer()}
Model: ${componentResult.getModel()}
Serial Number: ${componentResult.getSerialNumber()}
@@ -68,7 +78,17 @@
-
+
+ Component Class: ${componentInfo.getComponentClassStr()}
+ Manufacturer: ${componentInfo.getComponentManufacturer()}
+ Model: ${componentInfo.getComponentModel()}
+ Serial Number: ${componentInfo.getComponentSerial()}
+ Revision: ${componentInfo.getComponentRevision()}
+
+ + +
+ Component Class: ${componentInfo.getComponentClassStr()}
Manufacturer: ${componentInfo.getComponentManufacturer()}
Model: ${componentInfo.getComponentModel()}
Serial Number: ${componentInfo.getComponentSerial()}
From 1cdb07ae20dfc9245f4c668d4a9b0bd614b0a106 Mon Sep 17 00:00:00 2001 From: Cyrus <24922493+cyrus-dev@users.noreply.github.com> Date: Thu, 21 Mar 2024 16:25:13 -0400 Subject: [PATCH 12/18] Reverted some changes after a lot of bugs --- .../CertificateAttributeScvValidator.java | 41 ++++++++++-------- .../ComponentComparisonPageController.java | 42 +++++++++++++++---- 2 files changed, 57 insertions(+), 26 deletions(-) diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/CertificateAttributeScvValidator.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/CertificateAttributeScvValidator.java index 40d6542f8..9c61c283c 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/CertificateAttributeScvValidator.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/CertificateAttributeScvValidator.java @@ -337,7 +337,6 @@ public static AppraisalStatus validatePlatformCredentialAttributesV2p0( remainingComponentResults.add(componentResult); } } - List failedComponents = new ArrayList<>(); if (!remainingComponentResults.isEmpty()) { // continue down the options, move to a different method. // create component class mapping to component info @@ -370,23 +369,23 @@ public static AppraisalStatus validatePlatformCredentialAttributesV2p0( componentAttributeResult.setProvisionSessionId(provisionSessionId); componentAttributeRepository.save(componentAttributeResult); fieldValidation &= componentAttributeResult.checkMatchedStatus(); - if (!componentAttributeResult.checkMatchedStatus()) { - numOfAttributes++; - failedComponents.add(componentAttributeResult.getComponentId()); - } } + numOfAttributes = attributeResults.size(); } StringBuilder additionalInfo = new StringBuilder(); + if (!remainingComponentResults.isEmpty()) { + resultMessage.append(String.format("There are %d components not matched%n", + remainingComponentResults.size())); + resultMessage.append(String.format("\twith %d total attributes mismatched.", + numOfAttributes)); + } + passesValidation &= fieldValidation; if (passesValidation) { return new AppraisalStatus(PASS, PLATFORM_ATTRIBUTES_VALID); } else { - resultMessage.append(String.format("There are %d components not matched%n", - failedComponents.size())); - resultMessage.append(String.format("\twith %d total attributes mismatched.", - numOfAttributes)); return new AppraisalStatus(FAIL, resultMessage.toString(), additionalInfo.toString()); } } @@ -403,17 +402,25 @@ private static List generateComponentResults( final ComponentResult componentResult) { // there are instances of components with the same class (ie hard disks, memory) List attributeResults = new ArrayList<>(); - attributeResults.add(new ComponentAttributeResult(componentResult.getId(), componentInfo.getId(), - componentResult.getManufacturer(), componentInfo.getComponentManufacturer())); + if (!componentInfo.getComponentManufacturer().equals(componentResult.getManufacturer())) { + attributeResults.add(new ComponentAttributeResult(componentResult.getId(), componentInfo.getId(), + componentResult.getManufacturer(), componentInfo.getComponentManufacturer())); + } - attributeResults.add(new ComponentAttributeResult(componentResult.getId(), componentInfo.getId(), - componentResult.getModel(), componentInfo.getComponentModel())); + if (!componentInfo.getComponentModel().equals(componentResult.getModel())) { + attributeResults.add(new ComponentAttributeResult(componentResult.getId(), componentInfo.getId(), + componentResult.getModel(), componentInfo.getComponentModel())); + } - attributeResults.add(new ComponentAttributeResult(componentResult.getId(), componentInfo.getId(), - componentResult.getSerialNumber(), componentInfo.getComponentSerial())); + if (!componentInfo.getComponentSerial().equals(componentResult.getSerialNumber())) { + attributeResults.add(new ComponentAttributeResult(componentResult.getId(), componentInfo.getId(), + componentResult.getSerialNumber(), componentInfo.getComponentSerial())); + } - attributeResults.add(new ComponentAttributeResult(componentResult.getId(), componentInfo.getId(), - componentResult.getRevisionNumber(), componentInfo.getComponentRevision())); + if (!componentInfo.getComponentRevision().equals(componentResult.getRevisionNumber())) { + attributeResults.add(new ComponentAttributeResult(componentResult.getId(), componentInfo.getId(), + componentResult.getRevisionNumber(), componentInfo.getComponentRevision())); + } return attributeResults; } diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java index 2907c4160..0ae642b4a 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java @@ -28,6 +28,7 @@ import java.util.HashMap; import java.util.LinkedList; import java.util.List; +import java.util.Map; import java.util.UUID; @Log4j2 @@ -93,7 +94,7 @@ public ModelAndView initPage(final CertificateDetailsPageParams params, final Mo } if (data.isEmpty()) { - String notFoundMessage = "Unable to find RIM with ID: " + params.getId(); + String notFoundMessage = "Unable to find session with ID: " + params.getId(); messages.addError(notFoundMessage); log.warn(notFoundMessage); mav.addObject(MESSAGES_ATTRIBUTE, messages); @@ -146,19 +147,17 @@ public static HashMap getPlatformComponentInformation( + componentResults.get(0).getBoardSerialNumber()); return data; } - - List matchedResults = new LinkedList<>(); - List matchedDeviceComps = new LinkedList<>(); + List componentInfos = componentInfoRepository + .findByDeviceNameOrderByComponentClassAsc(deviceName); + Map componentInfoHashMap = findMatchedComponents(componentResults, componentInfos); + List matchedResults = new LinkedList<>(componentInfoHashMap.keySet()); + List matchedDeviceComps = new LinkedList<>(componentInfoHashMap.values()); List mismatchedResults = new LinkedList<>(); List mismatchedDeviceComps = new LinkedList<>(); for(ComponentAttributeResult dbObject : attributeResults) { - if (dbObject.checkMatchedStatus()) { - matchedResults.add(componentResultRepository.getReferenceById(dbObject.getComponentId())); - matchedDeviceComps.add(componentInfoRepository.getReferenceById(dbObject.getDeviceComponentId())); - } else { mismatchedResults.add(componentResultRepository.getReferenceById(dbObject.getComponentId())); mismatchedDeviceComps.add(componentInfoRepository.getReferenceById(dbObject.getDeviceComponentId())); - } + } // componentResults.clear(); @@ -213,6 +212,31 @@ private static List translateComponentClass(final List findMatchedComponents( + final List componentResults, final List componentInfos) { + // first create hash map based on hashCode + Map resultComponentInfoMap = new HashMap<>(); + Map deviceHashMap = new HashMap<>(); + componentInfos.stream().forEach((componentInfo) -> { + deviceHashMap.put(componentInfo.hashCommonElements(), componentInfo); + }); + + // Look for hash code in device mapping + // if it exists, don't save the component + List remainingComponentResults = new ArrayList<>(); + int numOfAttributes = 0; + for (ComponentResult componentResult : componentResults) { + if (!deviceHashMap.containsKey(componentResult.hashCommonElements())) { + // didn't find the component result in the hashed mapping + remainingComponentResults.add(componentResult); + } else { + resultComponentInfoMap.put(componentResult, deviceHashMap.get(componentResult.hashCommonElements())); + } + } + + return resultComponentInfoMap; + } } From cff577107829f25e17e65aea3e3febfd3140c90d Mon Sep 17 00:00:00 2001 From: Cyrus <24922493+cyrus-dev@users.noreply.github.com> Date: Thu, 21 Mar 2024 16:28:13 -0400 Subject: [PATCH 13/18] upated page left out of previous commit --- .../src/main/webapp/WEB-INF/jsp/component-comparison.jsp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp index 8c01bb5ce..6a2f6c826 100644 --- a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp +++ b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp @@ -63,7 +63,7 @@
-
+
Component Class: ${componentResult.getComponentClassStr()}
Manufacturer: ${componentResult.getManufacturer()}
Model: ${componentResult.getModel()}
@@ -78,7 +78,7 @@
-
+
Component Class: ${componentInfo.getComponentClassStr()}
Manufacturer: ${componentInfo.getComponentManufacturer()}
Model: ${componentInfo.getComponentModel()}
From b4940d664b0b93aea6c673f91e546912e7e0d870 Mon Sep 17 00:00:00 2001 From: Cyrus <24922493+cyrus-dev@users.noreply.github.com> Date: Thu, 21 Mar 2024 21:02:40 -0400 Subject: [PATCH 14/18] Cleaned up the errors --- .../userdefined/info/ComponentInfo.java | 49 +++++-- .../attestationca/persist/util/PciIds.java | 7 +- .../ComponentComparisonPageController.java | 131 ++++++++++-------- .../WEB-INF/jsp/component-comparison.jsp | 11 +- 4 files changed, 125 insertions(+), 73 deletions(-) diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/info/ComponentInfo.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/info/ComponentInfo.java index a4545ec79..c11da1831 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/info/ComponentInfo.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/info/ComponentInfo.java @@ -60,10 +60,11 @@ public class ComponentInfo extends ArchivableEntity { /** * Base constructor for children. + * * @param componentManufacturer Component Manufacturer (must not be null) - * @param componentModel Component Model (must not be null) - * @param componentSerial Component Serial Number (can be null) - * @param componentRevision Component Revision or Version (can be null) + * @param componentModel Component Model (must not be null) + * @param componentSerial Component Serial Number (can be null) + * @param componentRevision Component Revision or Version (can be null) */ public ComponentInfo(final String componentManufacturer, final String componentModel, @@ -72,13 +73,15 @@ public ComponentInfo(final String componentManufacturer, this(DeviceInfoEnums.NOT_SPECIFIED, componentManufacturer, componentModel, componentSerial, componentRevision); } + /** * Constructor. - * @param deviceName the host machine associated with this component. (must not be null) + * + * @param deviceName the host machine associated with this component. (must not be null) * @param componentManufacturer Component Manufacturer (must not be null) - * @param componentModel Component Model (must not be null) - * @param componentSerial Component Serial Number (can be null) - * @param componentRevision Component Revision or Version (can be null) + * @param componentModel Component Model (must not be null) + * @param componentSerial Component Serial Number (can be null) + * @param componentRevision Component Revision or Version (can be null) */ public ComponentInfo(final String deviceName, final String componentManufacturer, @@ -112,12 +115,13 @@ public ComponentInfo(final String deviceName, /** * Constructor. - * @param deviceName the host machine associated with this component. + * + * @param deviceName the host machine associated with this component. * @param componentManufacturer Component Manufacturer (must not be null) - * @param componentModel Component Model (must not be null) - * @param componentSerial Component Serial Number (can be null) - * @param componentRevision Component Revision or Version (can be null) - * @param componentClass Component Class (can be null) + * @param componentModel Component Model (must not be null) + * @param componentSerial Component Serial Number (can be null) + * @param componentRevision Component Revision or Version (can be null) + * @param componentClass Component Class (can be null) */ public ComponentInfo(final String deviceName, final String componentManufacturer, @@ -131,6 +135,18 @@ public ComponentInfo(final String deviceName, this.componentClass = Objects.requireNonNullElse(componentClass, StringUtils.EMPTY); } + /** + * Blank object to display on comparision page. + * @param empty nothing + */ + public ComponentInfo(final String empty) { + this.deviceName = StringUtils.EMPTY; + this.componentManufacturer = StringUtils.EMPTY; + this.componentModel = StringUtils.EMPTY; + this.componentSerial = StringUtils.EMPTY; + this.componentRevision = StringUtils.EMPTY; + } + /** * Determines whether the given properties represent a * ComponentInfo that will be useful in validation. @@ -138,9 +154,9 @@ public ComponentInfo(final String deviceName, * manufacturer and model are considered valid. * * @param componentManufacturer a String containing a component's manufacturer - * @param componentModel a String representing a component's model - * @param componentSerial a String representing a component's serial number - * @param componentRevision a String representing a component's revision + * @param componentModel a String representing a component's model + * @param componentSerial a String representing a component's serial number + * @param componentRevision a String representing a component's revision * @return true if the component is valid, false if not */ public static boolean isComplete(final String componentManufacturer, @@ -153,6 +169,7 @@ public static boolean isComplete(final String componentManufacturer, /** * Equals for the component info that just uses this classes attributes. + * * @param object the object to compare * @return the boolean result */ @@ -173,6 +190,7 @@ public boolean equals(Object object) { /** * Returns a hash code that is associated with common fields for components. + * * @return int value of the elements */ public int hashCommonElements() { @@ -182,6 +200,7 @@ public int hashCommonElements() { /** * Hash method for the attributes of this class. + * * @return int value that represents this class */ @Override diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/util/PciIds.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/util/PciIds.java index 1efeb3775..aaec23691 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/util/PciIds.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/util/PciIds.java @@ -146,7 +146,12 @@ public static List translateDeviceComponentInfo(final List newList = new ArrayList<>(); if (componentInfos != null && !componentInfos.isEmpty()) { for (final ComponentInfo componentInfo : componentInfos) { - newList.add(translateDeviceComponentInfo(componentInfo)); + if (!componentInfo.getDeviceName().isEmpty()) { + newList.add(translateDeviceComponentInfo(componentInfo)); + } else { + // if the object is all StringUtils.empty() + newList.add(componentInfo); + } } } diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java index 0ae642b4a..aa8cb0aaf 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java @@ -40,6 +40,7 @@ public class ComponentComparisonPageController extends PageController getPlatformComponentInformation( @@ -131,7 +132,7 @@ public static HashMap getPlatformComponentInformation( data.put("deviceName", deviceName); if (!attributeResults.isEmpty()) { ComponentResult componentResult = componentResultRepository.findById(attributeResults.get(0).getComponentId()).get(); - platformCredential = platformCertificateRepository + platformCredential = platformCertificateRepository .findByPlatformSerialAndSerialNumber(componentResult.getBoardSerialNumber(), BigInteger.valueOf(Long.parseLong( componentResult.getCertificateSerialNumber()))); @@ -147,39 +148,75 @@ public static HashMap getPlatformComponentInformation( + componentResults.get(0).getBoardSerialNumber()); return data; } + // get all db objects + componentResults = componentResultRepository + .findByBoardSerialNumberOrderByComponentClassValueAsc( + platformCredential.getPlatformSerial()); List componentInfos = componentInfoRepository .findByDeviceNameOrderByComponentClassAsc(deviceName); - Map componentInfoHashMap = findMatchedComponents(componentResults, componentInfos); - List matchedResults = new LinkedList<>(componentInfoHashMap.keySet()); - List matchedDeviceComps = new LinkedList<>(componentInfoHashMap.values()); + // first get what we know, the attribute results have the platform component + // and device component that are mismatched List mismatchedResults = new LinkedList<>(); List mismatchedDeviceComps = new LinkedList<>(); - for(ComponentAttributeResult dbObject : attributeResults) { - mismatchedResults.add(componentResultRepository.getReferenceById(dbObject.getComponentId())); - mismatchedDeviceComps.add(componentInfoRepository.getReferenceById(dbObject.getDeviceComponentId())); + // quick list to hold what we've found so we don't look for the ID again. + List tempIds = new ArrayList<>(); + for (ComponentAttributeResult car : attributeResults) { + if (!tempIds.contains(car.getComponentId())) { + mismatchedResults.add(componentResultRepository + .getReferenceById(car.getComponentId())); + tempIds.add(car.getComponentId()); + } + if (!tempIds.contains(car.getDeviceComponentId())) { + mismatchedDeviceComps.add(componentInfoRepository + .getReferenceById(car.getDeviceComponentId())); + tempIds.add(car.getDeviceComponentId()); + } + } + + // we got the provisioned mismatches, so all that is left are matched + Map deviceComponentHashMap = new HashMap<>(); + for (ComponentInfo componentInfo : componentInfos) { + // skip the ones we know + if (!tempIds.contains(componentInfo.getId())) { + deviceComponentHashMap.put(componentInfo.hashCommonElements(), componentInfo); + } + } + // do the same for componentResults + Map platformComponentHashMap = new HashMap<>(); + for (ComponentResult result : componentResults) { + // skip the ones we know + if (!tempIds.contains(result.getId())) { + platformComponentHashMap.put(result.hashCommonElements(), result); + } + } + // find platform component match + Map mappedComponents = new HashMap<>(); + for (Integer key : platformComponentHashMap.keySet()) { + if (deviceComponentHashMap.containsKey(key)) { + mappedComponents.put(platformComponentHashMap.get(key), + deviceComponentHashMap.get(key)); + deviceComponentHashMap.remove(key); + } else { + // it doesn't exist, put null + mappedComponents.put(platformComponentHashMap.get(key), new ComponentInfo("")); + } } -// componentResults.clear(); -// List componentInfos = componentInfoRepository -// .findByDeviceNameOrderByComponentClassAsc(deviceName); -// // find the ones that aren't matched or unmatched -// for (ComponentResult dbResult : componentResultRepository -// .findByBoardSerialNumberOrderByComponentClassValueAsc( -// platformCredential.getPlatformSerial())) { -// for (ComponentResult matched : matchedResults) { -// if (dbResult.getId().equals(matched.getId())) { -// -// } -// } -// } + List matchedResults = new LinkedList<>(mappedComponents.keySet()); + List matchedDeviceComps = new LinkedList<>(mappedComponents.values()); + List notFoundDevices = null; + if (!deviceComponentHashMap.values().isEmpty()) { + notFoundDevices = new ArrayList<>(deviceComponentHashMap.values()); + } if (PciIds.DB.isReady()) { -// componentResults = PciIds.translateResults(componentResults); -// componentInfos = PciIds.translateDeviceComponentInfo(componentInfos); matchedResults = PciIds.translateResults(matchedResults); matchedDeviceComps = PciIds.translateDeviceComponentInfo(matchedDeviceComps); mismatchedResults = PciIds.translateResults(mismatchedResults); mismatchedDeviceComps = PciIds.translateDeviceComponentInfo(mismatchedDeviceComps); + if (notFoundDevices != null) { + notFoundDevices = PciIds.translateDeviceComponentInfo(notFoundDevices); + } } matchedDeviceComps = translateComponentClass(matchedDeviceComps); @@ -189,8 +226,11 @@ public static HashMap getPlatformComponentInformation( data.put("componentInfos", matchedDeviceComps); data.put("misMatchedComponentResults", mismatchedResults); data.put("misMatchedComponentInfos", mismatchedDeviceComps); -// data.put("notFoundResults", ); -// data.put("notFoundComponentInfs", ); + + if (notFoundDevices != null) { + data.put("notFoundDeviceComponents", translateComponentClass(notFoundDevices)); + } + } else { String notFoundMessage = "No components attribute comparison found " + "with ID: " + sessionId; @@ -204,38 +244,17 @@ private static List translateComponentClass(final List findMatchedComponents( - final List componentResults, final List componentInfos) { - // first create hash map based on hashCode - Map resultComponentInfoMap = new HashMap<>(); - Map deviceHashMap = new HashMap<>(); - componentInfos.stream().forEach((componentInfo) -> { - deviceHashMap.put(componentInfo.hashCommonElements(), componentInfo); - }); - - // Look for hash code in device mapping - // if it exists, don't save the component - List remainingComponentResults = new ArrayList<>(); - int numOfAttributes = 0; - for (ComponentResult componentResult : componentResults) { - if (!deviceHashMap.containsKey(componentResult.hashCommonElements())) { - // didn't find the component result in the hashed mapping - remainingComponentResults.add(componentResult); + if (!info.getDeviceName().isEmpty()) { + componentInfo = info; + componentClass = new ComponentClass("TCG", info.getComponentClass()); + componentInfo.setComponentClassStr(componentClass.toString()); + tempList.add(componentInfo); } else { - resultComponentInfoMap.put(componentResult, deviceHashMap.get(componentResult.hashCommonElements())); + tempList.add(info); } } - return resultComponentInfoMap; + return tempList; } } diff --git a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp index 6a2f6c826..a8fb09f8f 100644 --- a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp +++ b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp @@ -62,7 +62,7 @@ Revision: ${componentResult.getRevisionNumber()}
- +
Component Class: ${componentResult.getComponentClassStr()}
Manufacturer: ${componentResult.getManufacturer()}
@@ -95,6 +95,15 @@ Revision: ${componentInfo.getComponentRevision()}
+ +
+ Component Class: ${componentInfo.getComponentClassStr()}
+ Manufacturer: ${componentInfo.getComponentManufacturer()}
+ Model: ${componentInfo.getComponentModel()}
+ Serial Number: ${componentInfo.getComponentSerial()}
+ Revision: ${componentInfo.getComponentRevision()}
+
+
From ebd36f1d6c8c88f34e53b4a0ff91de35c09261d7 Mon Sep 17 00:00:00 2001 From: Cyrus <24922493+cyrus-dev@users.noreply.github.com> Date: Fri, 22 Mar 2024 07:25:17 -0400 Subject: [PATCH 15/18] Updated colors and margins --- .../WEB-INF/jsp/component-comparison.jsp | 76 +++++++++---------- .../webapp/common/certificate_details.css | 4 + 2 files changed, 38 insertions(+), 42 deletions(-) diff --git a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp index a8fb09f8f..1c1e820fe 100644 --- a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp +++ b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp @@ -39,69 +39,61 @@

- -
+
Certificate Component
-
+
-
- Component Class: ${componentResult.getComponentClassStr()}
- Manufacturer: ${componentResult.getManufacturer()}
- Model: ${componentResult.getModel()}
- Serial Number: ${componentResult.getSerialNumber()}
- Revision: ${componentResult.getRevisionNumber()}
+
+ Component Class: ${componentResult.getComponentClassStr()}
+ Manufacturer: ${componentResult.getManufacturer()}
+ Model: ${componentResult.getModel()}
+ Serial Number: ${componentResult.getSerialNumber()}
+ Revision: ${componentResult.getRevisionNumber()}
-
- Component Class: ${componentResult.getComponentClassStr()}
- Manufacturer: ${componentResult.getManufacturer()}
- Model: ${componentResult.getModel()}
- Serial Number: ${componentResult.getSerialNumber()}
- Revision: ${componentResult.getRevisionNumber()}
+
+ Component Class: ${componentResult.getComponentClassStr()}
+ Manufacturer: ${componentResult.getManufacturer()}
+ Model: ${componentResult.getModel()}
+ Serial Number: ${componentResult.getSerialNumber()}
+ Revision: ${componentResult.getRevisionNumber()}
-
Device Components
+
Device Components
-
+
-
- Component Class: ${componentInfo.getComponentClassStr()}
- Manufacturer: ${componentInfo.getComponentManufacturer()}
- Model: ${componentInfo.getComponentModel()}
- Serial Number: ${componentInfo.getComponentSerial()}
- Revision: ${componentInfo.getComponentRevision()}
+
+ Component Class: ${componentInfo.getComponentClassStr()}
+ Manufacturer: ${componentInfo.getComponentManufacturer()}
+ Model: ${componentInfo.getComponentModel()}
+ Serial Number: ${componentInfo.getComponentSerial()}
+ Revision: ${componentInfo.getComponentRevision()}
-
- Component Class: ${componentInfo.getComponentClassStr()}
- Manufacturer: ${componentInfo.getComponentManufacturer()}
- Model: ${componentInfo.getComponentModel()}
- Serial Number: ${componentInfo.getComponentSerial()}
- Revision: ${componentInfo.getComponentRevision()}
+
+ Component Class: ${componentInfo.getComponentClassStr()}
+ Manufacturer: ${componentInfo.getComponentManufacturer()}
+ Model: ${componentInfo.getComponentModel()}
+ Serial Number: ${componentInfo.getComponentSerial()}
+ Revision: ${componentInfo.getComponentRevision()}
-
- Component Class: ${componentInfo.getComponentClassStr()}
- Manufacturer: ${componentInfo.getComponentManufacturer()}
- Model: ${componentInfo.getComponentModel()}
- Serial Number: ${componentInfo.getComponentSerial()}
- Revision: ${componentInfo.getComponentRevision()}
+
+ Component Class: ${componentInfo.getComponentClassStr()}
+ Manufacturer: ${componentInfo.getComponentManufacturer()}
+ Model: ${componentInfo.getComponentModel()}
+ Serial Number: ${componentInfo.getComponentSerial()}
+ Revision: ${componentInfo.getComponentRevision()}
diff --git a/HIRS_AttestationCAPortal/src/main/webapp/common/certificate_details.css b/HIRS_AttestationCAPortal/src/main/webapp/common/certificate_details.css index 5cafa4662..bb2e71811 100644 --- a/HIRS_AttestationCAPortal/src/main/webapp/common/certificate_details.css +++ b/HIRS_AttestationCAPortal/src/main/webapp/common/certificate_details.css @@ -39,6 +39,10 @@ width: 100px; display: inline-block; } +.compHeader { + width: 150px; + display: inline-block; +} #tbbsecurity .fieldHeader { width: 165px; From 465c9dea51cf90770481113a57a3db6805b686f8 Mon Sep 17 00:00:00 2001 From: Cyrus <24922493+cyrus-dev@users.noreply.github.com> Date: Fri, 22 Mar 2024 09:46:04 -0400 Subject: [PATCH 16/18] Updated component info to save the registry id --- .../persist/entity/userdefined/info/ComponentInfo.java | 7 ++++++- .../validation/SupplyChainCredentialValidator.java | 5 ++++- .../main/webapp/WEB-INF/jsp/component-comparison.jsp | 10 +++++----- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/info/ComponentInfo.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/info/ComponentInfo.java index c11da1831..2a4e134ea 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/info/ComponentInfo.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/info/ComponentInfo.java @@ -56,6 +56,8 @@ public class ComponentInfo extends ArchivableEntity { @Column private String componentClass; @Column + private String componentClassRegistry; + @Column private String componentClassStr; /** @@ -122,17 +124,20 @@ public ComponentInfo(final String deviceName, * @param componentSerial Component Serial Number (can be null) * @param componentRevision Component Revision or Version (can be null) * @param componentClass Component Class (can be null) + * @param componentClassRegistry The id that indicates TCG or SMBIOS */ public ComponentInfo(final String deviceName, final String componentManufacturer, final String componentModel, final String componentSerial, final String componentRevision, - final String componentClass) { + final String componentClass, + final String componentClassRegistry) { this(deviceName, componentManufacturer, componentModel, componentSerial, componentRevision); this.componentClass = Objects.requireNonNullElse(componentClass, StringUtils.EMPTY); + this.componentClassRegistry = Objects.requireNonNullElse(componentClassRegistry, StringUtils.EMPTY); } /** diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/SupplyChainCredentialValidator.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/SupplyChainCredentialValidator.java index ef378990f..eaf2872b3 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/SupplyChainCredentialValidator.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/SupplyChainCredentialValidator.java @@ -301,16 +301,19 @@ public static List getComponentInfoFromPaccorOutput(final String } else { // version 2 String componentClass = StringUtils.EMPTY; + String componentClassRegistry = StringUtils.EMPTY; for (JsonNode subNode : compClassNodes) { componentClass = getJSONNodeValueAsText(subNode, "COMPONENTCLASSVALUE"); + componentClassRegistry = getJSONNodeValueAsText(subNode, + "COMPONENTCLASSREGISTRY"); } componentInfoList.add(new ComponentInfo(hostName, getJSONNodeValueAsText(next, "MANUFACTURER"), getJSONNodeValueAsText(next, "MODEL"), getJSONNodeValueAsText(next, "SERIAL"), getJSONNodeValueAsText(next, "REVISION"), - componentClass)); + componentClass, componentClassRegistry)); } } } diff --git a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp index 1c1e820fe..5397ee4c1 100644 --- a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp +++ b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp @@ -40,11 +40,11 @@

-
-
+
+
Certificate Component
-
+
Component Class: ${componentResult.getComponentClassStr()}
@@ -65,10 +65,10 @@
-
+
Device Components
-
+
Component Class: ${componentInfo.getComponentClassStr()}
From 60d1192b3131bf79e45a25832e8a1ad8994ede9b Mon Sep 17 00:00:00 2001 From: Cyrus <24922493+cyrus-dev@users.noreply.github.com> Date: Fri, 22 Mar 2024 09:46:50 -0400 Subject: [PATCH 17/18] Updated the method for translating the component class value --- .../page/controllers/ComponentComparisonPageController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java index aa8cb0aaf..9c8d85c29 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ComponentComparisonPageController.java @@ -246,7 +246,7 @@ private static List translateComponentClass(final List Date: Fri, 22 Mar 2024 10:04:21 -0400 Subject: [PATCH 18/18] Updated the colors for the comparison page --- .../src/main/webapp/WEB-INF/jsp/component-comparison.jsp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp index 5397ee4c1..acbaa214f 100644 --- a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp +++ b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/component-comparison.jsp @@ -46,7 +46,7 @@
-
+
Component Class: ${componentResult.getComponentClassStr()}
Manufacturer: ${componentResult.getManufacturer()}
Model: ${componentResult.getModel()}
@@ -55,7 +55,7 @@
-
+
Component Class: ${componentResult.getComponentClassStr()}
Manufacturer: ${componentResult.getManufacturer()}
Model: ${componentResult.getModel()}
@@ -70,7 +70,7 @@
-
+
Component Class: ${componentInfo.getComponentClassStr()}
Manufacturer: ${componentInfo.getComponentManufacturer()}
Model: ${componentInfo.getComponentModel()}
@@ -79,7 +79,7 @@
-
+
Component Class: ${componentInfo.getComponentClassStr()}
Manufacturer: ${componentInfo.getComponentManufacturer()}
Model: ${componentInfo.getComponentModel()}