From c046851e07a98d91a977c39f3017aa5837d4d631 Mon Sep 17 00:00:00 2001 From: Cyrus <24922493+cyrus-dev@users.noreply.github.com> Date: Thu, 28 Sep 2023 06:47:43 -0400 Subject: [PATCH] Latest changes that fixes little issues --- .../persist/entity/AbstractEntity.java | 3 ++ .../service/SupplyChainValidationService.java | 5 +++ ...eferenceManifestDetailsPageController.java | 8 ++--- .../ReferenceManifestPageController.java | 31 +++---------------- .../src/main/webapp/WEB-INF/jsp/error.jsp | 18 +++++++++-- .../src/main/webapp/WEB-INF/jsp/help.jsp | 6 +++- 6 files changed, 37 insertions(+), 34 deletions(-) diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/AbstractEntity.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/AbstractEntity.java index 204b6dfd4..e89249c63 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/AbstractEntity.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/AbstractEntity.java @@ -67,6 +67,9 @@ public void setId(UUID id) { * @return creation time */ public Date getCreateTime() { + if (createTime == null) { + createTime = new Date(); + } return (Date) createTime.clone(); } 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 1ef73d122..c3ac6a917 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 @@ -8,6 +8,7 @@ import hirs.attestationca.persist.entity.manager.PolicyRepository; import hirs.attestationca.persist.entity.manager.ReferenceDigestValueRepository; import hirs.attestationca.persist.entity.manager.ReferenceManifestRepository; +import hirs.attestationca.persist.entity.manager.SupplyChainValidationRepository; import hirs.attestationca.persist.entity.manager.SupplyChainValidationSummaryRepository; import hirs.attestationca.persist.entity.userdefined.Device; import hirs.attestationca.persist.entity.userdefined.PolicySettings; @@ -47,6 +48,7 @@ public class SupplyChainValidationService { private ReferenceDigestValueRepository referenceDigestValueRepository; private ComponentResultRepository componentResultRepository; private CertificateRepository certificateRepository; + private SupplyChainValidationRepository supplyChainValidationRepository; private SupplyChainValidationSummaryRepository supplyChainValidationSummaryRepository; /** @@ -57,6 +59,7 @@ public class SupplyChainValidationService { * @param certificateRepository the cert manager * @param componentResultRepository the comp result manager * @param referenceManifestRepository the RIM manager + * @param supplyChainValidationRepository the scv manager * @param supplyChainValidationSummaryRepository the summary manager * @param referenceDigestValueRepository the even manager */ @@ -68,6 +71,7 @@ public SupplyChainValidationService( final CertificateRepository certificateRepository, final ComponentResultRepository componentResultRepository, final ReferenceManifestRepository referenceManifestRepository, + final SupplyChainValidationRepository supplyChainValidationRepository, final SupplyChainValidationSummaryRepository supplyChainValidationSummaryRepository, final ReferenceDigestValueRepository referenceDigestValueRepository) { this.caCredentialRepository = caCredentialRepository; @@ -75,6 +79,7 @@ public SupplyChainValidationService( this.certificateRepository = certificateRepository; this.componentResultRepository = componentResultRepository; this.referenceManifestRepository = referenceManifestRepository; + this.supplyChainValidationRepository = supplyChainValidationRepository; this.supplyChainValidationSummaryRepository = supplyChainValidationSummaryRepository; this.referenceDigestValueRepository = referenceDigestValueRepository; } diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestDetailsPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestDetailsPageController.java index 110bbd009..cd07a8a12 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestDetailsPageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestDetailsPageController.java @@ -266,8 +266,8 @@ private static HashMap getBaseRimInfo( baseRim.setAssociatedRim(support.getId()); } } else { - support = (SupportReferenceManifest) referenceManifestRepository - .getReferenceById(baseRim.getAssociatedRim()); + support = referenceManifestRepository + .getSupportRimEntityById(baseRim.getAssociatedRim()); } // going to have to pull the filename and grab that from the DB // to get the id to make the link @@ -319,8 +319,8 @@ private static HashMap getBaseRimInfo( data.put("issuerID", cert.getId().toString()); } } - } catch (NullPointerException e) { - log.warn("Unable to link signing certificate: " + e.getMessage()); + } catch (NullPointerException npEx) { + log.warn("Unable to link signing certificate: " + npEx.getMessage()); } return data; } diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestPageController.java index e8c756067..6a83348f9 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestPageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestPageController.java @@ -1,18 +1,15 @@ package hirs.attestationca.portal.page.controllers; -import hirs.attestationca.persist.CriteriaModifier; import hirs.attestationca.persist.DBManagerException; import hirs.attestationca.persist.FilteredRecordsList; import hirs.attestationca.persist.entity.manager.ReferenceDigestValueRepository; import hirs.attestationca.persist.entity.manager.ReferenceManifestRepository; -import hirs.attestationca.persist.entity.userdefined.Certificate; import hirs.attestationca.persist.entity.userdefined.ReferenceManifest; import hirs.attestationca.persist.entity.userdefined.rim.BaseReferenceManifest; import hirs.attestationca.persist.entity.userdefined.rim.ReferenceDigestValue; import hirs.attestationca.persist.entity.userdefined.rim.SupportReferenceManifest; import hirs.attestationca.portal.datatables.DataTableInput; import hirs.attestationca.portal.datatables.DataTableResponse; -import hirs.attestationca.portal.datatables.OrderedListQueryDataTableAdapter; import hirs.attestationca.portal.page.Page; import hirs.attestationca.portal.page.PageController; import hirs.attestationca.portal.page.PageMessages; @@ -20,13 +17,9 @@ import hirs.utils.tpm.eventlog.TCGEventLog; import hirs.utils.tpm.eventlog.TpmPcrEvent; import jakarta.persistence.EntityManager; -import jakarta.persistence.criteria.CriteriaBuilder; -import jakarta.persistence.criteria.CriteriaQuery; -import jakarta.persistence.criteria.Root; import jakarta.servlet.http.HttpServletResponse; import jakarta.validation.Valid; import lombok.extern.log4j.Log4j2; -import org.hibernate.Session; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; @@ -45,7 +38,6 @@ import org.springframework.web.servlet.view.RedirectView; import java.io.IOException; -import java.lang.ref.Reference; import java.net.URISyntaxException; import java.nio.charset.StandardCharsets; import java.security.NoSuchAlgorithmException; @@ -124,18 +116,6 @@ public DataTableResponse getTableData( String orderColumnName = input.getOrderColumnName(); log.info("Ordering on column: " + orderColumnName); - // check that the alert is not archived and that it is in the specified report - CriteriaModifier criteriaModifier = new CriteriaModifier() { - @Override - public void modify(final CriteriaQuery criteriaQuery) { - Session session = entityManager.unwrap(Session.class); - CriteriaBuilder cb = session.getCriteriaBuilder(); - Root rimRoot = criteriaQuery.from(Reference.class); - - criteriaQuery.select(rimRoot).distinct(true).where(cb.isNull(rimRoot.get(Certificate.ARCHIVE_FIELD))); - } - }; - log.info("Querying with the following dataTableInput: " + input.toString()); FilteredRecordsList records = new FilteredRecordsList<>(); @@ -144,15 +124,14 @@ public void modify(final CriteriaQuery criteriaQuery) { org.springframework.data.domain.Page pagedResult = referenceManifestRepository.findAll(paging); if (pagedResult.hasContent()) { - records.addAll(pagedResult.getContent()); + for (ReferenceManifest manifest : pagedResult.getContent()) { + if (!manifest.getRimType().equals(ReferenceManifest.MEASUREMENT_RIM)) { + records.add(manifest); + } + } } records.setRecordsTotal(input.getLength()); records.setRecordsFiltered(referenceManifestRepository.count()); -// FilteredRecordsList records -// = OrderedListQueryDataTableAdapter.getOrderedList( -// ReferenceManifest.class, -// this.referenceManifestRepository, -// input, orderColumnName, criteriaModifier); log.debug("Returning list of size: " + records.size()); return new DataTableResponse<>(records, input); 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 da7f58f91..88bb88771 100644 --- a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/error.jsp +++ b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/error.jsp @@ -1,3 +1,15 @@ -
-Page Not Found! Devices -
\ No newline at end of file +<%@page contentType="text/html" pageEncoding="UTF-8"%> + +<%-- JSP TAGS --%> +<%@taglib prefix="c" uri="jakarta.tags.core" %> +<%@taglib prefix="my" tagdir="/WEB-INF/tags"%> + +<%-- CONTENT --%> + + Error - 404 + + + + + \ No newline at end of file diff --git a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/help.jsp b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/help.jsp index 4ec2a763f..c6d478a37 100644 --- a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/help.jsp +++ b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/help.jsp @@ -10,12 +10,16 @@

Documentation

+ -

For more documentation on the project, you may visit the wiki section of our code repository.

+

+ For more documentation on the project, you may visit the wiki section of our code repository. +

\ No newline at end of file