mirror of
https://github.com/nsacyber/HIRS.git
synced 2025-02-20 17:52:47 +00:00
Updated code should be able to print one summary
This commit is contained in:
parent
792a248ba0
commit
0291b96ca8
@ -302,7 +302,7 @@ public abstract class AbstractAttestationCertificateAuthority
|
||||
// update the validation result in the device
|
||||
device.setSupplyChainStatus(summary.getOverallValidationResult());
|
||||
deviceManager.updateDevice(device);
|
||||
|
||||
LOG.error("This is the device id? {} ", device.getId());
|
||||
// check if supply chain validation succeeded.
|
||||
// If it did not, do not provide the IdentityResponseEnvelope
|
||||
if (summary.getOverallValidationResult() == AppraisalStatus.Status.PASS) {
|
||||
@ -452,6 +452,7 @@ public abstract class AbstractAttestationCertificateAuthority
|
||||
// perform supply chain validation
|
||||
SupplyChainValidationSummary summary = supplyChainValidationService.validateSupplyChain(
|
||||
endorsementCredential, platformCredentials, device);
|
||||
device.setSummaryId(summary.getId().toString());
|
||||
// update the validation result in the device
|
||||
AppraisalStatus.Status validationResult = summary.getOverallValidationResult();
|
||||
device.setSupplyChainStatus(validationResult);
|
||||
|
@ -1,6 +1,7 @@
|
||||
package hirs.attestationca.service;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import hirs.data.persist.Device;
|
||||
import hirs.data.persist.SupplyChainValidationSummary;
|
||||
import hirs.data.persist.certificate.EndorsementCredential;
|
||||
|
@ -23,6 +23,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.LinkedList;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
import org.apache.logging.log4j.Level;
|
||||
import hirs.appraiser.Appraiser;
|
||||
@ -47,6 +48,7 @@ import hirs.persist.DBManagerException;
|
||||
import hirs.persist.PersistenceConfiguration;
|
||||
import hirs.persist.PolicyManager;
|
||||
import hirs.validation.CredentialValidator;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ -254,6 +256,7 @@ public class SupplyChainValidationServiceImpl implements SupplyChainValidationSe
|
||||
} catch (DBManagerException ex) {
|
||||
LOGGER.error("Failed to save Supply Chain summary", ex);
|
||||
}
|
||||
|
||||
return summary;
|
||||
}
|
||||
|
||||
@ -339,6 +342,7 @@ public class SupplyChainValidationServiceImpl implements SupplyChainValidationSe
|
||||
for (SwidResource swid : swids) {
|
||||
baseline = swid.getPcrValues()
|
||||
.toArray(new String[swid.getPcrValues().size()]);
|
||||
LOGGER.error("is file size valid {}", swid.isValidFileSize());
|
||||
}
|
||||
pcrPolicy.setBaselinePcrs(baseline);
|
||||
|
||||
@ -453,9 +457,14 @@ public class SupplyChainValidationServiceImpl implements SupplyChainValidationSe
|
||||
|
||||
// Generate validation summary, save it, and return it.
|
||||
List<SupplyChainValidation> validations = new ArrayList<>();
|
||||
SupplyChainValidationSummary previous
|
||||
= this.supplyChainValidatorSummaryManager.get(
|
||||
UUID.fromString(device.getSummaryId()));
|
||||
validations.addAll(previous.getValidations());
|
||||
validations.add(quoteScv);
|
||||
summary = new SupplyChainValidationSummary(device, validations);
|
||||
supplyChainValidatorSummaryManager.save(summary);
|
||||
supplyChainValidatorSummaryManager.delete(previous.getId());
|
||||
}
|
||||
|
||||
return summary;
|
||||
|
@ -95,6 +95,9 @@ public class Device extends AbstractEntity {
|
||||
@Column(name = "state_override_reason")
|
||||
private String overrideReason;
|
||||
|
||||
@Column(name = "summary_id")
|
||||
private String summaryId;
|
||||
|
||||
/**
|
||||
* Default constructor required by Hibernate.
|
||||
*/
|
||||
@ -358,6 +361,22 @@ public class Device extends AbstractEntity {
|
||||
this.supplyChainValidationStatus = supplyChainValidationStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for the last summary id.
|
||||
* @return UUID for the summary
|
||||
*/
|
||||
public String getSummaryId() {
|
||||
return summaryId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for the last summary id.
|
||||
* @param summaryId UUID
|
||||
*/
|
||||
public void setSummaryId(final String summaryId) {
|
||||
this.summaryId = summaryId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code for this <code>Device</code>. The hash code is
|
||||
* determined from the name of the <code>Device</code>.
|
||||
|
@ -48,6 +48,7 @@ public class SwidResource {
|
||||
private List<String> pcrValues;
|
||||
private TpmWhiteListBaseline tpmWhiteList;
|
||||
private DigestAlgorithm digest = DigestAlgorithm.SHA1;
|
||||
private boolean validFileSize = false;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
@ -192,6 +193,14 @@ public class SwidResource {
|
||||
this.pcrValues = pcrValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* flag for if the file sizes match with the swidtag.
|
||||
* @return true if they match
|
||||
*/
|
||||
public boolean isValidFileSize() {
|
||||
return validFileSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for a generated map of the PCR values.
|
||||
*
|
||||
@ -223,6 +232,7 @@ public class SwidResource {
|
||||
if (Files.exists(logPath)) {
|
||||
logProcessor = new TCGEventLog(
|
||||
Files.readAllBytes(logPath));
|
||||
// this.validFileSize = Files.size(logPath) == Long.getLong(this.size);
|
||||
}
|
||||
this.setPcrValues(Arrays.asList(
|
||||
logProcessor.getExpectedPCRValues()));
|
||||
|
Loading…
x
Reference in New Issue
Block a user