From db19ed7b190b1ad7eade9a89d7b6372867b223f5 Mon Sep 17 00:00:00 2001 From: Cyrus <24922493+cyrus-dev@users.noreply.github.com> Date: Tue, 29 Nov 2022 09:22:21 -0500 Subject: [PATCH] investigating springboot not loading; getting lombok set --- HIRS_AttestationCA/build.gradle | 4 ++++ .../java/hirs/attestationca/AcaDbInit.java | 10 ++++----- .../java/hirs/attestationca/SystemInit.java | 6 +++--- .../entity/SupportReferenceManifest.java | 2 ++ .../certificate/ConformanceCredential.java | 2 +- .../repository/ReportSummaryRepository.java | 16 +++++++------- .../service/ReferenceManifestServiceImpl.java | 4 ++-- .../src/main/resources/applicationContext.xml | 2 +- HIRS_AttestationCAPortal/build.gradle | 2 ++ .../ReferenceManifestPageController.java | 21 ++++++++++--------- .../test/java/hirs/TPMReportRequestTest.java | 9 -------- settings.gradle | 1 + 12 files changed, 40 insertions(+), 39 deletions(-) diff --git a/HIRS_AttestationCA/build.gradle b/HIRS_AttestationCA/build.gradle index 2d66bed4..53db84ab 100644 --- a/HIRS_AttestationCA/build.gradle +++ b/HIRS_AttestationCA/build.gradle @@ -21,6 +21,8 @@ dependencies { implementation libs.commons.codec implementation libs.commons.lang implementation libs.commons.io + implementation libs.minimal.json + implementation libs.pci.ids implementation libs.guava implementation libs.javax.jaxb implementation libs.spring.webmvc @@ -31,6 +33,8 @@ dependencies { implementation libs.log4j2 implementation libs.log4j2.web implementation libs.protobuf.java + implementation libs.lombok + annotationProcessor libs.lombok implementation libs.servlet.api diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/AcaDbInit.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/AcaDbInit.java index 0cfac2bc..d65b2a37 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/AcaDbInit.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/AcaDbInit.java @@ -30,31 +30,31 @@ public final class AcaDbInit { public static synchronized void insertDefaultEntries( final AppraiserService appraiserService, final PolicyService policyService) { - LOG.info("Ensuring default ACA database entries are present."); + LOG.error("Ensuring default ACA database entries are present."); // If the SupplyChainAppraiser exists, do not attempt to re-save the supply chain appraiser // or SupplyChainPolicy SupplyChainAppraiser supplyChainAppraiser = (SupplyChainAppraiser) appraiserService.getAppraiser(SupplyChainAppraiser.NAME); if (supplyChainAppraiser != null) { - LOG.info("Supply chain appraiser is present; not inserting any more entries."); + LOG.error("Supply chain appraiser is present; not inserting any more entries."); LOG.info("ACA database initialization complete."); return; } // Create the SupplyChainAppraiser - LOG.info("Saving supply chain appraiser..."); + LOG.error("Saving supply chain appraiser..."); supplyChainAppraiser = (SupplyChainAppraiser) appraiserService.saveAppraiser(new SupplyChainAppraiser()); // Create the SupplyChainPolicy - LOG.info("Saving default supply chain policy..."); + LOG.error("Saving default supply chain policy..."); SupplyChainPolicy supplyChainPolicy = new SupplyChainPolicy( SupplyChainPolicy.DEFAULT_POLICY); policyService.savePolicy(supplyChainPolicy); policyService.setDefaultPolicy(supplyChainAppraiser, supplyChainPolicy); policyService.setPolicy(supplyChainAppraiser, supplyChainPolicy); - LOG.info("ACA database initialization complete."); + LOG.error("ACA database initialization complete."); } } diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/SystemInit.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/SystemInit.java index c240cb97..6d12f3d2 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/SystemInit.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/SystemInit.java @@ -54,7 +54,7 @@ public final class SystemInit { */ @SuppressWarnings("checkstyle:methodlength") public static void main(final String[] args) { - LOGGER.info("Seeding database with initial entries..."); + LOGGER.error("Seeding database with initial entries..."); // construct application context AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); context.getEnvironment().addActiveProfile(HIRSProfiles.SERVER); @@ -68,7 +68,7 @@ public final class SystemInit { // scan for appraiser plugins int registeredBeanCount = scanner.scan("hirs"); System.out.println("Beans scanned " + registeredBeanCount); - LOGGER.info("Beans scanned: " + registeredBeanCount); + LOGGER.error("Beans scanned: " + registeredBeanCount); // register the database configuration and refresh the context context.register(PersistenceConfiguration.class); @@ -94,7 +94,7 @@ public final class SystemInit { LOGGER.info("DeviceInfo appraiser found."); } - LOGGER.info("Checking for TPM appraiser..."); + LOGGER.error("Checking for TPM appraiser..."); TPMAppraiser tpmApp = (TPMAppraiser) appraiserServiceImpl.getAppraiser(TPMAppraiser.NAME); if (tpmApp == null) { LOGGER.info("TPM appraiser not found; creating..."); diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/entity/SupportReferenceManifest.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/entity/SupportReferenceManifest.java index 975d43bc..3f2e1650 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/entity/SupportReferenceManifest.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/entity/SupportReferenceManifest.java @@ -19,6 +19,8 @@ import java.util.Collection; /** * Sub class that will just focus on PCR Values and Events. */ +@Getter +@Setter @Entity public class SupportReferenceManifest extends ReferenceManifest { private static final Logger LOGGER = LogManager.getLogger(SupportReferenceManifest.class); diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/entity/certificate/ConformanceCredential.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/entity/certificate/ConformanceCredential.java index b5618749..38242f01 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/entity/certificate/ConformanceCredential.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/entity/certificate/ConformanceCredential.java @@ -1,7 +1,7 @@ package hirs.attestationca.entity.certificate; import hirs.attestationca.entity.CertificateSelector; -import hirs.persist.service.CertificateService; +import hirs.attestationca.service.CertificateService; import javax.persistence.Entity; import java.io.IOException; diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/repository/ReportSummaryRepository.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/repository/ReportSummaryRepository.java index cb450790..f35e3243 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/repository/ReportSummaryRepository.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/repository/ReportSummaryRepository.java @@ -13,14 +13,14 @@ import java.util.UUID; public interface ReportSummaryRepository extends JpaRepository { - /** - * Saves the ReportSummary in the database. This creates a new - * database session and saves the report summary. - * - * @param reportSummary ReportSummary to save - * @return reference to saved reportSummary - */ - T save(T reportSummary); +// /** +// * Saves the ReportSummary in the database. This creates a new +// * database session and saves the report summary. +// * +// * @param reportSummary ReportSummary to save +// * @return reference to saved reportSummary +// */ +// T save(T reportSummary); /** * Update the ReportSummary in the database. This creates a new diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/service/ReferenceManifestServiceImpl.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/service/ReferenceManifestServiceImpl.java index ed88ea5a..26c73a62 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/service/ReferenceManifestServiceImpl.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/service/ReferenceManifestServiceImpl.java @@ -1,12 +1,12 @@ package hirs.attestationca.service; import hirs.FilteredRecordsList; +import hirs.attestationca.entity.ReferenceManifest; +import hirs.attestationca.entity.ReferenceManifestSelector; import hirs.attestationca.repository.ReferenceManifestRepository; import hirs.data.persist.ArchivableEntity; -import hirs.attestationca.entity.ReferenceManifest; import hirs.persist.CriteriaModifier; import hirs.persist.DBManagerException; -import hirs.persist.service.ReferenceManifestService; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; diff --git a/HIRS_AttestationCA/src/main/resources/applicationContext.xml b/HIRS_AttestationCA/src/main/resources/applicationContext.xml index 8211f135..cab9bf30 100644 --- a/HIRS_AttestationCA/src/main/resources/applicationContext.xml +++ b/HIRS_AttestationCA/src/main/resources/applicationContext.xml @@ -7,6 +7,6 @@ http://www.springframework.org/schema/context/spring-context.xsd"> - + diff --git a/HIRS_AttestationCAPortal/build.gradle b/HIRS_AttestationCAPortal/build.gradle index d0025e3a..0f90cd7b 100644 --- a/HIRS_AttestationCAPortal/build.gradle +++ b/HIRS_AttestationCAPortal/build.gradle @@ -37,6 +37,8 @@ dependencies { implementation libs.spring.orm implementation libs.spring.transaction implementation libs.spring.webmvc + implementation libs.lombok + annotationProcessor libs.lombok testImplementation libs.hamcrest // override the servlet API for testing. Required for Spring Integration tests 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 31974217..f794405b 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 @@ -16,6 +16,7 @@ import hirs.attestationca.entity.ReferenceManifest; import hirs.attestationca.entity.SupportReferenceManifest; import hirs.attestationca.entity.SwidResource; import hirs.attestationca.entity.certificate.Certificate; +import hirs.attestationca.service.ReferenceDigestValueService; import hirs.persist.CriteriaModifier; import hirs.persist.DBManagerException; import hirs.attestationca.service.ReferenceManifestService; @@ -78,7 +79,7 @@ public class ReferenceManifestPageController @Autowired private final ReferenceManifestService referenceManifestService; @Autowired - private final ReferenceEventManager referenceEventManager; + private final ReferenceDigestValueService referenceDigestValueService; private static final Logger LOGGER = LogManager.getLogger(ReferenceManifestPageController.class); @@ -128,15 +129,15 @@ public class ReferenceManifestPageController * Constructor providing the Page's display and routing specification. * * @param referenceManifestService the reference manifest service - * @param referenceEventManager this is the reference event manager + * @param referenceDigestValueService this is the reference digest value service */ @Autowired public ReferenceManifestPageController( final ReferenceManifestService referenceManifestService, - final ReferenceEventManager referenceEventManager) { + final ReferenceDigestValueService referenceDigestValueService) { super(Page.REFERENCE_MANIFESTS); this.referenceManifestService = referenceManifestService; - this.referenceEventManager = referenceEventManager; + this.referenceDigestValueService = referenceDigestValueService; this.biosValidator = new BiosDateValidator(BIOS_RELEASE_DATE_FORMAT); } @@ -296,12 +297,12 @@ public class ReferenceManifestPageController // if support rim, update associated events if (referenceManifest instanceof SupportReferenceManifest) { - List rdvs = referenceEventManager - .getValuesByRimId(referenceManifest); + List rdvs = referenceDigestValueService + .getValuesByBaseRimId(referenceManifest.getId()); for (ReferenceDigestValue rdv : rdvs) { rdv.archive("Support RIM was deleted"); - referenceEventManager.updateEvent(rdv); + referenceDigestValueService.updateDigestValue(rdv, rdv.getId()); } } } @@ -652,7 +653,7 @@ public class ReferenceManifestPageController // get by support rim id NEXT if (dbSupport.getPlatformManufacturer() != null) { - tpmEvents = referenceEventManager.getValuesByRimId(dbSupport); + tpmEvents = referenceDigestValueService.getValuesByBaseRimId(dbSupport.getId()); baseRim = findBaseRim(dbSupport); if (tpmEvents.isEmpty()) { ReferenceDigestValue rdv; @@ -665,7 +666,7 @@ public class ReferenceManifestPageController tpe.getEventDigestStr(), tpe.getEventTypeStr(), false, false, updated, tpe.getEventContent()); - this.referenceEventManager.saveValue(rdv); + this.referenceDigestValueService.saveDigestValue(rdv); } } catch (CertificateException e) { e.printStackTrace(); @@ -678,7 +679,7 @@ public class ReferenceManifestPageController for (ReferenceDigestValue rdv : tpmEvents) { if (!rdv.isUpdated()) { rdv.updateInfo(dbSupport, baseRim.getId()); - this.referenceEventManager.updateEvent(rdv); + this.referenceDigestValueService.updateDigestValue(rdv, rdv.getId()); } } } diff --git a/HIRS_Utils/src/test/java/hirs/TPMReportRequestTest.java b/HIRS_Utils/src/test/java/hirs/TPMReportRequestTest.java index 563b7ce2..6dfa78f6 100644 --- a/HIRS_Utils/src/test/java/hirs/TPMReportRequestTest.java +++ b/HIRS_Utils/src/test/java/hirs/TPMReportRequestTest.java @@ -80,13 +80,4 @@ public class TPMReportRequestTest { TPMReportRequest tpmRepReq = new TPMReportRequest(TEST_NONCE, TEST_MASK); Assert.assertEquals(tpmRepReq.getPcrMask(), TEST_MASK); } - - /** - * Tests ReportType getter method. - */ - @Test - public final void getReportType() { - TPMReportRequest tpmRepReq = new TPMReportRequest(TEST_NONCE, TEST_MASK); - Assert.assertEquals(tpmRepReq.getReportType(), TPMReport.class); - } } diff --git a/settings.gradle b/settings.gradle index dd9ad52a..bb64586c 100644 --- a/settings.gradle +++ b/settings.gradle @@ -50,6 +50,7 @@ dependencyResolutionManagement { library('log4j2-impl', 'org.apache.logging.log4j:log4j-slf4j-impl:2.17.1') library('log4j2_web', 'org.apache.logging.log4j:log4j-web:2.17.1') library('log4j2_bridge', 'org.apache.logging.log4j:log4j-jcl:2.17.1') + library('lombok', 'org.projectlombok:lombok:1.18.24') library('mariadb', 'org.mariadb.jdbc:mariadb-java-client:3.0.4') library('minimal_json', 'com.eclipsesource.minimal-json:minimal-json:0.9.5') library('mockito', 'org.mockito:mockito-all:1.10.19')