mirror of
https://github.com/nsacyber/HIRS.git
synced 2024-12-21 05:53:27 +00:00
Prelminary changes to remove ReferenceDigestRecord as a database object.
This commit is contained in:
parent
0b4febf53b
commit
6d8392da45
@ -983,9 +983,10 @@ public abstract class AbstractAttestationCertificateAuthority
|
|||||||
TCGEventLog logProcessor = new TCGEventLog(dbSupport.getRimBytes());
|
TCGEventLog logProcessor = new TCGEventLog(dbSupport.getRimBytes());
|
||||||
ReferenceDigestValue rdv;
|
ReferenceDigestValue rdv;
|
||||||
for (TpmPcrEvent tpe : logProcessor.getEventList()) {
|
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(),
|
tpe.getEventDigestStr(), tpe.getEventTypeStr(),
|
||||||
false, false);
|
false, false, tpe.getEventContent());
|
||||||
this.referenceEventManager.saveValue(rdv);
|
this.referenceEventManager.saveValue(rdv);
|
||||||
}
|
}
|
||||||
} catch (CertificateException cEx) {
|
} catch (CertificateException cEx) {
|
||||||
@ -1021,9 +1022,10 @@ public abstract class AbstractAttestationCertificateAuthority
|
|||||||
TCGEventLog logProcessor = new TCGEventLog(dbSupport.getRimBytes());
|
TCGEventLog logProcessor = new TCGEventLog(dbSupport.getRimBytes());
|
||||||
ReferenceDigestValue rdv;
|
ReferenceDigestValue rdv;
|
||||||
for (TpmPcrEvent tpe : logProcessor.getEventList()) {
|
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(),
|
tpe.getEventDigestStr(), tpe.getEventTypeStr(),
|
||||||
false, false);
|
false, false, tpe.getEventContent());
|
||||||
this.referenceEventManager.saveValue(rdv);
|
this.referenceEventManager.saveValue(rdv);
|
||||||
}
|
}
|
||||||
dbSupport.setProcessed(true);
|
dbSupport.setProcessed(true);
|
||||||
|
@ -32,7 +32,6 @@ import org.springframework.web.servlet.ModelAndView;
|
|||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -45,7 +44,6 @@ public class TpmEventsPageController
|
|||||||
extends PageController<NoPageParams> {
|
extends PageController<NoPageParams> {
|
||||||
|
|
||||||
private static final String BIOS_RELEASE_DATE_FORMAT = "yyyy-MM-dd";
|
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 BiosDateValidator biosValidator;
|
||||||
private final ReferenceDigestManager referenceDigestManager;
|
private final ReferenceDigestManager referenceDigestManager;
|
||||||
@ -158,12 +156,11 @@ public class TpmEventsPageController
|
|||||||
ReferenceDigestRecord.class,
|
ReferenceDigestRecord.class,
|
||||||
referenceDigestManager,
|
referenceDigestManager,
|
||||||
input, orderColumnName, criteriaModifier);
|
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);
|
return new DataTableResponse<>(referenceDigestRecords, input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,13 +19,21 @@ public class ReferenceDigestValue extends AbstractEntity {
|
|||||||
private static final Logger LOGGER = LogManager.getLogger(ReferenceDigestValue.class);
|
private static final Logger LOGGER = LogManager.getLogger(ReferenceDigestValue.class);
|
||||||
@Type(type = "uuid-char")
|
@Type(type = "uuid-char")
|
||||||
@Column
|
@Column
|
||||||
private UUID digestRecordId;
|
private UUID baseRimId;
|
||||||
|
@Column
|
||||||
|
private UUID supportRimId;
|
||||||
|
@Column
|
||||||
|
private String manufacturer;
|
||||||
|
@Column
|
||||||
|
private String model;
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
private int pcrIndex;
|
private int pcrIndex;
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
private String digestValue;
|
private String digestValue;
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
private String eventType;
|
private String eventType;
|
||||||
|
@Column(columnDefinition = "blob", nullable = true)
|
||||||
|
private byte[] contentBlob;
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
private boolean matchFail;
|
private boolean matchFail;
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
@ -36,48 +44,78 @@ public class ReferenceDigestValue extends AbstractEntity {
|
|||||||
*/
|
*/
|
||||||
public ReferenceDigestValue() {
|
public ReferenceDigestValue() {
|
||||||
super();
|
super();
|
||||||
this.digestRecordId = UUID.randomUUID();
|
this.baseRimId = UUID.randomUUID();
|
||||||
|
this.supportRimId = UUID.randomUUID();
|
||||||
|
this.manufacturer = "";
|
||||||
|
this.model = "";
|
||||||
this.pcrIndex = -1;
|
this.pcrIndex = -1;
|
||||||
this.digestValue = "";
|
this.digestValue = "";
|
||||||
this.eventType = "";
|
this.eventType = "";
|
||||||
this.matchFail = false;
|
this.matchFail = false;
|
||||||
this.patched = false;
|
this.patched = false;
|
||||||
|
this.contentBlob = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default Constructor with parameters for all associated data.
|
* 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 pcrIndex the event number
|
||||||
* @param digestValue the key digest value
|
* @param digestValue the key digest value
|
||||||
* @param eventType the event type to store
|
* @param eventType the event type to store
|
||||||
* @param matchFail the status of the baseline check
|
* @param matchFail the status of the baseline check
|
||||||
* @param patched the status of the value being updated to to patch
|
* @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,
|
public ReferenceDigestValue(final UUID baseRimId, final UUID supportRimId,
|
||||||
final String digestValue, final String eventType,
|
final String manufacturer, final String model,
|
||||||
final boolean matchFail, final boolean patched) {
|
final int pcrIndex, final String digestValue,
|
||||||
this.digestRecordId = digestRecordId;
|
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.pcrIndex = pcrIndex;
|
||||||
this.digestValue = digestValue;
|
this.digestValue = digestValue;
|
||||||
this.eventType = eventType;
|
this.eventType = eventType;
|
||||||
this.matchFail = matchFail;
|
this.matchFail = matchFail;
|
||||||
this.patched = patched;
|
this.patched = patched;
|
||||||
|
this.contentBlob = contentBlob;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for the digest record UUID.
|
* Getter for the digest record UUID.
|
||||||
* @return the string of the UUID
|
* @return the string of the UUID
|
||||||
*/
|
*/
|
||||||
public UUID getDigestRecordId() {
|
public UUID getBaseRimId() {
|
||||||
return digestRecordId;
|
return baseRimId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setter for the digest record UUID.
|
* Setter for the digest record UUID.
|
||||||
* @param digestRecordId the value to store
|
* @param baseRimId the value to store
|
||||||
*/
|
*/
|
||||||
public void setDigestRecordId(final UUID digestRecordId) {
|
public void setBaseRimId(final UUID baseRimId) {
|
||||||
this.digestRecordId = digestRecordId;
|
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;
|
ReferenceDigestValue that = (ReferenceDigestValue) obj;
|
||||||
return pcrIndex == that.pcrIndex && matchFail == that.matchFail
|
return pcrIndex == that.pcrIndex && matchFail == that.matchFail
|
||||||
&& Objects.equals(digestValue, that.digestValue)
|
&& 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);
|
&& Objects.equals(eventType, that.eventType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int result = Objects.hash(pcrIndex, digestValue, digestRecordId,
|
int result = Objects.hash(pcrIndex, digestValue, baseRimId, supportRimId,
|
||||||
eventType, matchFail, patched);
|
eventType, matchFail, patched);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -767,7 +767,7 @@ public abstract class AbstractDbManager<T> implements CrudManager<T> {
|
|||||||
searchClass = this.clazz;
|
searchClass = this.clazz;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGGER.info(clazz.getName() + " querying for "
|
LOGGER.info(searchClass.getName() + " querying for "
|
||||||
+ Arrays.toString(searchableColumns.entrySet().toArray())
|
+ Arrays.toString(searchableColumns.entrySet().toArray())
|
||||||
+ " with search strings \"" + search + "\"");
|
+ " with search strings \"" + search + "\"");
|
||||||
|
|
||||||
@ -793,7 +793,7 @@ public abstract class AbstractDbManager<T> implements CrudManager<T> {
|
|||||||
if (totalResultCount != 0) {
|
if (totalResultCount != 0) {
|
||||||
LOGGER.info("Total result count greater than 0");
|
LOGGER.info("Total result count greater than 0");
|
||||||
//Builds the search criteria from all of the searchable columns
|
//Builds the search criteria from all of the searchable columns
|
||||||
if (searchableColumns != null) {
|
if (!searchableColumns.isEmpty()) {
|
||||||
// Search for all words in all searchable columns
|
// Search for all words in all searchable columns
|
||||||
String[] searchWords = search.split(" ");
|
String[] searchWords = search.split(" ");
|
||||||
for (String word : searchWords) {
|
for (String word : searchWords) {
|
||||||
@ -879,7 +879,7 @@ public abstract class AbstractDbManager<T> implements CrudManager<T> {
|
|||||||
}
|
}
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
LOGGER.info(clazz.getName() + " found " + aqr.getRecordsTotal() + " records");
|
LOGGER.info(searchClass.getName() + " found " + aqr.getRecordsTotal() + " records");
|
||||||
return aqr;
|
return aqr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ public class DBReferenceEventManager extends DBManager<ReferenceDigestValue>
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (referenceDigestValue.getDigestRecordId() == null
|
if (referenceDigestValue.getSupportRimId() == null
|
||||||
|| referenceDigestValue.getDigestValue() == null
|
|| referenceDigestValue.getDigestValue() == null
|
||||||
|| referenceDigestValue.getPcrIndex() == -1) {
|
|| referenceDigestValue.getPcrIndex() == -1) {
|
||||||
LOGGER.error("No reference to get record from db {}", referenceDigestValue);
|
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");
|
LOGGER.debug("retrieving referenceDigestValue from db");
|
||||||
tx = session.beginTransaction();
|
tx = session.beginTransaction();
|
||||||
dbRecord = (ReferenceDigestValue) session.createCriteria(ReferenceDigestValue.class)
|
dbRecord = (ReferenceDigestValue) session.createCriteria(ReferenceDigestValue.class)
|
||||||
.add(Restrictions.eq("digestRecordId",
|
.add(Restrictions.eq("supportRimId",
|
||||||
referenceDigestValue.getDigestRecordId()))
|
referenceDigestValue.getSupportRimId()))
|
||||||
.add(Restrictions.eq("digestValue",
|
.add(Restrictions.eq("digestValue",
|
||||||
referenceDigestValue.getDigestValue()))
|
referenceDigestValue.getDigestValue()))
|
||||||
.add(Restrictions.eq("eventNumber",
|
.add(Restrictions.eq("eventNumber",
|
||||||
@ -135,7 +135,7 @@ public class DBReferenceEventManager extends DBManager<ReferenceDigestValue>
|
|||||||
try {
|
try {
|
||||||
List<ReferenceDigestValue> dbTempList = super.getList(ReferenceDigestValue.class);
|
List<ReferenceDigestValue> dbTempList = super.getList(ReferenceDigestValue.class);
|
||||||
for (ReferenceDigestValue rdv : dbTempList) {
|
for (ReferenceDigestValue rdv : dbTempList) {
|
||||||
if (rdv.getDigestRecordId().equals(uuid)) {
|
if (rdv.getSupportRimId().equals(uuid)) {
|
||||||
dbDigestValues.add(rdv);
|
dbDigestValues.add(rdv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user