From 8a8fca726ccedc3a3aa1eab3da9296d4d8b795b7 Mon Sep 17 00:00:00 2001 From: Cyrus <24922493+cyrus-dev@users.noreply.github.com> Date: Tue, 9 Aug 2022 06:03:48 -0400 Subject: [PATCH] Resolved all non-unit test code errors --- ...stractAttestationCertificateAuthority.java | 52 ++++++++++--------- ...estfulAttestationCertificateAuthority.java | 8 +-- .../service/CertificateServiceImpl.java | 4 +- .../service/DeviceServiceImpl.java | 5 +- .../service/PolicyServiceImpl.java | 5 +- .../ReferenceDigestValueServiceImpl.java | 4 +- .../service/ReferenceManifestServiceImpl.java | 12 +++-- .../SupplyChainValidationService.java | 2 +- .../SupplyChainValidationServiceImpl.java | 2 +- .../validation/package-info.java | 5 ++ .../SupplyChainValidationServiceImplTest.java | 1 + .../controllers/DevicesPageController.java | 16 +++--- ...eferenceManifestDetailsPageController.java | 2 +- .../RimDatabasePageController.java | 14 ++--- .../persist/ReferenceManifestSelector.java | 2 +- .../persist/service/CertificateService.java | 3 +- .../hirs/persist/service/DeviceService.java | 3 +- .../hirs/persist/service/PolicyService.java | 3 +- .../service/ReferenceDigestValueService.java | 3 +- .../service/ReferenceManifestService.java | 12 ++++- 20 files changed, 90 insertions(+), 68 deletions(-) rename HIRS_AttestationCA/src/main/java/hirs/attestationca/{service => validation}/SupplyChainValidationService.java (97%) rename HIRS_AttestationCA/src/main/java/hirs/attestationca/{service => validation}/SupplyChainValidationServiceImpl.java (99%) create mode 100644 HIRS_AttestationCA/src/main/java/hirs/attestationca/validation/package-info.java diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/AbstractAttestationCertificateAuthority.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/AbstractAttestationCertificateAuthority.java index 8509fabf..a2595c29 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/AbstractAttestationCertificateAuthority.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/AbstractAttestationCertificateAuthority.java @@ -6,7 +6,7 @@ import hirs.attestationca.configuration.provisionerTpm2.ProvisionerTpm2; import hirs.attestationca.exceptions.CertificateProcessingException; import hirs.attestationca.exceptions.IdentityProcessingException; import hirs.attestationca.exceptions.UnexpectedServerException; -import hirs.attestationca.service.SupplyChainValidationService; +import hirs.attestationca.validation.SupplyChainValidationService; import hirs.data.persist.AppraisalStatus; import hirs.data.persist.BaseReferenceManifest; import hirs.data.persist.Device; @@ -30,9 +30,9 @@ import hirs.data.persist.policy.SupplyChainPolicy; import hirs.data.service.DeviceRegister; import hirs.persist.DeviceManager; import hirs.persist.ReferenceEventManager; -import hirs.persist.ReferenceManifestManager; import hirs.persist.TPM2ProvisionerState; import hirs.persist.service.CertificateService; +import hirs.persist.service.ReferenceManifestService; import hirs.structs.converters.SimpleStructBuilder; import hirs.structs.converters.StructConverter; import hirs.structs.elements.aca.IdentityRequestEnvelope; @@ -175,7 +175,7 @@ public abstract class AbstractAttestationCertificateAuthority private Integer validDays = 1; private final CertificateService certificateService; - private final ReferenceManifestManager referenceManifestManager; + private final ReferenceManifestService referenceManifestService; private final DeviceRegister deviceRegister; private final DeviceManager deviceManager; private final ReferenceEventManager referenceEventManager; @@ -189,7 +189,7 @@ public abstract class AbstractAttestationCertificateAuthority * @param acaCertificate the ACA certificate * @param structConverter the struct converter * @param certificateService the certificate service - * @param referenceManifestManager the Reference Manifest manager + * @param referenceManifestService the Reference Manifest service * @param deviceRegister the device register * @param validDays the number of days issued certs are valid * @param deviceManager the device manager @@ -201,7 +201,7 @@ public abstract class AbstractAttestationCertificateAuthority final PrivateKey privateKey, final X509Certificate acaCertificate, final StructConverter structConverter, final CertificateService certificateService, - final ReferenceManifestManager referenceManifestManager, + final ReferenceManifestService referenceManifestService, final DeviceRegister deviceRegister, final int validDays, final DeviceManager deviceManager, final ReferenceEventManager referenceEventManager) { @@ -210,7 +210,7 @@ public abstract class AbstractAttestationCertificateAuthority this.acaCertificate = acaCertificate; this.structConverter = structConverter; this.certificateService = certificateService; - this.referenceManifestManager = referenceManifestManager; + this.referenceManifestService = referenceManifestService; this.deviceRegister = deviceRegister; this.validDays = validDays; this.deviceManager = deviceManager; @@ -796,7 +796,7 @@ public abstract class AbstractAttestationCertificateAuthority if (dv.getLogfileCount() > 0) { for (ByteString logFile : dv.getLogfileList()) { try { - support = SupportReferenceManifest.select(referenceManifestManager) + support = SupportReferenceManifest.select(referenceManifestService) .byHexDecHash(Hex.encodeHexString(messageDigest.digest( logFile.toByteArray()))).includeArchived() .getRIM(); @@ -814,13 +814,14 @@ public abstract class AbstractAttestationCertificateAuthority support.getHexDecHash().substring( support.getHexDecHash().length() - NUM_OF_VARIABLES))); support.setDeviceName(dv.getNw().getHostname()); - this.referenceManifestManager.save(support); + this.referenceManifestService.saveRIM(support); } else { LOG.info("Client provided Support RIM already loaded in database."); if (support.isArchived()) { support.restore(); support.resetCreateTime(); - this.referenceManifestManager.update(support); + this.referenceManifestService.updateReferenceManifest(support, + support.getId()); } } } catch (IOException ioEx) { @@ -838,7 +839,7 @@ public abstract class AbstractAttestationCertificateAuthority if (dv.getSwidfileCount() > 0) { for (ByteString swidFile : dv.getSwidfileList()) { try { - dbBaseRim = BaseReferenceManifest.select(referenceManifestManager) + dbBaseRim = BaseReferenceManifest.select(referenceManifestService) .byBase64Hash(Base64.getEncoder() .encodeToString(messageDigest .digest(swidFile.toByteArray()))) @@ -850,7 +851,7 @@ public abstract class AbstractAttestationCertificateAuthority defaultClientName), swidFile.toByteArray()); dbBaseRim.setDeviceName(dv.getNw().getHostname()); - this.referenceManifestManager.save(dbBaseRim); + this.referenceManifestService.saveRIM(dbBaseRim); } else { LOG.info("Client provided Base RIM already loaded in database."); /** @@ -860,7 +861,8 @@ public abstract class AbstractAttestationCertificateAuthority if (dbBaseRim.isArchived()) { dbBaseRim.restore(); dbBaseRim.resetCreateTime(); - this.referenceManifestManager.update(dbBaseRim); + this.referenceManifestService.updateReferenceManifest(dbBaseRim, + dbBaseRim.getId()); } } } catch (IOException ioEx) { @@ -874,7 +876,7 @@ public abstract class AbstractAttestationCertificateAuthority //update Support RIMs and Base RIMs. for (ByteString swidFile : dv.getSwidfileList()) { - dbBaseRim = BaseReferenceManifest.select(referenceManifestManager) + dbBaseRim = BaseReferenceManifest.select(referenceManifestService) .byBase64Hash(Base64.getEncoder().encodeToString(messageDigest.digest( swidFile.toByteArray()))).includeArchived() .getRIM(); @@ -893,7 +895,7 @@ public abstract class AbstractAttestationCertificateAuthority // now update support rim SupportReferenceManifest dbSupport = SupportReferenceManifest - .select(referenceManifestManager) + .select(referenceManifestService) .byHexDecHash(swid.getHashValue()).getRIM(); if (dbSupport != null) { dbSupport.setFileName(swid.getName()); @@ -906,11 +908,13 @@ public abstract class AbstractAttestationCertificateAuthority dbBaseRim.setAssociatedRim(dbSupport.getId()); dbSupport.setUpdated(true); dbSupport.setAssociatedRim(dbBaseRim.getId()); - this.referenceManifestManager.update(dbSupport); + this.referenceManifestService.updateReferenceManifest(dbSupport, + dbSupport.getId()); listOfSavedRims.add(dbSupport); } } - this.referenceManifestManager.update(dbBaseRim); + this.referenceManifestService.updateReferenceManifest(dbBaseRim, + dbBaseRim.getId()); listOfSavedRims.add(dbBaseRim); } } @@ -925,18 +929,18 @@ public abstract class AbstractAttestationCertificateAuthority EventLogMeasurements temp = new EventLogMeasurements(fileName, dv.getLivelog().toByteArray()); // find previous version. - measurements = EventLogMeasurements.select(referenceManifestManager) + measurements = EventLogMeasurements.select(referenceManifestService) .byDeviceName(dv.getNw().getHostname()) .includeArchived() .getRIM(); if (measurements != null) { // Find previous log and delete it - referenceManifestManager.deleteReferenceManifest(measurements); + referenceManifestService.deleteRIM(measurements); } BaseReferenceManifest baseRim = BaseReferenceManifest - .select(referenceManifestManager) + .select(referenceManifestService) .byManufacturerModelBase(dv.getHw().getManufacturer(), dv.getHw().getProductName()) .getRIM(); @@ -948,19 +952,19 @@ public abstract class AbstractAttestationCertificateAuthority if (baseRim != null) { measurements.setAssociatedRim(baseRim.getAssociatedRim()); } - this.referenceManifestManager.save(measurements); + this.referenceManifestService.saveRIM(measurements); if (baseRim != null) { // pull the base versions of the swidtag and rimel and set the // event log hash for use during provision SupportReferenceManifest sBaseRim = SupportReferenceManifest - .select(referenceManifestManager) + .select(referenceManifestService) .byEntityId(baseRim.getAssociatedRim()) .getRIM(); baseRim.setEventLogHash(temp.getHexDecHash()); sBaseRim.setEventLogHash(temp.getHexDecHash()); - referenceManifestManager.update(baseRim); - referenceManifestManager.update(sBaseRim); + referenceManifestService.updateReferenceManifest(baseRim, baseRim.getId()); + referenceManifestService.updateReferenceManifest(sBaseRim, baseRim.getId()); } } catch (IOException ioEx) { LOG.error(ioEx); @@ -995,7 +999,7 @@ public abstract class AbstractAttestationCertificateAuthority List supplementalRims = new ArrayList<>(); List patchRims = new ArrayList<>(); Set dbSupportRims = SupportReferenceManifest - .select(referenceManifestManager) + .select(referenceManifestService) .byManufacturerModel(manufacturer, model).getRIMs(); List sourcedValues = referenceEventManager .getValueByManufacturerModel(manufacturer, model); diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/rest/RestfulAttestationCertificateAuthority.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/rest/RestfulAttestationCertificateAuthority.java index 0b1a76e0..884b960d 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/rest/RestfulAttestationCertificateAuthority.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/rest/RestfulAttestationCertificateAuthority.java @@ -1,7 +1,7 @@ package hirs.attestationca.rest; import hirs.attestationca.AbstractAttestationCertificateAuthority; -import hirs.attestationca.service.SupplyChainValidationService; +import hirs.attestationca.validation.SupplyChainValidationService; import hirs.data.service.DeviceRegister; import hirs.persist.CertificateManager; import hirs.persist.DeviceManager; @@ -35,7 +35,7 @@ public class RestfulAttestationCertificateAuthority * @param privateKey the ACA private key * @param acaCertificate the ACA certificate * @param structConverter the struct converter - * @param certificateManager the certificate manager + * @param certificateService the certificate service * @param referenceManifestManager the referenceManifestManager * @param deviceRegister the device register * @param validDays the number of days issued certs are valid @@ -48,14 +48,14 @@ public class RestfulAttestationCertificateAuthority final SupplyChainValidationService supplyChainValidationService, final PrivateKey privateKey, final X509Certificate acaCertificate, final StructConverter structConverter, - final CertificateManager certificateManager, + final CertificateManager certificateService, final ReferenceManifestManager referenceManifestManager, final DeviceRegister deviceRegister, final DeviceManager deviceManager, final ReferenceEventManager referenceEventManager, @Value("${aca.certificates.validity}") final int validDays) { super(supplyChainValidationService, privateKey, acaCertificate, structConverter, - certificateManager, referenceManifestManager, + certificateService, referenceManifestManager, deviceRegister, validDays, deviceManager, referenceEventManager); } diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/service/CertificateServiceImpl.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/service/CertificateServiceImpl.java index a0d58edb..e1b1bdc3 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/service/CertificateServiceImpl.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/service/CertificateServiceImpl.java @@ -10,7 +10,6 @@ import hirs.data.persist.certificate.PlatformCredential; import hirs.persist.CertificateSelector; import hirs.persist.CriteriaModifier; import hirs.persist.DBManagerException; -import hirs.persist.OrderedQuery; import hirs.persist.service.CertificateService; import hirs.persist.service.DefaultService; import org.apache.logging.log4j.LogManager; @@ -34,8 +33,7 @@ import java.util.UUID; */ @Service public class CertificateServiceImpl extends DbServiceImpl - implements DefaultService, - CertificateService, OrderedQuery { + implements DefaultService, CertificateService { private static final Logger LOGGER = LogManager.getLogger(CertificateServiceImpl.class); @Autowired diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/service/DeviceServiceImpl.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/service/DeviceServiceImpl.java index 33f0ccf8..284d05cf 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/service/DeviceServiceImpl.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/service/DeviceServiceImpl.java @@ -6,7 +6,6 @@ import hirs.data.persist.Device; import hirs.persist.CriteriaModifier; import hirs.persist.DBManagerException; import hirs.persist.DeviceManagerException; -import hirs.persist.OrderedQuery; import hirs.persist.service.DefaultService; import hirs.persist.service.DeviceService; import org.apache.logging.log4j.LogManager; @@ -27,8 +26,8 @@ import java.util.UUID; * support for the basic create, read, update, and delete methods. */ @Service -public class DeviceServiceImpl extends DbServiceImpl implements DefaultService, - DeviceService, OrderedQuery { +public class DeviceServiceImpl extends DbServiceImpl + implements DefaultService, DeviceService { private static final Logger LOGGER = LogManager.getLogger(DeviceServiceImpl.class); @Autowired diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/service/PolicyServiceImpl.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/service/PolicyServiceImpl.java index 7b5d19b5..bc00007e 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/service/PolicyServiceImpl.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/service/PolicyServiceImpl.java @@ -6,7 +6,6 @@ import hirs.attestationca.repository.PolicyRepository; import hirs.data.persist.policy.Policy; import hirs.persist.CriteriaModifier; import hirs.persist.DBManagerException; -import hirs.persist.OrderedQuery; import hirs.persist.PolicyMapper; import hirs.persist.service.DefaultService; import hirs.persist.service.PolicyService; @@ -35,8 +34,8 @@ import java.util.UUID; * support for the basic create, read, update, and delete methods. */ @Service -public class PolicyServiceImpl extends DbServiceImpl implements DefaultService, - PolicyService, OrderedQuery { +public class PolicyServiceImpl extends DbServiceImpl + implements DefaultService, PolicyService { private static final Logger LOGGER = LogManager.getLogger(PolicyServiceImpl.class); @Autowired diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/service/ReferenceDigestValueServiceImpl.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/service/ReferenceDigestValueServiceImpl.java index 17b29d5c..4038c844 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/service/ReferenceDigestValueServiceImpl.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/service/ReferenceDigestValueServiceImpl.java @@ -5,7 +5,6 @@ import hirs.attestationca.repository.ReferenceDigestValueRepository; import hirs.data.persist.ReferenceDigestValue; import hirs.persist.CriteriaModifier; import hirs.persist.DBManagerException; -import hirs.persist.OrderedQuery; import hirs.persist.service.DefaultService; import hirs.persist.service.ReferenceDigestValueService; import org.apache.logging.log4j.LogManager; @@ -27,8 +26,7 @@ import java.util.UUID; */ @Service public class ReferenceDigestValueServiceImpl extends DbServiceImpl - implements DefaultService, - ReferenceDigestValueService, OrderedQuery { + implements DefaultService, ReferenceDigestValueService { private static final Logger LOGGER = LogManager .getLogger(ReferenceDigestValueServiceImpl.class); 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 e61003ca..709bb896 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/service/ReferenceManifestServiceImpl.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/service/ReferenceManifestServiceImpl.java @@ -5,7 +5,6 @@ import hirs.attestationca.repository.ReferenceManifestRepository; import hirs.data.persist.ReferenceManifest; import hirs.persist.CriteriaModifier; import hirs.persist.DBManagerException; -import hirs.persist.OrderedQuery; import hirs.persist.service.DefaultService; import hirs.persist.service.ReferenceManifestService; import org.apache.logging.log4j.LogManager; @@ -27,8 +26,7 @@ import java.util.UUID; */ @Service public class ReferenceManifestServiceImpl extends DbServiceImpl - implements DefaultService, - ReferenceManifestService, OrderedQuery { + implements DefaultService, ReferenceManifestService { private static final Logger LOGGER = LogManager.getLogger(ReferenceManifestServiceImpl.class); @Autowired @@ -66,7 +64,8 @@ public class ReferenceManifestServiceImpl extends DbServiceImpl getList() { LOGGER.debug("Getting all reference manifest..."); diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/service/SupplyChainValidationService.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/validation/SupplyChainValidationService.java similarity index 97% rename from HIRS_AttestationCA/src/main/java/hirs/attestationca/service/SupplyChainValidationService.java rename to HIRS_AttestationCA/src/main/java/hirs/attestationca/validation/SupplyChainValidationService.java index a47072f9..8997f323 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/service/SupplyChainValidationService.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/validation/SupplyChainValidationService.java @@ -1,4 +1,4 @@ -package hirs.attestationca.service; +package hirs.attestationca.validation; import hirs.data.persist.Device; import hirs.data.persist.SupplyChainValidationSummary; diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/service/SupplyChainValidationServiceImpl.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/validation/SupplyChainValidationServiceImpl.java similarity index 99% rename from HIRS_AttestationCA/src/main/java/hirs/attestationca/service/SupplyChainValidationServiceImpl.java rename to HIRS_AttestationCA/src/main/java/hirs/attestationca/validation/SupplyChainValidationServiceImpl.java index 6d0c0093..35bc0d38 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/service/SupplyChainValidationServiceImpl.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/validation/SupplyChainValidationServiceImpl.java @@ -1,4 +1,4 @@ -package hirs.attestationca.service; +package hirs.attestationca.validation; import hirs.appraiser.Appraiser; import hirs.appraiser.SupplyChainAppraiser; diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/validation/package-info.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/validation/package-info.java new file mode 100644 index 00000000..1d71708f --- /dev/null +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/validation/package-info.java @@ -0,0 +1,5 @@ +/** + * Contains the main functionality of the SupplyChainValidationService. Executes the actual + * validation based on the current supply chain policy. + */ +package hirs.attestationca.validation; diff --git a/HIRS_AttestationCA/src/test/java/hirs/attestationca/service/SupplyChainValidationServiceImplTest.java b/HIRS_AttestationCA/src/test/java/hirs/attestationca/service/SupplyChainValidationServiceImplTest.java index f5838b23..67aed402 100644 --- a/HIRS_AttestationCA/src/test/java/hirs/attestationca/service/SupplyChainValidationServiceImplTest.java +++ b/HIRS_AttestationCA/src/test/java/hirs/attestationca/service/SupplyChainValidationServiceImplTest.java @@ -2,6 +2,7 @@ package hirs.attestationca.service; import hirs.attestationca.persist.SpringPersistenceTest; import hirs.appraiser.SupplyChainAppraiser; +import hirs.attestationca.validation.SupplyChainValidationServiceImpl; import hirs.data.persist.AppraisalStatus; import hirs.data.persist.Device; import hirs.data.persist.DeviceInfoReport; diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/DevicesPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/DevicesPageController.java index fc5682db..961cdcf0 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/DevicesPageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/DevicesPageController.java @@ -6,11 +6,11 @@ import hirs.attestationca.portal.datatables.DataTableResponse; import hirs.attestationca.portal.datatables.OrderedListQueryDataTableAdapter; import hirs.attestationca.portal.page.PageController; import hirs.attestationca.portal.page.params.NoPageParams; +import hirs.attestationca.servicemanager.DBManager; import hirs.data.persist.Device; import hirs.data.persist.certificate.Certificate; import hirs.data.persist.certificate.DeviceAssociatedCertificate; -import hirs.attestationca.servicemanager.DBManager; -import hirs.persist.DeviceManager; +import hirs.persist.service.DeviceService; import org.apache.logging.log4j.Logger; import org.hibernate.criterion.Restrictions; import org.springframework.beans.factory.annotation.Autowired; @@ -40,22 +40,22 @@ import static org.apache.logging.log4j.LogManager.getLogger; public class DevicesPageController extends PageController { @Autowired - private final DeviceManager deviceManager; + private final DeviceService deviceService; @Autowired - private final DBManager certificateDBManager; + private final DBManager certificateDBManager; // this may be what I need to do for all of them private static final Logger LOGGER = getLogger(DevicesPageController.class); /** * Constructor providing the Page's display and routing specification. - * @param deviceManager the device manager + * @param deviceService the device manager * @param certificateDBManager the certificate DB manager */ @Autowired public DevicesPageController( - final DeviceManager deviceManager, + final DeviceService deviceService, final DBManager certificateDBManager) { super(DEVICES); - this.deviceManager = deviceManager; + this.deviceService = deviceService; this.certificateDBManager = certificateDBManager; } @@ -90,7 +90,7 @@ public class DevicesPageController extends PageController { // get all the devices FilteredRecordsList deviceList = OrderedListQueryDataTableAdapter.getOrderedList(Device.class, - deviceManager, input, orderColumnName); + deviceService, input, orderColumnName); FilteredRecordsList> record = retrieveDevicesAndAssociatedCertificates(deviceList); 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 b471aa0f..f7791b89 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 @@ -4,7 +4,7 @@ import hirs.attestationca.portal.page.Page; import hirs.attestationca.portal.page.PageController; import hirs.attestationca.portal.page.PageMessages; import hirs.attestationca.portal.page.params.ReferenceManifestDetailsPageParams; -import hirs.attestationca.service.SupplyChainValidationServiceImpl; +import hirs.attestationca.validation.SupplyChainValidationServiceImpl; import hirs.data.persist.BaseReferenceManifest; import hirs.data.persist.EventLogMeasurements; import hirs.data.persist.ReferenceDigestValue; diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/RimDatabasePageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/RimDatabasePageController.java index fceb344b..82d8d1ef 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/RimDatabasePageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/RimDatabasePageController.java @@ -9,13 +9,13 @@ import hirs.attestationca.portal.page.Page; import hirs.attestationca.portal.page.PageController; import hirs.attestationca.portal.page.params.NoPageParams; import hirs.attestationca.service.ReferenceDigestValueServiceImpl; -import hirs.attestationca.servicemanager.DBReferenceManifestManager; +import hirs.attestationca.service.ReferenceManifestServiceImpl; import hirs.data.persist.ReferenceDigestValue; import hirs.data.persist.SupportReferenceManifest; import hirs.data.persist.certificate.Certificate; import hirs.persist.CriteriaModifier; import hirs.persist.DBManagerException; -import hirs.persist.ReferenceManifestManager; +import hirs.persist.service.ReferenceManifestService; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.hibernate.Criteria; @@ -45,7 +45,7 @@ public class RimDatabasePageController private static final String BIOS_RELEASE_DATE_FORMAT = "yyyy-MM-dd"; private final BiosDateValidator biosValidator; - private final ReferenceManifestManager referenceManifestManager; + private final ReferenceManifestService referenceManifestService; private final ReferenceDigestValueServiceImpl referenceDigestValueService; private static final Logger LOGGER = LogManager.getLogger(RimDatabasePageController.class); @@ -95,15 +95,15 @@ public class RimDatabasePageController /** * Constructor providing the Page's display and routing specification. * - * @param referenceManifestManager the ReferenceManifestManager object + * @param referenceManifestService the referenceManifestService object * @param referenceDigestValueService the referenceDigestValueService object */ @Autowired public RimDatabasePageController( - final DBReferenceManifestManager referenceManifestManager, + final ReferenceManifestServiceImpl referenceManifestService, final ReferenceDigestValueServiceImpl referenceDigestValueService) { super(Page.RIM_DATABASE); - this.referenceManifestManager = referenceManifestManager; + this.referenceManifestService = referenceManifestService; this.referenceDigestValueService = referenceDigestValueService; this.biosValidator = new BiosDateValidator(BIOS_RELEASE_DATE_FORMAT); } @@ -162,7 +162,7 @@ public class RimDatabasePageController for (ReferenceDigestValue rdv : referenceDigestValues) { // We are updating the base rim ID field if necessary and if (rdv.getBaseRimId() == null) { - support = SupportReferenceManifest.select(referenceManifestManager) + support = SupportReferenceManifest.select(referenceManifestService) .byEntityId(rdv.getSupportRimId()).getRIM(); if (support != null) { rdv.setBaseRimId(support.getAssociatedRim()); diff --git a/HIRS_Utils/src/main/java/hirs/persist/ReferenceManifestSelector.java b/HIRS_Utils/src/main/java/hirs/persist/ReferenceManifestSelector.java index a26d7a5e..a3270e7b 100644 --- a/HIRS_Utils/src/main/java/hirs/persist/ReferenceManifestSelector.java +++ b/HIRS_Utils/src/main/java/hirs/persist/ReferenceManifestSelector.java @@ -219,7 +219,7 @@ public abstract class ReferenceManifestSelector { // construct and execute query private Set execute() { - Set results = this.referenceManifestService.get; + Set results = this.referenceManifestService.ge; return results; } diff --git a/HIRS_Utils/src/main/java/hirs/persist/service/CertificateService.java b/HIRS_Utils/src/main/java/hirs/persist/service/CertificateService.java index abb92786..a126f869 100644 --- a/HIRS_Utils/src/main/java/hirs/persist/service/CertificateService.java +++ b/HIRS_Utils/src/main/java/hirs/persist/service/CertificateService.java @@ -2,6 +2,7 @@ package hirs.persist.service; import hirs.data.persist.certificate.Certificate; import hirs.persist.CertificateSelector; +import hirs.persist.OrderedQuery; import java.util.Set; import java.util.UUID; @@ -11,7 +12,7 @@ import java.util.UUID; * CertificateService is used to store and manage certificates. It has * support for the basic create, read, update, and delete methods. */ -public interface CertificateService { +public interface CertificateService extends OrderedQuery { /** * Saves the Certificate in the database. This creates a new diff --git a/HIRS_Utils/src/main/java/hirs/persist/service/DeviceService.java b/HIRS_Utils/src/main/java/hirs/persist/service/DeviceService.java index ad139384..e6076b6e 100644 --- a/HIRS_Utils/src/main/java/hirs/persist/service/DeviceService.java +++ b/HIRS_Utils/src/main/java/hirs/persist/service/DeviceService.java @@ -2,6 +2,7 @@ package hirs.persist.service; import hirs.data.persist.Device; import hirs.persist.DeviceManagerException; +import hirs.persist.OrderedQuery; import java.util.UUID; @@ -10,7 +11,7 @@ import java.util.UUID; * DeviceService is used to store and manage devices. It has * support for the basic create, read, update, and delete methods. */ -public interface DeviceService { +public interface DeviceService extends OrderedQuery { /** * Saves the Device in the database. This creates a new diff --git a/HIRS_Utils/src/main/java/hirs/persist/service/PolicyService.java b/HIRS_Utils/src/main/java/hirs/persist/service/PolicyService.java index 9846391b..78c29e05 100644 --- a/HIRS_Utils/src/main/java/hirs/persist/service/PolicyService.java +++ b/HIRS_Utils/src/main/java/hirs/persist/service/PolicyService.java @@ -2,6 +2,7 @@ package hirs.persist.service; import hirs.appraiser.Appraiser; import hirs.data.persist.policy.Policy; +import hirs.persist.OrderedQuery; import java.util.UUID; @@ -10,7 +11,7 @@ import java.util.UUID; * PolicyService is used to store and manage policies. It has * support for the basic create, read, update, and delete methods. */ -public interface PolicyService { +public interface PolicyService extends OrderedQuery { /** * Saves the Policy in the database. This creates a new diff --git a/HIRS_Utils/src/main/java/hirs/persist/service/ReferenceDigestValueService.java b/HIRS_Utils/src/main/java/hirs/persist/service/ReferenceDigestValueService.java index 4389c6e1..642dbdb9 100644 --- a/HIRS_Utils/src/main/java/hirs/persist/service/ReferenceDigestValueService.java +++ b/HIRS_Utils/src/main/java/hirs/persist/service/ReferenceDigestValueService.java @@ -1,6 +1,7 @@ package hirs.persist.service; import hirs.data.persist.ReferenceDigestValue; +import hirs.persist.OrderedQuery; import java.util.List; import java.util.UUID; @@ -10,7 +11,7 @@ import java.util.UUID; * ReferenceDigestValue is used to store and manage digest events. It has * support for the basic create, read, update, and delete methods. */ -public interface ReferenceDigestValueService { +public interface ReferenceDigestValueService extends OrderedQuery { /** * Saves the ReferenceDigestValue in the database. This creates a new diff --git a/HIRS_Utils/src/main/java/hirs/persist/service/ReferenceManifestService.java b/HIRS_Utils/src/main/java/hirs/persist/service/ReferenceManifestService.java index 972fde64..ea2182fe 100644 --- a/HIRS_Utils/src/main/java/hirs/persist/service/ReferenceManifestService.java +++ b/HIRS_Utils/src/main/java/hirs/persist/service/ReferenceManifestService.java @@ -1,6 +1,7 @@ package hirs.persist.service; import hirs.data.persist.ReferenceManifest; +import hirs.persist.OrderedQuery; import java.util.UUID; @@ -9,7 +10,7 @@ import java.util.UUID; * ReferenceManifestService is used to store and manage reference manifests. It has * support for the basic create, read, update, and delete methods. */ -public interface ReferenceManifestService { +public interface ReferenceManifestService extends OrderedQuery { /** * Saves the ReferenceManifest in the database. This creates a new @@ -29,4 +30,13 @@ public interface ReferenceManifestService { * @return a ReferenceManifest object */ ReferenceManifest updateReferenceManifest(ReferenceManifest rim, UUID uuid); + + /** + * Deletes the ReferenceManifest in the database. This creates a new + * database session and saves the device. + * + * @param rim ReferenceManifest to delete + * @return reference to deleted rim + */ + void deleteRIM(ReferenceManifest rim); }