Continuing to update to fix ACA issues

This commit is contained in:
Cyrus 2024-01-04 11:48:46 -05:00
parent 021e975074
commit 03055d29a6
6 changed files with 77 additions and 26 deletions

View File

@ -266,19 +266,35 @@ public class CommonCriteriaMeasures {
}
public URIReference getProfileUri() {
return new URIReference(profileUri.getSequence());
if (profileUri != null) {
return new URIReference(profileUri.getSequence());
} else {
return null;
}
}
public void setProfileUri(final URIReference profileUri) {
this.profileUri = new URIReference(profileUri.getSequence());
if (profileUri != null) {
this.profileUri = new URIReference(profileUri.getSequence());
} else {
this.profileUri = new URIReference();
}
}
public URIReference getTargetUri() {
return new URIReference(targetUri.getSequence());
if (targetUri != null) {
return new URIReference(targetUri.getSequence());
} else {
return null;
}
}
public void setTargetUri(final URIReference targetUri) {
this.targetUri = new URIReference(targetUri.getSequence());
if (targetUri != null) {
this.targetUri = new URIReference(targetUri.getSequence());
} else {
this.targetUri = new URIReference();
}
}
@Override

View File

@ -1,7 +1,6 @@
package hirs.attestationca.persist.entity.userdefined.certificate.attributes;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
@ -10,18 +9,18 @@ import java.util.List;
* the Platform Certificate Attribute.
*/
public abstract class PlatformConfiguration {
private List<ComponentIdentifier> componentIdentifier = new ArrayList<>();
private ArrayList<ComponentIdentifier> componentIdentifier = new ArrayList<>();
private URIReference componentIdentifierUri;
private List<PlatformProperty> platformProperties = new ArrayList<>();
private ArrayList<PlatformProperty> platformProperties = new ArrayList<>();
private URIReference platformPropertiesUri;
/**
* Default constructor.
*/
public PlatformConfiguration() {
this.componentIdentifier = Collections.EMPTY_LIST;
this.componentIdentifier = new ArrayList<>();
this.componentIdentifierUri = null;
this.platformProperties = Collections.EMPTY_LIST;
this.platformProperties = new ArrayList<>();
this.platformPropertiesUri = null;
}
/**
@ -53,28 +52,40 @@ public abstract class PlatformConfiguration {
public PlatformConfiguration(final List<ComponentIdentifier> componentIdentifier,
final List<PlatformProperty> platformProperties,
final URIReference platformPropertiesUri) {
this.componentIdentifier = componentIdentifier.stream().toList();
this.platformProperties = platformProperties.stream().toList();
this.componentIdentifier = new ArrayList<>(componentIdentifier);
this.platformProperties = new ArrayList<>(platformProperties);
this.platformPropertiesUri = new URIReference(platformPropertiesUri.getSequence());
}
public URIReference getComponentIdentifierUri() {
return new URIReference(componentIdentifierUri.getSequence());
if (componentIdentifierUri != null) {
return new URIReference(componentIdentifierUri.getSequence());
} else {
return null;
}
}
public void setComponentIdentifierUri(final URIReference componentIdentifierUri) {
if (platformPropertiesUri != null) {
if (componentIdentifierUri != null) {
this.componentIdentifierUri = new URIReference(componentIdentifierUri.getSequence());
} else {
this.componentIdentifierUri = new URIReference();
}
}
public URIReference getPlatformPropertiesUri() {
return new URIReference(platformPropertiesUri.getSequence());
if (platformPropertiesUri != null) {
return new URIReference(platformPropertiesUri.getSequence());
} else {
return null;
}
}
public void setPlatformPropertiesUri(final URIReference platformPropertiesUri) {
if (platformPropertiesUri != null) {
this.platformPropertiesUri = new URIReference(platformPropertiesUri.getSequence());
} else {
this.platformPropertiesUri = new URIReference();
}
}
@ -102,7 +113,7 @@ public abstract class PlatformConfiguration {
* @param componentIdentifier the componentIdentifier to set
*/
public void setComponentIdentifier(final List<ComponentIdentifier> componentIdentifier) {
this.componentIdentifier.addAll(componentIdentifier);
this.componentIdentifier = new ArrayList<>(componentIdentifier);
}
/**
@ -129,6 +140,6 @@ public abstract class PlatformConfiguration {
* @param platformProperties the platformProperties to set
*/
public void setPlatformProperties(final List<PlatformProperty> platformProperties) {
this.platformProperties.addAll(platformProperties);
this.platformProperties = new ArrayList<>(platformProperties);
}
}

