From 632927786a69f47fe992fdaa0e7ea01303ebcdeb Mon Sep 17 00:00:00 2001 From: Cyrus <24922493+cyrus-dev@users.noreply.github.com> Date: Thu, 4 May 2023 10:47:02 -0400 Subject: [PATCH] Missed the checkstyle errors previously and adding ComponentResultManager as a bean. --- .../persistence/PersistenceConfiguration.java | 11 +++++++++++ .../persist/certificate/ComponentResult.java | 19 +++++++++++++------ .../hirs/persist/ComponentResultManager.java | 3 ++- .../persist/DBComponentResultManager.java | 5 +++-- .../SupplyChainCredentialValidator.java | 6 +++++- 5 files changed, 34 insertions(+), 10 deletions(-) diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/persistence/PersistenceConfiguration.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/persistence/PersistenceConfiguration.java index f051b1a1..6d021c31 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/persistence/PersistenceConfiguration.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/persistence/PersistenceConfiguration.java @@ -5,6 +5,7 @@ import hirs.persist.AppraiserManager; import hirs.persist.CrudManager; import hirs.persist.DBAppraiserManager; import hirs.persist.DBCertificateManager; +import hirs.persist.DBComponentResultManager; import hirs.persist.DBDeviceGroupManager; import hirs.persist.DBDeviceManager; import hirs.persist.DBManager; @@ -53,6 +54,16 @@ public class PersistenceConfiguration { return new DBDeviceManager(sessionFactory.getObject()); } + /** + * Creates a {@link DBComponentResultManager} ready to use. + * + * @return {@link DBComponentResultManager} + */ + @Bean + public DBComponentResultManager componentResultManager() { + return new DBComponentResultManager(sessionFactory.getObject()); + } + /** * Creates a {@link DBCertificateManager} ready to use. * diff --git a/HIRS_Utils/src/main/java/hirs/data/persist/certificate/ComponentResult.java b/HIRS_Utils/src/main/java/hirs/data/persist/certificate/ComponentResult.java index 10b53051..0acf4960 100644 --- a/HIRS_Utils/src/main/java/hirs/data/persist/certificate/ComponentResult.java +++ b/HIRS_Utils/src/main/java/hirs/data/persist/certificate/ComponentResult.java @@ -7,7 +7,8 @@ import java.util.Objects; import java.util.UUID; /** - * + * A custom class that merges the result of the validation attribute components and allows for + * the matching of what was expected to actual and display this information to the portal. */ @Entity public class ComponentResult extends AbstractEntity { @@ -19,7 +20,7 @@ public class ComponentResult extends AbstractEntity { private boolean mismatched; /** - * Hibernate default constructor + * Hibernate default constructor. */ protected ComponentResult() { } @@ -82,10 +83,16 @@ public class ComponentResult extends AbstractEntity { } @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - if (!super.equals(o)) return false; + public boolean equals(final Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + if (!super.equals(o)) { + return false; + } ComponentResult that = (ComponentResult) o; return componentHash == that.componentHash && mismatched == that.mismatched diff --git a/HIRS_Utils/src/main/java/hirs/persist/ComponentResultManager.java b/HIRS_Utils/src/main/java/hirs/persist/ComponentResultManager.java index f1489f10..e0ee4186 100644 --- a/HIRS_Utils/src/main/java/hirs/persist/ComponentResultManager.java +++ b/HIRS_Utils/src/main/java/hirs/persist/ComponentResultManager.java @@ -45,8 +45,9 @@ public interface ComponentResultManager extends OrderedListQuerierComponentResults that are - * associated with the certificate + * associated with the certificate. * + * @param certificateId the certificate id * @return FilteredRecordsList object with fields for DataTables */ Set getComponentResultsByCertificate(UUID certificateId); diff --git a/HIRS_Utils/src/main/java/hirs/persist/DBComponentResultManager.java b/HIRS_Utils/src/main/java/hirs/persist/DBComponentResultManager.java index cf5ebeb1..48727eee 100644 --- a/HIRS_Utils/src/main/java/hirs/persist/DBComponentResultManager.java +++ b/HIRS_Utils/src/main/java/hirs/persist/DBComponentResultManager.java @@ -14,7 +14,8 @@ import java.util.Set; import java.util.UUID; /** - * This class is used to persist and retrieve {@link hirs.data.persist.certificate.ComponentResult}s into + * This class is used to persist and retrieve + * {@link hirs.data.persist.certificate.ComponentResult}s into * and from the database. */ public class DBComponentResultManager extends DBManager @@ -150,7 +151,7 @@ public class DBComponentResultManager extends DBManager } @Override - public boolean deleteResult(ComponentResult componentResult) { + public boolean deleteResult(final ComponentResult componentResult) { boolean result; LOGGER.info(String.format("Deleting component result to %s", componentResult.getId())); diff --git a/HIRS_Utils/src/main/java/hirs/validation/SupplyChainCredentialValidator.java b/HIRS_Utils/src/main/java/hirs/validation/SupplyChainCredentialValidator.java index 19b55d35..166cbf60 100644 --- a/HIRS_Utils/src/main/java/hirs/validation/SupplyChainCredentialValidator.java +++ b/HIRS_Utils/src/main/java/hirs/validation/SupplyChainCredentialValidator.java @@ -601,6 +601,7 @@ public final class SupplyChainCredentialValidator implements CredentialValidator * pick out the changes that lead to the delta cert and make sure the changes * are valid. * + * @param certificateId the certificate id * @param deviceInfoReport The paccor profile of device being validated against. * @param deltaMapping map of delta certificates to their validated status * @param origPcComponents The component identifier list associated with the @@ -782,7 +783,8 @@ public final class SupplyChainCredentialValidator implements CredentialValidator subCompIdList.remove(cId); subCompInfoList.remove(cInfo); } - } // I have to get the unmatched from here, maybe create a list of component result and use that TDM + } // I have to get the unmatched from here, + // maybe create a list of component result and use that } if (subCompIdList.isEmpty()) { @@ -1073,6 +1075,8 @@ public final class SupplyChainCredentialValidator implements CredentialValidator /** * Checks if the fields in the potentialMatch match the fields in the pcComponent, * or if the relevant field in the pcComponent is empty. + * + * @param certificateId the certificate id * @param pcComponent the platform credential component * @param potentialMatch the component info from a device info report * @return true if the fields match exactly (null is considered the same as an empty string)