This includes some refactoring of the component identifier.

This commit is contained in:
Cyrus 2021-01-11 13:24:49 -05:00
parent 058c58d208
commit fcb496686c
3 changed files with 53 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package hirs.data.persist.certificate.attributes;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
@ -287,6 +288,40 @@ public class ComponentIdentifier {
return Collections.unmodifiableList(addresses);
}
//
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
// ComponentIdentifier that = (ComponentIdentifier) o;
// return componentManufacturer.equals(that.componentManufacturer)
// && componentModel.equals(that.componentModel) && Objects.equals
// (componentSerial, that.componentSerial) && Objects.equals(componentRevision,
// that.componentRevision);
// }
//
@Override
public int hashCode() {
return Objects.hash(componentManufacturer, componentModel,
componentSerial, componentRevision);
}
@Override
public boolean equals(final Object obj) {
if (obj == null) {
return false;
}
if (obj instanceof ComponentIdentifier) {
ComponentIdentifier testCi = (ComponentIdentifier) obj;
return testCi.getComponentManufacturer().equals(this.getComponentManufacturer())
&& testCi.getComponentModel().equals(this.getComponentModel())
&& testCi.getComponentSerial().equals(this.getComponentSerial())
&& testCi.getComponentRevision().equals(this.getComponentRevision());
} else {
return false;
}
}
@Override
public String toString() {

View File

@ -251,6 +251,16 @@ public class ComponentIdentifierV2 extends ComponentIdentifier {
return true;
}
@Override
public boolean equals(final Object obj) {
return super.equals(obj);
}
@Override
public int hashCode() {
return super.hashCode();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();

View File

@ -792,9 +792,17 @@ public final class SupplyChainCredentialValidator implements CredentialValidator
private static String validateV2PlatformCredentialAttributes(
final List<ComponentIdentifier> fullDeltaChainComponents,
final List<ComponentInfo> allDeviceInfoComponents) {
LOGGER.error(String.format("fullDeltaChainComponents %d",
fullDeltaChainComponents.size()));
LOGGER.error(String.format("allDeviceInfoComponents %d",
allDeviceInfoComponents.size()));
ComponentIdentifierV2 ciV2;
StringBuilder invalidDeviceInfo = new StringBuilder();
StringBuilder invalidPcIds = new StringBuilder();
LOGGER.error("DELTA CHAIN PRINT");
fullDeltaChainComponents.stream().forEach(ci -> LOGGER.error(ci));
LOGGER.error("DEVICE INFOs");
allDeviceInfoComponents.stream().forEach(dic -> LOGGER.error(dic));
List<ComponentIdentifier> subCompIdList = fullDeltaChainComponents
.stream().collect(Collectors.toList());
List<ComponentInfo> subCompInfoList = allDeviceInfoComponents