diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/AbstractAttestationCertificateAuthority.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/AbstractAttestationCertificateAuthority.java index 82f9570b..5883b5c2 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/AbstractAttestationCertificateAuthority.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/AbstractAttestationCertificateAuthority.java @@ -1011,9 +1011,10 @@ public abstract class AbstractAttestationCertificateAuthority TCGEventLog logProcessor = new TCGEventLog(dbSupport.getRimBytes()); ReferenceDigestValue rdv; for (TpmPcrEvent tpe : logProcessor.getEventList()) { - rdv = new ReferenceDigestValue(rdr.getId(), tpe.getPcrIndex(), + rdv = new ReferenceDigestValue(dbSupport.getAssociatedRim(), + dbSupport.getId(), manufacturer, model, tpe.getPcrIndex(), tpe.getEventDigestStr(), tpe.getEventTypeStr(), - false, false); + false, false, tpe.getEventContent()); this.referenceEventManager.saveValue(rdv); } } catch (CertificateException cEx) { @@ -1045,24 +1046,15 @@ public abstract class AbstractAttestationCertificateAuthority } } } else if (dbSupport.isSwidSupplemental() && !dbSupport.isProcessed()) { - if (rdr != null) { - try { - TCGEventLog logProcessor = new TCGEventLog(dbSupport.getRimBytes()); - ReferenceDigestValue rdv; - for (TpmPcrEvent tpe : logProcessor.getEventList()) { - rdv = new ReferenceDigestValue(rdr.getId(), tpe.getPcrIndex(), - tpe.getEventDigestStr(), tpe.getEventTypeStr(), - false, false); - this.referenceEventManager.saveValue(rdv); - } - dbSupport.setProcessed(true); - this.referenceManifestManager.update(dbSupport); - } catch (CertificateException cEx) { - LOG.error(cEx); - } catch (NoSuchAlgorithmException noSaEx) { - LOG.error(noSaEx); - } catch (IOException ioEx) { - LOG.error(ioEx); + try { + TCGEventLog logProcessor = new TCGEventLog(dbSupport.getRimBytes()); + ReferenceDigestValue rdv; + for (TpmPcrEvent tpe : logProcessor.getEventList()) { + rdv = new ReferenceDigestValue(dbSupport.getAssociatedRim(), + dbSupport.getId(), manufacturer, model, tpe.getPcrIndex(), + tpe.getEventDigestStr(), tpe.getEventTypeStr(), + false, false, tpe.getEventContent()); + this.referenceEventManager.saveValue(rdv); } } } diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/TpmEventsPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/TpmEventsPageController.java index 10d447e9..3fd6ac64 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/TpmEventsPageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/TpmEventsPageController.java @@ -32,7 +32,6 @@ import org.springframework.web.servlet.ModelAndView; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; -import java.util.Arrays; import java.util.HashMap; import java.util.List; @@ -45,7 +44,6 @@ public class TpmEventsPageController extends PageController { private static final String BIOS_RELEASE_DATE_FORMAT = "yyyy-MM-dd"; - private static final String LOG_FILE_PATTERN = "([^\\s]+(\\.(?i)(rimpcr|rimel|bin|log))$)"; private final BiosDateValidator biosValidator; private final ReferenceDigestManager referenceDigestManager; @@ -158,12 +156,11 @@ public class TpmEventsPageController ReferenceDigestRecord.class, referenceDigestManager, input, orderColumnName, criteriaModifier); - LOGGER.info("ReferenceDigestManager returned: " - + Arrays.toString(referenceDigestRecords.toArray())); - FilteredRecordsList> - mappedRecordValues = mapRecordToValues(referenceDigestRecords); - LOGGER.info("Returning list mapping: " + Arrays.toString(mappedRecordValues.toArray())); +// FilteredRecordsList> +// mappedRecordValues = mapRecordToValues(referenceDigestRecords); + +// LOGGER.info("Returning list mapping: " + Arrays.toString(mappedRecordValues.toArray())); return new DataTableResponse<>(referenceDigestRecords, input); } diff --git a/HIRS_Utils/src/main/java/hirs/data/persist/ReferenceDigestValue.java b/HIRS_Utils/src/main/java/hirs/data/persist/ReferenceDigestValue.java index 37379ac0..d4a7275e 100644 --- a/HIRS_Utils/src/main/java/hirs/data/persist/ReferenceDigestValue.java +++ b/HIRS_Utils/src/main/java/hirs/data/persist/ReferenceDigestValue.java @@ -19,13 +19,21 @@ public class ReferenceDigestValue extends AbstractEntity { private static final Logger LOGGER = LogManager.getLogger(ReferenceDigestValue.class); @Type(type = "uuid-char") @Column - private UUID digestRecordId; + private UUID baseRimId; + @Column + private UUID supportRimId; + @Column + private String manufacturer; + @Column + private String model; @Column(nullable = false) private int pcrIndex; @Column(nullable = false) private String digestValue; @Column(nullable = false) private String eventType; + @Column(columnDefinition = "blob", nullable = true) + private byte[] contentBlob; @Column(nullable = false) private boolean matchFail; @Column(nullable = false) @@ -36,48 +44,78 @@ public class ReferenceDigestValue extends AbstractEntity { */ public ReferenceDigestValue() { super(); - this.digestRecordId = UUID.randomUUID(); + this.baseRimId = UUID.randomUUID(); + this.supportRimId = UUID.randomUUID(); + this.manufacturer = ""; + this.model = ""; this.pcrIndex = -1; this.digestValue = ""; this.eventType = ""; this.matchFail = false; this.patched = false; + this.contentBlob = null; } /** * Default Constructor with parameters for all associated data. - * @param digestRecordId the UUID of the associated record + * @param baseRimId the UUID of the associated record + * @param supportRimId the UUID of the associated record + * @param manufacturer associated creator for this information + * @param model the specific device type * @param pcrIndex the event number * @param digestValue the key digest value * @param eventType the event type to store * @param matchFail the status of the baseline check * @param patched the status of the value being updated to to patch + * @param contentBlob the data value of the content */ - public ReferenceDigestValue(final UUID digestRecordId, final int pcrIndex, - final String digestValue, final String eventType, - final boolean matchFail, final boolean patched) { - this.digestRecordId = digestRecordId; + public ReferenceDigestValue(final UUID baseRimId, final UUID supportRimId, + final String manufacturer, final String model, + final int pcrIndex, final String digestValue, + final String eventType, final boolean matchFail, + final boolean patched, final byte[] contentBlob) { + this.baseRimId = baseRimId; + this.supportRimId = supportRimId; + this.manufacturer = manufacturer; + this.model = model; this.pcrIndex = pcrIndex; this.digestValue = digestValue; this.eventType = eventType; this.matchFail = matchFail; this.patched = patched; + this.contentBlob = contentBlob; } /** * Getter for the digest record UUID. * @return the string of the UUID */ - public UUID getDigestRecordId() { - return digestRecordId; + public UUID getBaseRimId() { + return baseRimId; } /** * Setter for the digest record UUID. - * @param digestRecordId the value to store + * @param baseRimId the value to store */ - public void setDigestRecordId(final UUID digestRecordId) { - this.digestRecordId = digestRecordId; + public void setBaseRimId(final UUID baseRimId) { + this.baseRimId = baseRimId; + } + + /** + * Getter for the digest record UUID. + * @return the string of the UUID + */ + public UUID getSupportRimId() { + return supportRimId; + } + + /** + * Setter for the digest record UUID. + * @param supportRimId the value to store + */ + public void setSupportRimId(final UUID supportRimId) { + this.supportRimId = supportRimId; } /** @@ -171,13 +209,14 @@ public class ReferenceDigestValue extends AbstractEntity { ReferenceDigestValue that = (ReferenceDigestValue) obj; return pcrIndex == that.pcrIndex && matchFail == that.matchFail && Objects.equals(digestValue, that.digestValue) - && Objects.equals(digestRecordId, that.digestRecordId) + && Objects.equals(baseRimId, that.baseRimId) + && Objects.equals(supportRimId, that.supportRimId) && Objects.equals(eventType, that.eventType); } @Override public int hashCode() { - int result = Objects.hash(pcrIndex, digestValue, digestRecordId, + int result = Objects.hash(pcrIndex, digestValue, baseRimId, supportRimId, eventType, matchFail, patched); return result; } diff --git a/HIRS_Utils/src/main/java/hirs/persist/AbstractDbManager.java b/HIRS_Utils/src/main/java/hirs/persist/AbstractDbManager.java index 73b0e308..06383323 100644 --- a/HIRS_Utils/src/main/java/hirs/persist/AbstractDbManager.java +++ b/HIRS_Utils/src/main/java/hirs/persist/AbstractDbManager.java @@ -767,7 +767,7 @@ public abstract class AbstractDbManager implements CrudManager { searchClass = this.clazz; } - LOGGER.info(clazz.getName() + " querying for " + LOGGER.info(searchClass.getName() + " querying for " + Arrays.toString(searchableColumns.entrySet().toArray()) + " with search strings \"" + search + "\""); @@ -793,7 +793,7 @@ public abstract class AbstractDbManager implements CrudManager { if (totalResultCount != 0) { LOGGER.info("Total result count greater than 0"); //Builds the search criteria from all of the searchable columns - if (searchableColumns != null) { + if (!searchableColumns.isEmpty()) { // Search for all words in all searchable columns String[] searchWords = search.split(" "); for (String word : searchWords) { @@ -881,7 +881,7 @@ public abstract class AbstractDbManager implements CrudManager { } throw e; } - LOGGER.info(clazz.getName() + " found " + aqr.getRecordsTotal() + " records"); + LOGGER.info(searchClass.getName() + " found " + aqr.getRecordsTotal() + " records"); return aqr; } diff --git a/HIRS_Utils/src/main/java/hirs/persist/DBReferenceEventManager.java b/HIRS_Utils/src/main/java/hirs/persist/DBReferenceEventManager.java index f742ca59..c8d68238 100644 --- a/HIRS_Utils/src/main/java/hirs/persist/DBReferenceEventManager.java +++ b/HIRS_Utils/src/main/java/hirs/persist/DBReferenceEventManager.java @@ -48,7 +48,7 @@ public class DBReferenceEventManager extends DBManager return null; } - if (referenceDigestValue.getDigestRecordId() == null + if (referenceDigestValue.getSupportRimId() == null || referenceDigestValue.getDigestValue() == null || referenceDigestValue.getPcrIndex() == -1) { LOGGER.error("No reference to get record from db {}", referenceDigestValue); @@ -62,8 +62,8 @@ public class DBReferenceEventManager extends DBManager LOGGER.debug("retrieving referenceDigestValue from db"); tx = session.beginTransaction(); dbRecord = (ReferenceDigestValue) session.createCriteria(ReferenceDigestValue.class) - .add(Restrictions.eq("digestRecordId", - referenceDigestValue.getDigestRecordId())) + .add(Restrictions.eq("supportRimId", + referenceDigestValue.getSupportRimId())) .add(Restrictions.eq("digestValue", referenceDigestValue.getDigestValue())) .add(Restrictions.eq("eventNumber", @@ -135,7 +135,7 @@ public class DBReferenceEventManager extends DBManager try { List dbTempList = super.getList(ReferenceDigestValue.class); for (ReferenceDigestValue rdv : dbTempList) { - if (rdv.getDigestRecordId().equals(uuid)) { + if (rdv.getSupportRimId().equals(uuid)) { dbDigestValues.add(rdv); } } diff --git a/HIRS_Utils/src/main/java/hirs/persist/ReferenceDigestManager.java b/HIRS_Utils/src/main/java/hirs/persist/ReferenceDigestManager.java index 952ddfbd..33717457 100644 --- a/HIRS_Utils/src/main/java/hirs/persist/ReferenceDigestManager.java +++ b/HIRS_Utils/src/main/java/hirs/persist/ReferenceDigestManager.java @@ -10,7 +10,7 @@ import java.util.UUID; * This class facilitates the persistence of {@link hirs.data.persist.ReferenceDigestRecord}s * including storage, retrieval, and deletion. */ -public interface ReferenceDigestManager extends OrderedListQuerier{ +public interface ReferenceDigestManager extends OrderedListQuerier { /** * Persists a new Reference Digest.