mirror of
https://github.com/nsacyber/HIRS.git
synced 2024-12-19 04:58:00 +00:00
Prelminary changes to remove ReferenceDigestRecord as a database object.
This commit is contained in:
parent
ddada80add
commit
10915bdc3b
@ -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,25 +1046,16 @@ 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(),
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<NoPageParams> {
|
||||
|
||||
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<HashMap<ReferenceDigestRecord, ReferenceDigestValue>>
|
||||
mappedRecordValues = mapRecordToValues(referenceDigestRecords);
|
||||
|
||||
LOGGER.info("Returning list mapping: " + Arrays.toString(mappedRecordValues.toArray()));
|
||||
// FilteredRecordsList<HashMap<ReferenceDigestRecord, ReferenceDigestValue>>
|
||||
// mappedRecordValues = mapRecordToValues(referenceDigestRecords);
|
||||
|
||||
// LOGGER.info("Returning list mapping: " + Arrays.toString(mappedRecordValues.toArray()));
|
||||
return new DataTableResponse<>(referenceDigestRecords, input);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -767,7 +767,7 @@ public abstract class AbstractDbManager<T> implements CrudManager<T> {
|
||||
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<T> implements CrudManager<T> {
|
||||
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<T> implements CrudManager<T> {
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
LOGGER.info(clazz.getName() + " found " + aqr.getRecordsTotal() + " records");
|
||||
LOGGER.info(searchClass.getName() + " found " + aqr.getRecordsTotal() + " records");
|
||||
return aqr;
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ public class DBReferenceEventManager extends DBManager<ReferenceDigestValue>
|
||||
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<ReferenceDigestValue>
|
||||
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<ReferenceDigestValue>
|
||||
try {
|
||||
List<ReferenceDigestValue> dbTempList = super.getList(ReferenceDigestValue.class);
|
||||
for (ReferenceDigestValue rdv : dbTempList) {
|
||||
if (rdv.getDigestRecordId().equals(uuid)) {
|
||||
if (rdv.getSupportRimId().equals(uuid)) {
|
||||
dbDigestValues.add(rdv);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user