View File

@ -186,28 +186,44 @@ public class TBBSecurityAssertion {
* @return the ccInfo
*/
public CommonCriteriaMeasures getCcInfo() {
return new CommonCriteriaMeasures(ccInfo.getSequence());
if (ccInfo != null) {
return new CommonCriteriaMeasures(ccInfo.getSequence());
} else {
return null;
}
}
/**
* @param ccInfo the ccInfo to set
*/
public void setCcInfo(final CommonCriteriaMeasures ccInfo) {
this.ccInfo = new CommonCriteriaMeasures(ccInfo.getSequence());
if (ccInfo != null) {
this.ccInfo = new CommonCriteriaMeasures(ccInfo.getSequence());
} else {
this.ccInfo = new CommonCriteriaMeasures();
}
}
/**
* @return the fipsLevel
*/
public FIPSLevel getFipsLevel() {
return new FIPSLevel(fipsLevel.getAsn1Sequence());
if (fipsLevel != null) {
return new FIPSLevel(fipsLevel.getAsn1Sequence());
} else {
return null;
}
}
/**
* @param fipsLevel the fipsLevel to set
*/
public void setFipsLevel(final FIPSLevel fipsLevel) {
this.fipsLevel = new FIPSLevel(fipsLevel.getAsn1Sequence());
if (fipsLevel != null) {
this.fipsLevel = new FIPSLevel(fipsLevel.getAsn1Sequence());
} else {
this.fipsLevel = new FIPSLevel();
}
}
/**

View File

@ -167,14 +167,22 @@ public class ComponentIdentifierV2 extends ComponentIdentifier {
* @return the componentPlatformUri.
*/
public URIReference getComponentPlatformUri() {
return new URIReference(componentPlatformUri.getSequence());
if (this.componentPlatformUri != null) {
return new URIReference(componentPlatformUri.getSequence());
} else {
return null;
}
}
/**
* @param componentPlatformUri the componentPlatformUri to set.
*/
public void setComponentPlatformUri(final URIReference componentPlatformUri) {
this.componentPlatformUri = new URIReference(componentPlatformUri.getSequence());
if (componentPlatformUri != null) {
this.componentPlatformUri = new URIReference(componentPlatformUri.getSequence());
} else {
this.componentPlatformUri = new URIReference();
}
}
/**

View File

@ -63,10 +63,10 @@ public final class AppraiserTest {
final String name = "Test Appraiser";
final Appraiser appraiser = new TestAppraiser(name);
assertEquals(name, appraiser.getName());
NullPointerException expected = null;
Exception expected = null;
try {
appraiser.setName(null);
} catch (NullPointerException e) {
} catch (Exception e) {
expected = e;
}
assertNotNull(expected, "NullPointerException not caught");

View File

@ -49,7 +49,7 @@ public class PortalInfoTest {
try {
info.setSchemeName(scheme);
fail("The null scheme should have caused an error.");
} catch (NullPointerException e) {
} catch (Exception e) {
assertNull(info.getName());
}
}
@ -120,7 +120,7 @@ public class PortalInfoTest {
try {
info.setContextName(context);
fail("The null context should have caused an error.");
} catch (NullPointerException e) {
} catch (Exception e) {
assertNull(info.getContext());
}
}