Missed the checkstyle errors previously and adding

ComponentResultManager as a bean.
This commit is contained in:
Cyrus 2023-05-04 10:47:02 -04:00
parent e6d304542c
commit 632927786a
5 changed files with 34 additions and 10 deletions

View File

@ -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.
*

View File

@ -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

View File

@ -45,8 +45,9 @@ public interface ComponentResultManager extends OrderedListQuerier<ComponentResu
/**
* Returns a list of all <code>ComponentResult</code>s that are
* associated with the certificate
* associated with the certificate.
*
* @param certificateId the certificate id
* @return FilteredRecordsList object with fields for DataTables
*/
Set<ComponentResult> getComponentResultsByCertificate(UUID certificateId);

View File

@ -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<ComponentResult>
@ -150,7 +151,7 @@ public class DBComponentResultManager extends DBManager<ComponentResult>
}
@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()));

View File

@ -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)