Another minor change, didn't update the delta message for components and

add the restore function to the upload
This commit is contained in:
Cyrus 2024-03-14 10:41:45 -04:00
parent 350cf2b802
commit cf08b1d2d3
3 changed files with 27 additions and 16 deletions

View File

@ -636,7 +636,6 @@ public class IdentityClaimProcessor extends AbstractProcessor {
private void savePlatformComponents(final Certificate certificate) {
PlatformCredential platformCredential;
int componentResults = 0;
if (certificate instanceof PlatformCredential) {
platformCredential = (PlatformCredential) certificate;
ComponentResult componentResult;
@ -650,7 +649,6 @@ public class IdentityClaimProcessor extends AbstractProcessor {
componentResult.setFailedValidation(false);
componentResult.setDelta(!platformCredential.isPlatformBase());
componentResultRepository.save(componentResult);
componentResults++;
}
}
}

View File

@ -376,10 +376,12 @@ public class CertificateAttributeScvValidator extends SupplyChainCredentialValid
List<ComponentResult> remainingComponentResults = checkDeviceHashMap(
componentInfos, compiledComponentList);
List<UUID> componentIdList = new ArrayList<>();
int numOfAttributes = 0;
if (!remainingComponentResults.isEmpty()) {
List<ComponentAttributeResult> attributeResults = checkComponentClassMap(
componentInfos, remainingComponentResults);
numOfAttributes = attributeResults.size();
boolean saveAttributeResult;
for (ComponentAttributeResult componentAttributeResult : attributeResults) {
saveAttributeResult = true;
@ -391,17 +393,18 @@ public class CertificateAttributeScvValidator extends SupplyChainCredentialValid
componentAttributeResult.setProvisionSessionId(provisionSessionId);
componentAttributeRepository.save(componentAttributeResult);
fieldValidation &= componentAttributeResult.checkMatchedStatus();
componentIdList.add(componentAttributeResult.getComponentId());
} else {
numOfAttributes--;
}
}
numOfAttributes = attributeResults.size();
}
StringBuilder additionalInfo = new StringBuilder();
if (!remainingComponentResults.isEmpty()) {
resultMessage.append(String.format("There are %d components not matched%n",
remainingComponentResults.size()));
resultMessage.append(String.format("\twith %d total attributes mismatched.",
numOfAttributes));
resultMessage.append(String.format("There are %d component(s) not matched%n "
+ "with %d total attributes mismatched.",
componentIdList.stream().distinct().count(), numOfAttributes));
}
if (fieldValidation) {

View File

@ -978,15 +978,25 @@ public class CertificatePageController extends PageController<NoPageParams> {
if (certificate instanceof PlatformCredential) {
platformCredential = (PlatformCredential) certificate;
ComponentResult componentResult;
for (ComponentIdentifier componentIdentifier : platformCredential
.getComponentIdentifiers()) {
componentResult = new ComponentResult(platformCredential.getPlatformSerial(),
platformCredential.getSerialNumber().toString(),
platformCredential.getPlatformChainType(),
componentIdentifier);
componentResultRepository.save(componentResult);
List<ComponentResult> componentResults = componentResultRepository
.findByCertificateSerialNumberAndBoardSerialNumber(
platformCredential.getSerialNumber().toString(),
platformCredential.getPlatformSerial());
if (componentResults.isEmpty()) {
for (ComponentIdentifier componentIdentifier : platformCredential
.getComponentIdentifiers()) {
componentResultRepository.save(
new ComponentResult(platformCredential.getPlatformSerial(),
platformCredential.getSerialNumber().toString(),
platformCredential.getPlatformChainType(),
componentIdentifier));
}
} else {
for (ComponentResult componentResult : componentResults) {
componentResult.restore();
componentResult.resetCreateTime();
componentResultRepository.save(componentResult);
}
}
}
}