From 82efb88f603ffc4f10ee190df39d50024b94d484 Mon Sep 17 00:00:00 2001 From: iadgovuser62 Date: Wed, 19 Nov 2025 13:55:09 -0500 Subject: [PATCH 01/20] v3_issue_1018: Add remaining TPMSecurityAssertions and OID-value translation to EKCert details page --- .../certificate/EndorsementCredential.java | 249 +++++++++++++++--- .../attributes/CommonCriteriaMeasures.java | 117 +++++--- .../certificate/attributes/FIPSLevel.java | 24 +- .../attributes/TPMSecurityAssertions.java | 6 - .../certificate/PlatformCredentialTest.java | 12 +- .../utils/CertificateStringMapBuilder.java | 128 ++++++++- .../WEB-INF/jsp/certificate-details.jsp | 187 +++++++++++-- .../webapp/WEB-INF/tags/field-displayer.tag | 8 + 8 files changed, 598 insertions(+), 133 deletions(-) create mode 100644 HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/tags/field-displayer.tag diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/EndorsementCredential.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/EndorsementCredential.java index a9f6d1582..94bccd352 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/EndorsementCredential.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/EndorsementCredential.java @@ -1,6 +1,8 @@ package hirs.attestationca.persist.entity.userdefined.certificate; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import hirs.attestationca.persist.entity.userdefined.certificate.attributes.CommonCriteriaMeasures; +import hirs.attestationca.persist.entity.userdefined.certificate.attributes.FIPSLevel; import hirs.attestationca.persist.entity.userdefined.certificate.attributes.TPMSecurityAssertions; import hirs.attestationca.persist.entity.userdefined.certificate.attributes.TPMSpecification; import jakarta.persistence.Column; @@ -19,6 +21,7 @@ import org.bouncycastle.asn1.ASN1Encodable; import org.bouncycastle.asn1.ASN1Enumerated; import org.bouncycastle.asn1.ASN1GeneralizedTime; +import org.bouncycastle.asn1.ASN1IA5String; import org.bouncycastle.asn1.ASN1InputStream; import org.bouncycastle.asn1.ASN1Integer; import org.bouncycastle.asn1.ASN1Null; @@ -82,11 +85,27 @@ public class EndorsementCredential extends DeviceAssociatedCertificate { private static final int EK_LOC_VAL_MAX = 2; private static final int EK_TYPE_VAL_MIN = 0; private static final int EK_TYPE_VAL_MAX = 3; + private static final int ASSURANCE_VAL_MIN = 1; + private static final int ASSURANCE_VAL_MAX = 7; + private static final int EVAL_STATUS_VAL_MIN = 0; + private static final int EVAL_STATUS_VAL_MAX = 2; + private static final int STRENGTH_VAL_MIN = 0; + private static final int STRENGTH_VAL_MAX = 2; + private static final int SECURITY_VAL_MIN = 1; + private static final int SECURITY_VAL_MAX = 4; // EK Tag index values private static final int EK_TYPE_TAG = 0; private static final int EK_LOC_TAG = 1; private static final int EK_CERT_LOC_TAG = 2; + private static final int EK_CC_INFO_TAG = 3; + private static final int EK_FIPS_TAG = 4; + private static final int EK_ISO_9000_CERT_TAG = 5; + private static final int CC_INFO_STRENGTH_TAG = 0; + private static final int CC_INFO_PROF_OID_TAG = 1; + private static final int CC_INFO_PROF_URI_TAG = 2; + private static final int CC_INFO_TARGET_OID_TAG = 3; + private static final int CC_INFO_TARGET_URI_TAG = 4; private static final int ASN1_SEQ_UNKNOWN_SIZE = 2; private static final int ASN1_SEQ_KNOWN_SIZE = 3; @@ -150,6 +169,25 @@ public class EndorsementCredential extends DeviceAssociatedCertificate { @Embedded private TPMSecurityAssertions tpmSecurityAssertions = null; //optional + // Though these following fields structurally fall inside TPM Security Assertions, + // they are being added as Transient fields to the parent Endorsement Credential to + // avoid modifying DB schema. + @Getter + @Transient + private CommonCriteriaMeasures commonCriteriaMeasures = null; + + @Getter + @Transient + private FIPSLevel fipsLevel = null; + + @Getter + @Transient + private boolean iso9000Certified = false; + + @Getter + @Transient + private String iso9000Uri = null; + @Transient private Set expectedOids; @@ -236,7 +274,7 @@ private void prepareParser() { * @throws IOException the input certificate bytes were not readable into an X509 * certificate format */ - private void parseCertificate() throws IOException { + public void parseCertificate() throws IOException { prepareParser(); // although we start with a byte representation, we need to change the encoding to // make it parseable @@ -356,39 +394,51 @@ private void parseSequence(final ASN1Sequence seq, final boolean addToMapping, int tag; ASN1TaggedObject obj; for (int i = seqPosition; i < seq.size(); i++) { - if (seq.getObjectAt(i) instanceof ASN1TaggedObject) { + if (seq.getObjectAt(i) instanceof ASN1TaggedObject taggedObj) { obj = (ASN1TaggedObject) seq.getObjectAt(i); tag = obj.getTagNo(); - if (tag == EK_TYPE_TAG) { - int ekGenTypeVal = ((ASN1Enumerated) obj.getBaseObject()).getValue().intValue(); - if (ekGenTypeVal >= EK_TYPE_VAL_MIN && ekGenTypeVal <= EK_TYPE_VAL_MAX) { - TPMSecurityAssertions.EkGenerationType ekGenType - = TPMSecurityAssertions.EkGenerationType.values()[ekGenTypeVal]; - tpmSecurityAssertions.setEkGenType(ekGenType); - } - } else if (tag == EK_LOC_TAG) { - int ekGenLocVal = ((ASN1Enumerated) obj.getBaseObject()).getValue().intValue(); - if (ekGenLocVal >= EK_LOC_VAL_MIN && ekGenLocVal <= EK_LOC_VAL_MAX) { - TPMSecurityAssertions.EkGenerationLocation ekGenLocation - = TPMSecurityAssertions.EkGenerationLocation.values()[ekGenLocVal]; - tpmSecurityAssertions.setEkGenerationLocation(ekGenLocation); - } - } else if (tag == EK_CERT_LOC_TAG) { - int ekCertGenLocVal = ((ASN1Enumerated) obj.getBaseObject()) - .getValue().intValue(); - if (ekCertGenLocVal >= EK_LOC_VAL_MIN - && ekCertGenLocVal <= EK_LOC_VAL_MAX) { - TPMSecurityAssertions.EkGenerationLocation ekCertGenLoc - = TPMSecurityAssertions.EkGenerationLocation. - values()[ekCertGenLocVal]; - tpmSecurityAssertions.setEkCertificateGenerationLocation(ekCertGenLoc); - } + switch (tag) { + case EK_TYPE_TAG -> { + int ekGenTypeVal = ((ASN1Enumerated) obj.getBaseObject()).getValue().intValue(); + if (ekGenTypeVal >= EK_TYPE_VAL_MIN && ekGenTypeVal <= EK_TYPE_VAL_MAX) { + TPMSecurityAssertions.EkGenerationType ekGenType + = TPMSecurityAssertions.EkGenerationType.values()[ekGenTypeVal]; + tpmSecurityAssertions.setEkGenType(ekGenType); + } + } case EK_LOC_TAG -> { + int ekGenLocVal = ((ASN1Enumerated) obj.getBaseObject()).getValue().intValue(); + if (ekGenLocVal >= EK_LOC_VAL_MIN && ekGenLocVal <= EK_LOC_VAL_MAX) { + TPMSecurityAssertions.EkGenerationLocation ekGenLocation + = TPMSecurityAssertions.EkGenerationLocation.values()[ekGenLocVal]; + tpmSecurityAssertions.setEkGenerationLocation(ekGenLocation); + } + } case EK_CERT_LOC_TAG -> { + int ekCertGenLocVal = ((ASN1Enumerated) obj.getBaseObject()) + .getValue().intValue(); + if (ekCertGenLocVal >= EK_LOC_VAL_MIN + && ekCertGenLocVal <= EK_LOC_VAL_MAX) { + TPMSecurityAssertions.EkGenerationLocation ekCertGenLoc + = TPMSecurityAssertions.EkGenerationLocation. + values()[ekCertGenLocVal]; + tpmSecurityAssertions.setEkCertificateGenerationLocation(ekCertGenLoc); + } + } case EK_CC_INFO_TAG -> parseCommonCriteria(ASN1Sequence.getInstance( + taggedObj.getBaseObject())); + case EK_FIPS_TAG -> parseFipsLevel(ASN1Sequence.getInstance(taggedObj.getBaseObject())); + case EK_ISO_9000_CERT_TAG -> { + if (obj.getBaseObject() instanceof ASN1Boolean isoCertified) { + this.iso9000Certified = isoCertified.isTrue(); + } + } default -> log.warn("Encountered unknown TPM Security Assertions tag " + + "in Endorsement Credential: {}", tag); + } + } + if (seq.size() > 0) { + ASN1Encodable lastElement = seq.getObjectAt(seq.size() - 1); + if (lastElement instanceof ASN1IA5String isoUri) { + this.iso9000Uri = isoUri.getString(); } - // ccInfo, fipsLevel, iso9000Certified, and iso9000Uri still to be implemented } - // Will need additional else if case in the future for instanceof ASN1Boolean when - // supporting TPMSecurityAssertions iso9000Certified field, which could be either - // DERTaggedObject or ASN1Boolean } } else { //parse the elements of the sequence individually @@ -573,4 +623,143 @@ private void parseSingle(final ASN1Primitive component, final boolean addToMappi log.error("Unparsed type: {}", component.getClass()); } } + + /** + * Parses the Common Criteria information from an ASN1Sequence and populates + * a {@link CommonCriteriaMeasures} object with the discovered fields. + * + * @param ccSeq the ASN1Sequence containing Common Criteria information + */ + private void parseCommonCriteria(final ASN1Sequence ccSeq) { + CommonCriteriaMeasures parsedCommonCriteria = new CommonCriteriaMeasures(); + for (int i = 0; i < ccSeq.size(); i++) { + ASN1Encodable element = ccSeq.getObjectAt(i); + if (element instanceof ASN1IA5String ccVersion) { + parsedCommonCriteria.setCcVersion(ccVersion.getString()); + } else if (element instanceof ASN1Enumerated assurance && i == 1) { + int assuranceVal = assurance.getValue().intValue(); + if (assuranceVal >= ASSURANCE_VAL_MIN && assuranceVal <= ASSURANCE_VAL_MAX) { + CommonCriteriaMeasures.EvaluationAssuranceLevel level = + CommonCriteriaMeasures.EvaluationAssuranceLevel.values()[assuranceVal]; + parsedCommonCriteria.setAssuranceLevel(level); + } + } else if (element instanceof ASN1Enumerated evalStatus && i == 2) { + int evalStatusVal = evalStatus.getValue().intValue(); + if (evalStatusVal >= EVAL_STATUS_VAL_MIN && evalStatusVal <= EVAL_STATUS_VAL_MAX) { + CommonCriteriaMeasures.EvaluationStatus status = + CommonCriteriaMeasures.EvaluationStatus.values()[evalStatusVal]; + parsedCommonCriteria.setEvaluationStatus(status); + } + } else if (element instanceof ASN1Boolean plus) { + parsedCommonCriteria.setCcPlus(plus.isTrue()); + } else if (element instanceof ASN1TaggedObject) { + ASN1TaggedObject taggedObj = (ASN1TaggedObject) ccSeq.getObjectAt(i); + int tag = taggedObj.getTagNo(); + switch (tag) { + case CC_INFO_STRENGTH_TAG -> { + int strengthVal = ((ASN1Enumerated) taggedObj.getBaseObject()).getValue().intValue(); + if (strengthVal >= STRENGTH_VAL_MIN && strengthVal <= STRENGTH_VAL_MAX) { + CommonCriteriaMeasures.StrengthOfFunction strengthOfFunction + = CommonCriteriaMeasures.StrengthOfFunction.values()[strengthVal]; + parsedCommonCriteria.setStrengthOfFunction(strengthOfFunction); + } + } case CC_INFO_PROF_OID_TAG -> { + parsedCommonCriteria.setProfileOid(String.valueOf(taggedObj.getBaseObject())); + } case CC_INFO_PROF_URI_TAG -> { + Map profileUriMap = + parseUriReference(ASN1Sequence.getInstance(taggedObj.getBaseObject())); + parsedCommonCriteria.setProfileUri((String) profileUriMap.get("uri")); + parsedCommonCriteria.setProfileAlgOid((String) profileUriMap.get("algOid")); + parsedCommonCriteria.setProfileAlgParameters((byte[]) profileUriMap.get("algParams")); + parsedCommonCriteria.setProfileHashValue((byte[]) profileUriMap.get("hashValue")); + } case CC_INFO_TARGET_OID_TAG -> { + parsedCommonCriteria.setTargetOid(String.valueOf(taggedObj.getBaseObject())); + } case CC_INFO_TARGET_URI_TAG -> { + Map targetUriMap = + parseUriReference(ASN1Sequence.getInstance(taggedObj.getBaseObject())); + parsedCommonCriteria.setTargetUri((String) targetUriMap.get("uri")); + parsedCommonCriteria.setTargetAlgOid((String) targetUriMap.get("algOid")); + parsedCommonCriteria.setTargetAlgParameters((byte[]) targetUriMap.get("algParams")); + parsedCommonCriteria.setTargetHashValue((byte[]) targetUriMap.get("hashValue")); + } default -> log.warn("Encountered unknown Common Criteria tag " + + "in Endorsement Credential: {}", tag); + } + } + } + this.commonCriteriaMeasures = parsedCommonCriteria; + } + + /** + * Parses a URI reference structure from an ASN1Sequence. + * The sequence is expected to contain the URI itself, an optional + * algorithm identifier, and an optional hash value. + * + * @param uriReferenceSeq the ASN1Sequence containing the URI reference + * @return a Map with keys "uri", "algOid", "algParams", and "hashValue" representing + * the parsed URI reference information + */ + public static Map parseUriReference(final ASN1Sequence uriReferenceSeq) { + Map parsedUriReference = new HashMap<>(); + for (int i = 0; i < uriReferenceSeq.size(); i++) { + ASN1Encodable element = uriReferenceSeq.getObjectAt(i); + if (element instanceof ASN1IA5String uri && i == 0) { + parsedUriReference.put("uri", String.valueOf(uri)); + } else if (element instanceof ASN1Sequence algorithmIdSeq) { + parsedUriReference.putAll(parseAlgorithmIdentifier(ASN1Sequence.getInstance(algorithmIdSeq))); + } else if (element instanceof ASN1BitString hashValue) { + parsedUriReference.put("hashValue", hashValue.getBytes()); + } + } + return parsedUriReference; + } + + /** + * Parses an ASN1Sequence representing an AlgorithmIdentifier. + * Extracts the algorithm OID and optional algorithm parameters. + * + * @param algorithmIdSeq the ASN1Sequence containing the algorithm identifier + * @return a Map with keys "algOid" and "algParams" representing the parsed algorithm information + */ + private static Map parseAlgorithmIdentifier(final ASN1Sequence algorithmIdSeq) { + Map parsedAlgorithmIdentifier = new HashMap<>(); + for (int i = 0; i < algorithmIdSeq.size(); i++) { + ASN1Encodable element = algorithmIdSeq.getObjectAt(i); + if (element instanceof ASN1ObjectIdentifier oid && i == 0) { + parsedAlgorithmIdentifier.put("algOid", oid.getId()); + } else if (i > 0) { + try { + parsedAlgorithmIdentifier.put("algParams", element.toASN1Primitive().getEncoded()); + } catch (IOException e) { + throw new IllegalStateException("Failed to encode AlgorithmIdentifier parameters", e); + } + } + } + return parsedAlgorithmIdentifier; + } + + /** + * Parses a FIPS level structure from an ASN1Sequence and populates a {@link FIPSLevel} object + * with the discovered fields, including version, security level, and optional FIPS Plus flag. + * + * @param fipsLevelSeq the ASN1Sequence containing FIPS level information + */ + private void parseFipsLevel(final ASN1Sequence fipsLevelSeq) { + FIPSLevel parsedFips = new FIPSLevel(); + for (int i = 0; i < fipsLevelSeq.size(); i++) { + ASN1Encodable element = fipsLevelSeq.getObjectAt(i); + if (element instanceof ASN1IA5String fipsVersion && i == 0) { + parsedFips.setFipsVersion(fipsVersion.getString()); + } else if (element instanceof ASN1Enumerated securityLevel && i == 1) { + int securityLevelVal = securityLevel.getValue().intValue(); + if (securityLevelVal >= SECURITY_VAL_MIN && securityLevelVal <= SECURITY_VAL_MAX) { + FIPSLevel.SecurityLevel level = + FIPSLevel.SecurityLevel.values()[securityLevelVal]; + parsedFips.setSecurityLevel(level); + } + } else if (element instanceof ASN1Boolean plus) { + parsedFips.setFipsPlus(plus.isTrue()); + } + } + this.fipsLevel = parsedFips; + } } diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/attributes/CommonCriteriaMeasures.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/attributes/CommonCriteriaMeasures.java index a9c115a54..845cc5b4e 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/attributes/CommonCriteriaMeasures.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/attributes/CommonCriteriaMeasures.java @@ -9,9 +9,21 @@ import org.bouncycastle.asn1.ASN1Sequence; import org.bouncycastle.asn1.ASN1TaggedObject; +import java.io.Serializable; +import java.util.Arrays; +import java.util.Map; + +import static hirs.attestationca.persist.entity.userdefined.certificate.EndorsementCredential.parseUriReference; + /** * Basic class that handle CommonCriteriaMeasures for the Platform Certificate * Attribute. + * The URIReference and algorithm identifier fields + * (profileUri, profileAlgOid, profileAlgParameters, profileHashValue, + * targetUri, targetAlgOid, targetAlgParameters, targetHashValue) have been flattened + * into this class. They do not make use of HIRS' URIReference.java + * or BouncyCastle's AlgorithmIdentifier. + * *
  * CommonCriteriaMeasures ::= SEQUENCE {
  *      version IA5STRING (SIZE (1..STRMAX)), "2.2" or "3.1";
@@ -27,36 +39,48 @@
  */
 @Getter
 @Setter
-public class CommonCriteriaMeasures {
+public class CommonCriteriaMeasures implements Serializable {
 
     private static final int STRENGTH_OF_FUNCTION = 0;
     private static final int PROFILE_OID = 1;
     private static final int PROFILE_URI = 2;
     private static final int TARGET_OID = 3;
     private static final int TARGET_URI = 4;
-    private ASN1IA5String version;
+    private String ccVersion;
     private EvaluationAssuranceLevel assuranceLevel;
     private EvaluationStatus evaluationStatus;
-    private ASN1Boolean plus;
+    private boolean ccPlus;
     private StrengthOfFunction strengthOfFunction;
-    private ASN1ObjectIdentifier profileOid;
-    private ASN1ObjectIdentifier targetOid;
-    private URIReference profileUri;
-    private URIReference targetUri;
+    private String profileOid;
+    private String profileUri;
+    private String profileAlgOid;
+    private byte[] profileAlgParameters;
+    private byte[] profileHashValue;
+    private String targetOid;
+    private String targetUri;
+    private String targetAlgOid;
+    private byte[] targetAlgParameters;
+    private byte[] targetHashValue;
 
     /**
      * Default constructor.
      */
     public CommonCriteriaMeasures() {
-        this.version = null;
+        this.ccVersion = null;
         this.assuranceLevel = null;
         this.evaluationStatus = null;
-        this.plus = ASN1Boolean.FALSE;
+        this.ccPlus = Boolean.FALSE;
         this.strengthOfFunction = null;
         this.profileOid = null;
-        this.targetOid = null;
         this.profileUri = null;
+        this.profileAlgOid = null;
+        this.profileAlgParameters = null;
+        this.profileHashValue = null;
+        this.targetOid = null;
         this.targetUri = null;
+        this.targetAlgOid = null;
+        this.targetAlgParameters = null;
+        this.targetHashValue = null;
     }
 
     /**
@@ -68,7 +92,7 @@ public CommonCriteriaMeasures() {
     public CommonCriteriaMeasures(final ASN1Sequence sequence) throws IllegalArgumentException {
         //Get all the mandatory values
         int index = 0;
-        version = ASN1IA5String.getInstance(sequence.getObjectAt(index++));
+        ccVersion = ASN1IA5String.getInstance(sequence.getObjectAt(index++)).getString();
         ASN1Enumerated enumerated = ASN1Enumerated.getInstance(sequence.getObjectAt(index++));
         //Throw exception when is not between 1 and 7
         if (enumerated.getValue().intValue() <= 0
@@ -79,19 +103,25 @@ public CommonCriteriaMeasures(final ASN1Sequence sequence) throws IllegalArgumen
         enumerated = ASN1Enumerated.getInstance(sequence.getObjectAt(index++));
         evaluationStatus = EvaluationStatus.values()[enumerated.getValue().intValue()];
         //Default plus value
-        plus = ASN1Boolean.FALSE;
+        ccPlus = Boolean.FALSE;
 
         //Current sequence index
         if (sequence.getObjectAt(index).toASN1Primitive() instanceof ASN1Boolean) {
-            plus = ASN1Boolean.getInstance(sequence.getObjectAt(index++));
+            ccPlus = ASN1Boolean.getInstance(sequence.getObjectAt(index++)).isTrue();
         }
 
         //Optional values (default to null or empty)
         strengthOfFunction = null;
         profileOid = null;
         profileUri = null;
+        profileAlgOid = null;
+        profileAlgParameters = null;
+        profileHashValue = null;
         targetOid = null;
         targetUri = null;
+        targetAlgOid = null;
+        targetAlgParameters = null;
+        targetHashValue = null;
 
         //Sequence for the URIReference
         ASN1Sequence uriSequence;
@@ -106,18 +136,26 @@ public CommonCriteriaMeasures(final ASN1Sequence sequence) throws IllegalArgumen
                             = StrengthOfFunction.values()[enumerated.getValue().intValue()];
                     break;
                 case PROFILE_OID:
-                    profileOid = ASN1ObjectIdentifier.getInstance(taggedObj, false);
+                    profileOid = ASN1ObjectIdentifier.getInstance(taggedObj, false).getId();
                     break;
                 case PROFILE_URI:
                     uriSequence = ASN1Sequence.getInstance(taggedObj, false);
-                    profileUri = new URIReference(uriSequence);
+                    Map profileUriMap = parseUriReference(uriSequence);
+                    profileUri = (String) profileUriMap.get("uri");
+                    profileAlgOid = (String) profileUriMap.get("algOid");
+                    profileAlgParameters = (byte[]) profileUriMap.get("algParams");
+                    profileHashValue = (byte[]) profileUriMap.get("hashValue");
                     break;
                 case TARGET_OID:
-                    targetOid = ASN1ObjectIdentifier.getInstance(taggedObj, false);
+                    targetOid = ASN1ObjectIdentifier.getInstance(taggedObj, false).getId();
                     break;
                 case TARGET_URI:
                     uriSequence = ASN1Sequence.getInstance(taggedObj, false);
-                    targetUri = new URIReference(uriSequence);
+                    Map targetUriMap = parseUriReference(uriSequence);
+                    targetUri = (String) targetUriMap.get("uri");
+                    targetAlgOid = (String) targetUriMap.get("algOid");
+                    targetAlgParameters = (byte[]) targetUriMap.get("algParams");
+                    targetHashValue = (byte[]) targetUriMap.get("hashValue");
                     break;
                 default:
                     throw new IllegalArgumentException("Common criteria measures contains "
@@ -134,32 +172,27 @@ public CommonCriteriaMeasures(final ASN1Sequence sequence) throws IllegalArgumen
     @Override
     public String toString() {
         StringBuilder sb = new StringBuilder();
-        sb.append("ComponentIdentifier{");
-        sb.append("version=").append(version.toString());
-        sb.append(", assuranceLevel=").append(assuranceLevel.getValue());
-        sb.append(", evaluationStatus=").append(evaluationStatus.getValue());
-        sb.append(", plus=").append(plus.toString());
+        sb.append("CommonCriteriaMeasures{");
+        sb.append("ccVersion=").append(ccVersion);
+        sb.append(", assuranceLevel=").append(assuranceLevel != null ? assuranceLevel.getValue() : "");
+        sb.append(", evaluationStatus=").append(evaluationStatus != null ? evaluationStatus.getValue() : "");
+        sb.append(", ccPlus=").append(ccPlus);
         //Not null optional objects
-        sb.append(", strengthOfFunction=");
-        if (strengthOfFunction != null) {
-            sb.append(strengthOfFunction.getValue());
-        }
-        sb.append(", profileOid=");
-        if (profileOid != null) {
-            sb.append(profileOid.getId());
-        }
-        sb.append(", profileUri=");
-        if (profileUri != null) {
-            sb.append(profileUri);
-        }
-        sb.append(", targetOid=");
-        if (targetOid != null) {
-            sb.append(targetOid.getId());
-        }
-        sb.append(", targetUri=");
-        if (targetUri != null) {
-            sb.append(targetUri);
-        }
+        sb.append(", strengthOfFunction=").append(strengthOfFunction != null ? strengthOfFunction.getValue() : "");
+        sb.append(", profileOid=").append(profileOid != null ? profileOid : "");
+        sb.append(", profileUri=").append(profileUri != null ? profileUri : "");
+        sb.append(", profileAlgOid=").append(profileAlgOid != null ? profileAlgOid : "");
+        sb.append(", profileAlgParameters=")
+                .append(profileAlgParameters != null ? Arrays.toString(profileAlgParameters).replace(",", " ") : "");
+        sb.append(", profileHashValue=")
+                .append(profileHashValue != null ? Arrays.toString(profileHashValue).replace(",", " ") : "");
+        sb.append(", targetOid=").append(targetOid != null ? targetOid : "");
+        sb.append(", targetUri=").append(targetUri != null ? targetUri : "");
+        sb.append(", targetAlgOid=").append(targetAlgOid != null ? targetAlgOid : "");
+        sb.append(", targetAlgParameters=")
+                .append(targetAlgParameters != null ? Arrays.toString(targetAlgParameters).replace(",", " ") : "");
+        sb.append(", targetHashValue=")
+                .append(targetHashValue != null ? Arrays.toString(targetHashValue).replace(",", " ") : "");
         sb.append("}");
 
         return sb.toString();
diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/attributes/FIPSLevel.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/attributes/FIPSLevel.java
index b04ce00d6..e60aa8065 100644
--- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/attributes/FIPSLevel.java
+++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/attributes/FIPSLevel.java
@@ -9,6 +9,8 @@
 import org.bouncycastle.asn1.ASN1IA5String;
 import org.bouncycastle.asn1.ASN1Sequence;
 
+import java.io.Serializable;
+
 /**
  * Basic class that handle FIPS Level.
  * 
@@ -22,23 +24,23 @@
 @Setter
 @AllArgsConstructor
 @ToString
-public class FIPSLevel {
+public class FIPSLevel implements Serializable {
 
     private static final int MAX_SEQUENCE_SIZE = 3;
 
-    private ASN1IA5String version;
+    private String fipsVersion;
 
-    private SecurityLevel level;
+    private SecurityLevel securityLevel;
 
-    private ASN1Boolean plus;
+    private Boolean fipsPlus;
 
     /**
      * Default constructor.
      */
     public FIPSLevel() {
-        version = null;
-        level = null;
-        plus = null;
+        fipsVersion = null;
+        securityLevel = null;
+        fipsPlus = null;
     }
 
     /**
@@ -49,7 +51,7 @@ public FIPSLevel() {
      */
     public FIPSLevel(final ASN1Sequence sequence) throws IllegalArgumentException {
         //Get version
-        version = ASN1IA5String.getInstance(sequence.getObjectAt(0));
+        fipsVersion = ASN1IA5String.getInstance(sequence.getObjectAt(0)).getString();
         //Get and validate level
         ASN1Enumerated enumerated = ASN1Enumerated.getInstance(sequence.getObjectAt(1));
         //Throw exception when is not between 1 and 7
@@ -57,12 +59,12 @@ public FIPSLevel(final ASN1Sequence sequence) throws IllegalArgumentException {
                 || enumerated.getValue().intValue() > SecurityLevel.values().length) {
             throw new IllegalArgumentException("Invalid security level on FIPSLevel.");
         }
-        level = SecurityLevel.values()[enumerated.getValue().intValue() - 1];
+        securityLevel = SecurityLevel.values()[enumerated.getValue().intValue() - 1];
 
         //Check if there is another value on the sequence for the plus
-        plus = ASN1Boolean.FALSE;   //Default to false
+        fipsPlus = Boolean.FALSE;   //Default to false
         if (sequence.size() == MAX_SEQUENCE_SIZE) {
-            plus = ASN1Boolean.getInstance(sequence.getObjectAt(2));
+            fipsPlus = ASN1Boolean.getInstance(sequence.getObjectAt(2)).isTrue();
         }
     }
 
diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/attributes/TPMSecurityAssertions.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/attributes/TPMSecurityAssertions.java
index 11553e8e0..9aa411d76 100644
--- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/attributes/TPMSecurityAssertions.java
+++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/attributes/TPMSecurityAssertions.java
@@ -58,12 +58,6 @@ public TPMSecurityAssertions(final BigInteger version, final boolean fieldUpgrad
         this.fieldUpgradeable = fieldUpgradeable;
     }
 
-    // Future work (may need to create other classes):
-    //private CommonCriteriaMeasures commCritMeasures; //optional
-    //private FIPSLevel fipsLevel; //optional
-    //private boolean iso9000Certified; //default false
-    //private IA5String iso9000Uri; //optional
-
     /**
      * A type to handle the different endorsement key generation types used in the TPM
      * Assertions field of an endorsement credential. Ordering of enum types is intentional
diff --git a/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/entity/userdefined/certificate/PlatformCredentialTest.java b/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/entity/userdefined/certificate/PlatformCredentialTest.java
index 6ab46e530..30750ec42 100644
--- a/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/entity/userdefined/certificate/PlatformCredentialTest.java
+++ b/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/entity/userdefined/certificate/PlatformCredentialTest.java
@@ -610,9 +610,9 @@ public final void testPlatformConfiguration3() throws IOException, URISyntaxExce
         //Test TBBSecurityAssertion
         TBBSecurityAssertion tbbSec = platformCert.getTBBSecurityAssertion();
         Assertions.assertNotNull(tbbSec);
-        Assertions.assertEquals("3.1", tbbSec.getCcInfo().getVersion().getString());
-        Assertions.assertEquals("1.2.3.4.5.6", tbbSec.getCcInfo().getProfileOid().getId());
-        Assertions.assertEquals("140-2", tbbSec.getFipsLevel().getVersion().getString());
+        Assertions.assertEquals("3.1", tbbSec.getCcInfo().getCcVersion());
+        Assertions.assertEquals("1.2.3.4.5.6", tbbSec.getCcInfo().getProfileOid());
+        Assertions.assertEquals("140-2", tbbSec.getFipsLevel().getFipsVersion());
         Assertions.assertEquals("https://www.intel.com/isocertification.pdf",
                 tbbSec.getIso9000Uri().getString());
     }
@@ -680,9 +680,9 @@ public final void testPlatformConfiguration4() throws IOException, URISyntaxExce
         //Test TBBSecurityAssertion
         TBBSecurityAssertion tbbSec = platformCert.getTBBSecurityAssertion();
         Assertions.assertNotNull(tbbSec);
-        Assertions.assertEquals("3.1", tbbSec.getCcInfo().getVersion().getString());
-        Assertions.assertEquals("1.2.3.4.5.6", tbbSec.getCcInfo().getProfileOid().getId());
-        Assertions.assertEquals("140-2", tbbSec.getFipsLevel().getVersion().getString());
+        Assertions.assertEquals("3.1", tbbSec.getCcInfo().getCcVersion());
+        Assertions.assertEquals("1.2.3.4.5.6", tbbSec.getCcInfo().getProfileOid());
+        Assertions.assertEquals("140-2", tbbSec.getFipsLevel().getFipsVersion());
         Assertions.assertEquals("https://www.intel.com/isocertification.pdf",
                 tbbSec.getIso9000Uri().getString());
 
diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/utils/CertificateStringMapBuilder.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/utils/CertificateStringMapBuilder.java
index 95b3671bc..57c2b367f 100644
--- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/utils/CertificateStringMapBuilder.java
+++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/utils/CertificateStringMapBuilder.java
@@ -33,6 +33,7 @@
 import java.util.Comparator;
 import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.UUID;
 
 /**
@@ -41,12 +42,30 @@
  */
 @Log4j2
 public final class CertificateStringMapBuilder {
+
+    // Extended Key Usage (TCG KP) OIDs
+    private static final String TCG_KP_EK_CERTIFICATE = "2.23.133.8.1";
+    private static final String TCG_KP_PLATFORM_ATTRIBUTE_CERTIFICATE = "2.23.133.8.2";
+    private static final String TCG_KP_AIK_CERTIFICATE = "2.23.133.8.3";
+    private static final String TCG_KP_PLATFORM_KEY_CERTIFICATE = "2.23.133.8.4";
+    private static final String TCG_KP_DELTA_PLATFORM_ATTRIBUTE_CERTIFICATE = "2.23.133.8.5";
+
     /**
      * This private constructor was created to silence checkstyle error.
      */
     private CertificateStringMapBuilder() {
     }
 
+    private static Map getExtendedKeyUsageMap() {
+        Map ekuMap = new HashMap<>();
+        ekuMap.put(TCG_KP_EK_CERTIFICATE, "tcg-kp-EKCertificate");
+        ekuMap.put(TCG_KP_PLATFORM_ATTRIBUTE_CERTIFICATE, "tcg-kp-PlatformAttributeCertificate");
+        ekuMap.put(TCG_KP_AIK_CERTIFICATE, "tcg-kp-AIKCertificate");
+        ekuMap.put(TCG_KP_PLATFORM_KEY_CERTIFICATE, "tcg-kp-PlatformKeyCertificate");
+        ekuMap.put(TCG_KP_DELTA_PLATFORM_ATTRIBUTE_CERTIFICATE, "tcg-kp-DeltaPlatformAttributeCertificate");
+        return ekuMap;
+    }
+
     /**
      * Returns the general information.
      *
@@ -60,6 +79,7 @@ public static HashMap getGeneralCertificateInfo(
             final CertificateRepository certificateRepository,
             final CACredentialRepository caCertificateRepository) {
         HashMap data = new HashMap<>();
+        Map ekuMap = getExtendedKeyUsageMap();
 
         if (certificate != null) {
             data.put("issuer", certificate.getIssuer());
@@ -104,7 +124,7 @@ public static HashMap getGeneralCertificateInfo(
                     try {
                         KeyFactory ecFactory = KeyFactory.getInstance("EC");
                         publicKey = ecFactory.generatePublic(keySpec);
-                    } catch (Exception ignore) {}
+                    } catch (Exception ignore) { }
                     // If no EC then RSA
                     if (publicKey == null) {
                         KeyFactory rsaFactory = KeyFactory.getInstance("RSA");
@@ -135,7 +155,12 @@ public static HashMap getGeneralCertificateInfo(
 
             if (certificate.getExtendedKeyUsage() != null
                     && !certificate.getExtendedKeyUsage().isEmpty()) {
-                data.put("extendedKeyUsage", certificate.getExtendedKeyUsage());
+                String eku = certificate.getExtendedKeyUsage().replaceAll("\\n$", "");
+                if (ekuMap.containsKey(eku)) {
+                    data.put("extendedKeyUsage", eku + " (" + ekuMap.get(eku) + ")");
+                } else {
+                    data.put("extendedKeyUsage", eku + " (Warning: Unexpected OID)");
+                }
             }
 
             //Get issuer ID if not self signed
@@ -354,6 +379,22 @@ public static HashMap getEndorsementInformation(
             if (certificate.getTpmSecurityAssertions() != null) {
                 data.putAll(
                         convertStringToHash(certificate.getTpmSecurityAssertions().toString()));
+                // Reparse certificate to fetch additional details for display
+                try {
+                    certificate.parseCertificate();
+                } catch (IOException e) {
+                    throw new RuntimeException("Failed to re-parse Endorsement Credential for details display", e);
+                }
+                if (certificate.getCommonCriteriaMeasures() != null) {
+                    data.putAll(convertStringToHash(certificate.getCommonCriteriaMeasures().toString()));
+                }
+                if (certificate.getFipsLevel() != null) {
+                    data.putAll(convertStringToHash(certificate.getFipsLevel().toString()));
+                }
+                data.put("iso9000Certified", String.valueOf(certificate.isIso9000Certified()));
+                if (certificate.getIso9000Uri() != null) {
+                    data.put("iso9000Uri", certificate.getIso9000Uri());
+                }
             }
         } else {
             String notFoundMessage = "Unable to find Endorsement Credential "
@@ -531,17 +572,70 @@ public int compare(final PlatformCredential obj1,
      */
     private static HashMap convertStringToHash(final String str) {
         HashMap map = new HashMap<>();
-        String name = str.substring(0, str.indexOf('(')).trim();
-        String data = str.trim().substring(str.trim().indexOf('(') + 1,
-                str.trim().length() - 1);
-        // Separate key and value and parse the key
-        for (String pair : data.split(",")) {
-            String[] keyValue = pair.split("=");
-            // Remove white space and change first character in the key to uppercase
-            keyValue[0] = Character.toUpperCase(
-                    keyValue[0].trim().charAt(0)) + keyValue[0].trim().substring(1);
-
-            map.put(name + keyValue[0], keyValue[1].trim());
+        if (str == null || str.isEmpty()) {
+            return map;
+        }
+
+        // Determine delimiter type
+        int startIdx = str.indexOf('(');
+        char openDelim = '(';
+        char closeDelim = ')';
+
+        if (startIdx < 0) {
+            startIdx = str.indexOf('{');
+            openDelim = '{';
+            closeDelim = '}';
+        }
+
+        // If no delimiters, cannot parse
+        if (startIdx < 0) {
+            return map;
+        }
+
+        String name = str.substring(0, startIdx).trim();
+        String data = str.substring(startIdx + 1, str.lastIndexOf(closeDelim)).trim();
+
+        int braceDepth = 0;
+        StringBuilder current = new StringBuilder();
+        List pairs = new ArrayList<>();
+
+        // Split top-level key=value pairs, ignoring commas inside braces
+        for (char c : data.toCharArray()) {
+            if (c == '{' || c == '(') {
+                braceDepth++;
+            } else if (c == '}' || c == ')') {
+                braceDepth--;
+            }
+            if (c == ',' && braceDepth == 0) {
+                pairs.add(current.toString());
+                current.setLength(0);
+            } else {
+                current.append(c);
+            }
+        }
+        if (current.length() > 0) {
+            pairs.add(current.toString());
+        }
+
+        for (String pair : pairs) {
+            String[] keyValue = pair.split("=", 2);
+            if (keyValue.length < 2) {
+                continue;
+            }
+            String key = keyValue[0].trim();
+            String value = keyValue[1].trim();
+
+            // Capitalize first letter of key
+            key = Character.toUpperCase(key.charAt(0)) + key.substring(1);
+
+            // Handle nested object recursively if it contains braces or parentheses
+            if ((value.contains("{") && value.contains("}")) || (value.contains("(") && value.contains(")"))) {
+                HashMap nestedMap = convertStringToHash(value);
+                // Prefix nested keys with parent key
+                map.putAll(nestedMap);
+            } else {
+                map.put(name + key, value);
+            }
         }
         return map;
     }
@@ -638,6 +732,7 @@ public static HashMap getIdevidInformation(final UUID uuid,
                                                                        caCredentialRepository) {
 
         HashMap data = new HashMap<>();
+        Map ekuMap = getExtendedKeyUsageMap();
         IDevIDCertificate certificate = (IDevIDCertificate) certificateRepository.getCertificate(uuid);
 
         if (certificate != null) {
@@ -697,7 +792,12 @@ public static HashMap getIdevidInformation(final UUID uuid,
 
             if (certificate.getExtendedKeyUsage() != null
                     && !certificate.getExtendedKeyUsage().isEmpty()) {
-                data.put("extendedKeyUsage", certificate.getExtendedKeyUsage());
+                String eku = certificate.getExtendedKeyUsage().replaceAll("\\n$", "");
+                if (ekuMap.containsKey(eku)) {
+                    data.put("extendedKeyUsage", eku + " (" + ekuMap.get(eku) + ")");
+                } else {
+                    data.put("extendedKeyUsage", eku + " (Warning: Unexpected OID)");
+                }
             }
 
             if (certificate.getTpmPolicies() != null) {
diff --git a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/certificate-details.jsp b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/certificate-details.jsp
index 4a39b9855..8b2255ddf 100644
--- a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/certificate-details.jsp
+++ b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/jsp/certificate-details.jsp
@@ -5,6 +5,7 @@
 <%@taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
 <%@taglib prefix="fn" uri="jakarta.tags.functions"%>
 <%@taglib prefix="my" tagdir="/WEB-INF/tags"%>
+<%@taglib prefix="t" tagdir="/WEB-INF/tags" %>
 
 <%--CONTENT--%>
 
@@ -380,7 +381,7 @@
                             
                                 
                             
                         
@@ -399,26 +400,94 @@
                                 
                             
                         
                         
- @@ -1040,24 +1109,94 @@
- @@ -603,23 +603,252 @@

@@ -759,7 +988,7 @@

Version: - [[${ccinfo.getVersion()}]] + [[${ccinfo.getCcVersion()}]]
Assurance Level: @@ -772,10 +1001,10 @@

class="fieldValue">[[${#strings.toUpperCase(ccinfo.getEvaluationStatus().getValue())}]]

- + Plus - + Not Plus
@@ -794,23 +1023,23 @@

- +
Profile Hash Algorithm: [[${ccinfo.getProfileUri().getHashAlgorithm()}]] + class="fieldValue">[[${ccinfo.getProfileAlgOid()}]]
- +
Profile Hash Value: [[${ccinfo.getProfileUri().getHashValue()}]] + class="fieldValue">[[${ccinfo.getProfileHashValue()}]]
@@ -824,23 +1053,23 @@

- +
Target Hash Algorithm: [[${ccinfo.getTargetUri().getHashAlgorithm()}]] + class="fieldValue">[[${ccinfo.getTargetAlgOid()}]]
- +
Target Hash Value: [[${ccinfo.getTargetUri().getHashValue()}]] + class="fieldValue">[[${ccinfo.getTargetHashValue()}]]
@@ -875,21 +1104,22 @@

Version: - [[${fipslevel.getVersion()}]] + [[${fipslevel.getFipsVersion()}]]
Level: [[${#strings.toUpperCase(fipslevel.getLevel().getValue())}]] + class="fieldValue">[[${#strings.toUpperCase(fipslevel.getSecurityLevel().getValue())}]]
- + Plus - + Not Plus
+

@@ -1270,7 +1500,7 @@

@@ -1287,21 +1517,252 @@

diff --git a/HIRS_AttestationCAPortal/src/main/resources/templates/fragments/field-displayer.html b/HIRS_AttestationCAPortal/src/main/resources/templates/fragments/field-displayer.html new file mode 100644 index 000000000..263c07692 --- /dev/null +++ b/HIRS_AttestationCAPortal/src/main/resources/templates/fragments/field-displayer.html @@ -0,0 +1,3 @@ + + \ No newline at end of file diff --git a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/tags/field-displayer.tag b/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/tags/field-displayer.tag deleted file mode 100644 index b9826cd69..000000000 --- a/HIRS_AttestationCAPortal/src/main/webapp/WEB-INF/tags/field-displayer.tag +++ /dev/null @@ -1,8 +0,0 @@ -<%@ tag description="Render table row" pageEncoding="UTF-8" %> -<%@ attribute name="label" required="true" %> -<%@ attribute name="value" required="true" %> - - - ${label} - ${empty value ? '[Not Present]' : value} - \ No newline at end of file From 0e6d493eadc39d639697c07052d0c4fd6fac5685 Mon Sep 17 00:00:00 2001 From: iadgovuser62 Date: Tue, 10 Feb 2026 08:40:32 -0500 Subject: [PATCH 03/20] v3_issue_1018: Fix spotbugs --- .../certificate/EndorsementCredential.java | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/EndorsementCredential.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/EndorsementCredential.java index 8fbbe5b0e..9152fc154 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/EndorsementCredential.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/EndorsementCredential.java @@ -94,6 +94,11 @@ public class EndorsementCredential extends DeviceAssociatedCertificate { private static final int SECURITY_VAL_MIN = 1; private static final int SECURITY_VAL_MAX = 4; + private static final int BYTE_MASK_UNSIGNED = 0xFF; + private static final int ASCII_PRINTABLE_MIN = 0x20; + private static final int ASCII_PRINTABLE_MAX = 0x7E; + private static final int DER_OID_TAG = 0x06; + // EK Tag index values private static final int EK_TYPE_TAG = 0; private static final int EK_LOC_TAG = 1; @@ -413,7 +418,8 @@ private void parseSequence(final ASN1Sequence seq, final boolean addToMapping, tpmSecurityAssertions.setEkGenerationLocation(ekGenLocation); } } case EK_CERT_LOC_TAG -> { - int ekCertGenLocVal = ((ASN1Enumerated) unwrapTaggedObject(taggedObj)).getValue().intValue(); + int ekCertGenLocVal = ((ASN1Enumerated) unwrapTaggedObject(taggedObj)).getValue() + .intValue(); if (ekCertGenLocVal >= EK_LOC_VAL_MIN && ekCertGenLocVal <= EK_LOC_VAL_MAX) { TPMSecurityAssertions.EkGenerationLocation ekCertGenLoc @@ -766,9 +772,10 @@ private void parseFipsLevel(final ASN1Sequence fipsLevelSeq) { * Unwraps an ASN1TaggedObject to get the underlying ASN1Primitive, * handling both explicit (direct type) and implicit (octet string). * - * @param taggedObj the ASN1TaggedObject to manually parse + * @param taggedObj the ASN1TaggedObject to manually parse. + * @return the ASN1Primitive form of original object */ - private static ASN1Primitive unwrapTaggedObject(ASN1TaggedObject taggedObj) throws IOException { + private static ASN1Primitive unwrapTaggedObject(final ASN1TaggedObject taggedObj) { ASN1Encodable encodable = taggedObj.getBaseObject(); // Explicit = Leave as is @@ -785,17 +792,17 @@ private static ASN1Primitive unwrapTaggedObject(ASN1TaggedObject taggedObj) thro return parsed.toASN1Primitive(); } } catch (Exception e) { - // Ignore + log.debug("Failed DER parse of implicit tagged value, falling back to heuristics", e); } // Enum parse if (bytes.length == 1) { - return new ASN1Enumerated(bytes[0] & 0xFF); + return new ASN1Enumerated(bytes[0] & BYTE_MASK_UNSIGNED); } // IA5String parse boolean ascii = bytes.length > 0; for (byte b : bytes) { - int c = b & 0xFF; - if (c < 0x20 || c > 0x7E) { + int c = b & BYTE_MASK_UNSIGNED; + if (c < ASCII_PRINTABLE_MIN || c > ASCII_PRINTABLE_MAX) { ascii = false; break; } @@ -810,8 +817,9 @@ private static ASN1Primitive unwrapTaggedObject(ASN1TaggedObject taggedObj) thro * Parses an ASN.1 tagged object to extract an Object Identifier (OID) as a string. * * @param taggedObj the ASN1TaggedObject to manually parse + * @return oidString the Oid to return in String form */ - private static String parseTaggedOid(ASN1TaggedObject taggedObj) throws IOException { + private static String parseTaggedOid(final ASN1TaggedObject taggedObj) throws IOException { ASN1Primitive primitiveObj = unwrapTaggedObject(taggedObj); String oidString = ""; if (primitiveObj instanceof ASN1ObjectIdentifier oid) { @@ -819,7 +827,7 @@ private static String parseTaggedOid(ASN1TaggedObject taggedObj) throws IOExcept } else if (primitiveObj instanceof ASN1OctetString oct) { byte[] body = oct.getOctets(); byte[] der = new byte[body.length + 2]; - der[0] = 0x06; + der[0] = DER_OID_TAG; der[1] = (byte) body.length; System.arraycopy(body, 0, der, 2, body.length); oidString = ASN1ObjectIdentifier.getInstance(ASN1Primitive.fromByteArray(der)) @@ -829,4 +837,4 @@ private static String parseTaggedOid(ASN1TaggedObject taggedObj) throws IOExcept } return oidString; } -} \ No newline at end of file +} From 5586d55cab5c1046535f60ace93c3456aff117ac Mon Sep 17 00:00:00 2001 From: ThatSilentCoder <184309164+ThatSilentCoder@users.noreply.github.com> Date: Tue, 10 Feb 2026 11:54:17 -0500 Subject: [PATCH 04/20] v3.1_issue_1101: First cut at fixing javadoc warnings/errors --- .../persist/CriteriaModifier.java | 17 -- .../persist/OrderedListQuerier.java | 65 -------- .../persist/PersistenceConfiguration.java | 74 --------- .../manager/CACredentialRepository.java | 9 + .../entity/manager/CertificateRepository.java | 9 + .../entity/manager/DeviceRepository.java | 9 + .../EndorsementCredentialRepository.java | 9 + .../manager/IDevIDCertificateRepository.java | 9 + .../manager/IssuedCertificateRepository.java | 9 + .../PlatformCertificateRepository.java | 9 + .../entity/manager/PolicyRepository.java | 9 + .../ReferenceDigestValueRepository.java | 9 + .../manager/ReferenceManifestRepository.java | 10 ++ .../persist/entity/manager/package-info.java | 5 + .../certificate/CertificateVariables.java | 124 +++++++++----- .../provision/helper/ProvisionUtils.java | 33 ++-- .../portal/PageConfiguration.java | 40 ----- .../portal/PersistenceJPAConfig.java | 70 +++----- .../portal/page/PageController.java | 30 ++-- .../portal/page/PageMessages.java | 26 ++- .../page/controllers/HelpPageController.java | 1 + .../ValidationReportsPageController.java | 1 + .../portal/page/controllers/package-info.java | 6 + .../TcgCompRimCoswidConfig.java | 9 +- .../utils/signature/cose/Cbor/CborItems.java | 19 ++- .../utils/signature/cose/CoseAlgorithm.java | 157 ++++++++++++------ .../signature/cose/CoseHeaderUnprotected.java | 11 +- .../utils/xjc/CanonicalizationMethodType.java | 4 +- build.gradle | 4 + 29 files changed, 399 insertions(+), 388 deletions(-) delete mode 100644 HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/CriteriaModifier.java delete mode 100644 HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/OrderedListQuerier.java delete mode 100644 HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/PageConfiguration.java diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/CriteriaModifier.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/CriteriaModifier.java deleted file mode 100644 index 8c42b3837..000000000 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/CriteriaModifier.java +++ /dev/null @@ -1,17 +0,0 @@ -package hirs.attestationca.persist; - -import jakarta.persistence.criteria.CriteriaQuery; - -/** - * Allows a user of the DBManager to modify the criteria object before processing. - * - * @param the parameter type - */ -public interface CriteriaModifier { - /** - * Allows a client to modify the criteria object by reference. - * - * @param criteria The hibernate criteria builder object - */ - void modify(CriteriaQuery criteria); -} diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/OrderedListQuerier.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/OrderedListQuerier.java deleted file mode 100644 index 63e935156..000000000 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/OrderedListQuerier.java +++ /dev/null @@ -1,65 +0,0 @@ -package hirs.attestationca.persist; - -import java.util.Map; - -/** - * Interface defining methods for getting ordered lists from a data source. Includes - * properties for sorting, paging, and searching. - * - * @param the record type, T. - */ -public interface OrderedListQuerier { - - /** - * Returns a list of all Ts that are ordered by a column and - * direction (ASC, DESC) that is provided by the user. This method helps - * support the server-side processing in the JQuery DataTables. - * - * @param clazz class type of Ts to search for (may be null to - * use Class<T>) - * @param columnToOrder Column to be ordered - * @param ascending direction of sort - * @param firstResult starting point of first result in set - * @param maxResults total number we want returned for display in table - * @param search string of criteria to be matched to visible columns - * @param searchableColumns Map of String and boolean values with column - * headers and whether they should be searched. Boolean is true if field provides - * a typical String that can be searched by Hibernate without transformation. - * @return FilteredRecordsList object with query data - * @throws DBManagerException if unable to create the list - */ - FilteredRecordsList getOrderedList( - Class clazz, String columnToOrder, - boolean ascending, int firstResult, - int maxResults, String search, - Map searchableColumns) - throws DBManagerException; - - - /** - * Returns a list of all Ts that are ordered by a column and - * direction (ASC, DESC) that is provided by the user. This method helps - * support the server-side processing in the JQuery DataTables. For entities that support - * soft-deletes, the returned list does not contain Ts that have been soft-deleted. - * - * @param clazz class type of Ts to search for (may be null to - * use Class<T>) - * @param columnToOrder Column to be ordered - * @param ascending direction of sort - * @param firstResult starting point of first result in set - * @param maxResults total number we want returned for display in table - * @param search string of criteria to be matched to visible columns - * @param searchableColumns Map of String and boolean values with column - * headers and whether they should be searched. Boolean is true if field provides - * a typical String that can be searched by Hibernate without transformation. - * @param criteriaModifier a way to modify the criteria used in the query - * @return FilteredRecordsList object with query data - * @throws DBManagerException if unable to create the list - */ - FilteredRecordsList getOrderedList( - Class clazz, String columnToOrder, - boolean ascending, int firstResult, - int maxResults, String search, - Map searchableColumns, CriteriaModifier criteriaModifier) - throws DBManagerException; -} diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/PersistenceConfiguration.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/PersistenceConfiguration.java index 0526a4a7f..e8ef0e61f 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/PersistenceConfiguration.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/PersistenceConfiguration.java @@ -28,78 +28,4 @@ public class PersistenceConfiguration { public static StructConverter structConverter() { return new SimpleStructConverter(); } -// @Bean -// public FilesStorageService filesStorageService() { -// FilesStorageServiceImpl filesStorageService = new FilesStorageServiceImpl(new StorageProperties()); -// filesStorageService.init(); -// return filesStorageService; -// } - -// /** -// * Creates a {@link CertificateServiceImpl} ready to use. -// * -// * @return {@link CertificateServiceImpl} -// */ -// @Bean -// public CertificateServiceImpl certificateServiceImpl() { -// CertificateServiceImpl manager = new CertificateServiceImpl(); -// setDbManagerRetrySettings(manager); -// return manager; -// } -// -// /** -// * Creates a {@link DeviceServiceImpl} ready to use. -// * -// * @return {@link DeviceServiceImpl} -// */ -// @Bean -// public DeviceServiceImpl deviceServiceImpl() { -// DeviceServiceImpl manager = new DeviceServiceImpl(); -// setDbManagerRetrySettings(manager); -// return manager; -// } -// -// /** -// * Creates a {@link PolicyServiceImpl} ready to use. -// * -// * @return {@link PolicyServiceImpl} -// */ -// @Bean -// public PolicyServiceImpl policyServiceImpl() { -// PolicyServiceImpl manager = new PolicyServiceImpl(); -// setDbManagerRetrySettings(manager); -// return manager; -// } -// -// /** -// * Creates a {@link ReferenceManifestServiceImpl} ready to use. -// * -// * @return {@link ReferenceManifestServiceImpl} -// */ -// @Bean -// public ReferenceManifestServiceImpl referenceManifestServiceImpl() { -// ReferenceManifestServiceImpl manager = new ReferenceManifestServiceImpl(); -// setDbManagerRetrySettings(manager); -// return manager; -// } -// -// /** -// * Creates a {@link ReferenceDigestValueServiceImpl} ready to use. -// * -// * @return {@link ReferenceDigestValueServiceImpl} -// */ -// @Bean -// public ReferenceDigestValueServiceImpl referenceDigestValueServiceImpl() { -// ReferenceDigestValueServiceImpl manager = new ReferenceDigestValueServiceImpl(); -// setDbManagerRetrySettings(manager); -// return manager; -// } -// -// /** -// * Apply the spring-wired retry template settings to the db manager. -// * @param dbManager the manager to apply the retry settings to -// */ -// private void setDbManagerRetrySettings(final DefaultDbService dbManager) { -// dbManager.setRetryTemplate(); -// } } diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/CACredentialRepository.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/CACredentialRepository.java index 1319399e0..792444c3d 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/CACredentialRepository.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/CACredentialRepository.java @@ -9,6 +9,15 @@ import java.util.List; import java.util.UUID; +/** + * Repository interface for managing {@link CertificateAuthorityCredential} entities in the database. + * + *

+ * The {@link CACredentialRepository} interface extends {@link JpaRepository} to provide basic CRUD operations, + * including save, find, delete, and query methods. Custom query methods can be defined + * using Spring Data JPA's query method naming conventions or with the Query annotation. + *

+ */ @Repository public interface CACredentialRepository extends JpaRepository { diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/CertificateRepository.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/CertificateRepository.java index 4f389d191..493b51aee 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/CertificateRepository.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/CertificateRepository.java @@ -13,6 +13,15 @@ import java.util.List; import java.util.UUID; +/** + * Repository interface for managing {@link Certificate} entities in the database. + * + *

+ * The {@link CertificateRepository} interface extends {@link JpaRepository} to provide basic CRUD operations, + * including save, find, delete, and query methods. Custom query methods can be defined + * using Spring Data JPA's query method naming conventions or with the Query annotation. + *

+ */ @Repository public interface CertificateRepository extends JpaRepository { diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/DeviceRepository.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/DeviceRepository.java index e708812eb..f6efc801c 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/DeviceRepository.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/DeviceRepository.java @@ -6,6 +6,15 @@ import java.util.UUID; +/** + * Repository interface for managing {@link Device} entities in the database. + * + *

+ * The {@link DeviceRepository} interface extends {@link JpaRepository} to provide basic CRUD operations, + * including save, find, delete, and query methods. Custom query methods can be defined + * using Spring Data JPA's query method naming conventions or with the Query annotation. + *

+ */ @Repository public interface DeviceRepository extends JpaRepository { /** diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/EndorsementCredentialRepository.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/EndorsementCredentialRepository.java index dbf09fdf7..f9c135746 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/EndorsementCredentialRepository.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/EndorsementCredentialRepository.java @@ -10,6 +10,15 @@ import java.util.List; import java.util.UUID; +/** + * Repository interface for managing {@link EndorsementCredential} entities in the database. + * + *

+ * The {@link EndorsementCredentialRepository} interface extends {@link JpaRepository} to provide basic CRUD operations, + * including save, find, delete, and query methods. Custom query methods can be defined + * using Spring Data JPA's query method naming conventions or with the Query annotation. + *

+ */ @Repository public interface EndorsementCredentialRepository extends JpaRepository { diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/IDevIDCertificateRepository.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/IDevIDCertificateRepository.java index b8d062a09..4109896f4 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/IDevIDCertificateRepository.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/IDevIDCertificateRepository.java @@ -9,6 +9,15 @@ import java.util.List; import java.util.UUID; +/** + * Repository interface for managing {@link IDevIDCertificate} entities in the database. + * + *

+ * The {@link IDevIDCertificateRepository} interface extends {@link JpaRepository} to provide basic CRUD operations, + * including save, find, delete, and query methods. Custom query methods can be defined + * using Spring Data JPA's query method naming conventions or with the Query annotation. + *

+ */ @Repository public interface IDevIDCertificateRepository extends JpaRepository { diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/IssuedCertificateRepository.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/IssuedCertificateRepository.java index 0d50494f8..dc9410172 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/IssuedCertificateRepository.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/IssuedCertificateRepository.java @@ -9,6 +9,15 @@ import java.util.List; import java.util.UUID; +/** + * Repository interface for managing {@link IssuedAttestationCertificate} entities in the database. + * + *

+ * The {@link IssuedCertificateRepository} interface extends {@link JpaRepository} to provide basic CRUD operations, + * including save, find, delete, and query methods. Custom query methods can be defined + * using Spring Data JPA's query method naming conventions or with the Query annotation. + *

+ */ @Repository public interface IssuedCertificateRepository extends JpaRepository { diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/PlatformCertificateRepository.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/PlatformCertificateRepository.java index ad7a41905..053dadd1f 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/PlatformCertificateRepository.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/PlatformCertificateRepository.java @@ -9,6 +9,15 @@ import java.util.List; import java.util.UUID; +/** + * Repository interface for managing {@link PlatformCredential} entities in the database. + * + *

+ * The {@link PlatformCertificateRepository} interface extends {@link JpaRepository} to provide basic CRUD operations, + * including save, find, delete, and query methods. Custom query methods can be defined + * using Spring Data JPA's query method naming conventions or with the Query annotation. + *

+ */ @Repository public interface PlatformCertificateRepository extends JpaRepository { diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/PolicyRepository.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/PolicyRepository.java index ae30b9663..65d5708a2 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/PolicyRepository.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/PolicyRepository.java @@ -6,6 +6,15 @@ import java.util.UUID; +/** + * Repository interface for managing the ACA's {@link PolicySettings} in the database. + * + *

+ * The {@link PolicyRepository} interface extends {@link JpaRepository} to provide basic CRUD operations, + * including save, find, delete, and query methods. Custom query methods can be defined + * using Spring Data JPA's query method naming conventions or with the Query annotation. + *

+ */ @Repository public interface PolicyRepository extends JpaRepository { diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ReferenceDigestValueRepository.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ReferenceDigestValueRepository.java index 008c2abe8..3fcd5e01f 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ReferenceDigestValueRepository.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ReferenceDigestValueRepository.java @@ -7,6 +7,15 @@ import java.util.List; import java.util.UUID; +/** + * Repository interface for managing {@link ReferenceDigestValue} entities in the database. + * + *

+ * The {@link ReferenceDigestValueRepository} interface extends {@link JpaRepository} to provide basic CRUD operations, + * including save, find, delete, and query methods. Custom query methods can be defined + * using Spring Data JPA's query method naming conventions or with the Query annotation. + *

+ */ @Repository public interface ReferenceDigestValueRepository extends JpaRepository { diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ReferenceManifestRepository.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ReferenceManifestRepository.java index 984ea0e32..3ac92c491 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ReferenceManifestRepository.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ReferenceManifestRepository.java @@ -13,6 +13,15 @@ import java.util.List; import java.util.UUID; +/** + * Repository interface for managing {@link ReferenceManifest} entities in the database. + * + *

+ * The {@link ReferenceManifestRepository} interface extends {@link JpaRepository} to provide basic CRUD operations, + * including save, find, delete, and query methods. Custom query methods can be defined + * using Spring Data JPA's query method naming conventions or with the Query annotation. + *

+ */ @Repository public interface ReferenceManifestRepository extends JpaRepository { /** @@ -229,6 +238,7 @@ public interface ReferenceManifestRepository extends JpaRepository(SymmetricKey.class) - .set("algorithmId", SymmetricKey.ALGORITHM_AES) - .set("encryptionScheme", SymmetricKey.SCHEME_CBC) - .set("key", responseSymmetricKey).build(); - return sessionKey; + return new SimpleStructBuilder<>(SymmetricKey.class) + .set("algorithmId", SymmetricKey.ALGORITHM_AES) + .set("encryptionScheme", SymmetricKey.SCHEME_CBC) + .set("key", responseSymmetricKey).build(); } /** @@ -513,17 +508,15 @@ public static SymmetricAttestation generateAttestation(final X509Certificate cre byte[] credentialBytes = ArrayUtils.addAll(credentialIV, encryptedCredential); // create attestation for identity response that contains the credential - SymmetricAttestation attestation = - new SimpleStructBuilder<>(SymmetricAttestation.class) - .set("credential", credentialBytes) - .set("algorithm", - new SimpleStructBuilder<>(SymmetricKeyParams.class) - .set("algorithmId", SymmetricKeyParams.ALGORITHM_AES) - .set("encryptionScheme", - SymmetricKeyParams.SCHEME_CBC_PKCS5PADDING) - .set("signatureScheme", 0).build()).build(); - - return attestation; + + return new SimpleStructBuilder<>(SymmetricAttestation.class) + .set("credential", credentialBytes) + .set("algorithm", + new SimpleStructBuilder<>(SymmetricKeyParams.class) + .set("algorithmId", SymmetricKeyParams.ALGORITHM_AES) + .set("encryptionScheme", + SymmetricKeyParams.SCHEME_CBC_PKCS5PADDING) + .set("signatureScheme", 0).build()).build(); } catch (BadPaddingException | IllegalBlockSizeException | NoSuchAlgorithmException | InvalidKeyException | InvalidAlgorithmParameterException | NoSuchPaddingException diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/PageConfiguration.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/PageConfiguration.java deleted file mode 100644 index 04b112074..000000000 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/PageConfiguration.java +++ /dev/null @@ -1,40 +0,0 @@ -package hirs.attestationca.portal; - -import hirs.attestationca.portal.datatables.DataTableView; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; -import org.springframework.web.servlet.ViewResolver; -import org.springframework.web.servlet.view.UrlBasedViewResolver; - -/** - * Configuration file for the Page Controllers. - */ -@Configuration -@ComponentScan("hirs.attestationca.portal.page.controllers") -public class PageConfiguration { - - /** - * @return bean to resolve injected annotation.Value - * property expressions for beans. - */ - @Bean - public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { - return new PropertySourcesPlaceholderConfigurer(); - } - - /** - * Makes all URLs that end in "dataTable" use DataTableView to serialize DataTableResponse. - * - * @return ViewResolver that uses DataTableView. - */ - @Bean - public ViewResolver dataTableViewResolver() { - UrlBasedViewResolver resolver = new UrlBasedViewResolver(); - resolver.setViewClass(DataTableView.class); - resolver.setViewNames("*dataTable"); - resolver.setOrder(0); - return resolver; - } -} diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/PersistenceJPAConfig.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/PersistenceJPAConfig.java index dacadd720..eb0d3f8fe 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/PersistenceJPAConfig.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/PersistenceJPAConfig.java @@ -13,7 +13,6 @@ import org.springframework.context.annotation.PropertySource; import org.springframework.context.annotation.PropertySources; import org.springframework.core.env.Environment; -import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.jdbc.datasource.DriverManagerDataSource; import org.springframework.orm.jpa.JpaTransactionManager; @@ -22,7 +21,6 @@ import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.EnableTransactionManagement; -import org.springframework.web.multipart.support.StandardServletMultipartResolver; import javax.sql.DataSource; import java.nio.file.Files; @@ -90,6 +88,30 @@ public class PersistenceJPAConfig { @Autowired private Environment environment; + /** + * Initialization of the ACA. Detects environment and runs configuration + * methods as required. This method is intended to be invoked by the Spring + * application context. + */ + @PostConstruct + void initialize() { + // ensure that Bouncy Castle is registered as a security provider + Security.addProvider(new BouncyCastleProvider()); + } + + + /** + * Platform Transaction Manager bean. + * + * @return platform transaction manager bean + */ + @Bean + public PlatformTransactionManager transactionManager() { + final JpaTransactionManager transactionManager = new JpaTransactionManager(); + transactionManager.setEntityManagerFactory(entityManagerFactory().getObject()); + return transactionManager; + } + /** * Entity manager factory bean. * @@ -126,17 +148,6 @@ public DataSource dataSource() { return dataSource; } - /** - * Initialization of the ACA. Detects environment and runs configuration - * methods as required. This method is intended to be invoked by the Spring - * application context. - */ - @PostConstruct - void initialize() { - // ensure that Bouncy Castle is registered as a security provider - Security.addProvider(new BouncyCastleProvider()); - } - /** * @return the {@link PrivateKey} of the ACA */ @@ -256,28 +267,6 @@ public KeyStore keyStore() { } } - /** - * Platform Transaction Manager bean. - * - * @return platform transaction manager bean - */ - @Bean - public PlatformTransactionManager transactionManager() { - final JpaTransactionManager transactionManager = new JpaTransactionManager(); - transactionManager.setEntityManagerFactory(entityManagerFactory().getObject()); - return transactionManager; - } - - /** - * Persistence Exception Translation Post Processor bean. - * - * @return persistence exception translation post processor bean - */ - @Bean - public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { - return new PersistenceExceptionTranslationPostProcessor(); - } - /** * Helper method that validates the provided leaf certificate against the * established intermediate and root certificates. @@ -327,15 +316,4 @@ final Properties additionalProperties() { return hibernateProperties; } - - /** - * Creates a Spring Resolver for Multi-part form uploads. This is required - * for spring controllers to be able to process Spring MultiPartFiles - * - * @return bean to handle multipart form requests - */ - @Bean(name = "multipartResolver") - public StandardServletMultipartResolver multipartResolver() { - return new StandardServletMultipartResolver(); - } } diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/PageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/PageController.java index 317c966b3..6095ec4dc 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/PageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/PageController.java @@ -14,7 +14,6 @@ import java.net.URISyntaxException; import java.util.Map; -import java.util.Optional; /** * Abstract class to provide common functionality for page Controllers. @@ -110,10 +109,10 @@ protected final RedirectView redirectToSelf( /** * Redirects controller's page with the specified data. * - * @param newPage new page to get the model and view - * @param params The url parameters to pass to the page. - * @param model The model data to pass to the page. - * @param attr The request's RedirectAttributes to hold the model data. + * @param newPage new page to get the model and view + * @param params The url parameters to pass to the page. + * @param model The model data to pass to the page. + * @param redirectAttributes The request's RedirectAttributes to hold the model data. * @return RedirectView back to the page with the specified parameters. * @throws URISyntaxException if malformed URI */ @@ -121,33 +120,34 @@ protected final RedirectView redirectTo( final Page newPage, final P params, final Map model, - final RedirectAttributes attr) throws URISyntaxException { + final RedirectAttributes redirectAttributes) throws URISyntaxException { + + final String defaultUri = "../" + newPage.getViewName(); - String defaultUri = "../" + newPage.getViewName(); - // create uri with specified parameters - URIBuilder uri = new URIBuilder("../" + newPage.getViewName()); + // create uri with default uri + URIBuilder uri = new URIBuilder(defaultUri); log.debug("Redirection URI = {}", uri.toString()); if (params != null) { for (Map.Entry e : params.asMap().entrySet()) { - Object v = Optional.ofNullable(e.getValue()).orElse(null); + Object v = e.getValue(); uri.addParameter(e.getKey(), v.toString()); } } - // create view - RedirectView redirect = new RedirectView(defaultUri); + // create redirect view + RedirectView redirectView = new RedirectView(uri.toString()); // do not put model attributes in the url - redirect.setExposeModelAttributes(false); + redirectView.setExposeModelAttributes(false); // add model data to forward to redirected page if (model != null) { for (Map.Entry e : model.entrySet()) { - attr.addFlashAttribute(e.getKey(), e.getValue()); + redirectAttributes.addFlashAttribute(e.getKey(), e.getValue()); } } - return redirect; + return redirectView; } } diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/PageMessages.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/PageMessages.java index 3559ee00f..0163919d4 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/PageMessages.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/PageMessages.java @@ -10,13 +10,23 @@ */ @Getter public class PageMessages { - + /** + * A list of error messages to be displayed on the page. + */ private final List errorMessages = new ArrayList<>(); + + /** + * A list of success messages to be displayed on the page. + */ private final List successMessages = new ArrayList<>(); + + /** + * A list of informational messages to be displayed on the page. + */ private final List infoMessages = new ArrayList<>(); /** - * Adds an error message. + * Adds an error message to the list of error messages * * @param error the error message to add */ @@ -25,7 +35,7 @@ public void addErrorMessage(final String error) { } /** - * Adds multiple error messages. + * Adds multiple error messages to the list of error messages. * * @param multipleErrors list of error messages */ @@ -34,7 +44,7 @@ public void addErrorMessages(final List multipleErrors) { } /** - * Adds a success message. + * Adds a success message to the list of success messages. * * @param success the success message to add */ @@ -43,7 +53,7 @@ public void addSuccessMessage(final String success) { } /** - * Adds multiple success messages. + * Adds multiple success messages to the list of success messages. * * @param multipleSuccessMessages list of success messages to add */ @@ -52,7 +62,7 @@ public void addSuccessMessages(final List multipleSuccessMessages) { } /** - * Adds an informational message. + * Adds an informational message to the list of info messages. * * @param info the informational message to add */ @@ -61,11 +71,11 @@ public void addInfoMessage(final String info) { } /** - * Adds multiple informational messages. + * Adds multiple informational messages to the list of info messages * * @param multipleInfoMessages list of informational messages to add */ public void addInfoMessages(final List multipleInfoMessages) { - this.errorMessages.addAll(multipleInfoMessages); + this.infoMessages.addAll(multipleInfoMessages); } } diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/HelpPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/HelpPageController.java index fbe8e49ac..dc2daaf66 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/HelpPageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/HelpPageController.java @@ -125,6 +125,7 @@ public DataTableResponse getMainHIRSLogger(final DataTableInput data * @param redirectAttributes RedirectAttributes used to forward data back to the original * page. * @return the redirection view + * @throws URISyntaxException if any issues arise from redirecting to the Help page. */ @PostMapping("/setLogLevel") public RedirectView setLogLevel(@RequestParam final String loggerName, diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ValidationReportsPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ValidationReportsPageController.java index 8a8c6d43a..de94d24e1 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ValidationReportsPageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ValidationReportsPageController.java @@ -116,6 +116,7 @@ public DataTableResponse getValidationReportsTable * * @param request http request * @param response http response + * @throws IOException if any issues arise from downloading the validation report. */ @PostMapping("/download") public void downloadValidationReports(final HttpServletRequest request, diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/package-info.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/package-info.java index f64398906..f830ccbcc 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/package-info.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/package-info.java @@ -1 +1,7 @@ +/** + * This package contains all the classes and resources required to support the HIRS Attestation Portal's + * REST controllers. The components in this package are responsible for + * routing incoming requests to the appropriate controllers, processing the requests, and + * returning the necessary responses. + */ package hirs.attestationca.portal.page.controllers; diff --git a/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/cbor/tcgCompRimCoswid/TcgCompRimCoswidConfig.java b/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/cbor/tcgCompRimCoswid/TcgCompRimCoswidConfig.java index 1d5db8196..6a2c9c484 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/cbor/tcgCompRimCoswid/TcgCompRimCoswidConfig.java +++ b/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/cbor/tcgCompRimCoswid/TcgCompRimCoswidConfig.java @@ -17,6 +17,8 @@ */ @Getter public class TcgCompRimCoswidConfig extends CoswidConfig { + private final String componentLocator = null; + private final String firmwareVersion = null; /* * Attributes from the TCG Component RIM Binding for SWID and CoSWID specification. * Not found in the CoSWID or SWID specifications. @@ -28,8 +30,6 @@ public class TcgCompRimCoswidConfig extends CoswidConfig { private String persistentId = null; private String componentManufacturerStr = null; private String componentManufacturerID = null; - private String componentLocator = null; - private String firmwareVersion = null; private String supportRimType = null; private String supportRimFormat = null; private String supportRimUriGlobal = null; @@ -43,9 +43,10 @@ public class TcgCompRimCoswidConfig extends CoswidConfig { /** * Constructor for the TCG Component Rim Coswid Config. + * * @param filename TcgComponentRimConfig config created from a json file. */ - public TcgCompRimCoswidConfig(final String filename) throws IOException { + public TcgCompRimCoswidConfig(final String filename) { super(); try { String errMsg = ""; @@ -109,7 +110,7 @@ public TcgCompRimCoswidConfig(final String filename) throws IOException { .path(TcgCompRimCoswid.CRIM_SPDM_MEASUREMENT_RAW_DATA_STR).asText(); } catch (Exception e) { throw new RuntimeException("Error processing TCG Component RIM configuration file " - + filename + ": " + e.getMessage(), e); + + filename + ": " + e.getMessage(), e); } } } diff --git a/HIRS_Utils/src/main/java/hirs/utils/signature/cose/Cbor/CborItems.java b/HIRS_Utils/src/main/java/hirs/utils/signature/cose/Cbor/CborItems.java index 1e9b2e564..6dbe691bf 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/signature/cose/Cbor/CborItems.java +++ b/HIRS_Utils/src/main/java/hirs/utils/signature/cose/Cbor/CborItems.java @@ -7,12 +7,18 @@ */ public class CborItems { - /** Array of item names.*/ - private static final String[][] INDEX_NAMES = new String[0][0]; - /** Default item name. */ + /** + * Default item name. + */ public static final String UNKNOWN_STR = "Unknown"; - /** Default item id. */ + /** + * Default item id. + */ public static final int UNKNOWN_INT = 99; + /** + * Array of item names. + */ + private static final String[][] INDEX_NAMES = new String[0][0]; /** * Default constructor. @@ -22,7 +28,8 @@ protected CborItems() { /** * Converts the Item name to an item id. - * @param itemName + * + * @param itemName item name * @return id of the item. */ public static int getIndex(final String itemName) { @@ -33,8 +40,10 @@ public static int getIndex(final String itemName) { } return UNKNOWN_INT; } + /** * Searches for an Rfc 9393 specified index and returns the item name associated with the index. + * * @param index int rfc 939 sepcified index value * @return String item name associated with the index */ diff --git a/HIRS_Utils/src/main/java/hirs/utils/signature/cose/CoseAlgorithm.java b/HIRS_Utils/src/main/java/hirs/utils/signature/cose/CoseAlgorithm.java index e75ada155..c07ca5270 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/signature/cose/CoseAlgorithm.java +++ b/HIRS_Utils/src/main/java/hirs/utils/signature/cose/CoseAlgorithm.java @@ -9,45 +9,104 @@ * Processing is limited to the Algorithm Combinations suited to TCG registered signatures. */ public final class CoseAlgorithm { - /** IANA Registered COSE Algorithm. */ + /** + * IANA Registered COSE Algorithm. + */ public static final int COSE_RSA_SHA_512 = -259; // Uses PKCS-v1_5 padding - /** IANA Registered COSE Algorithm. */ + + /** + * IANA Registered COSE Algorithm. + */ public static final int COSE_RSA_SHA_384 = -258; - /** IANA Registered COSE Algorithm. */ + + /** + * IANA Registered COSE Algorithm. + */ public static final int COSE_RSA_SHA_256 = -257; - /** IANA Registered COSE Algorithm. */ + + /** + * IANA Registered COSE Algorithm. + */ public static final int COSE_ES_SHA_512 = -36; - /** IANA Registered COSE Algorithm. */ + + /** + * IANA Registered COSE Algorithm. + */ public static final int COSE_ES_SHA_384 = -35; - /** IANA Registered COSE Algorithm. */ + + /** + * IANA Registered COSE Algorithm. + */ public static final int COSE_ES_SHA_256 = -7; - /** IANA Registered COSE Algorithm. */ + + /** + * IANA Registered COSE Algorithm. + */ public static final int COSE_RSA_PSS_512 = -39; - /** IANA Registered COSE Algorithm. */ + + /** + * IANA Registered COSE Algorithm. + */ public static final int COSE_RSA_PSS_384 = -38; - /** IANA Registered COSE Algorithm. */ + + /** + * IANA Registered COSE Algorithm. + */ public static final int COSE_RSA_PSS_256 = -37; - /** IANA Registered COSE Algorithm. */ + + /** + * IANA Registered COSE Algorithm. + */ public static final int COSE_SHA_256 = -16; - /** IANA Registered COSE Algorithm Name. */ + + /** + * IANA Registered COSE Algorithm Name. + */ public static final String RSA_SHA512_PKCS1 = "RS512"; - /** IANA Registered COSE Algorithm Name. */ + + /** + * IANA Registered COSE Algorithm Name. + */ public static final String RSA_SHA384_PKCS1 = "RS384"; - /** IANA Registered COSE Algorithm Name. */ + + /** + * IANA Registered COSE Algorithm Name. + */ public static final String RSA_SHA256_PKCS1 = "RS256"; - /** IANA Registered COSE Algorithm Name. */ + + /** + * IANA Registered COSE Algorithm Name. + */ public static final String RSA_SHA512_PSS = "PS512"; - /** IANA Registered COSE Algorithm Name. */ + + /** + * IANA Registered COSE Algorithm Name. + */ public static final String RSA_SHA384_PSS = "PS384"; - /** IANA Registered COSE Algorithm Name. */ + + /** + * IANA Registered COSE Algorithm Name. + */ public static final String RSA_SHA256_PSS = "PS256"; - /** IANA Registered COSE Algorithm Name. */ + + /** + * IANA Registered COSE Algorithm Name. + */ public static final String ECDSA_SHA256 = "ES256"; - /** IANA Registered COSE Algorithm Name. */ + + /** + * IANA Registered COSE Algorithm Name. + */ public static final String ECDSA_SHA384 = "ES384"; - /** IANA Registered COSE Algorithm Name. */ + + /** + * IANA Registered COSE Algorithm Name. + */ public static final String ECDSA_SHA512 = "ES512"; - /** IANA Registered COSE Algorithm Name. */ + + /** + * IANA Registered COSE Algorithm Name. + */ public static final String SHA256 = "SHA-256"; private static final String[][] ALG_NAMES = { @@ -68,64 +127,66 @@ public final class CoseAlgorithm { */ private CoseAlgorithm() { } + /** * Searches Rfc 9393 Items Names for match to a specified item name and returns the index. - * @param coseAlg Iem Name specified in rfc 8152 + * + * @param coseAlg Iem Name specified in rfc 8152 * @return int tag of the cose type */ public static int getAlgId(final String coseAlg) { - int algId = 0; - for (int i = 0; i < ALG_NAMES.length; i++) { - if (coseAlg.compareToIgnoreCase(ALG_NAMES[i][1]) == 0) { - return (Integer.parseInt(ALG_NAMES[i][0])); + for (String[] algName : ALG_NAMES) { + if (coseAlg.compareToIgnoreCase(algName[1]) == 0) { + return (Integer.parseInt(algName[0])); } } return CoswidItems.UNKNOWN_INT; } + /** * Searches for an Rfc 8152 specified index and returns the item name associated with the index. + * * @param coseAlId IANA registered COSE Algorithm Value (ID) * @return String Algorithm name associated with the Algorithm Value (ID) */ public static String getAlgName(final int coseAlId) { - int algId = 0; - for (int i = 0; i < ALG_NAMES.length; i++) { - if (coseAlId == Integer.parseInt(ALG_NAMES[i][0])) { - return ALG_NAMES[i][1]; + for (String[] algName : ALG_NAMES) { + if (coseAlId == Integer.parseInt(algName[0])) { + return algName[1]; } } return CoswidItems.UNKNOWN_STR; } + /** * Returns true if the specified COSE algorithm identifier is a supported algorithm. * from the ECDSA family of algorithms. - * @param cosAlId + * + * @param cosAlId IANA registered COSE Algorithm Value (ID) * @return true if algorithm is COSE supported */ public static boolean isEcdsa(final int cosAlId) { - if ((cosAlId == CoseAlgorithm.COSE_ES_SHA_256) || (cosAlId == CoseAlgorithm.COSE_ES_SHA_384) - || (cosAlId == CoseAlgorithm.COSE_ES_SHA_512)) { - return true; - } - return false; + return (cosAlId == CoseAlgorithm.COSE_ES_SHA_256) || (cosAlId == CoseAlgorithm.COSE_ES_SHA_384) + || (cosAlId == CoseAlgorithm.COSE_ES_SHA_512); } + /** * Returns true of the specified COSE algorithm identifier is a supported algorithm * from the ECDSA family of algorithms. + * * @param coseAlgorithmName a IANA Registered COSE algorithm name * @return true if algorithm is an ecdsa variant */ public static boolean isEcdsaName(final String coseAlgorithmName) { - if ((coseAlgorithmName.compareToIgnoreCase(CoseAlgorithm.ECDSA_SHA256) == 0) + return (coseAlgorithmName.compareToIgnoreCase(CoseAlgorithm.ECDSA_SHA256) == 0) || (coseAlgorithmName.compareToIgnoreCase(CoseAlgorithm.ECDSA_SHA384) == 0) - || (coseAlgorithmName.compareToIgnoreCase(CoseAlgorithm.ECDSA_SHA512) == 0)) { - return true; - } - return false; + || (coseAlgorithmName.compareToIgnoreCase(CoseAlgorithm.ECDSA_SHA512) == 0); } + /** * Returns true of the specified COSE algorithm identifier is a supported algorithm * from the RSA family of algorithms. + * * @param cosAlId cose registered algorithm id * @return true if algorithm is a rsa variant */ @@ -138,32 +199,28 @@ public static boolean isRsa(final int cosAlId) { /** * Returns true of the specified COSE algorithm identifier is a supported algorithm * from the ECDSA family of algorithms. + * * @param coseAlgorithmName a IANA Registered COSE algorithm name * @return true if algorithm is a rsa variant */ public static boolean isRsaName(final String coseAlgorithmName) { - if ((coseAlgorithmName.compareToIgnoreCase(CoseAlgorithm.RSA_SHA256_PKCS1) == 0) + return (coseAlgorithmName.compareToIgnoreCase(CoseAlgorithm.RSA_SHA256_PKCS1) == 0) || (coseAlgorithmName.compareToIgnoreCase(CoseAlgorithm.RSA_SHA384_PKCS1) == 0) || (coseAlgorithmName.compareToIgnoreCase(CoseAlgorithm.RSA_SHA512_PKCS1) == 0) || (coseAlgorithmName.compareToIgnoreCase(CoseAlgorithm.RSA_SHA256_PSS) == 0) || (coseAlgorithmName.compareToIgnoreCase(CoseAlgorithm.RSA_SHA384_PSS) == 0) - || (coseAlgorithmName.compareToIgnoreCase(CoseAlgorithm.RSA_SHA512_PSS) == 0)) { - return true; - } - return false; + || (coseAlgorithmName.compareToIgnoreCase(CoseAlgorithm.RSA_SHA512_PSS) == 0); } /** * Returns true of the specified COSE algorithm is an RSA PSS variant. + * * @param coseAlgorithmName name of the algorithm * @return true if algorithm is a rsa-pss variant */ public static boolean isRsaPssName(final String coseAlgorithmName) { - if ((coseAlgorithmName.compareToIgnoreCase(CoseAlgorithm.RSA_SHA256_PSS) == 0) + return (coseAlgorithmName.compareToIgnoreCase(CoseAlgorithm.RSA_SHA256_PSS) == 0) || (coseAlgorithmName.compareToIgnoreCase(CoseAlgorithm.RSA_SHA384_PSS) == 0) - || (coseAlgorithmName.compareToIgnoreCase(CoseAlgorithm.RSA_SHA512_PSS) == 0)) { - return true; - } - return false; + || (coseAlgorithmName.compareToIgnoreCase(CoseAlgorithm.RSA_SHA512_PSS) == 0); } } diff --git a/HIRS_Utils/src/main/java/hirs/utils/signature/cose/CoseHeaderUnprotected.java b/HIRS_Utils/src/main/java/hirs/utils/signature/cose/CoseHeaderUnprotected.java index e8fe40968..20b1534e8 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/signature/cose/CoseHeaderUnprotected.java +++ b/HIRS_Utils/src/main/java/hirs/utils/signature/cose/CoseHeaderUnprotected.java @@ -15,6 +15,7 @@ public class CoseHeaderUnprotected extends CoseHeader { /** * Parser constructor to fill class variables. + * * @param uheader COSEUnprotectedHeader holding the COSE unprotected header */ public CoseHeaderUnprotected(final COSEUnprotectedHeader uheader) { @@ -37,9 +38,10 @@ public CoseHeaderUnprotected(final COSEUnprotectedHeader uheader) { /** * Default toString. + * * @return default "pretty" version */ - public String toString() { + public String toString() { try { return toString("pretty"); } catch (IOException e) { @@ -49,8 +51,11 @@ public String toString() { /** * Prints the processed COSE Unprotected Header data. - * @param format empty (default String) or "pretty" - * @return a formated string representation of the data in the COSE unproteced header object + * + * @param format empty (default String) or "pretty" + * @return a formated string representation of the data in the COSE unprotected header object + * @throws IOException if any issues arise while building the string representation of the COSE + * Unprotected Header data */ public String toString(final String format) throws IOException { String returnString = ""; diff --git a/HIRS_Utils/src/main/java/hirs/utils/xjc/CanonicalizationMethodType.java b/HIRS_Utils/src/main/java/hirs/utils/xjc/CanonicalizationMethodType.java index 33d09ea8c..4025f452e 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/xjc/CanonicalizationMethodType.java +++ b/HIRS_Utils/src/main/java/hirs/utils/xjc/CanonicalizationMethodType.java @@ -76,10 +76,12 @@ public class CanonicalizationMethodType { * Objects of the following type(s) are allowed in the list * {@link Object } * {@link String } + * + * @return list of objects that represent the content */ public List getContent() { if (content == null) { - content = new ArrayList(); + content = new ArrayList<>(); } return this.content; } diff --git a/build.gradle b/build.gradle index 0011a81a6..e1ce40123 100644 --- a/build.gradle +++ b/build.gradle @@ -67,6 +67,10 @@ subprojects { } } + tasks.withType(Javadoc).configureEach { + options.addStringOption('Xmaxwarns', '0') // Show unlimited warnings todo + } + tasks.withType(Checkstyle).configureEach { reports { xml.required = false From 68154095c83f705f4157468b5283453987ba7ca6 Mon Sep 17 00:00:00 2001 From: ThatSilentCoder <184309164+ThatSilentCoder@users.noreply.github.com> Date: Tue, 10 Feb 2026 14:46:06 -0500 Subject: [PATCH 05/20] v3.1_issue_1101: Slowly but surely cutting down warnings. Added a line in the build.gradle that prevents the javaDOc task from analyzing the geenrated protobuf file. --- .ci/system-tests/sys_test_common.sh | 2 +- .../persist/entity/manager/package-info.java | 2 +- .../persist/entity/package-info.java | 3 +- .../persist/entity/tpm/package-info.java | 3 + .../entity/userdefined/Certificate.java | 6 +- .../attributes/V2/package-info.java | 3 + .../certificate/attributes/package-info.java | 3 + .../userdefined/certificate/package-info.java | 3 + .../entity/userdefined/info/PortalInfo.java | 102 -------------- .../entity/userdefined/info/RIMInfo.java | 66 --------- .../entity/userdefined/info/package-info.java | 4 + .../entity/userdefined/package-info.java | 4 + .../userdefined/record/package-info.java | 3 + .../result/CertificateValidationResult.java | 50 ------- .../userdefined/result/package-info.java | 1 - .../attestationca/persist/package-info.java | 6 + .../service/CertificatePageService.java | 9 +- .../persist/service/DevicePageService.java | 8 +- .../persist/service/PolicyPageService.java | 1 - .../ReferenceDigestValuePageService.java | 9 +- .../service/ReferenceManifestPageService.java | 9 +- .../service/SupplyChainValidationService.java | 1 + .../persist/service/ValidationService.java | 5 + .../service/ValidationSummaryPageService.java | 8 +- .../CertificateAttributeScvValidator.java | 1 + .../validation/CredentialValidator.java | 1 + .../userdefined/info/PortalInfoTest.java | 130 ------------------ .../attestationca/portal/HIRSApplication.java | 3 + .../portal/HIRSDbInitializer.java | 13 -- .../PersistenceJPAConfig.java | 4 +- .../portal/configuration/package-info.java | 5 + .../portal/datatables/DataTableView.java | 46 ------- .../portal/datatables/package-info.java | 7 + .../AnnotationDrivenEndpointsListener.java | 31 ----- .../portal/listener/package-info.java | 1 - .../portal/page/controllers/package-info.java | 2 +- .../portal/page/package-info.java | 3 + .../params/CertificateDetailsPageParams.java | 17 --- .../params/ReferenceManifestPageParams.java | 44 ------ .../portal/page/params/package-info.java | 3 + .../portal/page/utils/package-info.java | 6 + .../java/hirs/utils/enums/PortalScheme.java | 16 --- build.gradle | 6 + 43 files changed, 106 insertions(+), 544 deletions(-) delete mode 100644 HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/info/PortalInfo.java delete mode 100644 HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/info/RIMInfo.java delete mode 100644 HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/result/CertificateValidationResult.java delete mode 100644 HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/result/package-info.java delete mode 100644 HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/entity/userdefined/info/PortalInfoTest.java delete mode 100644 HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/HIRSDbInitializer.java rename HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/{ => configuration}/PersistenceJPAConfig.java (99%) create mode 100644 HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/configuration/package-info.java delete mode 100644 HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/datatables/DataTableView.java delete mode 100644 HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/listener/AnnotationDrivenEndpointsListener.java delete mode 100644 HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/listener/package-info.java delete mode 100644 HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/params/ReferenceManifestPageParams.java delete mode 100644 HIRS_Utils/src/main/java/hirs/utils/enums/PortalScheme.java diff --git a/.ci/system-tests/sys_test_common.sh b/.ci/system-tests/sys_test_common.sh index a31313432..843a1bcc2 100644 --- a/.ci/system-tests/sys_test_common.sh +++ b/.ci/system-tests/sys_test_common.sh @@ -60,7 +60,7 @@ docker exec -i $aca_container mysql -u root -proot -D hirs_db -e "Update PolicyS clearAcaDb() { docker exec -i $aca_container mysql -u root -proot -e "use hirs_db; set foreign_key_checks=0; truncate Appraiser; truncate Certificate;truncate Issued_Attestation_Platform_Join_Table;truncate CertificatesUsedToValidate;truncate ComponentAttributeResult; - truncate ComponentInfo;truncate ComponentResult;truncate Device;truncate DeviceInfoReport;truncate PortalInfo; + truncate ComponentInfo;truncate ComponentResult;truncate Device;truncate DeviceInfoReport; truncate ReferenceDigestValue;truncate ReferenceManifest;truncate Report;truncate SupplyChainValidation; truncate SupplyChainValidationSummary;truncate SupplyChainValidationSummary_SupplyChainValidation; truncate TPM2ProvisionerState;set foreign_key_checks=1;" diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/package-info.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/package-info.java index f1439e726..1d6bc1772 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/package-info.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/package-info.java @@ -1,5 +1,5 @@ /** - * This package includes all the HIRS manager classes responsible for interacting with the database. + * Contains all the HIRS manager classes responsible for interacting with the database. * These managers encapsulate the logic for data retrieval, persistence, and manipulation, * providing a higher-level interface for accessing and modifying the underlying data models. */ diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/package-info.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/package-info.java index fa1fa47f5..c03d9b53f 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/package-info.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/package-info.java @@ -1,4 +1,5 @@ /** - * This package has objects for hibernate entity. + * Contains Hibernate entity classes that define the data model and map to database tables, + * providing the necessary structure for data persistence and retrieval. */ package hirs.attestationca.persist.entity; diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/tpm/package-info.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/tpm/package-info.java index 247ff4f63..4fa0ab9c9 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/tpm/package-info.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/tpm/package-info.java @@ -1 +1,4 @@ +/** + * Contains files for capturing information about the TPM Provisioning state. + */ package hirs.attestationca.persist.entity.tpm; diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/Certificate.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/Certificate.java index 5068fe634..507fb0261 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/Certificate.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/Certificate.java @@ -489,7 +489,8 @@ public static byte[] readBytes(final Path certificatePath) throws IOException { * found in various RFCs. * * @param certificate the certificate holding subject DNs - * @return IOException if there is an issue decoding the subject DNs + * @return subject distinguished name + * @throws IOException if there is an issue decoding the subject DNs */ public static String getSubjectDNString(final X509Certificate certificate) throws IOException { @@ -509,7 +510,8 @@ public static String getSubjectDNString(final X509Certificate certificate) * in various RFCs. * * @param certificate the certificate holding issuer DNs - * @return IOException if there is an issue decoding the issuer DNs + * @return issuer distinguished name + * @throws IOException if there is an issue decoding the issuer distinguished names */ public static String getIssuerDNString(final X509Certificate certificate) throws IOException { diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/attributes/V2/package-info.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/attributes/V2/package-info.java index 12ec500e2..e81fd1a38 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/attributes/V2/package-info.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/attributes/V2/package-info.java @@ -1 +1,4 @@ +/** + * Contains V2 certificate attributes/components. + */ package hirs.attestationca.persist.entity.userdefined.certificate.attributes.V2; diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/attributes/package-info.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/attributes/package-info.java index e165d514a..315e92471 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/attributes/package-info.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/attributes/package-info.java @@ -1 +1,4 @@ +/** + * Contains certificate attributes/components. + */ package hirs.attestationca.persist.entity.userdefined.certificate.attributes; diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/package-info.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/package-info.java index dea4ad9bd..62ec028fb 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/package-info.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/package-info.java @@ -1 +1,4 @@ +/** + * Contains the different types of certificates and certificate components. + */ package hirs.attestationca.persist.entity.userdefined.certificate; diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/info/PortalInfo.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/info/PortalInfo.java deleted file mode 100644 index 039e0302a..000000000 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/info/PortalInfo.java +++ /dev/null @@ -1,102 +0,0 @@ -package hirs.attestationca.persist.entity.userdefined.info; - -import hirs.utils.enums.PortalScheme; -import jakarta.persistence.Access; -import jakarta.persistence.AccessType; -import jakarta.persistence.Column; -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; -import jakarta.persistence.Table; -import lombok.Getter; -import lombok.NoArgsConstructor; - -import java.net.InetAddress; -import java.net.UnknownHostException; - -/** - * Store information about the Portal into the database. - */ -@NoArgsConstructor -@Getter -@Entity -@Table(name = "PortalInfo") -@Access(AccessType.FIELD) -public class PortalInfo { - - @Id - @Column - @GeneratedValue(strategy = GenerationType.AUTO) - private Long id; - @Column(unique = true, nullable = false) - private String name; - @Column - private InetAddress ipAddress; - @Column - private int port = 0; - @Column - private String context; - - /** - * Sets the scheme name of the portal. - * - * @param scheme Name of the portal. - */ - public void setSchemeName(final PortalScheme scheme) { - if (scheme == null) { - throw new NullPointerException("Scheme cannot be null"); - } - this.name = scheme.name(); - } - - /** - * Stores the address of the portal. - * - * @param inetAddress address used by the portal. - */ - public void setIpAddress(final InetAddress inetAddress) { - if (inetAddress == null) { - throw new IllegalArgumentException("setIpAddress input was null."); - } - - this.ipAddress = inetAddress; - } - - /** - * Resolves, then stores the address of the portal. - * - * @param host host name or address of the portal - * @throws UnknownHostException For problems resolving or storing the host. - */ - public void setIpAddress(final String host) throws UnknownHostException { - this.ipAddress = InetAddress.getByName(host); - } - - /** - * Store the port of the portal. - * - * @param port port of the portal - */ - public void setPort(final int port) { - final int upperBound = 65535; - if (port > 0 && port <= upperBound) { - this.port = port; - } else { - throw new IllegalArgumentException("Failed to store portal port. Provided number was" - + " outside of valid range (1 - " + upperBound + ")"); - } - } - - /** - * Sets the context name of the portal. - * - * @param context Context name of portal. - */ - public void setContextName(final String context) { - if (context == null) { - throw new NullPointerException("Context cannot be null"); - } - this.context = context; - } -} diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/info/RIMInfo.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/info/RIMInfo.java deleted file mode 100644 index 48c301cdd..000000000 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/info/RIMInfo.java +++ /dev/null @@ -1,66 +0,0 @@ -package hirs.attestationca.persist.entity.userdefined.info; - -import hirs.utils.StringValidator; -import hirs.utils.enums.DeviceInfoEnums; -import jakarta.persistence.Column; -import jakarta.persistence.Embeddable; -import jakarta.xml.bind.annotation.XmlElement; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.ToString; - -import java.io.Serializable; - -/** - * Store information about the RIM into the database. - */ -@Getter -@EqualsAndHashCode -@ToString -@Embeddable -public class RIMInfo implements Serializable { - - @XmlElement - @Column(length = DeviceInfoEnums.MED_STRING_LENGTH, nullable = false) - private final String rimManufacturer; - - @XmlElement - @Column(length = DeviceInfoEnums.MED_STRING_LENGTH, nullable = false) - private final String model; - - @XmlElement - @Column(length = DeviceInfoEnums.MED_STRING_LENGTH, nullable = false) - private final String fileHash; - - @XmlElement - @Column(length = DeviceInfoEnums.MED_STRING_LENGTH, nullable = false) - private final String pcrHash; - - /** - * Constructor for the initial values of the class. - * - * @param rimManufacturer string of the rimManufacturer - * @param model string of the model - * @param fileHash string of the file hash - * @param pcrHash string of the pcr hash - */ - public RIMInfo(final String rimManufacturer, final String model, - final String fileHash, final String pcrHash) { - this.rimManufacturer = StringValidator.check(rimManufacturer, "rimManufacturer") - .notBlank().maxLength(DeviceInfoEnums.MED_STRING_LENGTH).getValue(); - this.model = StringValidator.check(model, "model") - .notBlank().maxLength(DeviceInfoEnums.MED_STRING_LENGTH).getValue(); - this.fileHash = StringValidator.check(fileHash, "fileHash") - .notBlank().maxLength(DeviceInfoEnums.MED_STRING_LENGTH).getValue(); - this.pcrHash = StringValidator.check(pcrHash, "pcrHash") - .notBlank().maxLength(DeviceInfoEnums.MED_STRING_LENGTH).getValue(); - } - - /** - * Default no parameter constructor. - */ - public RIMInfo() { - this(DeviceInfoEnums.NOT_SPECIFIED, DeviceInfoEnums.NOT_SPECIFIED, - DeviceInfoEnums.NOT_SPECIFIED, DeviceInfoEnums.NOT_SPECIFIED); - } -} diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/info/package-info.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/info/package-info.java index 3e4d9b763..000e2a4a0 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/info/package-info.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/info/package-info.java @@ -1 +1,5 @@ +/** + * Contains classes that represent various information components that are embedded + * within larger entities. + */ package hirs.attestationca.persist.entity.userdefined.info; diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/package-info.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/package-info.java index 0962e038c..63f65b3fd 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/package-info.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/package-info.java @@ -1 +1,5 @@ +/** + * Contains user-defined classes that are mapped to database entities or serve + * as supporting components for the retrieval and storage of other entities. + */ package hirs.attestationca.persist.entity.userdefined; diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/record/package-info.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/record/package-info.java index a297fc9c9..98bfb8fcf 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/record/package-info.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/record/package-info.java @@ -1 +1,4 @@ +/** + * Contains files that store TPM information as a record. + */ package hirs.attestationca.persist.entity.userdefined.record; diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/result/CertificateValidationResult.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/result/CertificateValidationResult.java deleted file mode 100644 index a48573f30..000000000 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/result/CertificateValidationResult.java +++ /dev/null @@ -1,50 +0,0 @@ -package hirs.attestationca.persist.entity.userdefined.result; - -import lombok.Getter; -import lombok.Setter; - -/** - * An CertificateValidationResult represents the result of a certificate validation - * operation. - */ -@Getter -@Setter -public class CertificateValidationResult { - private CertificateValidationStatus validationStatus; - private String validationResultMessage; - - /** - * Sets the certificate validation status and result message. - * - * @param status enum representing the certificate validation status - * @param resultMessage String representing certificate validation message - */ - public final void setCertValidationStatusAndResultMessage( - final CertificateValidationStatus status, - final String resultMessage) { - this.validationStatus = status; - this.validationResultMessage = resultMessage; - } - - - /** - * Enum used to represent certificate validation status. - */ - public enum CertificateValidationStatus { - - /** - * Represents a passing validation. - */ - PASS, - - /** - * Represents a failed validation. - */ - FAIL, - - /** - * Represents a validation error. - */ - ERROR - } -} diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/result/package-info.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/result/package-info.java deleted file mode 100644 index 3ad7260fe..000000000 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/result/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package hirs.attestationca.persist.entity.userdefined.result; diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/package-info.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/package-info.java index 625de584d..d0a37f99e 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/package-info.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/package-info.java @@ -1 +1,7 @@ +/** + * This package contains classes and interfaces related to persistence operations + * and data management in the application backend. It includes database entities, + * Data Access Objects (DAOs), and services responsible for handling database + * transactions, data validation, and provisioning logic. + */ package hirs.attestationca.persist; diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/CertificatePageService.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/CertificatePageService.java index 4840d5627..951b19d3d 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/CertificatePageService.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/CertificatePageService.java @@ -173,10 +173,11 @@ public Page findCertificatesByColumnSpecificSearchTer * The results are returned with pagination support. *

* This method combines the logic of two search functionalities: - * - Global search: Searches across all specified columns for a matching term. - * - Column-specific search: Filters based on individual column search criteria, such as text - * or date searches. - *

+ *

    + *
  • Global search: Searches across all specified columns for a matching term.
  • + *
  • Column-specific search: Filters based on individual column search criteria, + * such as text or date searches.
  • + *
* * @param entityClass generic certificate entity class * @param searchableColumnNames list of the searchable column names diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/DevicePageService.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/DevicePageService.java index 58e19c81e..6b1841576 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/DevicePageService.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/DevicePageService.java @@ -151,9 +151,11 @@ public Page findDevicesByColumnSpecificSearchTerm( * The results are returned with pagination support. *

* This method combines the logic of two search functionalities: - * - Global search: Searches across all specified columns for a matching term. - * - Column-specific search: Filters based on individual column search criteria, such as text or date searches. - *

+ *

    + *
  • Global search: Searches across all specified columns for a matching term.
  • + *
  • Column-specific search: Filters based on individual column search criteria, + * such as text or date searches.
  • + *
* * @param searchableColumnNames list of the searchable column names * @param globalSearchTerm The term that the user enters in the global search box. diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/PolicyPageService.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/PolicyPageService.java index 750149dc3..56397bb2c 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/PolicyPageService.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/PolicyPageService.java @@ -374,7 +374,6 @@ public boolean updateAttestationCertExpirationPolicy( /** * Updates the Attestation Certificate generation threshold value under the generate attestation * certificate policy setting using the provided user input. - *

* * @param canGenerateAttestationCertificateOnExpiration boolean value representation of the current * policy option's state diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/ReferenceDigestValuePageService.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/ReferenceDigestValuePageService.java index 23821877e..c04d260de 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/ReferenceDigestValuePageService.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/ReferenceDigestValuePageService.java @@ -142,10 +142,11 @@ public Page findReferenceDigestValuesByColumnSpecificSearc * The results are returned with pagination support. *

* This method combines the logic of two search functionalities: - * - Global search: Searches across all specified columns for a matching term. - * - Column-specific search: Filters based on individual column search criteria, such as text - * or date searches. - *

+ *

    + *
  • Global search: Searches across all specified columns for a matching term.
  • + *
  • Column-specific search: Filters based on individual column search criteria, + * such as text or date searches.
  • + *
* * @param searchableColumnNames list of the searchable column names * @param globalSearchTerm text that was input in the global search textbox diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/ReferenceManifestPageService.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/ReferenceManifestPageService.java index 7d2ad6b85..047214b7f 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/ReferenceManifestPageService.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/ReferenceManifestPageService.java @@ -167,10 +167,11 @@ public Page findRIMSByColumnSpecificSearchTermAndArchiveFlag( * The results are returned with pagination support. *

* This method combines the logic of two search functionalities: - * - Global search: Searches across all specified columns for a matching term. - * - Column-specific search: Filters based on individual column search criteria, such as text - * or date searches. - *

+ *

    + *
  • Global search: Searches across all specified columns for a matching term.
  • + *
  • Column-specific search: Filters based on individual column search criteria, + * such as text or date searches.
  • + *
* * @param searchableColumnNames list of the searchable column names * @param globalSearchTerm text that was input in the global search textbox diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/SupplyChainValidationService.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/SupplyChainValidationService.java index c6ef4c6d6..3d244d660 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/SupplyChainValidationService.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/SupplyChainValidationService.java @@ -105,6 +105,7 @@ public SupplyChainValidationService( * @param device The device to be validated. * @param componentInfos list of components from the device * @return A summary of the validation results. + * @throws IOException if any issues arise from validating the supply chain */ public SupplyChainValidationSummary validateSupplyChain(final EndorsementCredential ec, final List pcs, diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/ValidationService.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/ValidationService.java index 34cac2220..f8595ff4a 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/ValidationService.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/ValidationService.java @@ -39,6 +39,10 @@ import java.util.Set; import java.util.UUID; +/** + * Service class responsible for validating platform credentials, endorsement credentials, firmware + * components and other types of data based on what was set in the {@link PolicySettings}. + */ @Log4j2 public final class ValidationService { @@ -133,6 +137,7 @@ public static SupplyChainValidation evaluatePlatformCredentialStatus( * @param ignoreRevisionAttribute whether to ignore revision attribute * @param ignorePcieVpdAttribute whether to ignore the pcie vpd attribute * @return a supply chain validation + * @throws IOException if any issues arise while evaluating the platform credential attributes */ public static SupplyChainValidation evaluatePCAttributesStatus( final PlatformCredential platformCredential, final DeviceInfoReport deviceInfoReport, diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/ValidationSummaryPageService.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/ValidationSummaryPageService.java index 3aad1cccb..d650610ad 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/ValidationSummaryPageService.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/ValidationSummaryPageService.java @@ -195,9 +195,11 @@ public Page findValidationReportsByGlobalSearchTer * The results are returned with pagination support. *

* This method combines the logic of two search functionalities: - * - Global search: Searches across all specified columns for a matching term. - * - Column-specific search: Filters based on individual column search criteria, such as text or date searches. - *

+ *

    + *
  • Global search: Searches across all specified columns for a matching term.
  • + *
  • Column-specific search: Filters based on individual column search criteria, + * such as text or date searches.
  • + *
* * @param searchableColumnNames list of the searchable column names * @param globalSearchTerm The term that the user enters in the global search box. diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/CertificateAttributeScvValidator.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/CertificateAttributeScvValidator.java index 84c309ad3..fd06e1e2d 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/CertificateAttributeScvValidator.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/CertificateAttributeScvValidator.java @@ -153,6 +153,7 @@ public static AppraisalStatus validatePlatformCredentialAttributesV1p2( * @param ignoreRevisionAttribute policy flag to ignore the revision attribute * @param ignorePcieVpdAttribute policy flag to ignore the pcie vpd attribute * @return either PASS or FAIL + * @throws IOException if any issues arise while validating v2 platform credential attributes */ public static AppraisalStatus validatePlatformCredentialAttributesV2p0( final PlatformCredential platformCredential, diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/CredentialValidator.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/CredentialValidator.java index 7909ee683..b385fc0ab 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/CredentialValidator.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/CredentialValidator.java @@ -176,6 +176,7 @@ public static AppraisalStatus validatePlatformCredential(final PlatformCredentia * @param ignoreRevisionAttribute policy flag to ignore the revision attribute * @param ignorePcieVpdAttribute policy flag to ignore the pcie vpd attribute * @return The result of the validation. + * @throws IOException if any issues arise while validating platform credential attributes */ public static AppraisalStatus validatePlatformCredentialAttributes( final PlatformCredential platformCredential, diff --git a/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/entity/userdefined/info/PortalInfoTest.java b/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/entity/userdefined/info/PortalInfoTest.java deleted file mode 100644 index ba3fa97a2..000000000 --- a/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/entity/userdefined/info/PortalInfoTest.java +++ /dev/null @@ -1,130 +0,0 @@ -package hirs.attestationca.persist.entity.userdefined.info; - -import hirs.utils.enums.PortalScheme; -import org.junit.jupiter.api.Test; - -import java.net.InetAddress; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.fail; - -/** - * Provides tests for PortalInfo. - */ -public class PortalInfoTest { - - /** - * Test the default state of the object, once constructed. - */ - @Test - public void testPortalInfoDefaults() { - PortalInfo info = new PortalInfo(); - assertNull(info.getName()); - assertNull(info.getIpAddress()); - assertEquals(info.getPort(), 0); - } - - /** - * Test that the scheme can be set and retrieved. - */ - @Test - public void testScheme() { - final PortalScheme scheme = PortalScheme.HTTPS; - - PortalInfo info = new PortalInfo(); - info.setSchemeName(scheme); - - assertEquals(info.getName(), scheme.name()); - } - - /** - * Test that setSchemeName does not accept a null input. - */ - @Test - public void testSchemeNull() { - final PortalScheme scheme = null; - - PortalInfo info = new PortalInfo(); - - try { - info.setSchemeName(scheme); - fail("The null scheme should have caused an error."); - } catch (Exception e) { - assertNull(info.getName()); - } - } - - /** - * Test that the ip address can be set and retrieved via an InetAddress. - * - * @throws Exception If there is a problem with InetAddress. - */ - @Test - public void testIpAddressInetAddress() throws Exception { - final InetAddress address = InetAddress.getLocalHost(); - - PortalInfo info = new PortalInfo(); - info.setIpAddress(address); - - assertEquals(info.getIpAddress(), address); - } - - /** - * Test that the ip address can be set and retrieved via a String. - * - * @throws Exception If there is a problem with InetAddress. - */ - @Test - public void testIpAddressString() throws Exception { - final String address = "localhost"; - - PortalInfo info = new PortalInfo(); - info.setIpAddress(address); - - assertEquals(info.getIpAddress().getHostName(), address); - } - - /** - * Test that the scheme can be set and retrieved. - */ - @Test - public void testPort() { - final int port = 127; - - PortalInfo info = new PortalInfo(); - info.setPort(port); - - assertEquals(info.getPort(), port); - } - - /** - * Test that the context name can be set and retrieved. - */ - @Test - public void testContext() { - final String context = "Portal"; - - PortalInfo info = new PortalInfo(); - info.setContextName(context); - - assertEquals(info.getContext(), context); - } - - /** - * Test that setContextName does not accept a null input. - */ - @Test - public void testContextNull() { - final String context = null; - - PortalInfo info = new PortalInfo(); - - try { - info.setContextName(context); - fail("The null context should have caused an error."); - } catch (Exception e) { - assertNull(info.getContext()); - } - } -} diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/HIRSApplication.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/HIRSApplication.java index 3ab0ebcb3..6d1e61adc 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/HIRSApplication.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/HIRSApplication.java @@ -3,6 +3,9 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +/** + * Spring Boot Application starting point for the HIRS application. + */ @SuppressWarnings("checkstyle:hideutilityclassconstructor") @SpringBootApplication public class HIRSApplication { diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/HIRSDbInitializer.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/HIRSDbInitializer.java deleted file mode 100644 index 4bbddb625..000000000 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/HIRSDbInitializer.java +++ /dev/null @@ -1,13 +0,0 @@ -package hirs.attestationca.portal; - -import lombok.extern.log4j.Log4j2; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; - -@Log4j2 -public class HIRSDbInitializer extends SpringBootServletInitializer { - @Override - protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { - return builder.sources(HIRSApplication.class).profiles("Server"); - } -} diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/PersistenceJPAConfig.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/configuration/PersistenceJPAConfig.java similarity index 99% rename from HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/PersistenceJPAConfig.java rename to HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/configuration/PersistenceJPAConfig.java index eb0d3f8fe..6fe8326c5 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/PersistenceJPAConfig.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/configuration/PersistenceJPAConfig.java @@ -1,4 +1,4 @@ -package hirs.attestationca.portal; +package hirs.attestationca.portal.configuration; import jakarta.annotation.PostConstruct; import lombok.extern.log4j.Log4j2; @@ -305,7 +305,7 @@ private void validateCertificateChain(final X509Certificate leafCert, certPathValidator.validate(certPath, pkixParams); } - final Properties additionalProperties() { + private Properties additionalProperties() { final Properties hibernateProperties = new Properties(); hibernateProperties.setProperty("hibernate.hbm2ddl.auto", environment.getProperty("hibernate.hbm2ddl.auto")); diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/configuration/package-info.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/configuration/package-info.java new file mode 100644 index 000000000..49b221c96 --- /dev/null +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/configuration/package-info.java @@ -0,0 +1,5 @@ +/** + * Contains all the configuration files needed to support the + * HIRS Attestation CA Portal functionality. + */ +package hirs.attestationca.portal.configuration; diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/datatables/DataTableView.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/datatables/DataTableView.java deleted file mode 100644 index d21b52310..000000000 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/datatables/DataTableView.java +++ /dev/null @@ -1,46 +0,0 @@ -package hirs.attestationca.portal.datatables; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import jakarta.servlet.ServletOutputStream; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; -import org.springframework.http.MediaType; -import org.springframework.web.servlet.view.AbstractUrlBasedView; - -import java.util.Map; - -/** - * Serializes the DataTableResponse from the view as JSON and writes it to the HTTP response. - */ -public class DataTableView extends AbstractUrlBasedView { - - private static final Gson GSON = new GsonBuilder().create(); - private static final String MODEL_FIELD; - - static { - final String name = DataTableResponse.class.getSimpleName(); - MODEL_FIELD = name.substring(0, 1).toLowerCase() + name.substring(1); - } - - /** - * Serializes the DataTableResponse from the view as JSON and writes it to the HTTP response. - * - * @param model combined output Map (never {@code null}), with dynamic values taking precedence - * over static attributes - * @param request current HTTP request - * @param response current HTTP response - * @throws Exception if rendering failed - */ - @Override - protected void renderMergedOutputModel( - final Map model, - final HttpServletRequest request, - final HttpServletResponse response) throws Exception { - response.setContentType(MediaType.APPLICATION_JSON_VALUE); - DataTableResponse dataTable = (DataTableResponse) model.get(MODEL_FIELD); - ServletOutputStream out = response.getOutputStream(); - String json = GSON.toJson(dataTable); - out.print(json); - } -} diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/datatables/package-info.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/datatables/package-info.java index d7bdd760c..a69f4481d 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/datatables/package-info.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/datatables/package-info.java @@ -1 +1,8 @@ +/** + * Contains Java class representation of DataTable objects used for managing + * and rendering tabular data with features like pagination, sorting, and filtering. + * + *

Classes in this package are used to facilitate communication between the front-end + * (DataTable UI) and the back-end logic, ensuring seamless data representation and manipulation.

+ */ package hirs.attestationca.portal.datatables; diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/listener/AnnotationDrivenEndpointsListener.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/listener/AnnotationDrivenEndpointsListener.java deleted file mode 100644 index 57abcc06e..000000000 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/listener/AnnotationDrivenEndpointsListener.java +++ /dev/null @@ -1,31 +0,0 @@ -package hirs.attestationca.portal.listener; - -import lombok.extern.log4j.Log4j2; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.event.ContextRefreshedEvent; -import org.springframework.context.event.EventListener; -import org.springframework.web.method.HandlerMethod; -import org.springframework.web.servlet.mvc.method.RequestMappingInfo; -import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; - -import java.util.Map; - -@Log4j2 -@Configuration -public class AnnotationDrivenEndpointsListener { - - /** - * Annotation Driven Endpoints event listener. - * - * @param event context refreshed event. - */ - @EventListener - public void handleContextRefresh(final ContextRefreshedEvent event) { - ApplicationContext applicationContext = event.getApplicationContext(); - RequestMappingHandlerMapping requestMappingHandlerMapping = applicationContext - .getBean("requestMappingHandlerMapping", RequestMappingHandlerMapping.class); - Map map = requestMappingHandlerMapping.getHandlerMethods(); - map.forEach((key, value) -> log.debug("{} {}", key, value)); - } -} diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/listener/package-info.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/listener/package-info.java deleted file mode 100644 index 9f6fb6a59..000000000 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/listener/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package hirs.attestationca.portal.listener; diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/package-info.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/package-info.java index f830ccbcc..ad279692a 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/package-info.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/package-info.java @@ -1,5 +1,5 @@ /** - * This package contains all the classes and resources required to support the HIRS Attestation Portal's + * Contains all the classes and resources required to support the HIRS Attestation Portal's * REST controllers. The components in this package are responsible for * routing incoming requests to the appropriate controllers, processing the requests, and * returning the necessary responses. diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/package-info.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/package-info.java index 5b9018e21..e0b0c23ed 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/package-info.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/package-info.java @@ -1 +1,4 @@ +/** + * Contains classes and utilities for managing page-related functionality. + */ package hirs.attestationca.portal.page; diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/params/CertificateDetailsPageParams.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/params/CertificateDetailsPageParams.java index 7f5a94ccd..25748aab9 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/params/CertificateDetailsPageParams.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/params/CertificateDetailsPageParams.java @@ -20,23 +20,6 @@ public class CertificateDetailsPageParams implements PageParams { private String id; private String type; - /** - * Constructor to set ID Certificate Details URL parameters. - * - * @param id the String parameter to set - */ - public CertificateDetailsPageParams(final String id) { - this.id = id; - } - - /** - * Default constructor for Spring. - */ - public CertificateDetailsPageParams() { - id = null; - type = null; - } - /** * Allows PageController to iterate over the url parameters. * diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/params/ReferenceManifestPageParams.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/params/ReferenceManifestPageParams.java deleted file mode 100644 index bd166cc57..000000000 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/params/ReferenceManifestPageParams.java +++ /dev/null @@ -1,44 +0,0 @@ -package hirs.attestationca.portal.page.params; - -import hirs.attestationca.portal.page.PageParams; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -import java.util.LinkedHashMap; - -/** - * URL parameters object for the ReferenceManifest page and controller. - */ -@Getter -@Setter -@NoArgsConstructor -@AllArgsConstructor -public class ReferenceManifestPageParams implements PageParams { - - private String id; - private String type; - - /** - * Constructor to set all Reference Integrity Manifest URL parameters. - * - * @param id the String parameter to set - */ - public ReferenceManifestPageParams(final String id) { - this.id = id; - } - - /** - * Allows PageController to iterate over the url parameters. - * - * @return map containing the object's URL parameters. - */ - @Override - public LinkedHashMap asMap() { - LinkedHashMap map = new LinkedHashMap<>(); - map.put("id", id); - map.put("type", type); - return map; - } -} diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/params/package-info.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/params/package-info.java index 6721ad964..dcf0bd642 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/params/package-info.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/params/package-info.java @@ -1 +1,4 @@ +/** + * Contains the files that hold the parameters used on the Details pages. + */ package hirs.attestationca.portal.page.params; diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/utils/package-info.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/utils/package-info.java index 442ddcc8e..a42b4bd69 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/utils/package-info.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/utils/package-info.java @@ -1 +1,7 @@ +/** + * Contains utility classes and methods for supporting the REST controller and frontend construction. + * This package includes functionality for common operations like data formatting, request handling, + * response building, and any other helper functions needed for seamless integration between + * the backend and frontend. + */ package hirs.attestationca.portal.page.utils; diff --git a/HIRS_Utils/src/main/java/hirs/utils/enums/PortalScheme.java b/HIRS_Utils/src/main/java/hirs/utils/enums/PortalScheme.java deleted file mode 100644 index c42f358d7..000000000 --- a/HIRS_Utils/src/main/java/hirs/utils/enums/PortalScheme.java +++ /dev/null @@ -1,16 +0,0 @@ -package hirs.utils.enums; - -/** - * Schemes used by the HIRS Portal. - */ -public enum PortalScheme { - - /** - * HTTP. - */ - HTTP, - /** - * HTTPS. - */ - HTTPS; -} diff --git a/build.gradle b/build.gradle index e1ce40123..d2f810ef6 100644 --- a/build.gradle +++ b/build.gradle @@ -68,6 +68,12 @@ subprojects { } tasks.withType(Javadoc).configureEach { + if (project.name == 'HIRS_AttestationCA') { + // Remove the generated files from the source set + source = source.filter { file -> + !file.path.contains('build/generated/source/proto/main/java') + } + } options.addStringOption('Xmaxwarns', '0') // Show unlimited warnings todo } From 9ac095c9b4403c6f72251cc086f7d3a0a66f9d44 Mon Sep 17 00:00:00 2001 From: ThatSilentCoder <184309164+ThatSilentCoder@users.noreply.github.com> Date: Tue, 10 Feb 2026 16:48:54 -0500 Subject: [PATCH 06/20] v3.1_issue_1101: Slowly but surely cutting down warnings. Moved files that should be in the same package, deleted unused files (confirmed by running the ACA and checking using the control + f combo), and create new packages for files that should be in their own package. almost done with attestationca module. --- .../config/spotbugs/spotbugs-exclude.xml | 2 +- .../PersistenceConfiguration.java | 2 +- .../persist/configuration/package-info.java | 4 + .../manager/ComponentAttributeRepository.java | 9 + .../manager/ComponentInfoRepository.java | 9 + .../manager/ComponentResultRepository.java | 9 + .../SupplyChainValidationRepository.java | 9 + ...upplyChainValidationSummaryRepository.java | 9 + .../TPM2ProvisionerStateRepository.java | 9 + .../userdefined}/DataTablesColumn.java | 2 +- .../persist/entity/userdefined/Device.java | 3 + .../userdefined}/DownloadFile.java | 2 +- .../userdefined/report/package-info.java | 3 + .../entity/userdefined/rim/package-info.java | 3 + .../util => enums}/CertificateType.java | 2 +- .../persist/enums/HealthStatus.java | 16 -- .../persist/enums/package-info.java | 3 + .../{ => exceptions}/DBManagerException.java | 2 +- .../{ => exceptions}/DBServiceException.java | 2 +- .../SupplyChainValidatorException.java | 2 +- .../persist/exceptions/package-info.java | 3 + .../persist/provision/AbstractProcessor.java | 5 + .../CertificateRequestProcessor.java | 3 + .../provision/IdentityClaimProcessor.java | 5 +- .../helper/CredentialManagementHelper.java | 2 +- .../provision/helper/package-info.java | 3 + .../persist/provision/package-info.java | 3 + .../service/CertificatePageService.java | 6 +- .../persist/service/DevicePageService.java | 2 +- .../ReferenceDigestValuePageService.java | 2 +- .../ReferenceManifestDetailsPageService.java | 24 +-- .../service/ReferenceManifestPageService.java | 4 +- .../service/SupplyChainValidationService.java | 2 +- .../service/ValidationSummaryPageService.java | 2 +- .../persist/service/package-info.java | 3 + .../persist/service/util/package-info.java | 4 + .../persist/tpm/package-info.java | 3 + .../persist/type/InetAddressType.java | 184 ---------------- .../persist/type/X509CertificateType.java | 197 ------------------ .../persist/type/package-info.java | 1 - .../persist/util/CredentialHelper.java | 33 ++- .../persist/util/package-info.java | 3 + .../CertificateAttributeScvValidator.java | 3 + .../validation/CredentialValidator.java | 4 + .../validation/FirmwareScvValidator.java | 8 +- .../SupplyChainCredentialValidator.java | 5 + .../persist/validation/package-info.java | 3 + .../AttestationCertificateAuthorityTest.java | 150 +++++++------ .../SupplyChainCredentialValidatorTest.java | 1 + .../portal/page/PageMessages.java | 4 +- .../controllers/DevicePageController.java | 2 +- .../EndorsementCredentialPageController.java | 6 +- .../IDevIdCertificatePageController.java | 6 +- .../IssuedCertificatePageController.java | 6 +- .../PlatformCredentialPageController.java | 6 +- .../ReferenceManifestPageController.java | 4 +- .../RimDatabasePageController.java | 4 +- .../TrustChainCertificatePageController.java | 6 +- .../ValidationReportsPageController.java | 2 +- .../page/utils/ControllerPagesUtils.java | 2 +- .../ReferenceManifestPageControllerTest.java | 1 - ...rustChainManagementPageControllerTest.java | 3 +- 62 files changed, 277 insertions(+), 545 deletions(-) rename HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/{ => configuration}/PersistenceConfiguration.java (95%) create mode 100644 HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/configuration/package-info.java rename HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/{service/util => entity/userdefined}/DataTablesColumn.java (95%) rename HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/{util => entity/userdefined}/DownloadFile.java (88%) rename HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/{service/util => enums}/CertificateType.java (97%) rename HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/{ => exceptions}/DBManagerException.java (95%) rename HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/{ => exceptions}/DBServiceException.java (95%) rename HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/{validation => exceptions}/SupplyChainValidatorException.java (96%) delete mode 100644 HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/type/InetAddressType.java delete mode 100644 HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/type/X509CertificateType.java delete mode 100644 HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/type/package-info.java diff --git a/HIRS_AttestationCA/config/spotbugs/spotbugs-exclude.xml b/HIRS_AttestationCA/config/spotbugs/spotbugs-exclude.xml index acdcaa9b1..b6ef1fae0 100644 --- a/HIRS_AttestationCA/config/spotbugs/spotbugs-exclude.xml +++ b/HIRS_AttestationCA/config/spotbugs/spotbugs-exclude.xml @@ -16,7 +16,7 @@ - + diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/PersistenceConfiguration.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/configuration/PersistenceConfiguration.java similarity index 95% rename from HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/PersistenceConfiguration.java rename to HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/configuration/PersistenceConfiguration.java index e8ef0e61f..d762381bc 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/PersistenceConfiguration.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/configuration/PersistenceConfiguration.java @@ -1,4 +1,4 @@ -package hirs.attestationca.persist; +package hirs.attestationca.persist.configuration; import hirs.structs.converters.SimpleStructConverter; import hirs.structs.converters.StructConverter; diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/configuration/package-info.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/configuration/package-info.java new file mode 100644 index 000000000..243c55c50 --- /dev/null +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/configuration/package-info.java @@ -0,0 +1,4 @@ +/** + * Contains all the configuration files used in this module. + */ +package hirs.attestationca.persist.configuration; diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ComponentAttributeRepository.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ComponentAttributeRepository.java index 87e4c9b46..fc4b520f7 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ComponentAttributeRepository.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ComponentAttributeRepository.java @@ -6,6 +6,15 @@ import java.util.List; import java.util.UUID; +/** + * Repository interface for managing {@link ComponentAttributeResult} entities in the database. + * + *

+ * The {@link ComponentAttributeRepository} interface extends {@link JpaRepository} to provide basic CRUD operations, + * including save, find, delete, and query methods. Custom query methods can be defined + * using Spring Data JPA's query method naming conventions or with the Query annotation. + *

+ */ public interface ComponentAttributeRepository extends JpaRepository { /** * Query to look up Attribute Results based on the PlatformCredential's diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ComponentInfoRepository.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ComponentInfoRepository.java index 919c0494c..6e9ab5a63 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ComponentInfoRepository.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ComponentInfoRepository.java @@ -6,6 +6,15 @@ import java.util.List; import java.util.UUID; +/** + * Repository interface for managing {@link ComponentInfo} entities in the database. + * + *

+ * The {@link ComponentInfoRepository} interface extends {@link JpaRepository} to provide basic CRUD operations, + * including save, find, delete, and query methods. Custom query methods can be defined + * using Spring Data JPA's query method naming conventions or with the Query annotation. + *

+ */ public interface ComponentInfoRepository extends JpaRepository { /** * Query that retrieves device components by device name. diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ComponentResultRepository.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ComponentResultRepository.java index 6daa861de..be5c9958c 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ComponentResultRepository.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ComponentResultRepository.java @@ -7,6 +7,15 @@ import java.util.List; import java.util.UUID; +/** + * Repository interface for managing {@link ComponentResult} entities in the database. + * + *

+ * The {@link ComponentResultRepository} interface extends {@link JpaRepository} to provide basic CRUD operations, + * including save, find, delete, and query methods. Custom query methods can be defined + * using Spring Data JPA's query method naming conventions or with the Query annotation. + *

+ */ @Repository public interface ComponentResultRepository extends JpaRepository { diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/SupplyChainValidationRepository.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/SupplyChainValidationRepository.java index b7571b423..906fc50f3 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/SupplyChainValidationRepository.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/SupplyChainValidationRepository.java @@ -8,6 +8,15 @@ import java.util.List; import java.util.UUID; +/** + * Repository interface for managing {@link SupplyChainValidation} entities in the database. + * + *

+ * The {@link SupplyChainValidationRepository} interface extends {@link JpaRepository} to provide basic CRUD + * operations, including save, find, delete, and query methods. Custom query methods can be defined + * using Spring Data JPA's query method naming conventions or with the Query annotation. + *

+ */ @Repository public interface SupplyChainValidationRepository extends JpaRepository { /** diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/SupplyChainValidationSummaryRepository.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/SupplyChainValidationSummaryRepository.java index bf4964b3e..c02d7344c 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/SupplyChainValidationSummaryRepository.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/SupplyChainValidationSummaryRepository.java @@ -10,6 +10,15 @@ import java.util.List; import java.util.UUID; +/** + * Repository interface for managing {@link SupplyChainValidationSummary} entities in the database. + * + *

+ * The {@link SupplyChainValidationSummaryRepository} interface extends {@link JpaRepository} to provide + * basic CRUD operations, including save, find, delete, and query methods. Custom query methods can be defined + * using Spring Data JPA's query method naming conventions or with the Query annotation. + *

+ */ @Repository public interface SupplyChainValidationSummaryRepository extends JpaRepository { diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/TPM2ProvisionerStateRepository.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/TPM2ProvisionerStateRepository.java index ea6c7e91d..48f58a263 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/TPM2ProvisionerStateRepository.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/TPM2ProvisionerStateRepository.java @@ -4,6 +4,15 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; +/** + * Repository interface for managing {@link TPM2ProvisionerState} entities in the database. + * + *

+ * The {@link TPM2ProvisionerStateRepository} interface extends {@link JpaRepository} to provide basic CRUD operations, + * including save, find, delete, and query methods. Custom query methods can be defined + * using Spring Data JPA's query method naming conventions or with the Query annotation. + *

+ */ @Repository public interface TPM2ProvisionerStateRepository extends JpaRepository { diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/util/DataTablesColumn.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/DataTablesColumn.java similarity index 95% rename from HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/util/DataTablesColumn.java rename to HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/DataTablesColumn.java index cb7d43296..b3c0b47ed 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/util/DataTablesColumn.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/DataTablesColumn.java @@ -1,4 +1,4 @@ -package hirs.attestationca.persist.service.util; +package hirs.attestationca.persist.entity.userdefined; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/Device.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/Device.java index 66a6ed8f2..cd9401e24 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/Device.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/Device.java @@ -22,6 +22,9 @@ import java.sql.Timestamp; import java.time.LocalDateTime; +/** + * User-defined, Java representation of a physical Device. + */ @Entity @Table(name = "Device") @Setter diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/util/DownloadFile.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/DownloadFile.java similarity index 88% rename from HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/util/DownloadFile.java rename to HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/DownloadFile.java index 0a7df9903..27735a804 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/util/DownloadFile.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/DownloadFile.java @@ -1,4 +1,4 @@ -package hirs.attestationca.persist.util; +package hirs.attestationca.persist.entity.userdefined; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/report/package-info.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/report/package-info.java index fca94e7e8..a20cd4c9a 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/report/package-info.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/report/package-info.java @@ -1 +1,4 @@ +/** + * Contains all user defined reports. + */ package hirs.attestationca.persist.entity.userdefined.report; diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/rim/package-info.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/rim/package-info.java index aa6343835..457a759b8 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/rim/package-info.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/rim/package-info.java @@ -1 +1,4 @@ +/** + * Contains user-defined Reference Integrity Manifest (RIM) files and supporting components. + */ package hirs.attestationca.persist.entity.userdefined.rim; diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/util/CertificateType.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/enums/CertificateType.java similarity index 97% rename from HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/util/CertificateType.java rename to HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/enums/CertificateType.java index ced9fa12e..721402a9b 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/util/CertificateType.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/enums/CertificateType.java @@ -1,4 +1,4 @@ -package hirs.attestationca.persist.service.util; +package hirs.attestationca.persist.enums; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/enums/HealthStatus.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/enums/HealthStatus.java index 4ff0c4571..66c9554d8 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/enums/HealthStatus.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/enums/HealthStatus.java @@ -4,9 +4,6 @@ import lombok.Getter; import lombok.ToString; -import java.util.Arrays; -import java.util.stream.Collectors; - /** * HealthStatus is used to represent the health of a device. */ @@ -30,17 +27,4 @@ public enum HealthStatus { UNKNOWN("unknown"); private final String healthStatus; - - /** - * Determines if the provided health status is a valid health status. - * - * @param healthStatus string representation of the healh status - * @return true if the health status is valid, otherwise false - */ - public static boolean isValidStatus(final String healthStatus) { - return Arrays.stream(HealthStatus.values()) - .map(HealthStatus::name) - .collect(Collectors.toSet()) - .contains(healthStatus); - } } diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/enums/package-info.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/enums/package-info.java index e1b0239f2..03821eaad 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/enums/package-info.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/enums/package-info.java @@ -1 +1,4 @@ +/** + * Contains various enumeration types (enums) used across this module. + */ package hirs.attestationca.persist.enums; diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/DBManagerException.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/exceptions/DBManagerException.java similarity index 95% rename from HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/DBManagerException.java rename to HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/exceptions/DBManagerException.java index aec4ddc93..fb9ace264 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/DBManagerException.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/exceptions/DBManagerException.java @@ -1,4 +1,4 @@ -package hirs.attestationca.persist; +package hirs.attestationca.persist.exceptions; /** * This class represents an Exception generated by a diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/DBServiceException.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/exceptions/DBServiceException.java similarity index 95% rename from HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/DBServiceException.java rename to HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/exceptions/DBServiceException.java index 35bddbbbd..bac65cb30 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/DBServiceException.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/exceptions/DBServiceException.java @@ -1,4 +1,4 @@ -package hirs.attestationca.persist; +package hirs.attestationca.persist.exceptions; /** * This class represents an Exception generated by a diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/SupplyChainValidatorException.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/exceptions/SupplyChainValidatorException.java similarity index 96% rename from HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/SupplyChainValidatorException.java rename to HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/exceptions/SupplyChainValidatorException.java index 456eb0439..6609d42a1 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/SupplyChainValidatorException.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/exceptions/SupplyChainValidatorException.java @@ -1,4 +1,4 @@ -package hirs.attestationca.persist.validation; +package hirs.attestationca.persist.exceptions; /** * This class represents exceptions thrown by the SupplyChainValidator class. diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/exceptions/package-info.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/exceptions/package-info.java index 4bc1b6248..1bd34b0a4 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/exceptions/package-info.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/exceptions/package-info.java @@ -1 +1,4 @@ +/** + * Contains user-defined exceptions. + */ package hirs.attestationca.persist.exceptions; diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/provision/AbstractProcessor.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/provision/AbstractProcessor.java index 7d981da83..849c213d6 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/provision/AbstractProcessor.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/provision/AbstractProcessor.java @@ -42,6 +42,11 @@ import java.util.LinkedList; import java.util.List; +/** + * Contains the default properties required for a processor that communicates with the provisioner. + * This class serves as a base for processors, providing essential configuration and functionality + * needed to interact with the provisioning system. + */ @Getter @Log4j2 @NoArgsConstructor diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/provision/CertificateRequestProcessor.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/provision/CertificateRequestProcessor.java index cc9e0b197..50a21589c 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/provision/CertificateRequestProcessor.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/provision/CertificateRequestProcessor.java @@ -28,6 +28,9 @@ import java.security.interfaces.RSAPublicKey; import java.util.List; +/** + * Processor class that is responsible for processing certificate requests from and to the provisioner. + */ @Log4j2 public class CertificateRequestProcessor extends AbstractProcessor { diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/provision/IdentityClaimProcessor.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/provision/IdentityClaimProcessor.java index 4866ff654..afbc4184f 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/provision/IdentityClaimProcessor.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/provision/IdentityClaimProcessor.java @@ -69,6 +69,9 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +/** + * Processor class that is responsible for processing identity claim requests from and to the provisioner. + */ @Log4j2 public class IdentityClaimProcessor extends AbstractProcessor { /** @@ -165,7 +168,7 @@ public byte[] processIdentityClaimTpm2(final byte[] identityClaim) { log.error(ex.getMessage()); } - ByteString blobStr = ByteString.copyFrom(new byte[]{}); + ByteString blobStr = ByteString.copyFrom(new byte[] {}); if (validationResult == AppraisalStatus.Status.PASS) { RSAPublicKey akPub = ProvisionUtils.parsePublicKey(claim.getAkPublicArea().toByteArray()); diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/provision/helper/CredentialManagementHelper.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/provision/helper/CredentialManagementHelper.java index 86a8ea5f2..4100006a9 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/provision/helper/CredentialManagementHelper.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/provision/helper/CredentialManagementHelper.java @@ -1,9 +1,9 @@ package hirs.attestationca.persist.provision.helper; -import hirs.attestationca.persist.DBManagerException; import hirs.attestationca.persist.entity.manager.CertificateRepository; import hirs.attestationca.persist.entity.userdefined.certificate.EndorsementCredential; import hirs.attestationca.persist.entity.userdefined.certificate.PlatformCredential; +import hirs.attestationca.persist.exceptions.DBManagerException; import lombok.extern.log4j.Log4j2; import java.util.List; diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/provision/helper/package-info.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/provision/helper/package-info.java index 52e582fe1..86d03f715 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/provision/helper/package-info.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/provision/helper/package-info.java @@ -1 +1,4 @@ +/** + * Contains all the helper function files that are used to support the provisioning process. + */ package hirs.attestationca.persist.provision.helper; diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/provision/package-info.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/provision/package-info.java index d995e10f1..a40871f5b 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/provision/package-info.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/provision/package-info.java @@ -1 +1,4 @@ +/** + * Contains all the files and components involved in the provisioning process. + */ package hirs.attestationca.persist.provision; diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/CertificatePageService.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/CertificatePageService.java index 951b19d3d..471f56125 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/CertificatePageService.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/CertificatePageService.java @@ -3,17 +3,17 @@ import hirs.attestationca.persist.entity.manager.CertificateRepository; import hirs.attestationca.persist.entity.manager.ComponentResultRepository; import hirs.attestationca.persist.entity.userdefined.Certificate; +import hirs.attestationca.persist.entity.userdefined.DataTablesColumn; +import hirs.attestationca.persist.entity.userdefined.DownloadFile; import hirs.attestationca.persist.entity.userdefined.certificate.CertificateAuthorityCredential; import hirs.attestationca.persist.entity.userdefined.certificate.ComponentResult; import hirs.attestationca.persist.entity.userdefined.certificate.PlatformCredential; import hirs.attestationca.persist.entity.userdefined.certificate.attributes.ComponentIdentifier; import hirs.attestationca.persist.entity.userdefined.certificate.attributes.V2.ComponentIdentifierV2; -import hirs.attestationca.persist.service.util.CertificateType; -import hirs.attestationca.persist.service.util.DataTablesColumn; +import hirs.attestationca.persist.enums.CertificateType; import hirs.attestationca.persist.service.util.PageServiceUtils; import hirs.attestationca.persist.service.util.PredicateFactory; import hirs.attestationca.persist.util.CredentialHelper; -import hirs.attestationca.persist.util.DownloadFile; import jakarta.persistence.EntityManager; import jakarta.persistence.EntityNotFoundException; import jakarta.persistence.TypedQuery; diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/DevicePageService.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/DevicePageService.java index 6b1841576..75bf678ad 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/DevicePageService.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/DevicePageService.java @@ -5,11 +5,11 @@ import hirs.attestationca.persist.entity.manager.EndorsementCredentialRepository; import hirs.attestationca.persist.entity.manager.IssuedCertificateRepository; import hirs.attestationca.persist.entity.manager.PlatformCertificateRepository; +import hirs.attestationca.persist.entity.userdefined.DataTablesColumn; import hirs.attestationca.persist.entity.userdefined.Device; import hirs.attestationca.persist.entity.userdefined.certificate.EndorsementCredential; import hirs.attestationca.persist.entity.userdefined.certificate.IssuedAttestationCertificate; import hirs.attestationca.persist.entity.userdefined.certificate.PlatformCredential; -import hirs.attestationca.persist.service.util.DataTablesColumn; import hirs.attestationca.persist.service.util.PredicateFactory; import jakarta.persistence.EntityManager; import jakarta.persistence.TypedQuery; diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/ReferenceDigestValuePageService.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/ReferenceDigestValuePageService.java index c04d260de..a7689157a 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/ReferenceDigestValuePageService.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/ReferenceDigestValuePageService.java @@ -2,9 +2,9 @@ import hirs.attestationca.persist.entity.manager.ReferenceDigestValueRepository; import hirs.attestationca.persist.entity.manager.ReferenceManifestRepository; +import hirs.attestationca.persist.entity.userdefined.DataTablesColumn; import hirs.attestationca.persist.entity.userdefined.ReferenceManifest; import hirs.attestationca.persist.entity.userdefined.rim.ReferenceDigestValue; -import hirs.attestationca.persist.service.util.DataTablesColumn; import hirs.attestationca.persist.service.util.PageServiceUtils; import hirs.attestationca.persist.service.util.PredicateFactory; import jakarta.persistence.EntityManager; diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/ReferenceManifestDetailsPageService.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/ReferenceManifestDetailsPageService.java index a12f8da8a..687fdec18 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/ReferenceManifestDetailsPageService.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/ReferenceManifestDetailsPageService.java @@ -1,6 +1,5 @@ package hirs.attestationca.persist.service; -import hirs.attestationca.persist.DBServiceException; import hirs.attestationca.persist.entity.manager.CACredentialRepository; import hirs.attestationca.persist.entity.manager.CertificateRepository; import hirs.attestationca.persist.entity.manager.ReferenceDigestValueRepository; @@ -12,8 +11,10 @@ import hirs.attestationca.persist.entity.userdefined.rim.EventLogMeasurements; import hirs.attestationca.persist.entity.userdefined.rim.ReferenceDigestValue; import hirs.attestationca.persist.entity.userdefined.rim.SupportReferenceManifest; +import hirs.attestationca.persist.exceptions.DBServiceException; +import hirs.attestationca.persist.exceptions.SupplyChainValidatorException; +import hirs.attestationca.persist.util.CredentialHelper; import hirs.attestationca.persist.validation.SupplyChainCredentialValidator; -import hirs.attestationca.persist.validation.SupplyChainValidatorException; import hirs.utils.SwidResource; import hirs.utils.rim.ReferenceManifestValidator; import hirs.utils.tpm.eventlog.TCGEventLog; @@ -36,7 +37,6 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.UUID; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -306,7 +306,7 @@ private HashMap getBaseRimInfo(final BaseReferenceManifest baseR KeyStore keystore = ValidationService.getCaChain(caCert, caCertificateRepository); try { List truststore = - convertCACsToX509Certificates(ValidationService.getCaChainRec(caCert, + CredentialHelper.convertCACsToX509Certificates(ValidationService.getCaChainRec(caCert, Collections.emptySet(), caCertificateRepository)); referenceManifestValidator.setTrustStore(truststore); @@ -554,20 +554,4 @@ private boolean eventIsType(final long eventType) { || eventType == EvConstants.EV_EFI_SPDM_DEVICE_AUTHORITY || eventType == EvConstants.EV_EFI_SPDM_DEVICE_POLICY; } - - /** - * This method converts a Set of CertificateAuthorityCredentials to a List of X509Certificates. - * - * @param set of CACs to convert - * @return list of X509Certificates - */ - private List convertCACsToX509Certificates(final Set set) - throws IOException { - List certs = new ArrayList<>(set.size()); - for (CertificateAuthorityCredential cac : set) { - certs.add(cac.getX509Certificate()); - } - return certs; - } - } diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/ReferenceManifestPageService.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/ReferenceManifestPageService.java index 047214b7f..630a9e09e 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/ReferenceManifestPageService.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/ReferenceManifestPageService.java @@ -2,13 +2,13 @@ import hirs.attestationca.persist.entity.manager.ReferenceDigestValueRepository; import hirs.attestationca.persist.entity.manager.ReferenceManifestRepository; +import hirs.attestationca.persist.entity.userdefined.DataTablesColumn; +import hirs.attestationca.persist.entity.userdefined.DownloadFile; import hirs.attestationca.persist.entity.userdefined.ReferenceManifest; import hirs.attestationca.persist.entity.userdefined.rim.BaseReferenceManifest; import hirs.attestationca.persist.entity.userdefined.rim.ReferenceDigestValue; import hirs.attestationca.persist.entity.userdefined.rim.SupportReferenceManifest; -import hirs.attestationca.persist.service.util.DataTablesColumn; import hirs.attestationca.persist.service.util.PredicateFactory; -import hirs.attestationca.persist.util.DownloadFile; import hirs.utils.tpm.eventlog.TCGEventLog; import hirs.utils.tpm.eventlog.TpmPcrEvent; import jakarta.persistence.EntityManager; diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/SupplyChainValidationService.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/SupplyChainValidationService.java index 3d244d660..39b12fcb0 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/SupplyChainValidationService.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/SupplyChainValidationService.java @@ -1,6 +1,5 @@ package hirs.attestationca.persist.service; -import hirs.attestationca.persist.DBManagerException; import hirs.attestationca.persist.entity.ArchivableEntity; import hirs.attestationca.persist.entity.manager.CACredentialRepository; import hirs.attestationca.persist.entity.manager.CertificateRepository; @@ -25,6 +24,7 @@ import hirs.attestationca.persist.entity.userdefined.rim.EventLogMeasurements; import hirs.attestationca.persist.entity.userdefined.rim.SupportReferenceManifest; import hirs.attestationca.persist.enums.AppraisalStatus; +import hirs.attestationca.persist.exceptions.DBManagerException; import hirs.attestationca.persist.validation.PcrValidator; import hirs.attestationca.persist.validation.SupplyChainCredentialValidator; import lombok.extern.log4j.Log4j2; diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/ValidationSummaryPageService.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/ValidationSummaryPageService.java index d650610ad..2677d33f1 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/ValidationSummaryPageService.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/ValidationSummaryPageService.java @@ -5,12 +5,12 @@ import hirs.attestationca.persist.entity.manager.DeviceRepository; import hirs.attestationca.persist.entity.manager.PlatformCertificateRepository; import hirs.attestationca.persist.entity.manager.SupplyChainValidationSummaryRepository; +import hirs.attestationca.persist.entity.userdefined.DataTablesColumn; import hirs.attestationca.persist.entity.userdefined.Device; import hirs.attestationca.persist.entity.userdefined.SupplyChainValidationSummary; import hirs.attestationca.persist.entity.userdefined.certificate.PlatformCredential; import hirs.attestationca.persist.entity.userdefined.certificate.attributes.ComponentIdentifier; import hirs.attestationca.persist.entity.userdefined.certificate.attributes.V2.ComponentIdentifierV2; -import hirs.attestationca.persist.service.util.DataTablesColumn; import hirs.attestationca.persist.service.util.PageServiceUtils; import hirs.attestationca.persist.service.util.PredicateFactory; import jakarta.persistence.EntityManager; diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/package-info.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/package-info.java index 0210df6cb..452f3da67 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/package-info.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/package-info.java @@ -1 +1,4 @@ +/** + * Contains all the HIRS service classes and supporting files. + */ package hirs.attestationca.persist.service; diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/util/package-info.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/util/package-info.java index 6c8ce4b49..3c0f7eae7 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/util/package-info.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/util/package-info.java @@ -1 +1,5 @@ +/** + * Contains utility classes and supporting components that assist service classes + * in performing various tasks. + */ package hirs.attestationca.persist.service.util; diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/tpm/package-info.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/tpm/package-info.java index 798996299..46f620c6a 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/tpm/package-info.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/tpm/package-info.java @@ -1 +1,4 @@ +/** + * Contains the plain java objects (POJOs) that are used for PCR validation. + */ package hirs.attestationca.persist.tpm; diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/type/InetAddressType.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/type/InetAddressType.java deleted file mode 100644 index a7ae064cf..000000000 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/type/InetAddressType.java +++ /dev/null @@ -1,184 +0,0 @@ -package hirs.attestationca.persist.type; - -import lombok.AccessLevel; -import lombok.NoArgsConstructor; -import org.hibernate.HibernateException; -import org.hibernate.engine.spi.SharedSessionContractImplementor; -import org.hibernate.usertype.UserType; - -import java.io.Serializable; -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Types; -import java.util.Objects; - -/** - * This is a class for persisting InetAddress objects via - * Hibernate. This class provides the mapping from InetAddress to - * Hibernate commands to JDBC. - */ -@NoArgsConstructor(access = AccessLevel.PUBLIC) -public final class InetAddressType implements UserType { - - /** - * Returns varchar type. - * - * @return varchar type - */ - @Override - public int getSqlType() { - return Types.VARCHAR; - } - - /** - * Returns the InetAddress class. - * - * @return InetAddress class - */ - @Override - public Class returnedClass() { - return InetAddress.class; - } - - /** - * Compares x and y using {@link Objects#equals(Object, Object)}. - * - * @param x x - * @param y y - * @return value from equals call - */ - @Override - public boolean equals(final Object x, final Object y) { - return Objects.equals(x, y); - } - - /** - * Returns the hash code of x, which will be the same as from - * InetAddress. - * - * @param x x - * @return hash value of x - */ - @Override - public int hashCode(final Object x) { - assert x != null; - return x.hashCode(); - } - - /** - * Converts the IP address that is stored as a String and - * converts it to an InetAddress. - * - * @param rs result set - * @param index column names - * @param session session - * @param owner owner - * @return InetAddress of String - * @throws HibernateException if unable to convert the String to an InetAddress - * @throws SQLException if unable to retrieve the String from the result set - */ - @Override - public Object nullSafeGet(final ResultSet rs, final int index, - final SharedSessionContractImplementor session, final Object owner) - throws HibernateException, SQLException { - - final String ip = rs.getString(index); - if (ip == null) { - return null; - } - try { - return InetAddress.getByName(ip); - } catch (UnknownHostException e) { - final String msg = String.format("unable to convert ip address: %s", ip); - throw new HibernateException(msg, e); - } - } - - /** - * Converts the InetAddress value to a - * String and stores it in the database. - * - * @param st prepared statement - * @param value InetAddress - * @param index index - * @param session session - * @throws SQLException if unable to set the value in the result set - */ - @Override - public void nullSafeSet(final PreparedStatement st, final Object value, - final int index, final SharedSessionContractImplementor session) - throws SQLException { - if (value == null) { - st.setString(index, null); - } else { - final InetAddress address = (InetAddress) value; - final String ip = address.getHostAddress(); - st.setString(index, ip); - } - } - - /** - * Returns value since InetAddress is immutable. - * - * @param value value - * @return value - * @throws HibernateException will never be thrown - */ - @Override - public Object deepCopy(final Object value) throws HibernateException { - return value; - } - - /** - * Returns false because InetAddress is immutable. - * - * @return false - */ - @Override - public boolean isMutable() { - return false; - } - - /** - * Returns value because InetAddress is - * immutable. - * - * @param value value - * @return value - */ - @Override - public Serializable disassemble(final Object value) { - return (Serializable) value; - } - - /** - * Returns cached because InetAddress is - * immutable. - * - * @param cached cached - * @param owner owner - * @return cached - */ - @Override - public Object assemble(final Serializable cached, final Object owner) { - return cached; - } - - /** - * Returns the original because InetAddress is - * immutable. - * - * @param original original - * @param target target - * @param owner owner - * @return original - */ - @Override - public Object replace(final Object original, final Object target, - final Object owner) { - return original; - } -} diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/type/X509CertificateType.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/type/X509CertificateType.java deleted file mode 100644 index 9dfc6eee5..000000000 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/type/X509CertificateType.java +++ /dev/null @@ -1,197 +0,0 @@ -package hirs.attestationca.persist.type; - -import lombok.AccessLevel; -import lombok.NoArgsConstructor; -import org.hibernate.HibernateException; -import org.hibernate.engine.spi.SharedSessionContractImplementor; -import org.hibernate.usertype.UserType; - -import javax.sql.rowset.serial.SerialBlob; -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.io.Serializable; -import java.security.cert.Certificate; -import java.security.cert.CertificateException; -import java.security.cert.CertificateFactory; -import java.security.cert.X509Certificate; -import java.sql.Blob; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Types; -import java.util.Objects; - -/** - * This is a class for persisting X509Certificate objects via - * Hibernate. This class provides the mapping from X509Certificate - * to Hibernate commands to JDBC. - */ -@NoArgsConstructor(access = AccessLevel.PUBLIC) -public final class X509CertificateType implements UserType { - - @Override - public int getSqlType() { - return Types.BLOB; - } - - /** - * Returns the X509Certificate class. - * - * @return X509Certificate class - */ - @Override - public Class returnedClass() { - return X509Certificate.class; - } - - /** - * Compares x and y using {@link Objects#equals(Object, Object)}. - * - * @param x x - * @param y y - * @return value from equals call - */ - @Override - public boolean equals(final Object x, final Object y) { - return Objects.equals(x, y); - } - - /** - * Returns the hash code of x, which will be the same as from - * X509Certificate. - * - * @param x x - * @return hash value of x - */ - @Override - public int hashCode(final Object x) { - assert x != null; - return x.hashCode(); - } - - /** - * Converts the X509Certificate that is stored as a String and - * converts it to an X509Certificate. - * - * @param rs result set - * @param names column names - * @param session session - * @param owner owner - * @return X509Certificate of String - * @throws HibernateException if unable to convert the String to an X509Certificate - * @throws SQLException if unable to retrieve the String from the result set - */ - @Override - public Object nullSafeGet(final ResultSet rs, final int names, - final SharedSessionContractImplementor session, final Object owner) - throws HibernateException, SQLException { - final Blob cert = rs.getBlob(names); - if (cert == null) { - return null; - } - try { - InputStream inputStream = new ByteArrayInputStream( - cert.getBytes(1, (int) cert.length())); - CertificateFactory cf = CertificateFactory.getInstance("X.509"); - return cf.generateCertificate(inputStream); - } catch (CertificateException e) { - final String msg = String.format( - "unable to convert certificate: %s", cert); - throw new HibernateException(msg, e); - } - } - - /** - * Converts the X509Certificate value to a - * String and stores it in the database. - * - * @param st prepared statement - * @param value X509Certificate - * @param index index - * @param session session - * @throws SQLException if unable to set the value in the result set - */ - @Override - public void nullSafeSet(final PreparedStatement st, final Object value, - final int index, final SharedSessionContractImplementor session) - throws SQLException { - if (value == null) { - st.setString(index, null); - } else { - try { - Blob blob = - new SerialBlob(((Certificate) value).getEncoded()); - st.setBlob(index, blob); - } catch (Exception e) { - final String msg = - String.format("unable to convert certificate: %s", - value); - throw new HibernateException(msg, e); - } - } - - } - - /** - * Returns value since X509Certificate is - * immutable. - * - * @param value value - * @return value - * @throws HibernateException will never be thrown - */ - @Override - public Object deepCopy(final Object value) throws HibernateException { - return value; - } - - /** - * Returns false because X509Certificate is immutable. - * - * @return false - */ - @Override - public boolean isMutable() { - return false; - } - - /** - * Returns value because X509Certificate is - * immutable. - * - * @param value value - * @return value - */ - @Override - public Serializable disassemble(final Object value) { - return (Serializable) value; - } - - /** - * Returns cached because X509Certificate is - * immutable. - * - * @param cached cached - * @param owner owner - * @return cached - */ - @Override - public Object assemble(final Serializable cached, final Object owner) { - return cached; - } - - /** - * Returns the original because X509Certificate is - * immutable. - * - * @param original original - * @param target target - * @param owner owner - * @return original - */ - @Override - public Object replace(final Object original, final Object target, - final Object owner) { - return original; - } -} diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/type/package-info.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/type/package-info.java deleted file mode 100644 index 8b7ae2138..000000000 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/type/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package hirs.attestationca.persist.type; diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/util/CredentialHelper.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/util/CredentialHelper.java index 5e2025641..942e855db 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/util/CredentialHelper.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/util/CredentialHelper.java @@ -1,15 +1,23 @@ package hirs.attestationca.persist.util; +import hirs.attestationca.persist.entity.userdefined.certificate.CertificateAuthorityCredential; import hirs.attestationca.persist.entity.userdefined.certificate.CertificateVariables; import lombok.extern.log4j.Log4j2; import org.bouncycastle.util.encoders.Base64; +import java.io.IOException; import java.nio.ByteBuffer; +import java.security.cert.X509Certificate; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.ListIterator; +import java.util.Set; +/** + * Helper class that provides various utility methods for handling credential-related tasks. + */ @Log4j2 public final class CredentialHelper { @@ -19,11 +27,31 @@ public final class CredentialHelper { private CredentialHelper() { } + /** + * Converts a set of {@link CertificateAuthorityCredential} certificates to a list of + * {@link X509Certificate} Certificates. + * + * @param certificateAuthorityCredentials Set of {@link CertificateAuthorityCredential} certificates + * to convert + * @return list of {@link X509Certificate} certificates + * @throws IOException if any issues arise attempting to convert the list of certificate + * authority credentials to X509 certificates + */ + public static List convertCACsToX509Certificates( + final Set certificateAuthorityCredentials) + throws IOException { + List certs = new ArrayList<>(certificateAuthorityCredentials.size()); + for (CertificateAuthorityCredential cac : certificateAuthorityCredentials) { + certs.add(cac.getX509Certificate()); + } + return certs; + } + /** * Small method to check if the certificate is a PEM. * * @param possiblePEM header information - * @return true if it is. + * @return true if the provided string is a PEM. */ public static boolean isPEM(final String possiblePEM) { return possiblePEM.contains(CertificateVariables.PEM_HEADER) @@ -34,7 +62,7 @@ public static boolean isPEM(final String possiblePEM) { * Small method to check if there are multi pem files. * * @param possiblePEM header information - * @return true if it is. + * @return true if the provided string is a Multi-PEM. */ public static boolean isMultiPEM(final String possiblePEM) { boolean multiPem = false; @@ -76,7 +104,6 @@ public static byte[] stripPemHeaderFooter(final String pemFile) { * @param certificateBytes raw byte form * @return a cleaned up byte form */ - public static byte[] trimCertificate(final byte[] certificateBytes) { int certificateStart = 0; int certificateLength = 0; diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/util/package-info.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/util/package-info.java index 736028a84..a589900c9 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/util/package-info.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/util/package-info.java @@ -1 +1,4 @@ +/** + * Contains general util classes used for all packages within the module. + */ package hirs.attestationca.persist.util; diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/CertificateAttributeScvValidator.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/CertificateAttributeScvValidator.java index fd06e1e2d..39fbb1991 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/CertificateAttributeScvValidator.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/CertificateAttributeScvValidator.java @@ -35,6 +35,9 @@ import static hirs.attestationca.persist.enums.AppraisalStatus.Status.FAIL; import static hirs.attestationca.persist.enums.AppraisalStatus.Status.PASS; +/** + * Validator class responsible for validating certificate attributes. + */ @Log4j2 public class CertificateAttributeScvValidator extends SupplyChainCredentialValidator { diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/CredentialValidator.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/CredentialValidator.java index b385fc0ab..629f4540c 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/CredentialValidator.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/CredentialValidator.java @@ -9,6 +9,7 @@ import hirs.attestationca.persist.entity.userdefined.info.ComponentInfo; import hirs.attestationca.persist.entity.userdefined.report.DeviceInfoReport; import hirs.attestationca.persist.enums.AppraisalStatus; +import hirs.attestationca.persist.exceptions.SupplyChainValidatorException; import lombok.extern.log4j.Log4j2; import org.bouncycastle.cert.X509AttributeCertificateHolder; @@ -27,6 +28,9 @@ import static hirs.attestationca.persist.enums.AppraisalStatus.Status.FAIL; import static hirs.attestationca.persist.enums.AppraisalStatus.Status.PASS; +/** + * Validator class responsible for validating certificates. + */ @Log4j2 public class CredentialValidator extends SupplyChainCredentialValidator { diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/FirmwareScvValidator.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/FirmwareScvValidator.java index 8b098a1a6..1c6ca6d09 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/FirmwareScvValidator.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/FirmwareScvValidator.java @@ -11,6 +11,7 @@ import hirs.attestationca.persist.entity.userdefined.rim.EventLogMeasurements; import hirs.attestationca.persist.entity.userdefined.rim.ReferenceDigestValue; import hirs.attestationca.persist.enums.AppraisalStatus; +import hirs.attestationca.persist.exceptions.SupplyChainValidatorException; import hirs.attestationca.persist.service.ValidationService; import hirs.utils.SwidResource; import hirs.utils.rim.ReferenceManifestValidator; @@ -35,6 +36,9 @@ import static hirs.attestationca.persist.enums.AppraisalStatus.Status.FAIL; import static hirs.attestationca.persist.enums.AppraisalStatus.Status.PASS; +/** + * Validator class responsible for validating firmware-related information. + */ @Log4j2 public class FirmwareScvValidator extends SupplyChainCredentialValidator { @@ -93,7 +97,7 @@ public static AppraisalStatus validateFirmware( } else if (measurement == null) { measurement = (EventLogMeasurements) referenceManifestRepository .findByHexDecHashAndRimTypeUnarchived(baseReferenceManifest.getEventLogHash(), - ReferenceManifest.MEASUREMENT_RIM); + ReferenceManifest.MEASUREMENT_RIM); if (measurement == null) { measurement = referenceManifestRepository.byMeasurementDeviceNameUnarchived( @@ -330,7 +334,7 @@ private static AppraisalStatus validatePcrValues( } if (pcrAppraisalStatus.getAppStatus().equals(FAIL)) { pcrAppraisalStatus = new AppraisalStatus(FAIL, String.format("%s%n%s", - pcrAppraisalStatus.getMessage(), sb.toString())); + pcrAppraisalStatus.getMessage(), sb)); } else { pcrAppraisalStatus = new AppraisalStatus(FAIL, sb.toString(), ReferenceManifest.MEASUREMENT_RIM); diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/SupplyChainCredentialValidator.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/SupplyChainCredentialValidator.java index 55328796c..bb74ab85d 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/SupplyChainCredentialValidator.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/SupplyChainCredentialValidator.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import hirs.attestationca.persist.entity.userdefined.info.ComponentInfo; +import hirs.attestationca.persist.exceptions.SupplyChainValidatorException; import lombok.extern.log4j.Log4j2; import org.apache.commons.lang3.StringUtils; import org.bouncycastle.asn1.x500.X500Name; @@ -33,6 +34,10 @@ import java.util.List; import java.util.Set; +/** + * Base class used for supply chain credential validators. This class provides common functionality and + * structure for validators + */ @Log4j2 public class SupplyChainCredentialValidator { diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/package-info.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/package-info.java index 27ae86db3..ad7ab12bd 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/package-info.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/package-info.java @@ -1 +1,4 @@ +/** + * Contains validator classes. + */ package hirs.attestationca.persist.validation; diff --git a/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/AttestationCertificateAuthorityTest.java b/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/AttestationCertificateAuthorityTest.java index 8dcca210d..b4f6beca0 100644 --- a/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/AttestationCertificateAuthorityTest.java +++ b/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/AttestationCertificateAuthorityTest.java @@ -1,6 +1,5 @@ package hirs.attestationca.persist; -import com.google.protobuf.ByteString; import hirs.attestationca.persist.entity.userdefined.certificate.EndorsementCredential; import hirs.attestationca.persist.entity.userdefined.certificate.PlatformCredential; import hirs.attestationca.persist.provision.AbstractProcessor; @@ -26,7 +25,6 @@ import org.bouncycastle.operator.ContentSigner; import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder; import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; @@ -51,7 +49,6 @@ import java.security.NoSuchAlgorithmException; import java.security.PrivateKey; import java.security.PublicKey; -import java.util.Random; import java.security.Security; import java.security.cert.X509Certificate; import java.security.interfaces.RSAPublicKey; @@ -60,7 +57,7 @@ import java.util.Date; import java.util.LinkedList; import java.util.List; -import java.util.Objects; +import java.util.Random; import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -121,12 +118,43 @@ public class AttestationCertificateAuthorityTest { private static final String AK_NAME_HEX = "00 0b 6e 8f 79 1c 7e 16 96 1b 11 71 65 9c e0 cd" + "ae 0d 4d aa c5 41 be 58 89 74 67 55 96 c2 5e 38" + "e2 94"; + private final Random random = new Random(); // object in test private AttestationCertificateAuthority aca; private AccessAbstractProcessor abstractProcessor; // test key pair private KeyPair keyPair; - private Random random = new Random(); + + /** + * Creates a self-signed X.509 public-key certificate. + * + * @param pair KeyPair to create the cert for + * @return self-signed X509Certificate + */ + private static X509Certificate createSelfSignedCertificate(final KeyPair pair) { + Security.addProvider(new BouncyCastleProvider()); + final int timeRange = 10000; + X509Certificate cert = null; + try { + + X500Name issuerName = new X500Name("CN=TEST2, OU=TEST2, O=TEST2, C=TEST2"); + X500Name subjectName = new X500Name("CN=TEST, OU=TEST, O=TEST, C=TEST"); + BigInteger serialNumber = BigInteger.ONE; + Date notBefore = new Date(System.currentTimeMillis() - timeRange); + Date notAfter = new Date(System.currentTimeMillis() + timeRange); + X509v3CertificateBuilder builder = + new JcaX509v3CertificateBuilder(issuerName, serialNumber, notBefore, notAfter, + subjectName, pair.getPublic()); + ContentSigner signer = + new JcaContentSignerBuilder("SHA256WithRSA").setProvider("BC").build( + pair.getPrivate()); + return new JcaX509CertificateConverter().setProvider("BC").getCertificate( + builder.build(signer)); + } catch (Exception e) { + fail("Exception occurred while creating a cert", e); + } + return cert; + } /** * Registers bouncy castle as a security provider. Normally the JEE container will handle this, @@ -381,37 +409,6 @@ public void testGenerateAttestation() throws Exception { verifyNoMoreInteractions(certificate, symmetricKey); } - /** - * Creates a self-signed X.509 public-key certificate. - * - * @param pair KeyPair to create the cert for - * @return self-signed X509Certificate - */ - private static X509Certificate createSelfSignedCertificate(final KeyPair pair) { - Security.addProvider(new BouncyCastleProvider()); - final int timeRange = 10000; - X509Certificate cert = null; - try { - - X500Name issuerName = new X500Name("CN=TEST2, OU=TEST2, O=TEST2, C=TEST2"); - X500Name subjectName = new X500Name("CN=TEST, OU=TEST, O=TEST, C=TEST"); - BigInteger serialNumber = BigInteger.ONE; - Date notBefore = new Date(System.currentTimeMillis() - timeRange); - Date notAfter = new Date(System.currentTimeMillis() + timeRange); - X509v3CertificateBuilder builder = - new JcaX509v3CertificateBuilder(issuerName, serialNumber, notBefore, notAfter, - subjectName, pair.getPublic()); - ContentSigner signer = - new JcaContentSignerBuilder("SHA256WithRSA").setProvider("BC").build( - pair.getPrivate()); - return new JcaX509CertificateConverter().setProvider("BC").getCertificate( - builder.build(signer)); - } catch (Exception e) { - fail("Exception occurred while creating a cert", e); - } - return cert; - } - /** * Tests {@link AttestationCertificateAuthority# * AttestationCertificateAuthority(SupplyChainValidationService, PrivateKey, @@ -610,46 +607,47 @@ public void testGenerateAkName() throws URISyntaxException, IOException, assertEquals(hex, realHex); } - /** - * Method to generate a make credential output file for use in manual testing. Feed to - * a TPM 2.0 or emulator using the activate credential command to ensure proper parsing. - * Must be performed manually. To use, copy the TPM's ek and ak into - * HIRS_AttestationCA/src/test/resources/tpm2/test/ and ensure the variables akPubPath - * and ekPubPath are correct. Your output file will be - * HIRS_AttestationCA/src/test/resources/tpm2/test/make.blob and the nonce used will be - * output as HIRS_AttestationCA/src/test/resources/tpm2/test/secret.blob - * - * @throws URISyntaxException invalid file path - * @throws IOException unable to read file - */ - @Disabled - @Test - public void testMakeCredential() throws URISyntaxException, IOException { - Path akPubPath = Paths.get(getClass().getResource( - AK_PUBLIC_PATH).toURI()); - Path ekPubPath = Paths.get(getClass().getResource( - EK_PUBLIC_PATH).toURI()); - - byte[] ekPubFile = Files.readAllBytes(ekPubPath); - byte[] akPubFile = Files.readAllBytes(akPubPath); - - RSAPublicKey ekPub = ProvisionUtils.parsePublicKey(ekPubFile); - RSAPublicKey akPub = ProvisionUtils.parsePublicKey(akPubFile); - - // prepare the nonce and wrap it with keys - final byte[] nonce = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}; - ByteString blob = ProvisionUtils.tpm20MakeCredential(ekPub, akPub, nonce); - - Path resources = Objects.requireNonNull(Paths.get(Objects.requireNonNull(this.getClass().getResource( - "/").toURI())) - .getParent().getParent().getParent().getParent()); - Path makeBlob = resources.resolve("src/test/resources/tpm2/test/make.blob"); - Files.write(makeBlob, blob.toByteArray()); - - Path secretPath = resources.resolve("src/test/resources/tpm2/test/secret.blob"); - Files.write(secretPath, nonce); - } +// /** +// * Method to generate a make credential output file for use in manual testing. Feed to +// * a TPM 2.0 or emulator using the activate credential command to ensure proper parsing. +// * Must be performed manually. To use, copy the TPM's ek and ak into +// * HIRS_AttestationCA/src/test/resources/tpm2/test/ and ensure the variables akPubPath +// * and ekPubPath are correct. Your output file will be +// * HIRS_AttestationCA/src/test/resources/tpm2/test/make.blob and the nonce used will be +// * output as HIRS_AttestationCA/src/test/resources/tpm2/test/secret.blob +// * +// * @throws URISyntaxException invalid file path +// * @throws IOException unable to read file +// */ +// @Disabled +// @Test +// public void testMakeCredential() throws URISyntaxException, IOException { +// Path akPubPath = Paths.get(Objects.requireNonNull(getClass().getResource( +// AK_PUBLIC_PATH)).toURI()); +// Path ekPubPath = Paths.get(Objects.requireNonNull(getClass().getResource( +// EK_PUBLIC_PATH)).toURI()); +// +// byte[] ekPubFile = Files.readAllBytes(ekPubPath); +// byte[] akPubFile = Files.readAllBytes(akPubPath); +// +// RSAPublicKey ekPub = ProvisionUtils.parsePublicKey(ekPubFile); +// RSAPublicKey akPub = ProvisionUtils.parsePublicKey(akPubFile); +// +// // prepare the nonce and wrap it with keys +// final byte[] nonce = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, +// 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}; +// ByteString blob = ProvisionUtils.tpm20MakeCredential(ekPub, akPub, nonce); +// +// Path resources = Objects.requireNonNull(Paths.get(Objects.requireNonNull( +// Objects.requireNonNull(this.getClass().getResource( +// "/")).toURI())) +// .getParent().getParent().getParent().getParent()); +// Path makeBlob = resources.resolve("src/test/resources/tpm2/test/make.blob"); +// Files.write(makeBlob, blob.toByteArray()); +// +// Path secretPath = resources.resolve("src/test/resources/tpm2/test/secret.blob"); +// Files.write(secretPath, nonce); +// } /** * Test helper method that encrypts a blob using the specified transformation and the test key diff --git a/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/validation/SupplyChainCredentialValidatorTest.java b/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/validation/SupplyChainCredentialValidatorTest.java index a8d946990..c32381519 100644 --- a/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/validation/SupplyChainCredentialValidatorTest.java +++ b/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/validation/SupplyChainCredentialValidatorTest.java @@ -22,6 +22,7 @@ import hirs.attestationca.persist.entity.userdefined.info.TPMInfo; import hirs.attestationca.persist.entity.userdefined.report.DeviceInfoReport; import hirs.attestationca.persist.enums.AppraisalStatus; +import hirs.attestationca.persist.exceptions.SupplyChainValidatorException; import hirs.utils.enums.DeviceInfoEnums; import lombok.NonNull; import org.apache.commons.io.IOUtils; diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/PageMessages.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/PageMessages.java index 0163919d4..eac5929c9 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/PageMessages.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/PageMessages.java @@ -26,7 +26,7 @@ public class PageMessages { private final List infoMessages = new ArrayList<>(); /** - * Adds an error message to the list of error messages + * Adds an error message to the list of error messages. * * @param error the error message to add */ @@ -71,7 +71,7 @@ public void addInfoMessage(final String info) { } /** - * Adds multiple informational messages to the list of info messages + * Adds multiple informational messages to the list of info messages. * * @param multipleInfoMessages list of informational messages to add */ diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/DevicePageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/DevicePageController.java index 795eae1fc..86e52e830 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/DevicePageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/DevicePageController.java @@ -1,9 +1,9 @@ package hirs.attestationca.portal.page.controllers; import hirs.attestationca.persist.FilteredRecordsList; +import hirs.attestationca.persist.entity.userdefined.DataTablesColumn; import hirs.attestationca.persist.entity.userdefined.Device; import hirs.attestationca.persist.service.DevicePageService; -import hirs.attestationca.persist.service.util.DataTablesColumn; import hirs.attestationca.portal.datatables.DataTableInput; import hirs.attestationca.portal.datatables.DataTableResponse; import hirs.attestationca.portal.datatables.Order; diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/EndorsementCredentialPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/EndorsementCredentialPageController.java index 8abcd2690..8bd828718 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/EndorsementCredentialPageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/EndorsementCredentialPageController.java @@ -1,12 +1,12 @@ package hirs.attestationca.portal.page.controllers; import hirs.attestationca.persist.FilteredRecordsList; +import hirs.attestationca.persist.entity.userdefined.DataTablesColumn; +import hirs.attestationca.persist.entity.userdefined.DownloadFile; import hirs.attestationca.persist.entity.userdefined.certificate.EndorsementCredential; +import hirs.attestationca.persist.enums.CertificateType; import hirs.attestationca.persist.service.CertificatePageService; import hirs.attestationca.persist.service.EndorsementCredentialPageService; -import hirs.attestationca.persist.service.util.CertificateType; -import hirs.attestationca.persist.service.util.DataTablesColumn; -import hirs.attestationca.persist.util.DownloadFile; import hirs.attestationca.portal.datatables.DataTableInput; import hirs.attestationca.portal.datatables.DataTableResponse; import hirs.attestationca.portal.datatables.Order; diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/IDevIdCertificatePageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/IDevIdCertificatePageController.java index 985e066b4..647dbad69 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/IDevIdCertificatePageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/IDevIdCertificatePageController.java @@ -1,12 +1,12 @@ package hirs.attestationca.portal.page.controllers; import hirs.attestationca.persist.FilteredRecordsList; +import hirs.attestationca.persist.entity.userdefined.DataTablesColumn; +import hirs.attestationca.persist.entity.userdefined.DownloadFile; import hirs.attestationca.persist.entity.userdefined.certificate.IDevIDCertificate; +import hirs.attestationca.persist.enums.CertificateType; import hirs.attestationca.persist.service.CertificatePageService; import hirs.attestationca.persist.service.IDevIdCertificatePageService; -import hirs.attestationca.persist.service.util.CertificateType; -import hirs.attestationca.persist.service.util.DataTablesColumn; -import hirs.attestationca.persist.util.DownloadFile; import hirs.attestationca.portal.datatables.DataTableInput; import hirs.attestationca.portal.datatables.DataTableResponse; import hirs.attestationca.portal.datatables.Order; diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/IssuedCertificatePageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/IssuedCertificatePageController.java index d71aa1025..0f3e36027 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/IssuedCertificatePageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/IssuedCertificatePageController.java @@ -1,12 +1,12 @@ package hirs.attestationca.portal.page.controllers; import hirs.attestationca.persist.FilteredRecordsList; +import hirs.attestationca.persist.entity.userdefined.DataTablesColumn; +import hirs.attestationca.persist.entity.userdefined.DownloadFile; import hirs.attestationca.persist.entity.userdefined.certificate.IssuedAttestationCertificate; +import hirs.attestationca.persist.enums.CertificateType; import hirs.attestationca.persist.service.CertificatePageService; import hirs.attestationca.persist.service.IssuedAttestationCertificatePageService; -import hirs.attestationca.persist.service.util.CertificateType; -import hirs.attestationca.persist.service.util.DataTablesColumn; -import hirs.attestationca.persist.util.DownloadFile; import hirs.attestationca.portal.datatables.DataTableInput; import hirs.attestationca.portal.datatables.DataTableResponse; import hirs.attestationca.portal.datatables.Order; diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/PlatformCredentialPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/PlatformCredentialPageController.java index d85eb4be1..d697ca6ee 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/PlatformCredentialPageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/PlatformCredentialPageController.java @@ -1,13 +1,13 @@ package hirs.attestationca.portal.page.controllers; import hirs.attestationca.persist.FilteredRecordsList; +import hirs.attestationca.persist.entity.userdefined.DataTablesColumn; +import hirs.attestationca.persist.entity.userdefined.DownloadFile; import hirs.attestationca.persist.entity.userdefined.certificate.EndorsementCredential; import hirs.attestationca.persist.entity.userdefined.certificate.PlatformCredential; +import hirs.attestationca.persist.enums.CertificateType; import hirs.attestationca.persist.service.CertificatePageService; import hirs.attestationca.persist.service.PlatformCredentialPageService; -import hirs.attestationca.persist.service.util.CertificateType; -import hirs.attestationca.persist.service.util.DataTablesColumn; -import hirs.attestationca.persist.util.DownloadFile; import hirs.attestationca.portal.datatables.DataTableInput; import hirs.attestationca.portal.datatables.DataTableResponse; import hirs.attestationca.portal.datatables.Order; diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestPageController.java index 15b6785da..870ba89e6 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestPageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestPageController.java @@ -1,12 +1,12 @@ package hirs.attestationca.portal.page.controllers; import hirs.attestationca.persist.FilteredRecordsList; +import hirs.attestationca.persist.entity.userdefined.DataTablesColumn; +import hirs.attestationca.persist.entity.userdefined.DownloadFile; import hirs.attestationca.persist.entity.userdefined.ReferenceManifest; import hirs.attestationca.persist.entity.userdefined.rim.BaseReferenceManifest; import hirs.attestationca.persist.entity.userdefined.rim.SupportReferenceManifest; import hirs.attestationca.persist.service.ReferenceManifestPageService; -import hirs.attestationca.persist.service.util.DataTablesColumn; -import hirs.attestationca.persist.util.DownloadFile; import hirs.attestationca.portal.datatables.DataTableInput; import hirs.attestationca.portal.datatables.DataTableResponse; import hirs.attestationca.portal.datatables.Order; diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/RimDatabasePageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/RimDatabasePageController.java index 63a1a6154..8ba126bc9 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/RimDatabasePageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/RimDatabasePageController.java @@ -1,11 +1,11 @@ package hirs.attestationca.portal.page.controllers; -import hirs.attestationca.persist.DBManagerException; import hirs.attestationca.persist.FilteredRecordsList; +import hirs.attestationca.persist.entity.userdefined.DataTablesColumn; import hirs.attestationca.persist.entity.userdefined.rim.ReferenceDigestValue; import hirs.attestationca.persist.entity.userdefined.rim.SupportReferenceManifest; +import hirs.attestationca.persist.exceptions.DBManagerException; import hirs.attestationca.persist.service.ReferenceDigestValuePageService; -import hirs.attestationca.persist.service.util.DataTablesColumn; import hirs.attestationca.portal.datatables.DataTableInput; import hirs.attestationca.portal.datatables.DataTableResponse; import hirs.attestationca.portal.datatables.Order; diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/TrustChainCertificatePageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/TrustChainCertificatePageController.java index eafdde42f..a7df4da08 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/TrustChainCertificatePageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/TrustChainCertificatePageController.java @@ -3,12 +3,12 @@ import hirs.attestationca.persist.FilteredRecordsList; import hirs.attestationca.persist.entity.manager.CACredentialRepository; import hirs.attestationca.persist.entity.manager.CertificateRepository; +import hirs.attestationca.persist.entity.userdefined.DataTablesColumn; +import hirs.attestationca.persist.entity.userdefined.DownloadFile; import hirs.attestationca.persist.entity.userdefined.certificate.CertificateAuthorityCredential; +import hirs.attestationca.persist.enums.CertificateType; import hirs.attestationca.persist.service.CertificatePageService; import hirs.attestationca.persist.service.TrustChainCertificatePageService; -import hirs.attestationca.persist.service.util.CertificateType; -import hirs.attestationca.persist.service.util.DataTablesColumn; -import hirs.attestationca.persist.util.DownloadFile; import hirs.attestationca.portal.datatables.DataTableInput; import hirs.attestationca.portal.datatables.DataTableResponse; import hirs.attestationca.portal.datatables.Order; diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ValidationReportsPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ValidationReportsPageController.java index de94d24e1..52796e39b 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ValidationReportsPageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ValidationReportsPageController.java @@ -1,9 +1,9 @@ package hirs.attestationca.portal.page.controllers; import hirs.attestationca.persist.FilteredRecordsList; +import hirs.attestationca.persist.entity.userdefined.DataTablesColumn; import hirs.attestationca.persist.entity.userdefined.SupplyChainValidationSummary; import hirs.attestationca.persist.service.ValidationSummaryPageService; -import hirs.attestationca.persist.service.util.DataTablesColumn; import hirs.attestationca.portal.datatables.DataTableInput; import hirs.attestationca.portal.datatables.DataTableResponse; import hirs.attestationca.portal.datatables.Order; diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/utils/ControllerPagesUtils.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/utils/ControllerPagesUtils.java index 97c8de64e..d002094c2 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/utils/ControllerPagesUtils.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/utils/ControllerPagesUtils.java @@ -1,8 +1,8 @@ package hirs.attestationca.portal.page.utils; import hirs.attestationca.persist.entity.userdefined.Certificate; +import hirs.attestationca.persist.entity.userdefined.DataTablesColumn; import hirs.attestationca.persist.entity.userdefined.certificate.PlatformCredential; -import hirs.attestationca.persist.service.util.DataTablesColumn; import hirs.attestationca.portal.datatables.Column; import hirs.attestationca.portal.datatables.Order; import io.micrometer.common.util.StringUtils; diff --git a/HIRS_AttestationCAPortal/src/test/java/hirs/attestationca/portal/page/controllers/ReferenceManifestPageControllerTest.java b/HIRS_AttestationCAPortal/src/test/java/hirs/attestationca/portal/page/controllers/ReferenceManifestPageControllerTest.java index 287fcd188..0b6865481 100644 --- a/HIRS_AttestationCAPortal/src/test/java/hirs/attestationca/portal/page/controllers/ReferenceManifestPageControllerTest.java +++ b/HIRS_AttestationCAPortal/src/test/java/hirs/attestationca/portal/page/controllers/ReferenceManifestPageControllerTest.java @@ -46,7 +46,6 @@ public void prepareTests() throws IOException { */ @AfterEach public void afterEachTest() { - } /** diff --git a/HIRS_AttestationCAPortal/src/test/java/hirs/attestationca/portal/page/controllers/TrustChainManagementPageControllerTest.java b/HIRS_AttestationCAPortal/src/test/java/hirs/attestationca/portal/page/controllers/TrustChainManagementPageControllerTest.java index 8a198b264..26bd8b1c3 100644 --- a/HIRS_AttestationCAPortal/src/test/java/hirs/attestationca/portal/page/controllers/TrustChainManagementPageControllerTest.java +++ b/HIRS_AttestationCAPortal/src/test/java/hirs/attestationca/portal/page/controllers/TrustChainManagementPageControllerTest.java @@ -116,12 +116,11 @@ public void testInitPage() throws Exception { } /** - * Tests download the ACA full trust chain/ + * Tests download the ACA full trust chain. * todo write download aca-trust-chain cert method */ @Test public void testDownloadACATrustChainCert() { - } /** From ee48571caca527fe0cbe9a8ba27ce761d93519df Mon Sep 17 00:00:00 2001 From: ThatSilentCoder <184309164+ThatSilentCoder@users.noreply.github.com> Date: Thu, 12 Feb 2026 15:31:12 -0500 Subject: [PATCH 07/20] v3.1_issue_1101: Fixed javadoc errors. Handling as many manageable javadoc warnings as possible. --- .../certificate/IDevIDCertificate.java | 9 + .../provision/helper/ProvisionUtils.java | 3 + .../service/SupplyChainValidationService.java | 3 + .../record/TPMMeasurementRecordTest.java | 2 +- .../CertificateDetailsPageController.java | 1 - .../controllers/DevicePageController.java | 1 - .../EndorsementCredentialPageController.java | 1 - .../page/controllers/HelpPageController.java | 1 - .../IDevIdCertificatePageController.java | 1 - .../page/controllers/IndexPageController.java | 1 - .../IssuedCertificatePageController.java | 1 - .../{ => controllers}/PageController.java | 4 +- .../PlatformCredentialPageController.java | 1 - .../controllers/PolicyPageController.java | 1 - ...eferenceManifestDetailsPageController.java | 4 +- .../ReferenceManifestPageController.java | 1 - .../RimDatabasePageController.java | 1 - .../TrustChainCertificatePageController.java | 1 - .../ValidationReportsPageController.java | 1 - .../params/CertificateDetailsPageParams.java | 1 - .../portal/page/params/NoPageParams.java | 2 - .../portal/page/{ => params}/PageParams.java | 2 +- .../ReferenceManifestDetailsPageParams.java | 1 - .../utils/CertificateStringMapBuilder.java | 12 +- .../portal/page/PageControllerTest.java | 1 + .../CertificateDetailsPageControllerTest.java | 1 - .../controllers/PolicyPageControllerTest.java | 1 - .../src/main/java/hirs/utils/PciIds.java | 2 +- .../hirs/utils/digest/AbstractDigest.java | 35 ++-- .../java/hirs/utils/digest/package-info.java | 3 + .../java/hirs/utils/enums/ComponentType.java | 85 --------- .../hirs/utils/enums/DeviceInfoEnums.java | 6 + .../java/hirs/utils/enums/package-info.java | 3 + .../TPMBaselineGeneratorException.java | 84 ++++----- .../hirs/utils/exception/package-info.java | 3 + .../main/java/hirs/utils/package-info.java | 4 + .../utils/rim/unsignedRim/GenericRim.java | 52 ++++-- .../cbor/ietfCorim/CoRimDigest.java | 12 +- .../unsignedRim/cbor/ietfCoswid/Coswid.java | 61 ++++--- .../cbor/ietfCoswid/CoswidBuilder.java | 93 ++++++---- .../TcgCompRimCoswidBuilder.java | 6 +- .../xml/pcclientrim/PcClientRim.java | 80 +++++---- .../hirs/utils/signature/SignatureFormat.java | 27 ++- .../hirs/utils/signature/SignatureHelper.java | 9 +- .../utils/signature/cose/Cbor/CborBstr.java | 48 +++--- .../hirs/utils/signature/cose/CoseHeader.java | 12 +- .../signature/cose/CoseHeaderProtected.java | 15 +- .../hirs/utils/signature/cose/CoseParser.java | 92 +++++++--- .../utils/signature/cose/CoseSignature.java | 163 +++++++++--------- .../specificationLookups/PlatformClass.java | 13 +- .../specificationLookups/package-info.java | 3 + .../hirs/utils/swid/CredentialParser.java | 15 +- .../main/java/hirs/utils/swid/HashSwid.java | 52 +++--- .../java/hirs/utils/swid/package-info.java | 3 + .../eventlog/events/DeviceSecurityEvent.java | 28 +-- .../events/DeviceSecurityEventData.java | 5 +- .../events/DeviceSecurityEventData2.java | 4 +- .../DeviceSecurityEventDataDeviceContext.java | 9 +- .../DeviceSecurityEventDataHeader2.java | 14 +- .../DeviceSecurityEventDataSubHeader.java | 5 +- ...ventDataSubHeaderSpdmMeasurementBlock.java | 11 +- .../events/DeviceSecurityEventHeader.java | 18 +- .../events/NvIndexDynamicEventLogData.java | 1 - .../events/NvIndexInstanceEventLogData.java | 1 - .../eventlog/spdm/SpdmCertificateChain.java | 18 +- .../tpm/eventlog/spdm/SpdmMeasurement.java | 12 +- .../eventlog/spdm/SpdmMeasurementBlock.java | 17 +- .../java/hirs/utils/xjc/DigestMethodType.java | 2 + .../main/java/hirs/utils/xjc/Ownership.java | 4 +- .../main/java/hirs/utils/xjc/PGPDataType.java | 2 + .../java/hirs/utils/xjc/SPKIDataType.java | 2 + .../hirs/utils/xjc/SignatureMethodType.java | 2 + .../utils/xjc/SignaturePropertiesType.java | 2 + .../java/hirs/utils/xjc/SignatureType.java | 4 +- .../java/hirs/utils/xjc/TransformType.java | 12 +- .../java/hirs/utils/xjc/TransformsType.java | 4 +- .../src/main/java/hirs/utils/xjc/Use.java | 4 +- 77 files changed, 698 insertions(+), 523 deletions(-) rename HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/{ => controllers}/PageController.java (97%) rename HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/{ => params}/PageParams.java (86%) delete mode 100644 HIRS_Utils/src/main/java/hirs/utils/enums/ComponentType.java rename HIRS_Utils/src/main/java/hirs/utils/{tpm => exception}/TPMBaselineGeneratorException.java (94%) diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/IDevIDCertificate.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/IDevIDCertificate.java index 2a30a6d4c..af72ce8ce 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/IDevIDCertificate.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/IDevIDCertificate.java @@ -26,6 +26,15 @@ import java.util.Iterator; import java.util.Map; +/** + * Represents the IEEE 802.1AR secure Device Identifier (DevID). + *

+ * The IDevID is a cryptographic identity bound to a device, used to assert its identity in secure networks. + * It is generated during manufacturing (e.g., in factories) and remains valid throughout the device's + * lifecycle. The IDevID, along with the Initial Attestation Key (IAK), provides a unique and + * persistent identity for the device, enabling secure authentication and communication within + * 802.1AR-compliant networks. + */ @Entity @Getter @EqualsAndHashCode(callSuper = true) diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/provision/helper/ProvisionUtils.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/provision/helper/ProvisionUtils.java index e6113bf79..cf689fbde 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/provision/helper/ProvisionUtils.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/provision/helper/ProvisionUtils.java @@ -48,6 +48,9 @@ import java.security.spec.RSAPublicKeySpec; import java.util.Date; +/** + * Utility class that provides utility methods to assist with the device provisioning process. + */ @Log4j2 public final class ProvisionUtils { diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/SupplyChainValidationService.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/SupplyChainValidationService.java index 39b12fcb0..9f73d4458 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/SupplyChainValidationService.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/SupplyChainValidationService.java @@ -45,6 +45,9 @@ import static hirs.attestationca.persist.enums.AppraisalStatus.Status.FAIL; import static hirs.attestationca.persist.enums.AppraisalStatus.Status.PASS; +/** + * A service layer class responsible for validating the supply chain based on the policy settings. + */ @Log4j2 @Service public class SupplyChainValidationService { diff --git a/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/entity/userdefined/record/TPMMeasurementRecordTest.java b/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/entity/userdefined/record/TPMMeasurementRecordTest.java index 9fdccee17..2894dfed3 100644 --- a/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/entity/userdefined/record/TPMMeasurementRecordTest.java +++ b/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/entity/userdefined/record/TPMMeasurementRecordTest.java @@ -2,7 +2,7 @@ import hirs.attestationca.persist.entity.userdefined.ExaminableRecord; import hirs.utils.digest.Digest; -import hirs.utils.digest.DigestAlgorithm; +import hirs.utils.enums.DigestAlgorithm; import org.apache.commons.codec.DecoderException; import org.apache.commons.codec.binary.Hex; import org.apache.logging.log4j.LogManager; diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/CertificateDetailsPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/CertificateDetailsPageController.java index 091075599..00898f49e 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/CertificateDetailsPageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/CertificateDetailsPageController.java @@ -4,7 +4,6 @@ import hirs.attestationca.persist.entity.manager.CertificateRepository; import hirs.attestationca.persist.entity.manager.ComponentResultRepository; import hirs.attestationca.portal.page.Page; -import hirs.attestationca.portal.page.PageController; import hirs.attestationca.portal.page.PageMessages; import hirs.attestationca.portal.page.params.CertificateDetailsPageParams; import hirs.attestationca.portal.page.utils.CertificateStringMapBuilder; diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/DevicePageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/DevicePageController.java index c5c00a6ac..27eac9a3b 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/DevicePageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/DevicePageController.java @@ -8,7 +8,6 @@ import hirs.attestationca.portal.datatables.DataTableResponse; import hirs.attestationca.portal.datatables.Order; import hirs.attestationca.portal.page.Page; -import hirs.attestationca.portal.page.PageController; import hirs.attestationca.portal.page.params.NoPageParams; import hirs.attestationca.portal.page.utils.ControllerPagesUtils; import lombok.extern.log4j.Log4j2; diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/EndorsementCredentialPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/EndorsementCredentialPageController.java index 97dfe573e..6031c0c0a 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/EndorsementCredentialPageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/EndorsementCredentialPageController.java @@ -11,7 +11,6 @@ import hirs.attestationca.portal.datatables.DataTableResponse; import hirs.attestationca.portal.datatables.Order; import hirs.attestationca.portal.page.Page; -import hirs.attestationca.portal.page.PageController; import hirs.attestationca.portal.page.PageMessages; import hirs.attestationca.portal.page.params.NoPageParams; import hirs.attestationca.portal.page.utils.ControllerPagesUtils; diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/HelpPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/HelpPageController.java index c73733196..87c954bf7 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/HelpPageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/HelpPageController.java @@ -6,7 +6,6 @@ import hirs.attestationca.portal.datatables.DataTableInput; import hirs.attestationca.portal.datatables.DataTableResponse; import hirs.attestationca.portal.page.Page; -import hirs.attestationca.portal.page.PageController; import hirs.attestationca.portal.page.PageMessages; import hirs.attestationca.portal.page.params.NoPageParams; import jakarta.servlet.http.HttpServletResponse; diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/IDevIdCertificatePageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/IDevIdCertificatePageController.java index 4153ed57b..384bee606 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/IDevIdCertificatePageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/IDevIdCertificatePageController.java @@ -11,7 +11,6 @@ import hirs.attestationca.portal.datatables.DataTableResponse; import hirs.attestationca.portal.datatables.Order; import hirs.attestationca.portal.page.Page; -import hirs.attestationca.portal.page.PageController; import hirs.attestationca.portal.page.PageMessages; import hirs.attestationca.portal.page.params.NoPageParams; import hirs.attestationca.portal.page.utils.ControllerPagesUtils; diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/IndexPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/IndexPageController.java index eb4f79117..6a9a19ac5 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/IndexPageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/IndexPageController.java @@ -1,7 +1,6 @@ package hirs.attestationca.portal.page.controllers; import hirs.attestationca.portal.page.Page; -import hirs.attestationca.portal.page.PageController; import hirs.attestationca.portal.page.params.NoPageParams; import lombok.extern.log4j.Log4j2; import org.springframework.stereotype.Controller; diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/IssuedCertificatePageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/IssuedCertificatePageController.java index a5df598a9..ead3129ae 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/IssuedCertificatePageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/IssuedCertificatePageController.java @@ -11,7 +11,6 @@ import hirs.attestationca.portal.datatables.DataTableResponse; import hirs.attestationca.portal.datatables.Order; import hirs.attestationca.portal.page.Page; -import hirs.attestationca.portal.page.PageController; import hirs.attestationca.portal.page.PageMessages; import hirs.attestationca.portal.page.params.NoPageParams; import hirs.attestationca.portal.page.utils.ControllerPagesUtils; diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/PageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/PageController.java similarity index 97% rename from HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/PageController.java rename to HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/PageController.java index 6095ec4dc..93a64d7ed 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/PageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/PageController.java @@ -1,5 +1,7 @@ -package hirs.attestationca.portal.page; +package hirs.attestationca.portal.page.controllers; +import hirs.attestationca.portal.page.Page; +import hirs.attestationca.portal.page.params.PageParams; import lombok.AllArgsConstructor; import lombok.extern.log4j.Log4j2; import org.apache.http.client.utils.URIBuilder; diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/PlatformCredentialPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/PlatformCredentialPageController.java index 0524f1d2d..1707ccf24 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/PlatformCredentialPageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/PlatformCredentialPageController.java @@ -12,7 +12,6 @@ import hirs.attestationca.portal.datatables.DataTableResponse; import hirs.attestationca.portal.datatables.Order; import hirs.attestationca.portal.page.Page; -import hirs.attestationca.portal.page.PageController; import hirs.attestationca.portal.page.PageMessages; import hirs.attestationca.portal.page.params.NoPageParams; import hirs.attestationca.portal.page.utils.ControllerPagesUtils; diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/PolicyPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/PolicyPageController.java index fa950e35b..27fc35fb7 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/PolicyPageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/PolicyPageController.java @@ -3,7 +3,6 @@ import hirs.attestationca.persist.entity.userdefined.PolicySettings; import hirs.attestationca.persist.service.PolicyPageService; import hirs.attestationca.portal.page.Page; -import hirs.attestationca.portal.page.PageController; import hirs.attestationca.portal.page.PageMessages; import hirs.attestationca.portal.page.PolicyPageModel; import hirs.attestationca.portal.page.params.NoPageParams; diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestDetailsPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestDetailsPageController.java index 6b3d03a28..c3106400a 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestDetailsPageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestDetailsPageController.java @@ -2,7 +2,6 @@ import hirs.attestationca.persist.service.ReferenceManifestDetailsPageService; import hirs.attestationca.portal.page.Page; -import hirs.attestationca.portal.page.PageController; import hirs.attestationca.portal.page.PageMessages; import hirs.attestationca.portal.page.params.ReferenceManifestDetailsPageParams; import lombok.extern.log4j.Log4j2; @@ -21,7 +20,8 @@ @Log4j2 @Controller @RequestMapping("/HIRS_AttestationCAPortal/portal/rim-details") -public class ReferenceManifestDetailsPageController extends PageController { +public class ReferenceManifestDetailsPageController + extends PageController { private final ReferenceManifestDetailsPageService referenceManifestDetailsPageService; /** diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestPageController.java index af603eae3..178b00670 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestPageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestPageController.java @@ -11,7 +11,6 @@ import hirs.attestationca.portal.datatables.DataTableResponse; import hirs.attestationca.portal.datatables.Order; import hirs.attestationca.portal.page.Page; -import hirs.attestationca.portal.page.PageController; import hirs.attestationca.portal.page.PageMessages; import hirs.attestationca.portal.page.params.NoPageParams; import hirs.attestationca.portal.page.utils.ControllerPagesUtils; diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/RimDatabasePageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/RimDatabasePageController.java index aa70be49d..82cf7b325 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/RimDatabasePageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/RimDatabasePageController.java @@ -10,7 +10,6 @@ import hirs.attestationca.portal.datatables.DataTableResponse; import hirs.attestationca.portal.datatables.Order; import hirs.attestationca.portal.page.Page; -import hirs.attestationca.portal.page.PageController; import hirs.attestationca.portal.page.params.NoPageParams; import hirs.attestationca.portal.page.utils.ControllerPagesUtils; import jakarta.validation.Valid; diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/TrustChainCertificatePageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/TrustChainCertificatePageController.java index 7465e180b..9d7763835 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/TrustChainCertificatePageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/TrustChainCertificatePageController.java @@ -13,7 +13,6 @@ import hirs.attestationca.portal.datatables.DataTableResponse; import hirs.attestationca.portal.datatables.Order; import hirs.attestationca.portal.page.Page; -import hirs.attestationca.portal.page.PageController; import hirs.attestationca.portal.page.PageMessages; import hirs.attestationca.portal.page.params.NoPageParams; import hirs.attestationca.portal.page.utils.CertificateStringMapBuilder; diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ValidationReportsPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ValidationReportsPageController.java index 4ccc8795f..ca907c74d 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ValidationReportsPageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ValidationReportsPageController.java @@ -8,7 +8,6 @@ import hirs.attestationca.portal.datatables.DataTableResponse; import hirs.attestationca.portal.datatables.Order; import hirs.attestationca.portal.page.Page; -import hirs.attestationca.portal.page.PageController; import hirs.attestationca.portal.page.params.NoPageParams; import hirs.attestationca.portal.page.utils.ControllerPagesUtils; import jakarta.servlet.http.HttpServletRequest; diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/params/CertificateDetailsPageParams.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/params/CertificateDetailsPageParams.java index 25748aab9..82e26c6c1 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/params/CertificateDetailsPageParams.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/params/CertificateDetailsPageParams.java @@ -1,6 +1,5 @@ package hirs.attestationca.portal.page.params; -import hirs.attestationca.portal.page.PageParams; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/params/NoPageParams.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/params/NoPageParams.java index a270d0afc..d9def2e01 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/params/NoPageParams.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/params/NoPageParams.java @@ -1,7 +1,5 @@ package hirs.attestationca.portal.page.params; -import hirs.attestationca.portal.page.PageParams; - import java.util.LinkedHashMap; /** diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/PageParams.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/params/PageParams.java similarity index 86% rename from HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/PageParams.java rename to HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/params/PageParams.java index 0771facdd..08f2ad091 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/PageParams.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/params/PageParams.java @@ -1,4 +1,4 @@ -package hirs.attestationca.portal.page; +package hirs.attestationca.portal.page.params; import java.util.LinkedHashMap; diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/params/ReferenceManifestDetailsPageParams.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/params/ReferenceManifestDetailsPageParams.java index 0acb4eb6a..b7a22f449 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/params/ReferenceManifestDetailsPageParams.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/params/ReferenceManifestDetailsPageParams.java @@ -1,6 +1,5 @@ package hirs.attestationca.portal.page.params; -import hirs.attestationca.portal.page.PageParams; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/utils/CertificateStringMapBuilder.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/utils/CertificateStringMapBuilder.java index 8686f8ab2..8d49a3676 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/utils/CertificateStringMapBuilder.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/utils/CertificateStringMapBuilder.java @@ -126,7 +126,8 @@ public static HashMap getGeneralCertificateInfo( try { KeyFactory ecFactory = KeyFactory.getInstance("EC"); publicKey = ecFactory.generatePublic(keySpec); - } catch (Exception ignore) { } + } catch (Exception ignore) { + } // If no EC then RSA if (publicKey == null) { KeyFactory rsaFactory = KeyFactory.getInstance("RSA"); @@ -136,7 +137,8 @@ public static HashMap getGeneralCertificateInfo( if (publicKey != null) { String keySizeStr; if (publicKey instanceof ECPublicKey ecKey) { - keySizeStr = Integer.toString(ecKey.getParams().getCurve().getField().getFieldSize()); + keySizeStr = + Integer.toString(ecKey.getParams().getCurve().getField().getFieldSize()); } else { keySizeStr = String.valueOf(certificate.getPublicKeySize()); } @@ -377,7 +379,8 @@ public static HashMap getEndorsementInformation( try { certificate.parseCertificate(); } catch (IOException e) { - throw new RuntimeException("Failed to re-parse Endorsement Credential for details display", e); + throw new RuntimeException("Failed to re-parse Endorsement Credential for details display", + e); } // Add hashmap with TPM information if available if (certificate.getTpmSpecification() != null) { @@ -640,7 +643,8 @@ private static HashMap convertStringToHash(final String str) { key = Character.toUpperCase(key.charAt(0)) + key.substring(1); // Handle nested object recursively if it contains braces or parentheses - if ((value.contains("{") && value.contains("}")) || (value.contains("(") && value.contains(")"))) { + if ((value.contains("{") && value.contains("}")) || + (value.contains("(") && value.contains(")"))) { HashMap nestedMap = convertStringToHash(value); // Prefix nested keys with parent key map.putAll(nestedMap); diff --git a/HIRS_AttestationCAPortal/src/test/java/hirs/attestationca/portal/page/PageControllerTest.java b/HIRS_AttestationCAPortal/src/test/java/hirs/attestationca/portal/page/PageControllerTest.java index 839b0a2cc..0da0857b0 100644 --- a/HIRS_AttestationCAPortal/src/test/java/hirs/attestationca/portal/page/PageControllerTest.java +++ b/HIRS_AttestationCAPortal/src/test/java/hirs/attestationca/portal/page/PageControllerTest.java @@ -6,6 +6,7 @@ import hirs.attestationca.persist.entity.userdefined.certificate.IDevIDCertificate; import hirs.attestationca.persist.entity.userdefined.certificate.IssuedAttestationCertificate; import hirs.attestationca.persist.entity.userdefined.certificate.PlatformCredential; +import hirs.attestationca.portal.page.controllers.PageController; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; diff --git a/HIRS_AttestationCAPortal/src/test/java/hirs/attestationca/portal/page/controllers/CertificateDetailsPageControllerTest.java b/HIRS_AttestationCAPortal/src/test/java/hirs/attestationca/portal/page/controllers/CertificateDetailsPageControllerTest.java index 09cbbbe30..d1d0f69e2 100644 --- a/HIRS_AttestationCAPortal/src/test/java/hirs/attestationca/portal/page/controllers/CertificateDetailsPageControllerTest.java +++ b/HIRS_AttestationCAPortal/src/test/java/hirs/attestationca/portal/page/controllers/CertificateDetailsPageControllerTest.java @@ -10,7 +10,6 @@ import hirs.attestationca.persist.enums.AppraisalStatus; import hirs.attestationca.persist.enums.HealthStatus; import hirs.attestationca.portal.page.Page; -import hirs.attestationca.portal.page.PageController; import hirs.attestationca.portal.page.PageControllerTest; import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.junit.jupiter.api.BeforeAll; diff --git a/HIRS_AttestationCAPortal/src/test/java/hirs/attestationca/portal/page/controllers/PolicyPageControllerTest.java b/HIRS_AttestationCAPortal/src/test/java/hirs/attestationca/portal/page/controllers/PolicyPageControllerTest.java index 45aec3237..2ad67b086 100644 --- a/HIRS_AttestationCAPortal/src/test/java/hirs/attestationca/portal/page/controllers/PolicyPageControllerTest.java +++ b/HIRS_AttestationCAPortal/src/test/java/hirs/attestationca/portal/page/controllers/PolicyPageControllerTest.java @@ -2,7 +2,6 @@ import hirs.attestationca.persist.entity.manager.PolicyRepository; import hirs.attestationca.persist.entity.userdefined.PolicySettings; -import hirs.attestationca.portal.page.PageController; import hirs.attestationca.portal.page.PageControllerTest; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; diff --git a/HIRS_Utils/src/main/java/hirs/utils/PciIds.java b/HIRS_Utils/src/main/java/hirs/utils/PciIds.java index e55e94581..cd429fb89 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/PciIds.java +++ b/HIRS_Utils/src/main/java/hirs/utils/PciIds.java @@ -226,7 +226,7 @@ public static String translateDevice(final String refManufacturer, * . Class: "01" * . Subclass: "08" * . Programming Interface: "02" - * @return List 3-element list with the class code + * @return 3-element string list with the class code * . 1st element: human-readable description of Class * . 2nd element: human-readable description of Subclass * . 3rd element: human-readable description of Programming Interface diff --git a/HIRS_Utils/src/main/java/hirs/utils/digest/AbstractDigest.java b/HIRS_Utils/src/main/java/hirs/utils/digest/AbstractDigest.java index 763ba8f64..01f4f3321 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/digest/AbstractDigest.java +++ b/HIRS_Utils/src/main/java/hirs/utils/digest/AbstractDigest.java @@ -15,8 +15,8 @@ *

* Two classes were made to facilitate persisting them with Hibernate in different ways. * To persist non-nullable entries in an embedded collection, use {@link hirs.utils.digest.Digest} (see - * {@link TPMBaseline} for reference.) To persist nullable entries, - * use {@link hirs.utils.digest.OptionalDigest} (see {@link ImaBlacklistRecord} for reference.) + * TPMBaseline for reference.) To persist nullable entries, + * use {@link hirs.utils.digest.OptionalDigest} (see ImaBlacklistRecord for reference.) */ @Log4j2 public abstract class AbstractDigest { @@ -24,22 +24,27 @@ public abstract class AbstractDigest { * Length of MD2 digest. */ public static final int MD2_DIGEST_LENGTH = 16; + /** * Length of MD5 digest. */ public static final int MD5_DIGEST_LENGTH = 16; + /** * Length of SHA1 digest. */ public static final int SHA1_DIGEST_LENGTH = 20; + /** * Length of SHA256 digest. */ public static final int SHA256_DIGEST_LENGTH = 32; + /** * Length of SHA384 digest. */ public static final int SHA384_DIGEST_LENGTH = 48; + /** * Length of SHA512 digest. */ @@ -52,25 +57,19 @@ public abstract class AbstractDigest { * @param digest list of pcr values. * @return the associated algorithm. */ - public static final DigestAlgorithm getDigestAlgorithm(final byte[] digest) { + public static DigestAlgorithm getDigestAlgorithm(final byte[] digest) { if (digest == null || ArrayUtils.isEmpty(digest)) { return DigestAlgorithm.UNSPECIFIED; } - switch (digest.length) { - case MD2_DIGEST_LENGTH: - return DigestAlgorithm.MD5; - case SHA1_DIGEST_LENGTH: - return DigestAlgorithm.SHA1; - case SHA256_DIGEST_LENGTH: - return DigestAlgorithm.SHA256; - case SHA384_DIGEST_LENGTH: - return DigestAlgorithm.SHA384; - case SHA512_DIGEST_LENGTH: - return DigestAlgorithm.SHA512; - default: - return DigestAlgorithm.UNSPECIFIED; - } + return switch (digest.length) { + case MD2_DIGEST_LENGTH -> DigestAlgorithm.MD5; + case SHA1_DIGEST_LENGTH -> DigestAlgorithm.SHA1; + case SHA256_DIGEST_LENGTH -> DigestAlgorithm.SHA256; + case SHA384_DIGEST_LENGTH -> DigestAlgorithm.SHA384; + case SHA512_DIGEST_LENGTH -> DigestAlgorithm.SHA512; + default -> DigestAlgorithm.UNSPECIFIED; + }; } /** @@ -80,7 +79,7 @@ public static final DigestAlgorithm getDigestAlgorithm(final byte[] digest) { * @param digest list of pcr values. * @return the associated algorithm. */ - public static final DigestAlgorithm getDigestAlgorithm(final String digest) { + public static DigestAlgorithm getDigestAlgorithm(final String digest) { try { return getDigestAlgorithm(Hex.decodeHex(digest.toCharArray())); } catch (Exception deEx) { diff --git a/HIRS_Utils/src/main/java/hirs/utils/digest/package-info.java b/HIRS_Utils/src/main/java/hirs/utils/digest/package-info.java index 2d2e9eca2..252552b44 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/digest/package-info.java +++ b/HIRS_Utils/src/main/java/hirs/utils/digest/package-info.java @@ -1 +1,4 @@ +/** + * Contains all classes and supporting files that represent the digest event. + */ package hirs.utils.digest; diff --git a/HIRS_Utils/src/main/java/hirs/utils/enums/ComponentType.java b/HIRS_Utils/src/main/java/hirs/utils/enums/ComponentType.java deleted file mode 100644 index d896b1268..000000000 --- a/HIRS_Utils/src/main/java/hirs/utils/enums/ComponentType.java +++ /dev/null @@ -1,85 +0,0 @@ -package hirs.utils.enums; - -public enum ComponentType { - - /** - * Baseboard. - */ - BASEBOARD(Values.BASEBOARD), - /** - * BIOS or UEFI. - */ - BIOS_UEFI(Values.BIOS_UEFI), - /** - * Chassis. - */ - CHASSIS(Values.CHASSIS), - /** - * Hard Drive. - */ - HARD_DRIVE(Values.HARD_DRIVE), - /** - * Memory. - */ - MEMORY(Values.MEMORY), - /** - * Network Interface Card. - */ - NIC(Values.NIC), - /** - * Processor. - */ - PROCESSOR(Values.PROCESSOR); - - /** - * Constructor. - * - * @param val string value - */ - ComponentType(final String val) { - if (!this.name().equals(val)) { - throw new IllegalArgumentException("Incorrect use of ComponentType"); - } - } - - /** - * String values for use in {@link ComponentType}. - */ - public static class Values { - - /** - * Baseboard. - */ - public static final String BASEBOARD = "BASEBOARD"; - - /** - * BIOS or UEFI. - */ - public static final String BIOS_UEFI = "BIOS_UEFI"; - - /** - * Chassis. - */ - public static final String CHASSIS = "CHASSIS"; - - /** - * Hard Drive. - */ - public static final String HARD_DRIVE = "HARD_DRIVE"; - - /** - * Memory. - */ - public static final String MEMORY = "MEMORY"; - - /** - * Network Interface Card. - */ - public static final String NIC = "NIC"; - - /** - * Processor. - */ - public static final String PROCESSOR = "PROCESSOR"; - } -} diff --git a/HIRS_Utils/src/main/java/hirs/utils/enums/DeviceInfoEnums.java b/HIRS_Utils/src/main/java/hirs/utils/enums/DeviceInfoEnums.java index 418fb0594..7c2f058d9 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/enums/DeviceInfoEnums.java +++ b/HIRS_Utils/src/main/java/hirs/utils/enums/DeviceInfoEnums.java @@ -1,19 +1,25 @@ package hirs.utils.enums; +/** + * Enum values that are used for the embedded info objects. + */ public final class DeviceInfoEnums { /** * A variable used to describe unavailable hardware, firmware, or OS info. */ public static final String NOT_SPECIFIED = "Not Specified"; + /** * Constant variable representing the various Short sized strings. */ public static final int SHORT_STRING_LENGTH = 32; + /** * Constant variable representing the various Medium sized strings. */ public static final int MED_STRING_LENGTH = 64; + /** * Constant variable representing the various Long sized strings. */ diff --git a/HIRS_Utils/src/main/java/hirs/utils/enums/package-info.java b/HIRS_Utils/src/main/java/hirs/utils/enums/package-info.java index 3ff5c9ba5..b21dcf0d9 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/enums/package-info.java +++ b/HIRS_Utils/src/main/java/hirs/utils/enums/package-info.java @@ -1 +1,4 @@ +/** + * Contains all the generic enums that are used throughout the HIRS UTILS module. + */ package hirs.utils.enums; diff --git a/HIRS_Utils/src/main/java/hirs/utils/tpm/TPMBaselineGeneratorException.java b/HIRS_Utils/src/main/java/hirs/utils/exception/TPMBaselineGeneratorException.java similarity index 94% rename from HIRS_Utils/src/main/java/hirs/utils/tpm/TPMBaselineGeneratorException.java rename to HIRS_Utils/src/main/java/hirs/utils/exception/TPMBaselineGeneratorException.java index 89485beaf..751773446 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/tpm/TPMBaselineGeneratorException.java +++ b/HIRS_Utils/src/main/java/hirs/utils/exception/TPMBaselineGeneratorException.java @@ -1,42 +1,42 @@ -package hirs.utils.tpm; - -/** - * This class represents an Exception generated by - * CreateTPMBaseline. - */ -public class TPMBaselineGeneratorException extends Exception { - - private static final long serialVersionUID = 8850867303391694668L; - - /** - * Creates a new CreateTPMBaselineException that has the - * message msg. - * - * @param msg exception message - */ - TPMBaselineGeneratorException(final String msg) { - super(msg); - } - - /** - * Creates a new CreateTPMBaselineException that wraps the - * given Throwable. - * - * @param t root cause - */ - TPMBaselineGeneratorException(final Throwable t) { - super(t); - } - - /** - * Creates a new CreateTPMBaselineException that has the - * message msg and wraps the root cause. - * - * @param msg exception message - * @param t root cause - */ - TPMBaselineGeneratorException(final String msg, final Throwable t) { - super(msg, t); - } - -} +package hirs.utils.exception; + +/** + * This class represents an Exception generated by + * CreateTPMBaseline. + */ +public class TPMBaselineGeneratorException extends Exception { + + private static final long serialVersionUID = 8850867303391694668L; + + /** + * Creates a new CreateTPMBaselineException that has the + * message msg. + * + * @param msg exception message + */ + TPMBaselineGeneratorException(final String msg) { + super(msg); + } + + /** + * Creates a new CreateTPMBaselineException that wraps the + * given Throwable. + * + * @param t root cause + */ + TPMBaselineGeneratorException(final Throwable t) { + super(t); + } + + /** + * Creates a new CreateTPMBaselineException that has the + * message msg and wraps the root cause. + * + * @param msg exception message + * @param t root cause + */ + TPMBaselineGeneratorException(final String msg, final Throwable t) { + super(msg, t); + } + +} diff --git a/HIRS_Utils/src/main/java/hirs/utils/exception/package-info.java b/HIRS_Utils/src/main/java/hirs/utils/exception/package-info.java index 464dea8c2..215e46d56 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/exception/package-info.java +++ b/HIRS_Utils/src/main/java/hirs/utils/exception/package-info.java @@ -1 +1,4 @@ +/** + * Contains all the exceptions that are used in the HIRS Utils module. + */ package hirs.utils.exception; diff --git a/HIRS_Utils/src/main/java/hirs/utils/package-info.java b/HIRS_Utils/src/main/java/hirs/utils/package-info.java index 361ebc748..9b9ea208d 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/package-info.java +++ b/HIRS_Utils/src/main/java/hirs/utils/package-info.java @@ -1 +1,5 @@ +/** + * Contains all the utility classes, enums and other supporting files that are used to support HIRS + * application. + */ package hirs.utils; diff --git a/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/GenericRim.java b/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/GenericRim.java index 9bce0d476..73b91c95c 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/GenericRim.java +++ b/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/GenericRim.java @@ -14,12 +14,12 @@ *

  • SIGTYPE_COSE: IETF RFC 9052 defined CBOR Signatures * (https://datatracker.ietf.org/doc/html/rfc9052)
  • *
  • SIGTYPE_DSIG: W3C Defined Signatures for XML (https://www.w3.org/TR/xmldsig-core1/)
  • - *

    + * *

    Unsigned RIM Types used for PC *

      *
    • RIMTYPE_PCRIM: TCG Defined PC Client RIM which uses SWID
    • *
    • RIMTYPE_COMP_SWID: TCG Component-RIM which uses SWID
    • - *

    + * *

    Unsigned RIM Types used for PC Components *

      *
    • RIMTYPE_COSWID: IETF RFC 9393 defined CoSWID (Concise SWID) tags
    • @@ -27,38 +27,56 @@ *
    • RIMTYPE_CORIM_COMID: IETF CoRIM (Concise RIM) which envelopes a comid
    • *
    • RIMTYPE_CORIM_COSWID: IETF CoRIM which envelopes a CoSWID
    • *
    - *

    */ public interface GenericRim { // Signature types - /** Signature type COSE. */ + /** + * Signature type COSE. + */ String SIGTYPE_COSE = "cose"; - /** Signature type DSIG. */ + /** + * Signature type DSIG. + */ String SIGTYPE_DSIG = "dsig"; // Unsigned RIM Types used for PC - /** RIM type PC RIM. */ + /** + * RIM type PC RIM. + */ String RIMTYPE_PCRIM = "pcrim"; - /** RIM type CoSWID. */ + /** + * RIM type CoSWID. + */ String RIMTYPE_COMP_SWID = "comp_swid"; // Unsigned RIM Types used for PC Components - /** RIM type TCG Comp RIM CoSWID. */ + /** + * RIM type TCG Comp RIM CoSWID. + */ String RIMTYPE_COSWID = "coswid"; - /** RIM type TCG Comp RIM SWID. */ + /** + * RIM type TCG Comp RIM SWID. + */ String RIMTYPE_COMP_COSWID = "comp_coswid"; - /** RIM type CORIM-COMID. */ + /** + * RIM type CORIM-COMID. + */ String RIMTYPE_CORIM_COMID = "corim_comid"; - /** RIM type CORIM-CoSWID. */ + /** + * RIM type CORIM-CoSWID. + */ String RIMTYPE_CORIM_COSWID = "corim_coswid"; - /** Human-readable string listing RIM types available. */ + /** + * Human-readable string listing RIM types available. + */ String RIMTYPES_AVAILABLE = RIMTYPE_PCRIM + " " + RIMTYPE_COSWID + " " + RIMTYPE_COMP_SWID + " " + RIMTYPE_COMP_COSWID + " " + RIMTYPE_CORIM_COMID + " " + RIMTYPE_CORIM_COSWID + "."; /** * Returns the signature type options. + * * @return the signature type options */ static String getValidSigTypes() { @@ -67,6 +85,7 @@ static String getValidSigTypes() { /** * Returns signature type of RIM. + * * @param rimType the RIM type * @return the signature type */ @@ -84,6 +103,7 @@ static String getSigType(String rimType) { /** * Returns a unique identifier String describing the type of RIM. + * * @return the RIM type */ String getRimType(); @@ -91,12 +111,14 @@ static String getSigType(String rimType) { /** * Returns a unique identifier String (Manufacturer+Model in most cases) * or perhaps hash of a string to use as a DB lookup value for the RIMs Digests and the RIM itself. + * * @return the Rim ID */ String getRimID(); /** * Retrieves the Signer info for the RIM. + * * @return String representing the SKID of the RIM Signer */ String getSignerId(); @@ -106,24 +128,28 @@ static String getSigType(String rimType) { * Should include signature checks, content checks, and formatting checks * Requires a cert chain to verify the RIMs signature * SignerId would provide the reference for the ACA to look up the certs + * * @return true if valid, false if not */ boolean isValid(); /** * Returns a list of Measurement objects for given RIM identifier that were found in payload (if any). - * @return List that holds the reference measurements + * + * @return reference measurements */ List getReferenceMeasurements(); /** * ReferencedRims is a list of RimId references found in the payload (if any). + * * @return the string of RIMId references */ String getReferencedRims(); /** * Produces an object specific string with info about the object. + * * @return the human-readable string */ String toString(); diff --git a/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/cbor/ietfCorim/CoRimDigest.java b/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/cbor/ietfCorim/CoRimDigest.java index bc41ce061..b58dd0156 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/cbor/ietfCorim/CoRimDigest.java +++ b/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/cbor/ietfCorim/CoRimDigest.java @@ -1,26 +1,26 @@ package hirs.utils.rim.unsignedRim.cbor.ietfCorim; -import java.util.ArrayList; -import java.util.List; - import com.authlete.cbor.CBORByteArray; import com.authlete.cbor.CBORInteger; import com.authlete.cbor.CBORItem; import com.authlete.cbor.CBORItemList; - import lombok.Getter; import lombok.Setter; +import java.util.ArrayList; +import java.util.List; + /** * Represents a {@code digest} containing hash information relevant to CoMID * measurements. See Section 7.7 of the IETF CoRIM specification. *

    * Note that this is conceptually the same as - * {@link hirs.rim.unsignedRim.cbor.ietfCorim.comid.ComidDigest}, though this + * {@link hirs.utils.rim.unsignedRim.cbor.ietfCorim.comid.ComidDigest}, though this * class is used exclusively for CoRIM CBOR building. */ public class CoRimDigest { - @Getter @Setter + @Getter + @Setter private int alg; private byte[] val; diff --git a/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/cbor/ietfCoswid/Coswid.java b/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/cbor/ietfCoswid/Coswid.java index 667df11cf..a50afc5af 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/cbor/ietfCoswid/Coswid.java +++ b/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/cbor/ietfCoswid/Coswid.java @@ -15,16 +15,25 @@ * Class that holds CoSWID (rfc 9393) Defined attributes, attribute names, and assigned indexes. * All variable names match those defined in rfc 9393. */ -@Setter @Getter +@Setter +@Getter public class Coswid extends Swid implements GenericRim { - /** Reference to the primary CoSWID JsonNode object. */ + /** + * IANA CBOR registry define Coswid Tag. + */ + @Setter + public static int coswidTag = 1398229316; + /** + * Reference to the primary CoSWID JsonNode object. + */ protected JsonNode rootNode = null; - /** Reference to a Payload JsonNode object. */ - protected JsonNode payloadNode = null; // CoSWID defined attributes (not Sets or Arrays) found in rfc 9393 // ------------------------------------ - + /** + * Reference to a Payload JsonNode object. + */ + protected JsonNode payloadNode = null; // concise-swid-tag map protected String tagId = null; protected String softwareName = null; @@ -36,27 +45,22 @@ public class Coswid extends Swid implements GenericRim { protected String softwareVersion = null; protected String softwareScheme = null; // versionScheme - // global-attributes group - protected String lang = null; - // resource-collection group // (reserved for future values) - + // global-attributes group + protected String lang = null; // entity-entry map protected String entityName = null; protected String regId = null; protected List roleCoswid = new ArrayList<>(); protected String thumbprint = null; - // evidence-entry map protected String date = null; protected String deviceId = null; - // link-entry map protected String ownership = null; protected String mediaType = null; protected String use = null; - // software-meta-entry map protected String activationStatus = null; protected String channelType = null; @@ -71,15 +75,13 @@ public class Coswid extends Swid implements GenericRim { protected String revision = null; protected String summary = null; protected String unspscCode = null; - protected String unspscVersion = null; // End CoSWID defined attributes // ----------------------------------------------------------------------- - + protected String unspscVersion = null; // Payload (including measurement) data protected String nonpayloadPrintOneline = null; protected String nonpayloadPrintPretty = null; - // Payload (including measurement) data protected String payloadPrintOneline = null; protected String payloadPrintPretty = null; @@ -87,65 +89,68 @@ public class Coswid extends Swid implements GenericRim { // List of hash measurements in this CoSWID and their associated data protected List measurements = new ArrayList<>(); - /** IANA CBOR registry define Coswid Tag.*/ - @Setter - public static int coswidTag = 1398229316; - /** * Returns a unique identifier String describing the type of RIM. + * * @return the RIM type */ public String getRimType() { return GenericRim.RIMTYPE_COSWID; - }; + } /** * Returns a unique identifier String (Manufacturer+Model in most cases) * or perhaps hash of a string to use as a DB lookup value for the RIMs Digests and the RIM itself. + * * @return the Rim ID */ public String getRimID() { return ""; // TBD - }; + } /** * Retrieves the Signer info for the RIM. + * * @return String representing the SKID of the RIM Signer */ public String getSignerId() { // signer ID does not apply to unsigned CoSWID return ""; - }; + } /** * Runs checks on the rim to check validity * Should include signature checks, content checks, and formatting checks. * Requires a cert chain to verify the RIMs signature. * SignerId would provide the reference for the ACA to look up the certs + * * @return true if valid, false if not */ public boolean isValid() { return false; // TODO - }; + } /** * Returns a list of Measurement objects for the given rim identifier that were found in the payload. - * @return List that holds the reference measurements + * + * @return the reference measurements */ public List getReferenceMeasurements() { return measurements; - }; + } /** * ReferencedRims is a list of RimId's references found in the payload (if any). - * @return String contianing a list of reference RIMs. + * + * @return String contianing a list of reference RIMs. */ public String getReferencedRims() { return ""; // TODO - }; + } /** * Default toString that contains all key/value pairs in the CoSWID data with no line breaks. + * * @return Human-readable form of the measurement */ public String measurementsToString() { @@ -162,6 +167,7 @@ public String measurementsToString() { /** * Default toString that contains all key/value pairs in the CoSWID data with no line breaks. + * * @return Human-readable form of this coswid objec */ public String toString() { @@ -170,6 +176,7 @@ public String toString() { /** * Prints the processed CoSWID data that was stored when initially parsed. + * * @param format options: "pretty" (default is anything else) * @return Human-readable form of this coswid object */ diff --git a/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/cbor/ietfCoswid/CoswidBuilder.java b/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/cbor/ietfCoswid/CoswidBuilder.java index 61d28874b..4b3383e07 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/cbor/ietfCoswid/CoswidBuilder.java +++ b/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/cbor/ietfCoswid/CoswidBuilder.java @@ -12,10 +12,10 @@ import java.io.IOException; import java.nio.file.Files; import java.util.ArrayList; +import java.util.HexFormat; import java.util.Iterator; import java.util.Map; import java.util.UUID; -import java.util.HexFormat; /** * Class that is used to build a Coswid file based upon values previously retrieved from a config file. @@ -27,11 +27,13 @@ public class CoswidBuilder extends Coswid { protected CoswidConfig config = null; protected IanaHashAlg algInfo = null; protected CoswidItems coswidItems = new CoswidItems(); + /** * Constructor for the Coswid Builder. * Configuration file is a json formatted file consisting of Coswid defined variables * to be encoded as Cbor items. - * @param conf Coswid Configuration file + * + * @param conf Coswid Configuration file */ public CoswidBuilder(final CoswidConfig conf) { config = conf; @@ -64,10 +66,13 @@ public CoswidBuilder(final CoswidConfig conf) { setProductFamily(config.getProductFamily()); setSummary(config.getSummary()); } + /** * Method for creating a Coswid Object. + * * @param out Byte array to write Coswid data to * @return updated Byte array. + * @throws IOException if an I/O error occurs during the COSWID data creation. */ public ByteArrayOutputStream createCoswidData(final ByteArrayOutputStream out) throws IOException { initCoswid(out); @@ -76,10 +81,13 @@ public ByteArrayOutputStream createCoswidData(final ByteArrayOutputStream out) t out.flush(); return out; } + /** * Method for creating a Coswid Object. * Note 1398229316 is the IANA CBOR Tag for coswid + * * @param fileName File name to place the encoded Coswid data + * @throws IOException if an I/O error occurs during the creation of the COSWID data. */ public void createCoswidData(final String fileName) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); @@ -94,10 +102,12 @@ public void createCoswidData(final String fileName) throws IOException { throw new RuntimeException(e); } } + /** * Encodes the Coswid variables within this class but does not finish the encoding. * This allows for addition of other objects by other classes. * Use completeCoswid to close the ByteArrayOutputStream for writing to a file. + * * @param out ByteArrayOutputStream to hold the encoded Coswid data * @return ByteArrayOutputStream that contains the encoded Coswid data */ @@ -151,6 +161,7 @@ public ByteArrayOutputStream initCoswid(final ByteArrayOutputStream out) { /** * Completes the encoding of the coswid data contained in a ByteArrayOutputStream object. + * * @param out ByteArrayOutputStream to hold the encoded Coswid data * @return ByteArrayOutputStream that contains the encoded Coswid data */ @@ -164,11 +175,13 @@ protected ByteArrayOutputStream completeCoswid(final ByteArrayOutputStream out) } return out; } + /** * Adds a string attribute to the ByteArrayOutputStream. + * * @param attribute String to hold the field value * @param fieldItem int : spec defined Coswid "index" for the item - * @param out ByteArrayOutputStream that holds the encoded Coswid object + * @param out ByteArrayOutputStream that holds the encoded Coswid object */ protected void addStringAttribute(final String attribute, final int fieldItem, final ByteArrayOutputStream out) { @@ -186,11 +199,13 @@ protected void addStringAttribute(final String attribute, final int fieldItem, throw new RuntimeException(e); } } + /** * Adds a string attribute to the ByteArrayOutputStream. + * * @param attribute Int to hold the field value * @param fieldItem int : spec defined Coswid "index" for the item - * @param out ByteArrayOutputStream that holds the encoded Coswid object + * @param out ByteArrayOutputStream that holds the encoded Coswid object */ protected void addIntAttribute(final int attribute, final int fieldItem, final ByteArrayOutputStream out) { @@ -201,8 +216,10 @@ protected void addIntAttribute(final int attribute, final int fieldItem, throw new RuntimeException(e); } } + /** * Adds a boolean attribute to the ByteArrayOutputStream. + * * @param attribute Boolean to hold the field value * @param fieldItem int : spec defined Coswid "index" for the item * @param out ByteArrayOutputStream that holds the encoded Coswid object @@ -216,8 +233,10 @@ protected void addBooleanAttribute(final boolean attribute, final int fieldItem, throw new RuntimeException(e); } } + /** * Adds the tagid to the encoded Coswid Object. + * * @param tagId String GUID * @param out ByteArrayOutputStream to add the tagid into. */ @@ -230,9 +249,11 @@ protected void addTagId(final String tagId, final ByteArrayOutputStream out) { throw new RuntimeException(e); } } + /** * Converts a comma separated string from the configuration file, converts each sting item to an int index * and encodes it as an array using the provided index as a array identifier. + * * @param roles comma separated string , each item must exactly match the role name in rfc9393 * @param roleIndex the dex value to use for the role array * @param out ByteArrayOutputStream to add the role array into @@ -254,6 +275,7 @@ protected void addRoles(final String roles, final int roleIndex, final ByteArray /** * Converts a tagid string (UUID) into a "16-byte binary string" per rfc 9393. + * * @param guid Global Unique Identifier * @return byte array holding the UUID */ @@ -269,27 +291,31 @@ protected byte[] convertUUIDtoBytes(final String guid) { } return bytes; } + /** * Uses the role string field name defined in rfc9393 to convert the index value. * This lookup is specific for roles defined in section 2.6 + * * @param role The index value defined in RFC-9393 for roles * @return role index */ protected int roleLookup(final String role) { return switch (role) { - case "tag-creator" -> 1; + case "tag-creator" -> 1; case "software-creator" -> 2; - case "aggregator" -> 3; - case "distributor" -> 4; - case "licensor" -> 5; - case "maintainer" -> 6; - default -> 0xff; + case "aggregator" -> 3; + case "distributor" -> 4; + case "licensor" -> 5; + case "maintainer" -> 6; + default -> 0xff; }; } + /** * Builds a Coswid payload based upon the Json based config file. + * * @param payloadNode A JSonNode pointing to the Payload of Json Config File - * @param out ByteArrayOutputStream that holds the encoded Coswid object + * @param out ByteArrayOutputStream that holds the encoded Coswid object */ protected void createPayload(final JsonNode payloadNode, final ByteArrayOutputStream out) { @@ -309,7 +335,7 @@ protected void createPayload(final JsonNode payloadNode, final ByteArrayOutputSt } else { JsonNode item = field.getValue(); String value = field.getValue().textValue(); - addStringAttribute(key, coswidItems.getIndex(value), out); + addStringAttribute(key, CoswidItems.getIndex(value), out); } cborGen.writeEndObject(); } @@ -317,10 +343,12 @@ protected void createPayload(final JsonNode payloadNode, final ByteArrayOutputSt throw new RuntimeException(e); } } + /** * Adds a Cbor directory based upon input from the Json Configuration file. - * @param node JsonNode to place the directory - * @param out ByteArrayOutputStream that holds the encoded Coswid object + * + * @param node JsonNode to place the directory + * @param out ByteArrayOutputStream that holds the encoded Coswid object * @throws IOException if an issue occur when updating cbor data */ protected void createDirectory(final JsonNode node, final ByteArrayOutputStream out) throws IOException { @@ -335,15 +363,17 @@ protected void createDirectory(final JsonNode node, final ByteArrayOutputStream prepFile(field.getValue(), out); } else { String value = field.getValue().textValue(); - addStringAttribute(value, coswidItems.getIndex(key), out); + addStringAttribute(value, CoswidItems.getIndex(key), out); } } cborGen.writeEndObject(); } + /** * Saves the current Coswid Data to A Byte array. + * * @param node cbor encoded data - * @param out ByteArrayOutputStream that holds the encoded Coswid object + * @param out ByteArrayOutputStream that holds the encoded Coswid object * @throws IOException if an issue occurs when creating or writing a file */ protected void prepFile(final JsonNode node, final ByteArrayOutputStream out) throws IOException { @@ -363,37 +393,38 @@ protected void prepFile(final JsonNode node, final ByteArrayOutputStream out) th String key = field.getKey(); if (key.compareToIgnoreCase(CoswidItems.FILE_STR) == 0) { String value = field.getValue().textValue(); - addStringAttribute(value, coswidItems.getIndex(key), out); + addStringAttribute(value, CoswidItems.getIndex(key), out); } else if (key.compareToIgnoreCase(CoswidItems.SIZE_STR) == 0) { int value = Integer.parseInt(field.getValue().textValue()); - addIntAttribute(value, coswidItems.getIndex(key), out); + addIntAttribute(value, CoswidItems.getIndex(key), out); } else if (key.compareToIgnoreCase(CoswidItems.HASH_STR) == 0) { String value = field.getValue().textValue(); createFileHash(out, value, IanaHashAlg.SHA_256); } else { String value = field.getValue().textValue(); - addStringAttribute(value, coswidItems.getIndex(key), out); + addStringAttribute(value, CoswidItems.getIndex(key), out); } } cborGen.writeEndObject(); } } + /** * Create a hash-entry array as specified i rfc 9393. * hash-entry = [ - * hash-alg-id: int, - * hash-value: bytes, + * hash-alg-id: int, + * hash-value: bytes, * ] * where hash-alg-id value is defined by Iana : - * https://www.iana.org/assignments/named-information/named-information.xhtml + * + * named-information + * * @param out ByteArrayOutputStream to add the tagid into. - * @param hash String holding the text representation of the hash value - * @param alg Iana registered algorithm ID - * @throws IOException if an issue occur when updating cbor data + * @param hash String holding the text representation of the hash value + * @param alg Iana registered algorithm ID */ - protected void createFileHash(final ByteArrayOutputStream out, final String hash, final IanaHashAlg alg) - throws IOException { - HexFormat hexTool = HexFormat.of(); + protected void createFileHash(final ByteArrayOutputStream out, final String hash, final IanaHashAlg alg) { + HexFormat hexTool = HexFormat.of(); int size = hash.length() / 2; byte[] hashByteArray = hexTool.parseHex(hash); @@ -408,14 +439,16 @@ protected void createFileHash(final ByteArrayOutputStream out, final String hash throw new RuntimeException(e); } } + /** * "1398229316" is a CBOR tag defined for coswid that gets written to the start of the Coswid object. * Cbor Tags are defined in https://www.iana.org/assignments/cbor-tags/cbor-tags.xhtml * Note in section 8 of RFC 9393 states that Coswid tags should be tagged but redundant tagging * should be avoided. - * @param untaggedCoswid Coswid Byte array to add the tag to - * @throws IOException if an issue occur when updating cbor data + * + * @param untaggedCoswid Coswid Byte array to add the tag to * @return Coswid Byte array with a Coswid CBOR tag added + * @throws IOException if an issue occur when updating cbor data */ public ByteArrayOutputStream addCborTag(final ByteArrayOutputStream untaggedCoswid) throws IOException { ByteArrayOutputStream taggedCoswid = new ByteArrayOutputStream(); diff --git a/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/cbor/tcgCompRimCoswid/TcgCompRimCoswidBuilder.java b/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/cbor/tcgCompRimCoswid/TcgCompRimCoswidBuilder.java index bfecd1381..341945397 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/cbor/tcgCompRimCoswid/TcgCompRimCoswidBuilder.java +++ b/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/cbor/tcgCompRimCoswid/TcgCompRimCoswidBuilder.java @@ -18,10 +18,11 @@ public class TcgCompRimCoswidBuilder extends CoswidBuilder { /** * Holds the TCG Component RIM Coswid. */ - private TcgCompRimCoswid tcRim = new TcgCompRimCoswid(); + private final TcgCompRimCoswid tcRim = new TcgCompRimCoswid(); /** * Constructor for the Component Rim Builder. + * * @param config TcgComponentRimConfig config created from a json file. */ public TcgCompRimCoswidBuilder(final TcgCompRimCoswidConfig config) { @@ -41,7 +42,9 @@ public TcgCompRimCoswidBuilder(final TcgCompRimCoswidConfig config) { /** * Writes a TCG Component RIM Coswid object to a file. + * * @param fileName file to hold the new TCG Component rim + * @throws IOException if any issues arise attempting to create a TCG Component RIM */ public void createTcgComponentRim(final String fileName) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); @@ -56,6 +59,7 @@ public void createTcgComponentRim(final String fileName) throws IOException { /** * Creates a TCG Component RIM Coswid object. + * * @param out ByteArrayOutputStream to wite the object to */ public void initTcgRim(final ByteArrayOutputStream out) { diff --git a/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/xml/pcclientrim/PcClientRim.java b/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/xml/pcclientrim/PcClientRim.java index 7bdf68ce6..1b559c8d5 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/xml/pcclientrim/PcClientRim.java +++ b/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/xml/pcclientrim/PcClientRim.java @@ -1,14 +1,18 @@ package hirs.utils.rim.unsignedRim.xml.pcclientrim; -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.rmi.RemoteException; -import java.util.ArrayList; -import java.util.HexFormat; -import java.util.List; -import java.util.UUID; +import hirs.utils.rim.ReferenceManifestValidator; +import hirs.utils.rim.unsignedRim.GenericRim; +import hirs.utils.rim.unsignedRim.common.measurement.Measurement; +import hirs.utils.swid.SwidTagConstants; +import hirs.utils.swid.SwidTagGateway; +import jakarta.xml.bind.JAXBContext; +import jakarta.xml.bind.JAXBException; +import jakarta.xml.bind.UnmarshalException; +import jakarta.xml.bind.Unmarshaller; +import lombok.NoArgsConstructor; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; import javax.xml.transform.Source; import javax.xml.transform.Transformer; @@ -18,21 +22,15 @@ import javax.xml.transform.dom.DOMResult; import javax.xml.transform.stream.StreamSource; import javax.xml.validation.Schema; - -import lombok.NoArgsConstructor; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; - -import hirs.utils.rim.unsignedRim.GenericRim; -import hirs.utils.rim.unsignedRim.common.measurement.Measurement; -import hirs.utils.swid.SwidTagConstants; -import hirs.utils.swid.SwidTagGateway; -import hirs.utils.rim.ReferenceManifestValidator; -import jakarta.xml.bind.JAXBContext; -import jakarta.xml.bind.JAXBException; -import jakarta.xml.bind.UnmarshalException; -import jakarta.xml.bind.Unmarshaller; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.rmi.RemoteException; +import java.util.ArrayList; +import java.util.HexFormat; +import java.util.List; +import java.util.UUID; /** * Class that holds a PC Client RIM. @@ -40,10 +38,11 @@ @NoArgsConstructor public class PcClientRim extends SwidTagGateway implements GenericRim { - private boolean isValid = false; - private Unmarshaller unmarshaller; private static final String SCHEMA_PACKAGE = "hirs.utils.xjc"; private static final String IDENTITY_TRANSFORM = "identity_transform.xslt"; + private final List measurements = new ArrayList<>(); + private boolean isValid = false; + private Unmarshaller unmarshaller; private Schema schema; private Document rim; // private Measurement measurement = new Measurement(); @@ -53,15 +52,16 @@ public class PcClientRim extends SwidTagGateway implements GenericRim { private String revision = ""; private String digest = ""; private UUID tagUuid = null; // private String tagId = ""; - private List measurements = new ArrayList<>();; /** * Validate a PC Client RIM. - * @param verifyFile RIM to verify + * + * @param verifyFile RIM to verify * @param certificateFile certificate - * @param rimel RIM event log - * @param trustStore certificate chain + * @param rimel RIM event log + * @param trustStore certificate chain * @return true if validated + * @throws IOException if there is an I/O error during the operation. */ public boolean validate(final String verifyFile, final String certificateFile, final String rimel, final String trustStore) throws IOException { @@ -136,6 +136,7 @@ public boolean validate(final String verifyFile, final String certificateFile, f /** * Get RIM type. + * * @return PC Client RIM */ @Override @@ -145,12 +146,13 @@ public String getRimType() { /** * Create a PC Client RIM. - * @param configFile config file - * @param rimEventLog event log + * + * @param configFile config file + * @param rimEventLog event log * @param certificateFile certificate - * @param privateKeyFile private key - * @param embeddedCert true if cert should be embedded - * @param outFile ouptut RIM + * @param privateKeyFile private key + * @param embeddedCert true if cert should be embedded + * @param outFile ouptut RIM */ public void create(final String configFile, final String rimEventLog, final String certificateFile, final String privateKeyFile, final boolean embeddedCert, final String outFile) { @@ -183,6 +185,7 @@ public void create(final String configFile, final String rimEventLog, final Stri /** * Default getRimID. + * * @return n/a */ @Override @@ -192,6 +195,7 @@ public String getRimID() { /** * Default getSignerId. + * * @return n/a */ @Override @@ -201,6 +205,7 @@ public String getSignerId() { /** * Default isValid. + * * @return n/a */ @Override @@ -210,6 +215,7 @@ public boolean isValid() { /** * Default getReferenceMeasurements. + * * @return n/a */ @Override @@ -219,6 +225,7 @@ public List getReferenceMeasurements() { /** * Default getReferencedRims. + * * @return n/a */ @Override @@ -228,6 +235,7 @@ public String getReferencedRims() { /** * Default toString. + * * @return n/a */ @Override @@ -264,7 +272,7 @@ private Document validateSwidtagSchema(final Document doc) { * @param source of the input xml. * @return Document representation of the xml. */ - private Document removeXMLWhitespace(final StreamSource source) throws IOException { + private Document removeXMLWhitespace(final StreamSource source) { TransformerFactory tf = TransformerFactory.newInstance(); Source identitySource = new StreamSource( ReferenceManifestValidator.class.getClassLoader().getResourceAsStream(IDENTITY_TRANSFORM)); diff --git a/HIRS_Utils/src/main/java/hirs/utils/signature/SignatureFormat.java b/HIRS_Utils/src/main/java/hirs/utils/signature/SignatureFormat.java index ed4293250..6547cf65d 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/signature/SignatureFormat.java +++ b/HIRS_Utils/src/main/java/hirs/utils/signature/SignatureFormat.java @@ -12,27 +12,36 @@ public interface SignatureFormat { /** * Creates a signature structure to be signed by a cryptographic engine. - * @param algId IANA registered COSE Algorithm String - * @param kid Key Identifier - * @param payload data to be placed in the payload - * @param signingCert signing cert to embed (if embedded parameter is set to true) + * + * @param algId IANA registered COSE Algorithm String + * @param kid Key Identifier + * @param payload data to be placed in the payload + * @param signingCert signing cert to embed (if embedded parameter is set to true) * @param useUnprotectedKid if supported and true kid will be placed in an unprotected header - * @param embedded if true embed a signing certificate - * @param rimType RIM type used to match a CoAP content-type + * @param embedded if true embed a signing certificate + * @param rimType RIM type used to match a CoAP content-type * @return byte array holding the to be signed data + * @throws IOException if there is an I/O error during the operation. + * @throws CertificateEncodingException if there is an error encoding the certificate. + * @throws NoSuchAlgorithmException if the specified algorithm is not available. */ byte[] createToBeSigned(int algId, byte[] kid, byte[] payload, X509Certificate signingCert, - boolean useUnprotectedKid, boolean embedded, String rimType) + boolean useUnprotectedKid, boolean embedded, String rimType) throws IOException, CertificateEncodingException, NoSuchAlgorithmException; /** * Adds a signature of the toBeSignedData to the Signature structure generated by a Cryptographic engine. + * * @param signature byte array holding signature data + * @throws IOException if there is an I/O error while adding signature. */ - void addSignature(byte[] signature) throws IOException; + void addSignature(byte[] signature) throws IOException; + /** * Gets the signed data after the signature has been added. - * @return byte array holding the signature structure with the payload + * + * @return byte array holding the signature structure with the payload + * @throws IOException if there is an I/O error while retrieving the signed data. */ byte[] getSignedData() throws IOException; diff --git a/HIRS_Utils/src/main/java/hirs/utils/signature/SignatureHelper.java b/HIRS_Utils/src/main/java/hirs/utils/signature/SignatureHelper.java index d1243beb6..e053ddd84 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/signature/SignatureHelper.java +++ b/HIRS_Utils/src/main/java/hirs/utils/signature/SignatureHelper.java @@ -16,23 +16,26 @@ public final class SignatureHelper { */ private SignatureHelper() { } + /** * Extracts the SKID from an X.509 certificate. * The TCG PC Client RIM and TCG Component RIM defines the key identifier as the * Subject Key identifier (SKID) of the certificate to be used for verification. * SKID is usually a hash of the public key. + * * @param signCert x.509 certificate * @return byte array holding the certificates SKID */ - public static byte[] getKidFromCert(final X509Certificate signCert) { - return signCert.getExtensionValue("2.5.29.14"); + public static byte[] getKidFromCert(final X509Certificate signCert) { + return signCert.getExtensionValue("2.5.29.14"); } /** * Extracts the COSE defined algorithm identifier associated with a certificates signing algorithm. + * * @param signCert X.509 certificate to extract the algorithm identifier from * @return a COSE defined algorithm identifier - * @throws NoSuchAlgorithmException + * @throws NoSuchAlgorithmException if the specified algorithm is not available */ public static int getCoseAlgFromCert(final X509Certificate signCert) throws NoSuchAlgorithmException { diff --git a/HIRS_Utils/src/main/java/hirs/utils/signature/cose/Cbor/CborBstr.java b/HIRS_Utils/src/main/java/hirs/utils/signature/cose/Cbor/CborBstr.java index c9195bd61..6c053cb64 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/signature/cose/Cbor/CborBstr.java +++ b/HIRS_Utils/src/main/java/hirs/utils/signature/cose/Cbor/CborBstr.java @@ -8,15 +8,17 @@ * Note: use getContent() to retrieve the data with the byteSting encoding stripped off. */ public class CborBstr { + private static final int typeMask = 0xE0; + private static final int infoMask = 0x1F; + private static final int shiftOffset = 0x05; + private static final int byteStringType = 0x02; + private static final int byteStringLength = 0x03; + private static final int coseNilByte = 0xa0; // Cose defined nil byte for empty payloads. private byte[] contents = null; - private static int typeMask = 0xE0; - private static int infoMask = 0x1F; - private static int shiftOffset = 0x05; - private static int byteStringType = 0x02; - private static int byteStringLength = 0x03; - private static int coseNilByte = 0xa0; // Cose defined nil byte for empty payloads. + /** * Constructor for the Cbor Byte String. + * * @param data data holding the Cbor Byte String data. */ public CborBstr(final byte[] data) { @@ -31,23 +33,24 @@ public CborBstr(final byte[] data) { contents = new byte[data.length - byteStringLength]; System.arraycopy(data, byteStringLength, contents, 0, data.length - byteStringLength); } + /** * Checks to see if byte array is a string. + * * @param data byte array holding the cbor data to check. - * @return true if the byte array holds a string. + * @return true if the byte array holds a string. */ public static boolean isByteString(final byte[] data) { byte type = data[0]; // Check if byte 0 is of major type 0x02 (Byte String) byte cborType = (byte) ((type & typeMask) >> shiftOffset); - if (cborType == byteStringType) { - return true; - } - return false; + return cborType == byteStringType; } + /** * Checks to see if a byte array is empty. - * @param data byte array to check. + * + * @param data byte array to check. * @return true of the byte array is empty. */ public static boolean isEmptyByteString(final byte[] data) { @@ -55,14 +58,13 @@ public static boolean isEmptyByteString(final byte[] data) { return false; } // per the cose spec 0xa0 is equivalent to {} - if ((data[3] & 0xFF) == coseNilByte) { - return true; - } - return false; + return (data[3] & 0xFF) == coseNilByte; } + /** * Processes byte string length rfc 8489. - * @param data + * + * @param data byte array representation of the data * @return length of the byte string in bytes */ public static int getByteStringLength(final byte[] data) { @@ -72,9 +74,9 @@ public static int getByteStringLength(final byte[] data) { if (tagInfo < CborTagProcessor.CBOR_ONE_BYTE_UNSIGNED_INT) { length = tagInfo; // values 0 to 0x17 } else if (tagInfo == CborTagProcessor.CBOR_ONE_BYTE_UNSIGNED_INT) { - length = (int) data[1]; + length = data[1]; } else if (tagInfo == CborTagProcessor.CBOR_TWO_BYTE_UNSIGNED_INT) { - byte[] tmpArray = {0, 0, data[1], data[2] }; + byte[] tmpArray = {0, 0, data[1], data[2]}; ByteBuffer buf = ByteBuffer.wrap(tmpArray); length = buf.getInt(); } else if (tagInfo == CborTagProcessor.CBOR_FOUR_BYTE_UNSIGNED_INT) { @@ -84,8 +86,10 @@ public static int getByteStringLength(final byte[] data) { } return length; } + /** * Determines length of the byte sting header per rfc 8489. + * * @param data byte array holding cbor data * @return length of the byte string tag in bytes */ @@ -93,7 +97,7 @@ public static int getByteStringTagLength(final byte[] data) { int length = 0; byte type = data[0]; byte tagInfo = (byte) (type & infoMask); - if (tagInfo < CborTagProcessor.CBOR_ONE_BYTE_UNSIGNED_INT) { + if (tagInfo < CborTagProcessor.CBOR_ONE_BYTE_UNSIGNED_INT) { length = 1; // values 0 to 0x17 } else if (tagInfo == CborTagProcessor.CBOR_ONE_BYTE_UNSIGNED_INT) { length = 2; @@ -104,8 +108,10 @@ public static int getByteStringTagLength(final byte[] data) { } return length; } + /** - * Removes a preceeding byte string from the byte array. + * Removes a preceding byte string from the byte array. + * * @param data bate array holding cbor data. * @return new byte array with the byte string stripped off. */ diff --git a/HIRS_Utils/src/main/java/hirs/utils/signature/cose/CoseHeader.java b/HIRS_Utils/src/main/java/hirs/utils/signature/cose/CoseHeader.java index fe6d49060..9dd838649 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/signature/cose/CoseHeader.java +++ b/HIRS_Utils/src/main/java/hirs/utils/signature/cose/CoseHeader.java @@ -3,7 +3,6 @@ import lombok.Getter; import lombok.Setter; -import java.io.IOException; import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.HashMap; @@ -11,28 +10,33 @@ import java.util.Map; /** - * Class to hold COSE header components common to both Protected and Unprotected headers, - * specified in rfc rfc8152 (https://datatracker.ietf.org/doc/html/rfc8152#section-3.1). + * Class to hold COSE header components common to both Protected and Unprotected headers, specified in + * rfc rfc8152 (rfc rfc8152). */ public class CoseHeader { @Setter @Getter protected String algIdentifier = ""; + @Setter @Getter protected String keyIdentifier = ""; + @Setter @Getter protected String contentType = ""; + protected Map parameters = null; + protected List x5chain = null; /** * Prints the processed COSE Header data that is common to both Protected and Unprotected headers. + * * @return a formated string representation of the data in the COSE header object */ - public String printHeaderCommonContentsPretty() throws IOException { + public String printHeaderCommonContentsPretty() { String returnString = ""; if (!algIdentifier.isEmpty()) { diff --git a/HIRS_Utils/src/main/java/hirs/utils/signature/cose/CoseHeaderProtected.java b/HIRS_Utils/src/main/java/hirs/utils/signature/cose/CoseHeaderProtected.java index bb5d8a1ff..395723d2f 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/signature/cose/CoseHeaderProtected.java +++ b/HIRS_Utils/src/main/java/hirs/utils/signature/cose/CoseHeaderProtected.java @@ -9,6 +9,7 @@ import hirs.utils.rim.unsignedRim.cbor.ietfCorim.CoRim; import hirs.utils.rim.unsignedRim.cbor.ietfCorim.MetaMap; import lombok.Getter; + import java.io.IOException; import java.util.Iterator; import java.util.List; @@ -20,7 +21,7 @@ public class CoseHeaderProtected extends CoseHeader { // criticality @Getter - private String crit = ""; + private final String crit = ""; // CBor Pairs (currently only 2 being processed: metamap and x5t for corim) private MetaMap mmap = null; @Getter @@ -28,8 +29,10 @@ public class CoseHeaderProtected extends CoseHeader { @Getter private String x5tHashVal = ""; private String toStringCborDiag = ""; + /** * Parser constructor to fill class variables. + * * @param pheader COSEUnprotectedHeader holding the COSE protected header */ public CoseHeaderProtected(final COSEProtectedHeader pheader) { @@ -79,21 +82,27 @@ public CoseHeaderProtected(final COSEProtectedHeader pheader) { } } } + /** * Default toString. + * * @return default "pretty" version */ - public String toString() { + public String toString() { try { return toString("pretty"); } catch (IOException e) { throw new RuntimeException(e); } } + /** * Prints the processed COSE Protected Header data. - * @param format empty (default String) or "pretty" + * + * @param format empty (default String) or "pretty" * @return a formated string representation of the data in the COSE protected header object + * @throws IOException if any issues trying to create the string representation of the COSE Protected + * Header object. */ public String toString(final String format) throws IOException { String returnString = ""; diff --git a/HIRS_Utils/src/main/java/hirs/utils/signature/cose/CoseParser.java b/HIRS_Utils/src/main/java/hirs/utils/signature/cose/CoseParser.java index 842ff4717..29b2113c0 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/signature/cose/CoseParser.java +++ b/HIRS_Utils/src/main/java/hirs/utils/signature/cose/CoseParser.java @@ -1,19 +1,20 @@ package hirs.utils.signature.cose; -import com.authlete.cbor.CBORItem; import com.authlete.cbor.CBORDecoder; +import com.authlete.cbor.CBORItem; +import com.authlete.cose.COSEException; +import com.authlete.cose.COSEProtectedHeader; import com.authlete.cose.COSESign1; import com.authlete.cose.COSEUnprotectedHeader; -import com.authlete.cose.COSEProtectedHeader; -import com.authlete.cose.COSEException; import hirs.utils.rim.unsignedRim.cbor.ietfCorim.CoRim; import hirs.utils.rim.unsignedRim.cbor.ietfCorim.CoRimParser; import hirs.utils.rim.unsignedRim.cbor.ietfCoswid.Coswid; -import hirs.utils.signature.cose.Cbor.CborTagProcessor; import hirs.utils.rim.unsignedRim.cbor.tcgCompRimCoswid.TcgCompRimCoswidParser; import hirs.utils.signature.cose.Cbor.CborBstr; +import hirs.utils.signature.cose.Cbor.CborTagProcessor; import lombok.Getter; import lombok.Setter; + import java.io.IOException; import java.util.ArrayList; @@ -24,24 +25,36 @@ public class CoseParser { @Setter @Getter private int coseTag = 0; + private byte[] toBeSigned = null; + private byte[] payload = null; + private byte[] signature = null; + @Setter @Getter private String algIdentifier = ""; + private byte[] keyIdBytes = null; + @Setter @Getter private String keyIdentifier = ""; + private CoseHeaderProtected coseHeaderP = null; + private CoseHeaderUnprotected coseHeaderU = null; + @Getter private String contentType = ""; + private byte[] protectedHeaders = null; + @Setter @Getter private String toStringCborDiag = ""; + private CborTagProcessor cborTag = null; /** @@ -51,6 +64,7 @@ public class CoseParser { * If alg is not found, an error will be thrown. * Key Identifier (kid) should be in the protected header but can be in the unprotected header, * or not provided. + * * @param coseData Byte array holding the COSE data */ public CoseParser(final byte[] coseData) { @@ -113,11 +127,26 @@ public CoseParser(final byte[] coseData) { } } + /** + * Method to print hex data. + * + * @param data byte containing hex data to be print + * @return String containing hex representation of the data + */ + public static String hexToString(final byte[] data) { + StringBuilder sb2 = new StringBuilder(); + for (byte b : data) { + sb2.append(String.format("%02X", b)); + } + return sb2.toString(); + } + /** * Checks the payload for a valid tag. * by parsing the first byte of the payload as a tag * and checking for one of the supported tags by this application * If a supported tag is found the payload and coswid tag references are adjusted + * * @param payloadData * @return true if a valid tag is found */ @@ -134,22 +163,10 @@ private boolean checkForTag(final byte[] payloadData) { return tagFound; } - /** - * Method to print hex data. - * @param data byte containing hex data to be print - * @return String containing hex representation of the data - */ - public static String hexToString(final byte[] data) { - StringBuilder sb2 = new StringBuilder(); - for (byte b : data) { - sb2.append(String.format("%02X", b)); - } - return sb2.toString(); - } - /** * Looks up the COSE types defined in Table 1 of RFC 9052. * Also processes CoRim options for COSE. + * * @param tag the CBOR Tag (int) defined in Table 1 * @return a String defined in Table 1 that corresponds to the tag */ @@ -162,21 +179,29 @@ public String coseTagLookup(final int tag) { final int coseMac0 = 17; switch (tag) { - case coseSign: return "cose-sign"; - case coseSignOne: return "cose-sign1"; - case coseEncrypt: return "cose-encrypt"; - case coseEncrypt0: return "cose-encrypt0"; - case coseMac: return "cose-mac"; - case coseMac0: return "cose-mac0"; - default: return CoRim.getTagLabel(tag); + case coseSign: + return "cose-sign"; + case coseSignOne: + return "cose-sign1"; + case coseEncrypt: + return "cose-encrypt"; + case coseEncrypt0: + return "cose-encrypt0"; + case coseMac: + return "cose-mac"; + case coseMac0: + return "cose-mac0"; + default: + return CoRim.getTagLabel(tag); } } /** * Default toString. + * * @return default "pretty" version */ - public String toString() { + public String toString() { try { return toString("pretty"); } catch (IOException e) { @@ -186,12 +211,15 @@ public String toString() { /** * Creates human-readable text from a Cose Object. + * * @param format empty (default String) or "pretty" * @return a formated string representation of the data in the COSE object + * @throws IOException if issues arrise while trying to create the string representation + * of the provided string format. */ public String toString(final String format) throws IOException { String returnString = ""; - final int lineLength = 100; + final int lineLength = 100; if (format.compareToIgnoreCase("pretty") == 0) { returnString = " COSE Signed object:\n"; returnString += " tag = " + coseTagLookup(coseTag) + "\n"; @@ -199,7 +227,7 @@ public String toString(final String format) throws IOException { returnString += coseHeaderU.toString("pretty"); returnString += "COSE Payload: " + "\n"; if (contentType.compareToIgnoreCase("application/rim+cbor") == 0) { - returnString += " Processing payload as CoRim:" + "\n"; + returnString += " Processing payload as CoRim:" + "\n"; CoRimParser cparser = new CoRimParser(payload); returnString += cparser.toString(); } else if (!cborTag.isTagged()) { @@ -233,6 +261,7 @@ public String toString(final String format) throws IOException { /** * Returns a copy of the toBeSigned bytes. + * * @return copy of toBeSigned */ public byte[] getToBeSigned() { @@ -241,6 +270,7 @@ public byte[] getToBeSigned() { /** * Sets a copy of the toBeSigned bytes. + * * @param toBeSigned byte array to set */ public void setToBeSigned(final byte[] toBeSigned) { @@ -249,6 +279,7 @@ public void setToBeSigned(final byte[] toBeSigned) { /** * Returns a copy of the payload bytes. + * * @return copy of payload */ public byte[] getPayload() { @@ -257,6 +288,7 @@ public byte[] getPayload() { /** * Sets a copy of the payload bytes. + * * @param payload byte array to set */ public void setPayload(final byte[] payload) { @@ -265,6 +297,7 @@ public void setPayload(final byte[] payload) { /** * Returns a copy of the signature bytes. + * * @return copy of signature */ public byte[] getSignature() { @@ -273,6 +306,7 @@ public byte[] getSignature() { /** * Sets a copy of the signature bytes. + * * @param signature byte array to set */ public void setSignature(final byte[] signature) { @@ -281,6 +315,7 @@ public void setSignature(final byte[] signature) { /** * Returns a copy of the keyIdBytes. + * * @return copy of keyIdBytes */ public byte[] getKeyIdBytes() { @@ -289,6 +324,7 @@ public byte[] getKeyIdBytes() { /** * Sets a copy of the keyIdBytes. + * * @param keyIdBytes byte array to set */ public void setKeyIdBytes(final byte[] keyIdBytes) { @@ -297,6 +333,7 @@ public void setKeyIdBytes(final byte[] keyIdBytes) { /** * Returns a copy of the protected headers. + * * @return copy of protected headers */ public byte[] getProtectedHeaders() { @@ -305,6 +342,7 @@ public byte[] getProtectedHeaders() { /** * Sets a copy of the protected headers. + * * @param protectedHeaders byte array to set */ public void setProtectedHeaders(final byte[] protectedHeaders) { diff --git a/HIRS_Utils/src/main/java/hirs/utils/signature/cose/CoseSignature.java b/HIRS_Utils/src/main/java/hirs/utils/signature/cose/CoseSignature.java index df507a90b..85fc64d7d 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/signature/cose/CoseSignature.java +++ b/HIRS_Utils/src/main/java/hirs/utils/signature/cose/CoseSignature.java @@ -1,64 +1,66 @@ package hirs.utils.signature.cose; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import java.io.IOException; -import java.util.Arrays; -import java.util.Objects; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.security.cert.CertificateEncodingException; -import java.security.cert.X509Certificate; -import java.util.ArrayList; -import java.util.List; import com.authlete.cbor.CBORByteArray; +import com.authlete.cbor.CBORDecoder; import com.authlete.cbor.CBORInteger; import com.authlete.cbor.CBORItem; import com.authlete.cbor.CBORItemList; -import com.authlete.cbor.CBORDecoder; -import com.authlete.cbor.CBORTaggedItem; import com.authlete.cbor.CBORNull; -import com.authlete.cose.COSESign1; -import com.authlete.cose.COSEUnprotectedHeader; +import com.authlete.cbor.CBORTaggedItem; +import com.authlete.cose.COSEException; import com.authlete.cose.COSEProtectedHeader; import com.authlete.cose.COSEProtectedHeaderBuilder; -import com.authlete.cose.COSEUnprotectedHeaderBuilder; -import com.authlete.cose.COSEException; +import com.authlete.cose.COSESign1; import com.authlete.cose.COSESign1Builder; +import com.authlete.cose.COSEUnprotectedHeader; +import com.authlete.cose.COSEUnprotectedHeaderBuilder; import com.authlete.cose.SigStructure; import com.authlete.cose.SigStructureBuilder; import hirs.utils.signature.SignatureFormat; import hirs.utils.signature.SignatureHelper; import hirs.utils.signature.cose.Cbor.CborContentTypes; import hirs.utils.signature.cose.Cbor.CborTagProcessor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import java.io.IOException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.security.cert.CertificateEncodingException; +import java.security.cert.X509Certificate; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; + /** * Class for implementing rfc rfc9052 CBOR Object Signing and Encryption (COSE) * Refer to https://datatracker.ietf.org/doc/html/rfc9053 - * + *

    * COSE_Sign = [ - * Headers, - * payload : bstr / nil, - * signatures : [+ COSE_Signature] - * ] - * From section 4.4 of rfc 9052 "How to compute a signature: - * 1. Create a Sig_structure and populate it with the appropriate fields. - * 2. Create the value ToBeSigned by encoding the Sig_structure to a - * byte string, using the encoding described in Section 9. - * 3. Call the signature creation algorithm, passing in K (the key to - * sign with), alg (the algorithm to sign with), and ToBeSigned (the value to sign). - * 4. Strip off the DER encoding from the Signature field placed on by - * Java.Security. Even though RFC 9052 does not specify a format, - * The COSE Working Groups test patterns use a "Raw" (IEEE P1363) format. - * 5. Place the resulting signature value in the correct location. - * This is the "signature" field of the COSE_Signature or COSE_Sign1 structure. + * Headers, + * payload : bstr / nil, + * signatures : [+ COSE_Signature] + * ] + * From section 4.4 of rfc 9052 "How to compute a signature: + * 1. Create a Sig_structure and populate it with the appropriate fields. + * 2. Create the value ToBeSigned by encoding the Sig_structure to a + * byte string, using the encoding described in Section 9. + * 3. Call the signature creation algorithm, passing in K (the key to + * sign with), alg (the algorithm to sign with), and ToBeSigned (the value to sign). + * 4. Strip off the DER encoding from the Signature field placed on by + * Java.Security. Even though RFC 9052 does not specify a format, + * The COSE Working Groups test patterns use a "Raw" (IEEE P1363) format. + * 5. Place the resulting signature value in the correct location. + * This is the "signature" field of the COSE_Signature or COSE_Sign1 structure. */ @NoArgsConstructor public class CoseSignature implements SignatureFormat { + private static final Logger LOGGER = LogManager.getLogger(CoseSignature.class); // COSE Generic Header @Setter @Getter @@ -69,21 +71,36 @@ public class CoseSignature implements SignatureFormat { private byte[] keyId = null; private byte[] protectedHeaders = null; private COSESign1Builder coseBuilder = null; - private static final Logger LOGGER = LogManager.getLogger(CoseSignature.class); + + /** + * Obtain the SHA-256 thumbprint of an X.509 certificate (used for embedding). + * + * @param cert The input X.509 certificate. + * @return The SHA-256 thumbprint corresponding to the certificate. + * @throws NoSuchAlgorithmException if the SHA-256 algorithm is unsupported + * @throws CertificateEncodingException if the certificate cannot be encoded to DER + */ + public static byte[] getThumbprint(final X509Certificate cert) throws NoSuchAlgorithmException, + CertificateEncodingException { + MessageDigest md = MessageDigest.getInstance("SHA-256"); + md.update(cert.getEncoded()); + return md.digest(); + } /** * Create toBeSigned using supplied kid and algorithm for testing only. * Kid will be assigned to the unprotected header for tests. - * @param algId IANA registered COSE Algorithm String - * @param kid Key Identifier - * @param payload data to be placed in the payload - * @param signingCert a signing certificate used if the embedded parameter is true - * @param embedded if true, embeds the signing certificate and thumbprint per RFC 9360 - * @param rimType the type of RIM, for use with the protected header content-type + * + * @param algId IANA registered COSE Algorithm String + * @param kid Key Identifier + * @param payload data to be placed in the payload + * @param signingCert a signing certificate used if the embedded parameter is true + * @param embedded if true, embeds the signing certificate and thumbprint per RFC 9360 + * @param rimType the type of RIM, for use with the protected header content-type * @param useUnprotectedKid will place kid in unprotected header if true * @return the COSE_Sign1 toBeSigned data - * @throws CertificateEncodingException - * @throws NoSuchAlgorithmException + * @throws CertificateEncodingException if an error occurs during certificate encoding or decoding. + * @throws NoSuchAlgorithmException if the requested algorithm is not available in the system. */ public byte[] createToBeSigned(final int algId, final byte[] kid, final byte[] payload, final X509Certificate signingCert, final boolean useUnprotectedKid, @@ -133,12 +150,14 @@ public byte[] createToBeSigned(final int algId, final byte[] kid, final byte[] p /** * Follows the "The steps for verifying a signature are" of section 4.4. of rfc9052 Signing * and Verification Process. - * https://datatracker.ietf.org/doc/html/rfc9052#section-4.4 - * Steps 1 and 2. - * Note that step 3 (verify, the final step) is handled by a Cryptographic Engine + * rfc9052 Signing + * * and Verification Process + * Steps 1 and 2. + * Note that step 3 (verify, the final step) is handled by a Cryptographic Engine * * @param coseData byte array holding the data to be verified * @return toBeVerified data + * @throws IOException if an I/O error occurs during processing. */ public byte[] getToBeVerified(final byte[] coseData) throws IOException { processCose(coseData, true); @@ -150,10 +169,11 @@ public byte[] getToBeVerified(final byte[] coseData) throws IOException { * used for signature verification. * Uses the protected header from the signed structure and the supplied payload * to create the toBeVerified data. - * @param coseData + * + * @param coseData byte array representation of the sCOSE data * @param detachedPayload a detached signature (Cose detached content) which is actually just the payload * @return toBeVerfied data to be used with the java signature verification - * @throws IOException + * @throws IOException if an I/O error occurs during processing. */ public byte[] getToBeVerified(final byte[] coseData, final byte[] detachedPayload) throws IOException { COSEProtectedHeader pheader = processCose(coseData, false); @@ -162,11 +182,12 @@ public byte[] getToBeVerified(final byte[] coseData, final byte[] detachedPayloa /** * Parses a cose object and populated this classes member variables. - * @param coseData signed cose object + * + * @param coseData signed cose object * @param genToBeSinged if true the toBeSigned variable will be populated. * Should be set to false when processing a detached signature * @return a protected header object - * @throws IOException + * @throws IOException if an I/O error occurs while attempting to process the COSE data. */ private COSEProtectedHeader processCose(final byte[] coseData, final boolean genToBeSinged) throws IOException { @@ -195,7 +216,7 @@ private COSEProtectedHeader processCose(final byte[] coseData, final boolean gen COSEUnprotectedHeader uheader = signOne.getUnprotectedHeader(); status = "Checking Cose headers for required Algorithm Identifier"; if (pheader.getAlg() != null) { - Object algObject = (Object) pheader.getAlg(); + Object algObject = pheader.getAlg(); if (algObject instanceof String) { // library will return a String if algorithm is unknown String sAlg = (String) pheader.getAlg(); if (sAlg.compareToIgnoreCase("unknown") == 0) { @@ -235,7 +256,8 @@ private COSEProtectedHeader processCose(final byte[] coseData, final boolean gen /** * Creates the toBeSigned structure from a pre-processed header and payload data. - * @param data byte array holding to be signed data + * + * @param data byte array holding to be signed data * @param pHeader cose header to be included in final cose object * @return the COSE_Sign1 toBeSigned data */ @@ -254,26 +276,27 @@ private byte[] finalizeToBeSigned(final byte[] data, final COSEProtectedHeader p } /** - * Performs step 4 of the "How to compute a signature" section. - * from https://datatracker.ietf.org/doc/html/rfc9052#section-4.4 - * - * 4. Place the resulting signature value in the correct location. - * This is the "signature" field of the COSE_Signature or COSE_Sign1 structure. + * Performs step 4 of the "How to compute a signature" section. + * from https://datatracker.ietf.org/doc/html/rfc9052#section-4.4 + *

    + * 4. Place the resulting signature value in the correct location. + * This is the "signature" field of the COSE_Signature or COSE_Sign1 structure. * - * @param signatureBytes data generated from step 3. Note step 3 is performed by a Cryptographic Engine + * @param signatureBytes data generated from step 3. Note step 3 is performed by a Cryptographic Engine */ @Override - public void addSignature(final byte[] signatureBytes) throws IOException { + public void addSignature(final byte[] signatureBytes) { signature = signatureBytes.clone(); coseBuilder.signature(signatureBytes); } /** * Encodes the signature data an updates class variables. - * @return byte array holding the singed data + * + * @return byte array holding the signed data */ @Override - public byte[] getSignedData() throws IOException { + public byte[] getSignedData() { COSESign1 sigData = coseBuilder.build(); // Set local variables for future use // byte[] rawSignature = sigData.getSignature().getValue(); @@ -282,21 +305,6 @@ public byte[] getSignedData() throws IOException { return taggedCose.encode().clone(); } - /** - * Obtain the SHA-256 thumbprint of an X.509 certificate (used for embedding). - * - * @param cert The input X.509 certificate. - * @return The SHA-256 thumbprint corresponding to the certificate. - * @throws NoSuchAlgorithmException if the SHA-256 algorithm is unsupported - * @throws CertificateEncodingException if the certificate cannot be encoded to DER - */ - public static byte[] getThumbprint(final X509Certificate cert) throws NoSuchAlgorithmException, - CertificateEncodingException { - MessageDigest md = MessageDigest.getInstance("SHA-256"); - md.update(cert.getEncoded()); - return md.digest(); - } - /** * Provides a nil CBOR object as defined for supporting "Detached signatures" * (referred to as "detached content" in rfc 9052). @@ -307,7 +315,8 @@ public void setNilPayload() { /** * Validates the thumbprint of a given protected header and certificate contents. - * @param cert The embedded cert to validate. + * + * @param cert The embedded cert to validate. * @param pHeader The protected header contents (containing thumbprint) to validate against. * @return True if the contents are validated; false otherwise. */ diff --git a/HIRS_Utils/src/main/java/hirs/utils/specificationLookups/PlatformClass.java b/HIRS_Utils/src/main/java/hirs/utils/specificationLookups/PlatformClass.java index c56cc8107..29b116aa1 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/specificationLookups/PlatformClass.java +++ b/HIRS_Utils/src/main/java/hirs/utils/specificationLookups/PlatformClass.java @@ -8,9 +8,9 @@ /** * Enum to lookup values for platform class specified by section 4 of the following registry. - * @see - * Registry of Reserved TPM 2.0 Handles and Localities + * + * @see + * Registry of Reserved TPM 2.0 Handles and Localities */ @Getter @AllArgsConstructor @@ -32,9 +32,6 @@ public enum PlatformClass { MULTITENANT(0xE, "Multi Tenant (Deprecated)"), TC(0xF, "TC (Deprecated)"); - private final int platformClassId; - private final String comments; - /** * Map of PlatformClass values. */ @@ -46,8 +43,12 @@ public enum PlatformClass { } } + private final int platformClassId; + private final String comments; + /** * Searches platform class array for match to an enum value. + * * @param platformClassId int id of the platform class you want to look up * @return the corresponding platform class */ diff --git a/HIRS_Utils/src/main/java/hirs/utils/specificationLookups/package-info.java b/HIRS_Utils/src/main/java/hirs/utils/specificationLookups/package-info.java index c202bb398..96a012d37 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/specificationLookups/package-info.java +++ b/HIRS_Utils/src/main/java/hirs/utils/specificationLookups/package-info.java @@ -1 +1,4 @@ +/** + * Contains utility classes that do quick specification lookups. + */ package hirs.utils.specificationLookups; diff --git a/HIRS_Utils/src/main/java/hirs/utils/swid/CredentialParser.java b/HIRS_Utils/src/main/java/hirs/utils/swid/CredentialParser.java index 0e276633d..cafe9283f 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/swid/CredentialParser.java +++ b/HIRS_Utils/src/main/java/hirs/utils/swid/CredentialParser.java @@ -84,7 +84,7 @@ public void parseJKSCredentials(final String jksKeystore) { * extracting the certificate, private key, and public key. * * @param certificateFile the path to the PEM-encoded certificate file - * @param privateKeyFile the path to the PEM-encoded private key file + * @param privateKeyFile the path to the PEM-encoded private key file * @throws Exception if parsing fails or the certificate is self-signed */ public void parsePEMCredentials(final String certificateFile, final String privateKeyFile) @@ -126,8 +126,7 @@ public X509Certificate parseCertFromPEMString(final String pemString) throws Cer * @param certificateFile the path to the PEM certificate file * @return a list of X509Certificate objects parsed from the file */ - public List parseCertsFromPEM(final String certificateFile) - throws FileNotFoundException { + public List parseCertsFromPEM(final String certificateFile) { return parsePEMCertificates(certificateFile); } @@ -250,8 +249,8 @@ private KeyPair getPKCS1KeyPair(final String filename) throws IOException { * This method returns the private key from a JKS keystore. * * @param keystoreFile the path to the JKS keystore file - * @param alias the alias of the key entry in the keystore - * @param password the password for the keystore and key entry + * @param alias the alias of the key entry in the keystore + * @param password the password for the keystore and key entry * @return the PrivateKeyEntry containing the private key and certificate */ private KeyStore.PrivateKeyEntry parseKeystorePrivateKey(final String keystoreFile, @@ -275,6 +274,8 @@ private KeyStore.PrivateKeyEntry parseKeystorePrivateKey(final String keystoreFi * This method returns the authorityInfoAccess from an X509Certificate. * * @return a formatted string listing the AIA information from the certificate + * @throws IOException if an I/O error occurs while trying to retrieve the certificate authority info + * access. */ public String getCertificateAuthorityInfoAccess() throws IOException { StringBuilder sb = new StringBuilder("Authority Info Access:\n"); @@ -298,7 +299,7 @@ public String getCertificateAuthorityInfoAccess() throws IOException { * This method returns the subjectKeyIdentifier from the local X509Certificate. * * @return the String representation of the subjectKeyIdentifier - * @throws IOException + * @throws IOException if an I/O error occurs while retrieving the certificate subject key identifier. */ public String getCertificateSubjectKeyIdentifier() throws IOException { byte[] extension = certificate.getExtensionValue(Extension.subjectKeyIdentifier.getId()); @@ -314,7 +315,7 @@ public String getCertificateSubjectKeyIdentifier() throws IOException { * * @param certificate the cert to pull the subjectKeyIdentifier from * @return the String representation of the subjectKeyIdentifier - * @throws IOException + * @throws IOException if an I/O error occurs while retrieving the certificate subject key identifier. */ public String getCertificateSubjectKeyIdentifier(final X509Certificate certificate) throws IOException { byte[] extension = certificate.getExtensionValue(Extension.subjectKeyIdentifier.getId()); diff --git a/HIRS_Utils/src/main/java/hirs/utils/swid/HashSwid.java b/HIRS_Utils/src/main/java/hirs/utils/swid/HashSwid.java index 1cdda7f69..fb39e3d2d 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/swid/HashSwid.java +++ b/HIRS_Utils/src/main/java/hirs/utils/swid/HashSwid.java @@ -23,31 +23,15 @@ public class HashSwid { /** * Getter method for the hash that uses 256 bit hash. + * * @param filepath the file to hash. * @return the SHA-256 hash of the file's contents, as a hexadecimal string. + * @throws Exception if any issues arise while retrieving the SHA256 hash */ public static String get256Hash(final String filepath) throws Exception { return getHashValue(filepath, SHA256); } - /** - * Getter method for the hash that uses 384 bit hash. - * @param filepath the file to hash. - * @return the SHA-384 hash of the file's contents, as a hexadecimal string. - */ - public String get384Hash(final String filepath) throws Exception { - return getHashValue(filepath, SHA384); - } - - /** - * Getter method for the hash that uses 512 bit hash. - * @param filepath the file to hash. - * @return the SHA-512 hash of the file's contents, as a hexadecimal string. - */ - public String get512Hash(final String filepath) throws Exception { - return getHashValue(filepath, SHA512); - } - /** * This method creates the hash based on the provided algorithm * only accessible through helper methods. @@ -56,8 +40,9 @@ public String get512Hash(final String filepath) throws Exception { * getHashValue() below. * * @param filepath file contents to hash - * @param sha the algorithm to use for the hash + * @param sha the algorithm to use for the hash * @return the hash of the file's contents, as a hexadecimal string + * @throws Exception if any issues arise while retrieving the hash value */ private static String getHashValue(final String filepath, final String sha) throws Exception { String resultString = null; @@ -74,7 +59,7 @@ private static String getHashValue(final String filepath, final String sha) thro String errorMessage = "Error hashing file " + filepath + ": "; if (e instanceof UnsupportedEncodingException || e instanceof NoSuchAlgorithmException) { - errorMessage += ((Exception) e).getMessage(); + errorMessage += e.getMessage(); } else if (e instanceof IOException) { errorMessage += "error reading file."; } @@ -87,6 +72,7 @@ private static String getHashValue(final String filepath, final String sha) thro /** * This method is a public access hash function that operates on a string * value and uses default assumptions on the salt and algorithm. + * * @param value string object to hash * @return the Base64-encoded SHA-256 hash of the file */ @@ -107,8 +93,8 @@ public static String getHashValue(final String value) { } catch (UnsupportedEncodingException | NoSuchAlgorithmException grex) { System.out.println(grex.getMessage()); } catch (IOException ioEx) { - System.out.println(String.format("%s: %n%s is not valid...", - ioEx.getMessage(), value)); + System.out.printf("%s: %n%s is not valid...%n", + ioEx.getMessage(), value); } finally { try { if (bis != null) { @@ -125,5 +111,27 @@ public static String getHashValue(final String value) { return Base64.getEncoder().encodeToString(hash); } + + /** + * Getter method for the hash that uses 384 bit hash. + * + * @param filepath the file to hash. + * @return the SHA-384 hash of the file's contents, as a hexadecimal string. + * @throws Exception if any issues arise while retrieving the SHA384 hash. + */ + public String get384Hash(final String filepath) throws Exception { + return getHashValue(filepath, SHA384); + } + + /** + * Getter method for the hash that uses 512 bit hash. + * + * @param filepath the file to hash. + * @return the SHA-512 hash of the file's contents, as a hexadecimal string. + * @throws Exception if any issues arise while retrieving the SHA512 hash. + */ + public String get512Hash(final String filepath) throws Exception { + return getHashValue(filepath, SHA512); + } } diff --git a/HIRS_Utils/src/main/java/hirs/utils/swid/package-info.java b/HIRS_Utils/src/main/java/hirs/utils/swid/package-info.java index 91c5a00fb..53e2b1fd0 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/swid/package-info.java +++ b/HIRS_Utils/src/main/java/hirs/utils/swid/package-info.java @@ -1 +1,4 @@ +/** + * Contains all Swid and Swid-related files. + */ package hirs.utils.swid; diff --git a/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/DeviceSecurityEvent.java b/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/DeviceSecurityEvent.java index c6a1e2659..497a45664 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/DeviceSecurityEvent.java +++ b/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/DeviceSecurityEvent.java @@ -8,36 +8,44 @@ * Abstract base class to process the DEVICE_SECURITY_EVENT_DATA or ..DATA2 event. * Parses event data per PFP v1.06 Rev52 Tables 20 and 26. * The event data comes in 2 forms: - * . 1) DEVICE_SECURITY_EVENT_DATA or - * . 2) DEVICE_SECURITY_EVENT_DATA2 + * 1) DEVICE_SECURITY_EVENT_DATA or + * 2) DEVICE_SECURITY_EVENT_DATA2 + *

    * The first 2 fields of the respective headers are the same in both ..DATA and ..DATA2. + *

    * Field 1: - * . The first 16 bytes of the event data header MUST be a String based identifier (Signature), - * . per PFP. The only currently defined Signatures are "SPDM Device Sec" and "SPDM Device Sec2", - * . which implies the data is a DEVICE_SECURITY_EVENT_DATA or ..DATA2, respectively. + * The first 16 bytes of the event data header MUST be a String based identifier (Signature), + * per PFP. The only currently defined Signatures are "SPDM Device Sec" and "SPDM Device Sec2", + * which implies the data is a DEVICE_SECURITY_EVENT_DATA or ..DATA2, respectively. + *

    * Field 2: - * . The Version field also indicates whether the Device Security Event is ..DATA or ..DATA2. + * The Version field also indicates whether the Device Security Event is ..DATA or ..DATA2. *

    * DEVICE SECURITY EVENT structures defined by PFP v1.06 Rev 52: - *

    + * + *

      * typedef struct tdDEVICE_SECURITY_EVENT_DATA {
      * .     DEVICE_SECURITY_EVENT_DATA_HEADER            EventDataHeader;
      * .     DEVICE_SECURITY_EVENT_DATA_DEVICE_CONTEXT    DeviceContext;
      * } DEVICE_SECURITY_EVENT_DATA;
    - * 

    + *

    + * + *
      * typedef struct tdDEVICE_SECURITY_EVENT_DATA2 {
      * .     DEVICE_SECURITY_EVENT_DATA_HEADER2           EventDataHeader;
      * .     DEVICE_SECURITY_EVENT_DATA_SUB_HEADER        EventDataSubHeader;
      * .     DEVICE_SECURITY_EVENT_DATA_DEVICE_CONTEXT    DeviceContext;
      * } DEVICE_SECURITY_EVENT_DATA2;
    - * 

    + *

    + * + *
      * typedef struct tdDEVICE_SECURITY_EVENT_DATA_HEADER or HEADER2 {
      * .     UINT8                           Signature[16];
      * .     UINT16                          Version;
      * .     ...                             ...
      * .     (The rest of the components are different for HEADER vs HEADER2)
      * }
    - * 

    + *

    */ @Getter public abstract class DeviceSecurityEvent { diff --git a/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/DeviceSecurityEventData.java b/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/DeviceSecurityEventData.java index 2fe954746..bb6181f7d 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/DeviceSecurityEventData.java +++ b/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/DeviceSecurityEventData.java @@ -5,12 +5,13 @@ /** * Class to process DEVICE_SECURITY_EVENT_DATA. * Parses event data per PFP v1.06 Rev52 Table 20. - *

    + * + *

      * typedef struct tdDEVICE_SECURITY_EVENT_DATA {
      * .    DEVICE_SECURITY_EVENT_DATA_HEADER            EventDataHeader;
      * .    DEVICE_SECURITY_EVENT_DATA_DEVICE_CONTEXT    DeviceContext;
      * } DEVICE_SECURITY_EVENT_DATA;
    - * 

    + *

    */ public class DeviceSecurityEventData extends DeviceSecurityEvent { diff --git a/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/DeviceSecurityEventData2.java b/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/DeviceSecurityEventData2.java index bc3813b4b..c774405b6 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/DeviceSecurityEventData2.java +++ b/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/DeviceSecurityEventData2.java @@ -5,13 +5,13 @@ /** * Class to process DEVICE_SECURITY_EVENT_DATA2. * Parses event data per PFP v1.06 Rev52 Table 26. - *

    + *

      * typedef struct tdDEVICE_SECURITY_EVENT_DATA2 {
      * .    DEVICE_SECURITY_EVENT_DATA_HEADER2           EventDataHeader;
      * .    DEVICE_SECURITY_EVENT_DATA_SUB_HEADER        EventDataSubHeader;
      * .    DEVICE_SECURITY_EVENT_DATA_DEVICE_CONTEXT    DeviceContext;
      * } DEVICE_SECURITY_EVENT_DATA2;
    - * 

    + *

    */ public class DeviceSecurityEventData2 extends DeviceSecurityEvent { diff --git a/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/DeviceSecurityEventDataDeviceContext.java b/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/DeviceSecurityEventDataDeviceContext.java index f984ad39c..389cd888c 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/DeviceSecurityEventDataDeviceContext.java +++ b/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/DeviceSecurityEventDataDeviceContext.java @@ -8,12 +8,13 @@ * DEVICE_SECURITY_EVENT_DATA_DEVICE_CONTEXT is a common SPDM structure which includes the * identification of the device, device vendor, subsystem, etc. Device can be either a PCI * or USB connection. - *

    + * + *

      * typedef union tdDEVICE_SECURITY_EVENT_DATA_DEVICE_CONTEXT {
      * .     DEVICE_SECURITY_EVENT_DATA_PCI_CONTEXT       PciContext;
      * .     DEVICE_SECURITY_EVENT_DATA_USB_CONTEXT       UsbContext;
      * } DEVICE_SECURITY_EVENT_DATA_DEVICE_CONTEXT;
    - * 

    + *

    */ @Getter public abstract class DeviceSecurityEventDataDeviceContext { @@ -22,18 +23,22 @@ public abstract class DeviceSecurityEventDataDeviceContext { * Device Security Event Data Device Type = no device type. */ public static final int DEVICE_TYPE_NONE = 0; + /** * Device Security Event Data Device Type = DEVICE_TYPE_PCI. */ public static final int DEVICE_TYPE_PCI = 1; + /** * Device Security Event Data Device Type = DEVICE_TYPE_USB. */ public static final int DEVICE_TYPE_USB = 2; + /** * PCI Version. */ private int version = 0; + /** * PCI Length. */ diff --git a/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/DeviceSecurityEventDataHeader2.java b/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/DeviceSecurityEventDataHeader2.java index ecacfdbf7..55154413d 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/DeviceSecurityEventDataHeader2.java +++ b/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/DeviceSecurityEventDataHeader2.java @@ -9,7 +9,7 @@ * returned by the SPDM "GET_MEASUREMENTS" function. *

    * HEADERS defined by PFP v1.06 Rev 52: - *

    + *

      * typedef struct tdDEVICE_SECURITY_EVENT_DATA_HEADER2 {
      * .    UINT8                           Signature[16];
      * .    UINT16                          Version;
    @@ -23,7 +23,7 @@
      * .    UINT64                          DevicePathLength;
      * .    UNIT8                           DevicePath[DevicePathLength]
      * } DEVICE_SECURITY_EVENT_DATA_HEADER2;
    - * 

    + *

    */ public class DeviceSecurityEventDataHeader2 extends DeviceSecurityEventHeader { @@ -31,38 +31,46 @@ public class DeviceSecurityEventDataHeader2 extends DeviceSecurityEventHeader { * Auth state - success. */ public static final int AUTH_SUCCESS = 0; + /** * Auth state - digital signature of the data is valid, but the public key certificate chain is not * validated with the entry in the UEFI device signature variable. */ public static final int AUTH_NO_AUTHORITY = 1; + /** * Auth state - digital signature of the measurement data is valid, but the reported device capabilities, * negotiated parameters or certificate chains were not validated by a transcript. */ public static final int AUTH_NO_BINDING = 2; + /** * Auth state - data has no digital signature. */ public static final int AUTH_FAIL_NO_SIG = 3; + /** * Auth state - data is invalid. */ public static final int AUTH_FAIL_INVALID = 4; + /** * Auth state - device is not an SPDM-capable device. */ public static final int AUTH_NO_SPDM = 0xFF; + /** * Event auth state. */ @Getter private int authState = 0; + /** * Event data length. */ @Getter private int length = 0; + /** * Event sub headerType. * SUBHEADERTYPE_MEAS_BLOCK = 0 @@ -70,11 +78,13 @@ public class DeviceSecurityEventDataHeader2 extends DeviceSecurityEventHeader { */ @Getter private int subHeaderType = -1; + /** * Event sub header length. */ @Getter private int subHeaderLength = 0; + /** * Event sub header UID. */ diff --git a/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/DeviceSecurityEventDataSubHeader.java b/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/DeviceSecurityEventDataSubHeader.java index 620c9a906..442dfdd3a 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/DeviceSecurityEventDataSubHeader.java +++ b/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/DeviceSecurityEventDataSubHeader.java @@ -3,13 +3,13 @@ /** * Class to process the DEVICE_SECURITY_EVENT_DATA_SUB_HEADER event per PFP. * - *

    + *

      * typedef union tdDEVICE_SECURITY_EVENT_DATA_SUB_HEADER {
      * .     DEVICE_SECURITY_EVENT_DATA_SUB_HEADER_SPDM_MEASUREMENT_BLOCK  SpdmMeasurementBlock;
      * .     DEVICE_SECURITY_EVENT_DATA_SUB_HEADER_SPDM_CERT_CHAIN         SpdmCertChain;
      * .     DEVICE_SECURITY_EVENT_DATA_SUB_HEADER_OEM_MEASUREMENT         OemMeasurement;
      * } DEVICE_SECURITY_EVENT_DATA_SUB_HEADER;
    - * 

    + *

    */ public abstract class DeviceSecurityEventDataSubHeader { @@ -17,6 +17,7 @@ public abstract class DeviceSecurityEventDataSubHeader { * Sub header type - SPDM measurement block. */ public static final int SUBHEADERTYPE_MEAS_BLOCK = 0; + /** * Sub header type - SPDM cert chain. */ diff --git a/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/DeviceSecurityEventDataSubHeaderSpdmMeasurementBlock.java b/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/DeviceSecurityEventDataSubHeaderSpdmMeasurementBlock.java index 348a26c70..b7a9123a9 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/DeviceSecurityEventDataSubHeaderSpdmMeasurementBlock.java +++ b/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/DeviceSecurityEventDataSubHeaderSpdmMeasurementBlock.java @@ -13,7 +13,7 @@ /** * Class to process the DEVICE_SECURITY_EVENT_DATA_SUB_HEADER_SPDM_MEASUREMENT_BLOCK event per PFP. * - *

    + *

      * typedef union tdDEVICE_SECURITY_EVENT_DATA_SUB_HEADER_SPDM_MEASUREMENT_BLOCK {
      * .     UINT16                  SpdmVersion;
      * .     UINT8                   SpdmMeasurementBlockCount;
    @@ -21,8 +21,8 @@
      * .     UINT32                  SpdmMeasurementHashAlgo;
      * .     SPDM_MEASUREMENT_BLOCK  SpdmMeasurementBlock[SpdmMeasurementBlockCount];
      * } DEVICE_SECURITY_EVENT_DATA_SUB_HEADER_SPDM_MEASUREMENT_BLOCK;
    - * 

    - *

    + *

    + *
      * SpdmMeasurementBlock is an array of SPDM_MEASUREMENT_BLOCKs
      * .  The size of each block is the same and can be found by either:
      * .      1) 4 + SpdmMeasurementBlock MeasurementSize
    @@ -30,6 +30,7 @@
      * .      2) 4 + hash length of the hash algorithm found in
      * .             DEVICE_SECURITY_EVENT_DATA_SUB_HEADER_SPDM_MEASUREMENT_BLOCK SpdmMeasurementHashAlgo
      * .      where 4 is the size of the SpdmMeasurementBlock header
    + * 
    */ public class DeviceSecurityEventDataSubHeaderSpdmMeasurementBlock extends DeviceSecurityEventDataSubHeader { @@ -37,21 +38,25 @@ public class DeviceSecurityEventDataSubHeaderSpdmMeasurementBlock extends Device * List of SPDM Measurement Blocks. */ private final List spdmMeasurementBlockList; + /** * SPDM version. */ @Getter private int spdmVersion = 0; + /** * SPDM measurement block count. */ @Getter private int spdmMeasurementBlockCount = 0; + /** * SPDM measurement hash algorithm. */ @Getter private int spdmMeasurementHashAlgo = -1; + /** * Error reading SPDM Measurement Block. */ diff --git a/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/DeviceSecurityEventHeader.java b/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/DeviceSecurityEventHeader.java index 2b6760219..0137d0d23 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/DeviceSecurityEventHeader.java +++ b/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/DeviceSecurityEventHeader.java @@ -15,7 +15,8 @@ *

    * HEADERS defined by PFP v1.06 Rev 52. * Certain fields are common to both ..HEADER and ..HEADER2, and are noted below the structures. - *

    + * + *

      * typedef struct tdDEVICE_SECURITY_EVENT_DATA_HEADER {
      * .     UINT8                           Signature[16];
      * .     UINT16                          Version;
    @@ -26,7 +27,9 @@
      * .     UINT64                          DevicePathLength;
      * .     UNIT8                           DevicePath[DevicePathLength]
      * } DEVICE_SECURITY_EVENT_DATA_HEADER;
    - * 

    + *

    + * + *
      * typedef struct tdDEVICE_SECURITY_EVENT_DATA_HEADER2 {        - NOT IMPLEMENTED YET
      * .     UINT8                           Signature[16];
      * .     UINT16                          Version;
    @@ -40,14 +43,16 @@
      * .     UINT64                          DevicePathLength;
      * .     UNIT8                           DevicePath[DevicePathLength]
      * } DEVICE_SECURITY_EVENT_DATA_HEADER2;
    - * 

    + *

    + * + *
      * Fields common to both ..HEADER and ..HEADER2:
      * .  Signature
      * .  Version
      * .  DeviceType
      * .  DevicePathLength
      * .  DevicePath
    - * 

    + *

    */ public abstract class DeviceSecurityEventHeader { @@ -56,27 +61,32 @@ public abstract class DeviceSecurityEventHeader { */ @Getter private static final int DEVICE_PATH_LENGTH = 0; + /** * Contains the size (in bytes) of the header. */ @Getter private Integer dsedHeaderLength = 0; + /** * Signature (text) data. */ @Getter private String signature = ""; + /** * Version determines data structure used (..DATA or ..DATA2). * This determines whether ..HEADER or ..HEADER2 is used. */ @Getter private String version = ""; + /** * Device type. */ @Getter private int deviceType = -1; + /** * UEFI Device path. */ diff --git a/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/NvIndexDynamicEventLogData.java b/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/NvIndexDynamicEventLogData.java index e79aaece2..30492e543 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/NvIndexDynamicEventLogData.java +++ b/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/NvIndexDynamicEventLogData.java @@ -22,7 +22,6 @@ * . UINT16 DataSize; * . UINT8 Data[DataSize]; * } NV_INDEX_DYNAMIC_EVENT_LOG_DATA; - *

    */ public class NvIndexDynamicEventLogData { diff --git a/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/NvIndexInstanceEventLogData.java b/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/NvIndexInstanceEventLogData.java index 63bbbf8a0..d22096e1b 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/NvIndexInstanceEventLogData.java +++ b/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/events/NvIndexInstanceEventLogData.java @@ -20,7 +20,6 @@ * . UINT8[6] Reserved; * . DEVICE_SECURITY_EVENT_DATA2 Data; * } NV_INDEX_INSTANCE_EVENT_LOG_DATA; - *

    */ public class NvIndexInstanceEventLogData { diff --git a/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/spdm/SpdmCertificateChain.java b/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/spdm/SpdmCertificateChain.java index 1d89495c0..8a0b66704 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/spdm/SpdmCertificateChain.java +++ b/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/spdm/SpdmCertificateChain.java @@ -12,15 +12,18 @@ /** * Class to process the SpdmCertificateChain. - *

    + * + *

      * Certificate chain format, defined by SPDM v1.03, Sect 10.6.1, Table 33:
      * Certificate chain format {
      * .     Length                          2 bytes;
      * .     Reserved                        2 bytes;
    - * .     RootHash                         bytes;
    - * .     Certificates                     - (4 + ) bytes;
    + * .     RootHash                        (H) bytes;
    + * .     Certificates                    (Length) - (4 + (H)) bytes;
      * }
    - * 

    + *

    + * + *
      * Length: total length of cert chain including all fields in this block
      * H: the output size of the hash algorithm selected by the most recent ALGORITHMS response
      * .  this field shall be in hash byte order
    @@ -31,6 +34,7 @@
      * .  the hash algorithm is the DEVICE_SECURITY_EVENT_DATA_SUB_HEADER_SPDM_CERT_CHAIN SpdmBaseHashAlgo
      * Certificates: Complete cert chain consisting of 1 or more ASN.1 DER-encoded X.509 v3 certs
      * .  this field shall be in Encoded ASN.1 byte order
    + * 
    */ public class SpdmCertificateChain { @@ -41,19 +45,23 @@ public class SpdmCertificateChain { /** * Array List of certs found in the chain. */ - private final ArrayList certList = new ArrayList(); + private final ArrayList certList = new ArrayList<>(); + /** * Root hash. */ private byte[] rootHash = null; + /** * Number of certs in the SPDM cert chain. */ private int numberOfCerts = 0; + /** * Human-readable description of any error associated with SPDM base hash alg. */ private String spdmBaseHashAlgoError = ""; + /** * Human-readable description of any error associated with parsing the X509 certs. */ diff --git a/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/spdm/SpdmMeasurement.java b/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/spdm/SpdmMeasurement.java index 9c056a27c..fb124f8d6 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/spdm/SpdmMeasurement.java +++ b/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/spdm/SpdmMeasurement.java @@ -5,14 +5,17 @@ /** * Class to process the SpdmMeasurement. - *

    + * + *

      * Measurement, defined by SPDM v1.03, Sect 10.11.1, Table 54:
      * DMTF measurement spec format {
      * .     DMTFSpecMeasurementValueType    1 byte;
      * .     DMTFSpecMeasurementValueSize    2 bytes;
    - * .     DMTFSpecMeasurementValue         bytes;
    + * .     DMTFSpecMeasurementValue        (DMTFSpecMeasurementValueSize) bytes;
      * }
    - * 

    + *

    + * + *
      * DMTFSpecMeasurementValueType[7]
      * .     Indicates how bits [0:6] are represented
      * .     Bit = 0: Digest
    @@ -23,7 +26,7 @@
      * .     Hardware configuration          0x2
      * .     Firmware configuration          0x3
      * .     etc.
    - * 

    + *

    */ public class SpdmMeasurement { @@ -86,6 +89,7 @@ public class SpdmMeasurement { * Measurement value (digest). */ private final byte[] dmtfSpecMeasurementValue; + /** * Measurement value type (such as mutable firmware, etc). */ diff --git a/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/spdm/SpdmMeasurementBlock.java b/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/spdm/SpdmMeasurementBlock.java index 8a26ac942..6cbb0db51 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/spdm/SpdmMeasurementBlock.java +++ b/HIRS_Utils/src/main/java/hirs/utils/tpm/eventlog/spdm/SpdmMeasurementBlock.java @@ -8,14 +8,16 @@ /** * Class to process the SpdmMeasurementBlock. - *

    + * + *

      * Measurement block format, defined by SPDM v1.03, Sect 10.11.1, Table 53:
      * Measurement block format {
      * Index                           1 byte;
      * MeasurementSpec                 1 byte;
      * MeasurementSize                 2 bytes;
    - * Measurement                      bytes;
    + * Measurement                     (MeasurementSize) bytes;
      * }
    + * 
    *

    * Index: index of the measurement block, as there can be more than one * MeasurementSpec: bit mask; the measurement specification that the requested Measurement follows @@ -26,25 +28,28 @@ */ public class SpdmMeasurementBlock { + /** + * SPDM Measurement. + */ + private final SpdmMeasurement spdmMeasurement; + /** * Measurement block index, as an SPDM measurement exchange can contain several measurements. */ @Getter private int index = 0; + /** * Measurement Spec. */ @Getter private int measurementSpec = 0; - /** - * SPDM Measurement. - */ - private final SpdmMeasurement spdmMeasurement; /** * SpdmMeasurementBlock Constructor. * * @param spdmMeasBlocks byte array holding the SPDM Measurement Block bytes. + * @throws IOException if any issues arise creating the SPDM Measurement Block object. */ public SpdmMeasurementBlock(final ByteArrayInputStream spdmMeasBlocks) throws IOException { diff --git a/HIRS_Utils/src/main/java/hirs/utils/xjc/DigestMethodType.java b/HIRS_Utils/src/main/java/hirs/utils/xjc/DigestMethodType.java index 296cf5899..33c5456c2 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/xjc/DigestMethodType.java +++ b/HIRS_Utils/src/main/java/hirs/utils/xjc/DigestMethodType.java @@ -78,6 +78,8 @@ public class DigestMethodType { * {@link Object } * {@link Element } * {@link String } + * + * @return list of objects */ public List getContent() { if (content == null) { diff --git a/HIRS_Utils/src/main/java/hirs/utils/xjc/Ownership.java b/HIRS_Utils/src/main/java/hirs/utils/xjc/Ownership.java index 769957ba9..d9e8e34fe 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/xjc/Ownership.java +++ b/HIRS_Utils/src/main/java/hirs/utils/xjc/Ownership.java @@ -17,7 +17,7 @@ *

    Java class for Ownership. * *

    The following schema fragment specifies the expected content contained within this class. - *

    + * *

      * <simpleType name="Ownership">
      *   <restriction base="{http://www.w3.org/2001/XMLSchema}NMTOKEN">
    @@ -31,8 +31,6 @@
     @XmlType(name = "Ownership", namespace = "http://standards.iso.org/iso/19770/-2/2015/schema.xsd")
     @XmlEnum
     public enum Ownership {
    -
    -
         /**
          * Determines the relative strength of ownership of the target
          * piece of software.
    diff --git a/HIRS_Utils/src/main/java/hirs/utils/xjc/PGPDataType.java b/HIRS_Utils/src/main/java/hirs/utils/xjc/PGPDataType.java
    index a0b8c3599..bd223f5ae 100644
    --- a/HIRS_Utils/src/main/java/hirs/utils/xjc/PGPDataType.java
    +++ b/HIRS_Utils/src/main/java/hirs/utils/xjc/PGPDataType.java
    @@ -91,6 +91,8 @@ public class PGPDataType {
          * {@link JAXBElement }{@code <}{@link byte[]}{@code >}
          * {@link Element }
          * {@link Object }
    +     *
    +     * @return list of objects
          */
         public List getContent() {
             if (content == null) {
    diff --git a/HIRS_Utils/src/main/java/hirs/utils/xjc/SPKIDataType.java b/HIRS_Utils/src/main/java/hirs/utils/xjc/SPKIDataType.java
    index 2a8a645a2..9eceb40eb 100644
    --- a/HIRS_Utils/src/main/java/hirs/utils/xjc/SPKIDataType.java
    +++ b/HIRS_Utils/src/main/java/hirs/utils/xjc/SPKIDataType.java
    @@ -69,6 +69,8 @@ public class SPKIDataType {
          * {@link JAXBElement }{@code <}{@link byte[]}{@code >}
          * {@link Object }
          * {@link Element }
    +     *
    +     * @return list of objects
          */
         public List getSPKISexpAndAny() {
             if (spkiSexpAndAny == null) {
    diff --git a/HIRS_Utils/src/main/java/hirs/utils/xjc/SignatureMethodType.java b/HIRS_Utils/src/main/java/hirs/utils/xjc/SignatureMethodType.java
    index 86989fb59..8081858ae 100644
    --- a/HIRS_Utils/src/main/java/hirs/utils/xjc/SignatureMethodType.java
    +++ b/HIRS_Utils/src/main/java/hirs/utils/xjc/SignatureMethodType.java
    @@ -82,6 +82,8 @@ public class SignatureMethodType {
          * {@link JAXBElement }{@code <}{@link BigInteger }{@code >}
          * {@link Object }
          * {@link String }
    +     *
    +     * @return list of objects
          */
         public List getContent() {
             if (content == null) {
    diff --git a/HIRS_Utils/src/main/java/hirs/utils/xjc/SignaturePropertiesType.java b/HIRS_Utils/src/main/java/hirs/utils/xjc/SignaturePropertiesType.java
    index f00f82634..b69e8b65a 100644
    --- a/HIRS_Utils/src/main/java/hirs/utils/xjc/SignaturePropertiesType.java
    +++ b/HIRS_Utils/src/main/java/hirs/utils/xjc/SignaturePropertiesType.java
    @@ -78,6 +78,8 @@ public class SignaturePropertiesType {
          * 

    * Objects of the following type(s) are allowed in the list * {@link SignaturePropertyType } + * + * @return list of signature property types */ public List getSignatureProperty() { if (signatureProperty == null) { diff --git a/HIRS_Utils/src/main/java/hirs/utils/xjc/SignatureType.java b/HIRS_Utils/src/main/java/hirs/utils/xjc/SignatureType.java index fd9e27691..44d8356a3 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/xjc/SignatureType.java +++ b/HIRS_Utils/src/main/java/hirs/utils/xjc/SignatureType.java @@ -62,7 +62,7 @@ public class SignatureType { @XmlElement(name = "SignatureValue", required = true) protected SignatureValueType signatureValue; - + @XmlElement(name = "KeyInfo") protected KeyInfoType keyInfo; @@ -96,6 +96,8 @@ public class SignatureType { *

    * Objects of the following type(s) are allowed in the list * {@link ObjectType } + * + * @return list of object types */ public List getObject() { if (object == null) { diff --git a/HIRS_Utils/src/main/java/hirs/utils/xjc/TransformType.java b/HIRS_Utils/src/main/java/hirs/utils/xjc/TransformType.java index 25af4f1ba..023a3ced6 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/xjc/TransformType.java +++ b/HIRS_Utils/src/main/java/hirs/utils/xjc/TransformType.java @@ -33,12 +33,12 @@ *

      * <complexType name="TransformType">
      *   <complexContent>
    - *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
    + *     <restriction base="{https://www.w3.org/2001/XMLSchema}anyType">
      *       <choice maxOccurs="unbounded" minOccurs="0">
      *         <any processContents='lax' namespace='##other'/>
    - *         <element name="XPath" type="{http://www.w3.org/2001/XMLSchema}string"/>
    + *         <element name="XPath" type="{https://www.w3.org/2001/XMLSchema}string"/>
      *       </choice>
    - *       <attribute name="Algorithm" use="required" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
    + *       <attribute name="Algorithm" use="required" type="{https://www.w3.org/2001/XMLSchema}anyURI" />
      *     </restriction>
      *   </complexContent>
      * </complexType>
    @@ -54,7 +54,7 @@ public class TransformType {
         @XmlMixed
         @XmlAnyElement(lax = true)
         protected List content;
    -    
    +
         @Getter
         @Setter
         @XmlAttribute(name = "Algorithm", required = true)
    @@ -83,10 +83,12 @@ public class TransformType {
          * {@link String }
          * {@link JAXBElement }{@code <}{@link String }{@code >}
          * {@link Object }
    +     *
    +     * @return list of objects
          */
         public List getContent() {
             if (content == null) {
    -            content = new ArrayList();
    +            content = new ArrayList<>();
             }
             return this.content;
         }
    diff --git a/HIRS_Utils/src/main/java/hirs/utils/xjc/TransformsType.java b/HIRS_Utils/src/main/java/hirs/utils/xjc/TransformsType.java
    index e2e073bc9..0582ffd48 100644
    --- a/HIRS_Utils/src/main/java/hirs/utils/xjc/TransformsType.java
    +++ b/HIRS_Utils/src/main/java/hirs/utils/xjc/TransformsType.java
    @@ -62,10 +62,12 @@ public class TransformsType {
          * 

    * Objects of the following type(s) are allowed in the list * {@link TransformType } + * + * @return list of transform types */ public List getTransform() { if (transform == null) { - transform = new ArrayList(); + transform = new ArrayList<>(); } return this.transform; } diff --git a/HIRS_Utils/src/main/java/hirs/utils/xjc/Use.java b/HIRS_Utils/src/main/java/hirs/utils/xjc/Use.java index 9e8de20b3..5873ff166 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/xjc/Use.java +++ b/HIRS_Utils/src/main/java/hirs/utils/xjc/Use.java @@ -17,7 +17,7 @@ *

    Java class for Use. * *

    The following schema fragment specifies the expected content contained within this class. - *

    + * *

      * <simpleType name="Use">
      *   <restriction base="{http://www.w3.org/2001/XMLSchema}NMTOKEN">
    @@ -31,8 +31,6 @@
     @XmlType(name = "Use", namespace = "http://standards.iso.org/iso/19770/-2/2015/schema.xsd")
     @XmlEnum
     public enum Use {
    -
    -
         /**
          * The [Link]'d software is absolutely required for installation
          */
    
    From 38fd1a1b2b52be96b04998782d86994668624229 Mon Sep 17 00:00:00 2001
    From: ThatSilentCoder <184309164+ThatSilentCoder@users.noreply.github.com>
    Date: Thu, 12 Feb 2026 16:23:24 -0500
    Subject: [PATCH 08/20] v3.1_issue_1101: Fixed build error.
    
    ---
     .../config/spotbugs/spotbugs-exclude.xml      |  2 +-
     .../AttestationCertificateAuthority.java      |  4 +-
     .../AttestationCertificateAuthorityTest.java  | 84 ++++++++++---------
     .../record/TPMMeasurementRecordTest.java      |  2 +-
     .../utils/signature/cose/Cbor/CborBstr.java   | 30 +++----
     .../signature/cose/CoseHeaderProtected.java   | 14 ++--
     6 files changed, 69 insertions(+), 67 deletions(-)
    
    diff --git a/HIRS_AttestationCA/config/spotbugs/spotbugs-exclude.xml b/HIRS_AttestationCA/config/spotbugs/spotbugs-exclude.xml
    index b6ef1fae0..acdcaa9b1 100644
    --- a/HIRS_AttestationCA/config/spotbugs/spotbugs-exclude.xml
    +++ b/HIRS_AttestationCA/config/spotbugs/spotbugs-exclude.xml
    @@ -16,7 +16,7 @@
             
         
         
    -        
    +        
             
         
     
    diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/provision/AttestationCertificateAuthority.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/provision/AttestationCertificateAuthority.java
    index b16821481..89d0733c3 100644
    --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/provision/AttestationCertificateAuthority.java
    +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/provision/AttestationCertificateAuthority.java
    @@ -123,7 +123,7 @@ public AttestationCertificateAuthority(
          * @param identityClaim a byte array representation of the identity claim
          * @return processed identity claim response
          */
    -    byte[] processIdentityClaimTpm2(final byte[] identityClaim) {
    +    public byte[] processIdentityClaimTpm2(final byte[] identityClaim) {
             return this.identityClaimHandler.processIdentityClaimTpm2(identityClaim);
         }
     
    @@ -133,7 +133,7 @@ byte[] processIdentityClaimTpm2(final byte[] identityClaim) {
          * @param certificateRequest a byte array representation of the certificate request
          * @return processed certificate request response
          */
    -    byte[] processCertificateRequest(final byte[] certificateRequest) {
    +    public byte[] processCertificateRequest(final byte[] certificateRequest) {
             return this.certificateRequestHandler.processCertificateRequest(certificateRequest);
         }
     
    diff --git a/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/AttestationCertificateAuthorityTest.java b/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/AttestationCertificateAuthorityTest.java
    index 7805b6375..207465bce 100644
    --- a/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/AttestationCertificateAuthorityTest.java
    +++ b/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/AttestationCertificateAuthorityTest.java
    @@ -1,5 +1,6 @@
     package hirs.attestationca.persist;
     
    +import com.google.protobuf.ByteString;
     import hirs.attestationca.persist.entity.userdefined.certificate.EndorsementCredential;
     import hirs.attestationca.persist.entity.userdefined.certificate.PlatformCredential;
     import hirs.attestationca.persist.provision.AbstractProcessor;
    @@ -26,6 +27,7 @@
     import org.bouncycastle.operator.ContentSigner;
     import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder;
     import org.junit.jupiter.api.BeforeAll;
    +import org.junit.jupiter.api.Disabled;
     import org.junit.jupiter.api.Nested;
     import org.junit.jupiter.api.Test;
     import org.junit.jupiter.api.TestInstance;
    @@ -58,6 +60,7 @@
     import java.util.Date;
     import java.util.LinkedList;
     import java.util.List;
    +import java.util.Objects;
     import java.util.Random;
     
     import static org.junit.jupiter.api.Assertions.assertArrayEquals;
    @@ -608,47 +611,46 @@ public void testGenerateAkName() throws URISyntaxException, IOException,
             assertEquals(hex, realHex);
         }
     
    -//    /**
    -//     * Method to generate a make credential output file for use in manual testing. Feed to
    -//     * a TPM 2.0 or emulator using the activate credential command to ensure proper parsing.
    -//     * Must be performed manually. To use, copy the TPM's ek and ak into
    -//     * HIRS_AttestationCA/src/test/resources/tpm2/test/ and ensure the variables akPubPath
    -//     * and ekPubPath are correct. Your output file will be
    -//     * HIRS_AttestationCA/src/test/resources/tpm2/test/make.blob and the nonce used will be
    -//     * output as HIRS_AttestationCA/src/test/resources/tpm2/test/secret.blob
    -//     *
    -//     * @throws URISyntaxException invalid file path
    -//     * @throws IOException        unable to read file
    -//     */
    -//    @Disabled
    -//    @Test
    -//    public void testMakeCredential() throws URISyntaxException, IOException {
    -//        Path akPubPath = Paths.get(Objects.requireNonNull(getClass().getResource(
    -//                AK_PUBLIC_PATH)).toURI());
    -//        Path ekPubPath = Paths.get(Objects.requireNonNull(getClass().getResource(
    -//                EK_PUBLIC_PATH)).toURI());
    -//
    -//        byte[] ekPubFile = Files.readAllBytes(ekPubPath);
    -//        byte[] akPubFile = Files.readAllBytes(akPubPath);
    -//
    -//        RSAPublicKey ekPub = ProvisionUtils.parsePublicKey(ekPubFile);
    -//        RSAPublicKey akPub = ProvisionUtils.parsePublicKey(akPubFile);
    -//
    -//        // prepare the nonce and wrap it with keys
    -//        final byte[] nonce = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
    -//                21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31};
    -//        ByteString blob = ProvisionUtils.tpm20MakeCredential(ekPub, akPub, nonce);
    -//
    -//        Path resources = Objects.requireNonNull(Paths.get(Objects.requireNonNull(
    -//                        Objects.requireNonNull(this.getClass().getResource(
    -//                                "/")).toURI()))
    -//                .getParent().getParent().getParent().getParent());
    -//        Path makeBlob = resources.resolve("src/test/resources/tpm2/test/make.blob");
    -//        Files.write(makeBlob, blob.toByteArray());
    -//
    -//        Path secretPath = resources.resolve("src/test/resources/tpm2/test/secret.blob");
    -//        Files.write(secretPath, nonce);
    -//    }
    +    /**
    +     * Method to generate a make credential output file for use in manual testing. Feed to
    +     * a TPM 2.0 or emulator using the activate credential command to ensure proper parsing.
    +     * Must be performed manually. To use, copy the TPM's ek and ak into
    +     * HIRS_AttestationCA/src/test/resources/tpm2/test/ and ensure the variables akPubPath
    +     * and ekPubPath are correct. Your output file will be
    +     * HIRS_AttestationCA/src/test/resources/tpm2/test/make.blob and the nonce used will be
    +     * output as HIRS_AttestationCA/src/test/resources/tpm2/test/secret.blob
    +     *
    +     * @throws URISyntaxException invalid file path
    +     * @throws IOException        unable to read file
    +     */
    +    @Disabled
    +    @Test
    +    public void testMakeCredential() throws URISyntaxException, IOException {
    +        Path akPubPath = Paths.get(getClass().getResource(
    +                AK_PUBLIC_PATH).toURI());
    +        Path ekPubPath = Paths.get(getClass().getResource(
    +                EK_PUBLIC_PATH).toURI());
    +
    +        byte[] ekPubFile = Files.readAllBytes(ekPubPath);
    +        byte[] akPubFile = Files.readAllBytes(akPubPath);
    +
    +        RSAPublicKey ekPub = ProvisionUtils.parsePublicKey(ekPubFile);
    +        RSAPublicKey akPub = ProvisionUtils.parsePublicKey(akPubFile);
    +
    +        // prepare the nonce and wrap it with keys
    +        final byte[] nonce = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
    +                21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31};
    +        ByteString blob = ProvisionUtils.tpm20MakeCredential(ekPub, akPub, nonce);
    +
    +        Path resources = Objects.requireNonNull(Paths.get(Objects.requireNonNull(this.getClass().getResource(
    +                        "/").toURI()))
    +                .getParent().getParent().getParent().getParent());
    +        Path makeBlob = resources.resolve("src/test/resources/tpm2/test/make.blob");
    +        Files.write(makeBlob, blob.toByteArray());
    +
    +        Path secretPath = resources.resolve("src/test/resources/tpm2/test/secret.blob");
    +        Files.write(secretPath, nonce);
    +    }
     
         /**
          * Test helper method that encrypts a blob using the specified transformation and the test key
    diff --git a/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/entity/userdefined/record/TPMMeasurementRecordTest.java b/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/entity/userdefined/record/TPMMeasurementRecordTest.java
    index 2894dfed3..9fdccee17 100644
    --- a/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/entity/userdefined/record/TPMMeasurementRecordTest.java
    +++ b/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/entity/userdefined/record/TPMMeasurementRecordTest.java
    @@ -2,7 +2,7 @@
     
     import hirs.attestationca.persist.entity.userdefined.ExaminableRecord;
     import hirs.utils.digest.Digest;
    -import hirs.utils.enums.DigestAlgorithm;
    +import hirs.utils.digest.DigestAlgorithm;
     import org.apache.commons.codec.DecoderException;
     import org.apache.commons.codec.binary.Hex;
     import org.apache.logging.log4j.LogManager;
    diff --git a/HIRS_Utils/src/main/java/hirs/utils/signature/cose/Cbor/CborBstr.java b/HIRS_Utils/src/main/java/hirs/utils/signature/cose/Cbor/CborBstr.java
    index 6c053cb64..1eb80c90e 100644
    --- a/HIRS_Utils/src/main/java/hirs/utils/signature/cose/Cbor/CborBstr.java
    +++ b/HIRS_Utils/src/main/java/hirs/utils/signature/cose/Cbor/CborBstr.java
    @@ -8,12 +8,12 @@
      * Note: use getContent() to retrieve the data with the byteSting encoding stripped off.
      */
     public class CborBstr {
    -    private static final int typeMask = 0xE0;
    -    private static final int infoMask = 0x1F;
    -    private static final int shiftOffset = 0x05;
    -    private static final int byteStringType = 0x02;
    -    private static final int byteStringLength = 0x03;
    -    private static final int coseNilByte = 0xa0; // Cose defined nil byte for empty payloads.
    +    private static final int TYPE_MASK = 0xE0;
    +    private static final int INFO_MASK = 0x1F;
    +    private static final int SHIFT_OFFSET = 0x05;
    +    private static final int BYTE_STRING_TYPE = 0x02;
    +    private static final int BYTE_STRING_LENGTH = 0x03;
    +    private static final int COSE_NIL_BYTE = 0xa0; // Cose defined nil byte for empty payloads.
         private byte[] contents = null;
     
         /**
    @@ -25,13 +25,13 @@ public CborBstr(final byte[] data) {
     
             byte type = data[0];
             // Check if byte 0 is of major type 0x02 (Byte String)
    -        byte cborType = (byte) ((type & typeMask) >> shiftOffset);
    -        if (cborType != byteStringType) {
    +        byte cborType = (byte) ((type & TYPE_MASK) >> SHIFT_OFFSET);
    +        if (cborType != BYTE_STRING_TYPE) {
                 throw new RuntimeException("Byte Array Decode Error, expecting a byte String (Type 2) but found "
                         + cborType);
             }
    -        contents = new byte[data.length - byteStringLength];
    -        System.arraycopy(data, byteStringLength, contents, 0, data.length - byteStringLength);
    +        contents = new byte[data.length - BYTE_STRING_LENGTH];
    +        System.arraycopy(data, BYTE_STRING_LENGTH, contents, 0, data.length - BYTE_STRING_LENGTH);
         }
     
         /**
    @@ -43,8 +43,8 @@ public CborBstr(final byte[] data) {
         public static boolean isByteString(final byte[] data) {
             byte type = data[0];
             // Check if byte 0 is of major type 0x02 (Byte String)
    -        byte cborType = (byte) ((type & typeMask) >> shiftOffset);
    -        return cborType == byteStringType;
    +        byte cborType = (byte) ((type & TYPE_MASK) >> SHIFT_OFFSET);
    +        return cborType == BYTE_STRING_TYPE;
         }
     
         /**
    @@ -58,7 +58,7 @@ public static boolean isEmptyByteString(final byte[] data) {
                 return false;
             }
             // per the cose spec 0xa0 is equivalent to {}
    -        return (data[3] & 0xFF) == coseNilByte;
    +        return (data[3] & 0xFF) == COSE_NIL_BYTE;
         }
     
         /**
    @@ -70,7 +70,7 @@ public static boolean isEmptyByteString(final byte[] data) {
         public static int getByteStringLength(final byte[] data) {
             int length = 0;
             byte type = data[0];
    -        byte tagInfo = (byte) (type & infoMask);
    +        byte tagInfo = (byte) (type & INFO_MASK);
             if (tagInfo < CborTagProcessor.CBOR_ONE_BYTE_UNSIGNED_INT) {
                 length = tagInfo; // values 0 to 0x17
             } else if (tagInfo == CborTagProcessor.CBOR_ONE_BYTE_UNSIGNED_INT) {
    @@ -96,7 +96,7 @@ public static int getByteStringLength(final byte[] data) {
         public static int getByteStringTagLength(final byte[] data) {
             int length = 0;
             byte type = data[0];
    -        byte tagInfo = (byte) (type & infoMask);
    +        byte tagInfo = (byte) (type & INFO_MASK);
             if (tagInfo < CborTagProcessor.CBOR_ONE_BYTE_UNSIGNED_INT) {
                 length = 1; // values 0 to 0x17
             } else if (tagInfo == CborTagProcessor.CBOR_ONE_BYTE_UNSIGNED_INT) {
    diff --git a/HIRS_Utils/src/main/java/hirs/utils/signature/cose/CoseHeaderProtected.java b/HIRS_Utils/src/main/java/hirs/utils/signature/cose/CoseHeaderProtected.java
    index 395723d2f..23495c111 100644
    --- a/HIRS_Utils/src/main/java/hirs/utils/signature/cose/CoseHeaderProtected.java
    +++ b/HIRS_Utils/src/main/java/hirs/utils/signature/cose/CoseHeaderProtected.java
    @@ -11,7 +11,6 @@
     import lombok.Getter;
     
     import java.io.IOException;
    -import java.util.Iterator;
     import java.util.List;
     
     /**
    @@ -21,11 +20,14 @@
     public class CoseHeaderProtected extends CoseHeader {
         // criticality
         @Getter
    -    private final String crit = "";
    +    private static final String CRIT = "";
    +
         // CBor Pairs (currently only 2 being processed: metamap and x5t for corim)
         private MetaMap mmap = null;
    +
         @Getter
         private String x5tHashAlg = "";
    +
         @Getter
         private String x5tHashVal = "";
         private String toStringCborDiag = "";
    @@ -57,9 +59,7 @@ public CoseHeaderProtected(final COSEProtectedHeader pheader) {
             // Cbor pairs
             if (pheader.getDecodedContent() != null) {
                 List cborPairs = (List) pheader.getPairs();
    -            Iterator pairs = cborPairs.iterator();
    -            while (pairs.hasNext()) {
    -                CBORPair pair = (CBORPair) pairs.next();
    +            for (CBORPair pair : cborPairs) {
                     // Look for corim-meta (index 8)
                     if (Integer.parseInt(pair.getKey().toString()) == CoRim.CORIM_META_MAP) {
                         byte[] corimMap = pair.getValue().encode();
    @@ -110,8 +110,8 @@ public String toString(final String format) throws IOException {
                 returnString = "Protected Header Contents: " + "\n";
                 returnString += printHeaderCommonContentsPretty();
     
    -            if (!crit.isEmpty()) {
    -                returnString += "  Criticality = " + crit + "\n";
    +            if (!CRIT.isEmpty()) {
    +                returnString += "  Criticality = " + CRIT + "\n";
                 }
                 if (mmap != null) {
                     returnString += "  Signer Name = " + mmap.getSignerName() + "\n";
    
    From 1e1cc8734e80e846f2481fe74d2a2bdcce7fbea5 Mon Sep 17 00:00:00 2001
    From: ThatSilentCoder <184309164+ThatSilentCoder@users.noreply.github.com>
    Date: Fri, 13 Feb 2026 15:23:57 -0500
    Subject: [PATCH 09/20] v3.1_issue_1101: Fixed broken issue
    
    ---
     .../utils/rim/unsignedRim/cbor/ietfCoswid/CoswidBuilder.java   | 3 +--
     1 file changed, 1 insertion(+), 2 deletions(-)
    
    diff --git a/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/cbor/ietfCoswid/CoswidBuilder.java b/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/cbor/ietfCoswid/CoswidBuilder.java
    index 5f09819cd..3659add05 100644
    --- a/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/cbor/ietfCoswid/CoswidBuilder.java
    +++ b/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/cbor/ietfCoswid/CoswidBuilder.java
    @@ -11,10 +11,9 @@
     import java.io.File;
     import java.io.IOException;
     import java.nio.file.Files;
    -import java.util.ArrayList;
     import java.util.HexFormat;
    -import java.util.Iterator;
     import java.util.Map;
    +import java.util.Set;
     import java.util.UUID;
     
     /**
    
    From 7920ebcc8b4ec5677961a794d7c724947b22ab8f Mon Sep 17 00:00:00 2001
    From: ThatSilentCoder <184309164+ThatSilentCoder@users.noreply.github.com>
    Date: Tue, 17 Feb 2026 15:09:49 -0500
    Subject: [PATCH 10/20] v3.1_issue_1101: Fixed more warnings and errors from
     javadocs. Will continue addressing more warnings from the utils module.
    
    ---
     .../utils/rim/unsignedRim/GenericRim.java     |   1 -
     .../cbor/ietfCoswid/CoswidConfig.java         |   9 +-
     .../hirs/utils/rim/unsignedRim/xml/Swid.java  | 270 ++++++++++++------
     .../xml/pcclientrim/PcClientRimBuilder.java   | 125 ++++----
     .../java/hirs/utils/swid/SwidTagGateway.java  |   5 +-
     .../main/java/hirs/utils/xjc/Directory.java   |   2 +
     .../src/main/java/hirs/utils/xjc/Entity.java  |   4 +
     .../main/java/hirs/utils/xjc/KeyInfoType.java |   2 +
     .../java/hirs/utils/xjc/KeyValueType.java     |   2 +
     .../java/hirs/utils/xjc/ManifestType.java     |   2 +
     .../java/hirs/utils/xjc/ObjectFactory.java    | 265 ++++++++++++++---
     .../main/java/hirs/utils/xjc/ObjectType.java  |   2 +
     .../main/java/hirs/utils/xjc/PGPDataType.java |   8 +-
     .../hirs/utils/xjc/ResourceCollection.java    |   2 +
     .../java/hirs/utils/xjc/SPKIDataType.java     |   7 +-
     .../hirs/utils/xjc/SignaturePropertyType.java |   2 +
     .../java/hirs/utils/xjc/SignedInfoType.java   |   2 +
     .../java/hirs/utils/xjc/SoftwareIdentity.java |   2 +
     .../java/hirs/utils/xjc/X509DataType.java     |  11 +-
     build.gradle                                  |   2 +-
     20 files changed, 516 insertions(+), 209 deletions(-)
    
    diff --git a/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/GenericRim.java b/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/GenericRim.java
    index 3d6e3a30f..0e0886fc5 100644
    --- a/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/GenericRim.java
    +++ b/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/GenericRim.java
    @@ -27,7 +27,6 @@
      *   
  • RIMTYPE_CORIM_COMID: IETF CoRIM (Concise RIM) which envelopes a comid
  • *
  • RIMTYPE_CORIM_COSWID: IETF CoRIM which envelopes a CoSWID
  • * - *

    */ public interface GenericRim { diff --git a/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/cbor/ietfCoswid/CoswidConfig.java b/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/cbor/ietfCoswid/CoswidConfig.java index b5298be54..f6918e649 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/cbor/ietfCoswid/CoswidConfig.java +++ b/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/cbor/ietfCoswid/CoswidConfig.java @@ -6,8 +6,8 @@ import java.io.ByteArrayInputStream; import java.io.File; -import java.nio.file.Files; import java.io.IOException; +import java.nio.file.Files; import java.util.Map; /** @@ -16,10 +16,12 @@ @NoArgsConstructor public class CoswidConfig extends Coswid { protected JsonNode rootNode = null; + /** * Constructor that takes in a filename and runs a validation on the config file. + * * @param filename name of the Json formatted configration file. - * @throws IOException if parsing errrors are encountered. + * @throws IOException if parsing errrors are encountered. */ public CoswidConfig(final String filename) throws IOException { try { @@ -48,7 +50,8 @@ public CoswidConfig(final String filename) throws IOException { /** * Initializes Class variables based upon a JsonNode object. * Used by inherited classes to fill in Coswid variables from a json node - * @param initNode + * + * @param initNode initial node */ protected void init(final JsonNode initNode) { lang = rootNode.path(CoswidItems.LANG_STR).asText(); diff --git a/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/xml/Swid.java b/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/xml/Swid.java index 6f1076ca8..b10122635 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/xml/Swid.java +++ b/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/xml/Swid.java @@ -7,7 +7,8 @@ * Class that contains definitions found in the SWID specification ISO/IEC 19770-2:2015. * Used by Coswid (Rfc 9393) which is based upon SWID specification. */ -@Setter @Getter +@Setter +@Getter public class Swid { // Order of variables follows the order listed in the table in section 8.5.1 of the SWID spec @@ -15,144 +16,227 @@ public class Swid { // SWID Elements are listed first public static final String SWID_SOFTWARE_IDENTITY_STR = "SoftwareIdentity"; // Software Identity Element Attributes - /** Flag set to true if tag is a patch tag which indicates this tag applies to pre-installation data. */ - protected boolean corpus = false; public static final String SWID_CORPUS_STR = "corpus"; - /** Flag set to true if tag is a patch tag that implies modification to the software. */ - protected boolean patch = false; public static final String SWID_PATCH_STR = "patch"; - /** String that desribes the "Platform" this software applies to. */ - protected String swidMedia = null; public static final String SWID_MEDIA_STR = "media"; - /** String that provides the software component name. */ - protected String softwareName = null; public static final String SWID_NAME_STR = "name"; - /** Flag set to true if tag is a Supplemental tag which is generally provided by different entities. */ - protected boolean supplemental = false; public static final String SWID_SUPPLEMENTAL_STR = "supplemental"; - /** Tag Identifier - usually a UUID. */ - protected String swidTagId = null; public static final String SWID_TAG_ID_STR = "tagId"; - /** Version of the tag. */ - protected String tagVersion = null; public static final String SWID_TAG_VERSION_STR = "tagVersion"; - /** Swid spec version. */ - protected String softwareVersion = null; public static final String SWID_VERSION_STR = "version"; - /** Swid spec version. */ - protected String swidVersionScheme = null; public static final String SWID_VERSION_SCHEME_STR = "versionScheme"; - - /** Entity Element. */ + /** + * Entity Element. + */ public static final String SWID_ENTITY_STR = "Entity"; - /** Name of the Entity that created this tag. */ - protected String swidEntityName = null; public static final String SWID_ENTITY_NAME_STR = "name"; - /** IANA ID of the Entity that created this tag. */ - protected String regId = null; public static final String SWID_ENTITY_REGID_STR = "regid"; - /** Role of the entity had in creating this tag. */ - protected String role = null; public static final String SWID_ENTITY_ROL_STR = "role"; - /** hash of the cert used to sign this tag. */ - protected String thumbprint = null; public static final String SWID_ENTITY_THUMBPRINT_STR = "thumbprint"; - - // Evidence Element - /** Evidence is a scan of the system where software which does not have a swid tag is discovered. */ + /** + * Evidence is a scan of the system where software which does not have a swid tag is discovered. + */ public static final String SWID_EVIDENCE_STR = "Evidence"; - /** Date and time the evidence was collected. */ - protected String swidEvidenceDate = null; public static final String SWID_EVIDENCE_DATE_STR = "date"; - /** Identifier of the device the evidence was collected from. */ - protected String swidEvidenceDeviceId = null; public static final String SWID_EVIDENCE_DEVICE_ID_STR = "deviceId"; - - // Link Element - /** Link is a reference to any other item. */ + /** + * Link is a reference to any other item. + */ public static final String SWID_LINK_STR = "Link"; - /** Canonical name for the item being referenced. */ - protected String swidLinkArtifact = null; public static final String SWID_LINK_ARTIFACT_STR = "artifact"; - /** Link to the item being referenced. */ - protected String href = null; public static final String SWID_LINK_HREF_STR = "href"; - /** String that describes the "Platform" this software applies to. */ - protected String swidLinkMedia = null; public static final String SWID_LINK_MEDIA_STR = "media"; - /** String that describes the "Strength of ownership" of the target piece of software. */ - protected String swidLinkOwnership = null; public static final String SWID_LINK_OWNERSHIP_STR = "ownership"; - /** String that describes the "relationship" betwen the tag abd the target software. */ - protected String rel = null; public static final String SWID_LINK_REL_STR = "rel"; - /** String type of media the device the link refers to. */ - protected String swidLinkType = null; public static final String SWID_LINK_TYPE_STR = "type"; - /** Determines if the target is a hard requirement. */ - protected String swidLinkUse = null; public static final String SWID_LINK_USE_STR = "use"; - // Meta Element public static final String SWID_META_STR = "Meta"; - // Payload Element public static final String SWID_PAYLOAD_STR = "Payload"; - /** Directory where the payload is located. */ - protected String swidPayloadDirectory = null; + + // Evidence Element public static final String SWID_PAYLOAD_DIR_STR = "directory"; - /** Flag to denote the importance of the directory. */ - private boolean swidPayloadDirectoryKey = false; public static final String SWID_PAYLOAD_DIR_KEY_STR = "payloadDirKey"; - /** location of the directory. */ - protected String swidPayloadDirectoryLocation = null; public static final String SWID_PAYLOAD_DIR_LOC_STR = "location"; - /** name of the directory. */ - protected String swidPayloadDirectoryName = null; public static final String SWID_PAYLOAD_DIR_NAME_STR = "directoryName"; - /** Root directory the directory os relative to. */ - protected String swidPayloadDirectoryRoot = null; public static final String SWID_PAYLOAD_DIR_ROOT_STR = "rootDirectory"; - /** file the payload refers to. */ - protected String swidPayloadFile = null; + + // Link Element public static final String SWID_PAYLOAD_FILE_STR = "file"; - /** name of the file the payload refers to. */ - protected String swidPayloadFileName = null; public static final String SWID_PAYLOAD_FILE_NAME = "fileName"; - /** size the payload refers to. */ - protected int swidPayloadFileSize = 0; public static final String SWID_PAYLOAD_FILE_SIZE = "size"; - /** version of the file the payload refers to. */ - protected String swidPayloadFileVersion = null; public static final String SWID_PAYLOAD_FILE_VER_STR = "file-version"; - - // Process - /** OS Process information. */ + /** + * OS Process information. + */ public static final String SWID_PROCESS_STR = "process"; - /** Process id string (name). */ - protected String swidProcessName = null; public static final String SWID_PROCESS_NAME_STR = "process"; - /** Process id int (name). */ - protected int swidProcessPid = 0; public static final String SWID_PROCESS_PID_STR = "processId"; - - // Resource - /** OS Process information. */ + /** + * OS Process information. + */ public static final String SWID_RESOURCE_STR = "resource"; - /** Genric description of the resource (name). */ - protected String swidResourceType = null; public static final String SWID_RESOURCE_TYPE_STR = "resourceType"; + public static final String SWID_META_COL_VER_STR = "colloquialVersion"; + public static final String SWID_META_COL_PRODUCT_STR = "product"; + public static final String SWID_META_REV_STR = "revision"; + public static final String SWID_META_EDITION_STR = "edition"; + /** + * Flag set to true if tag is a patch tag which indicates this tag applies to pre-installation data. + */ + protected boolean corpus = false; + /** + * Flag set to true if tag is a patch tag that implies modification to the software. + */ + protected boolean patch = false; + /** + * String that desribes the "Platform" this software applies to. + */ + protected String swidMedia = null; + /** + * String that provides the software component name. + */ + protected String softwareName = null; + /** + * Flag set to true if tag is a Supplemental tag which is generally provided by different entities. + */ + protected boolean supplemental = false; + /** + * Tag Identifier - usually a UUID. + */ + protected String swidTagId = null; + /** + * Version of the tag. + */ + protected String tagVersion = null; + /** + * Swid spec version. + */ + protected String softwareVersion = null; + /** + * Swid spec version. + */ + protected String swidVersionScheme = null; + /** + * Name of the Entity that created this tag. + */ + protected String swidEntityName = null; + /** + * IANA ID of the Entity that created this tag. + */ + protected String regId = null; + /** + * Role of the entity had in creating this tag. + */ + protected String role = null; + /** + * hash of the cert used to sign this tag. + */ + protected String thumbprint = null; + /** + * Date and time the evidence was collected. + */ + protected String swidEvidenceDate = null; + /** + * Identifier of the device the evidence was collected from. + */ + protected String swidEvidenceDeviceId = null; + /** + * Canonical name for the item being referenced. + */ + protected String swidLinkArtifact = null; + /** + * Link to the item being referenced. + */ + protected String href = null; + /** + * String that describes the "Platform" this software applies to. + */ + protected String swidLinkMedia = null; + /** + * String that describes the "Strength of ownership" of the target piece of software. + */ + protected String swidLinkOwnership = null; + /** + * String that describes the "relationship" betwen the tag abd the target software. + */ + protected String rel = null; + /** + * String type of media the device the link refers to. + */ + protected String swidLinkType = null; + /** + * Determines if the target is a hard requirement. + */ + protected String swidLinkUse = null; + + // Process + /** + * Directory where the payload is located. + */ + protected String swidPayloadDirectory = null; + /** + * location of the directory. + */ + protected String swidPayloadDirectoryLocation = null; + /** + * name of the directory. + */ + protected String swidPayloadDirectoryName = null; + /** + * Root directory the directory os relative to. + */ + protected String swidPayloadDirectoryRoot = null; + /** + * file the payload refers to. + */ + protected String swidPayloadFile = null; + + // Resource + /** + * name of the file the payload refers to. + */ + protected String swidPayloadFileName = null; + /** + * size the payload refers to. + */ + protected int swidPayloadFileSize = 0; + /** + * version of the file the payload refers to. + */ + protected String swidPayloadFileVersion = null; // NIST IR 8060 defined Meta fields used by Coswid and TCG PC Client RIM - /** Version defined by NIST IR 8060. */ + /** + * Process id string (name). + */ + protected String swidProcessName = null; + /** + * Process id int (name). + */ + protected int swidProcessPid = 0; + /** + * Genric description of the resource (name). + */ + protected String swidResourceType = null; + /** + * Version defined by NIST IR 8060. + */ protected String colloquialVersion = null; - public static final String SWID_META_COL_VER_STR = "colloquialVersion"; - /** Product defined by NIST IR 8060. */ + /** + * Product defined by NIST IR 8060. + */ protected String product = null; - public static final String SWID_META_COL_PRODUCT_STR = "product"; - /** Revision defined by NIST IR 8060. */ + /** + * Revision defined by NIST IR 8060. + */ protected String revision = null; - public static final String SWID_META_REV_STR = "revision"; - /** Edition defined by NIST IR 8060. */ + /** + * Edition defined by NIST IR 8060. + */ protected String edition = null; - public static final String SWID_META_EDITION_STR = "edition"; + /** + * Flag to denote the importance of the directory. + */ + private boolean swidPayloadDirectoryKey = false; } diff --git a/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/xml/pcclientrim/PcClientRimBuilder.java b/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/xml/pcclientrim/PcClientRimBuilder.java index dbbb99639..4ff21e12e 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/xml/pcclientrim/PcClientRimBuilder.java +++ b/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/xml/pcclientrim/PcClientRimBuilder.java @@ -3,7 +3,20 @@ import hirs.utils.swid.CredentialParser; import hirs.utils.swid.HashSwid; import hirs.utils.swid.SwidTagConstants; +import hirs.utils.xjc.Directory; +import hirs.utils.xjc.Entity; import hirs.utils.xjc.File; +import hirs.utils.xjc.FilesystemItem; +import hirs.utils.xjc.Link; +import hirs.utils.xjc.ObjectFactory; +import hirs.utils.xjc.ResourceCollection; +import hirs.utils.xjc.SoftwareIdentity; +import hirs.utils.xjc.SoftwareMeta; +import jakarta.json.Json; +import jakarta.json.JsonArray; +import jakarta.json.JsonException; +import jakarta.json.JsonObject; +import jakarta.json.JsonReader; import jakarta.xml.bind.JAXBContext; import jakarta.xml.bind.JAXBElement; import jakarta.xml.bind.JAXBException; @@ -16,6 +29,14 @@ import javax.xml.crypto.MarshalException; import javax.xml.crypto.XMLStructure; import javax.xml.crypto.dom.DOMStructure; +import javax.xml.crypto.dsig.Reference; +import javax.xml.crypto.dsig.SignatureProperties; +import javax.xml.crypto.dsig.SignatureProperty; +import javax.xml.crypto.dsig.SignedInfo; +import javax.xml.crypto.dsig.XMLObject; +import javax.xml.crypto.dsig.XMLSignature; +import javax.xml.crypto.dsig.XMLSignatureException; +import javax.xml.crypto.dsig.XMLSignatureFactory; import javax.xml.crypto.dsig.dom.DOMSignContext; import javax.xml.crypto.dsig.keyinfo.KeyInfo; import javax.xml.crypto.dsig.keyinfo.KeyInfoFactory; @@ -27,58 +48,34 @@ import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.Source; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerConfigurationException; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; -import java.math.BigInteger; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.security.cert.X509Certificate; -import java.time.LocalDateTime; - -import hirs.utils.xjc.Directory; -import hirs.utils.xjc.Entity; -import hirs.utils.xjc.FilesystemItem; -import hirs.utils.xjc.Link; -import hirs.utils.xjc.ObjectFactory; -import hirs.utils.xjc.ResourceCollection; -import hirs.utils.xjc.SoftwareIdentity; -import hirs.utils.xjc.SoftwareMeta; -import jakarta.json.Json; -import jakarta.json.JsonArray; -import jakarta.json.JsonException; -import jakarta.json.JsonObject; -import jakarta.json.JsonReader; - import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; +import java.math.BigInteger; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; import java.security.InvalidAlgorithmParameterException; import java.security.KeyException; import java.security.NoSuchAlgorithmException; import java.security.PrivateKey; +import java.security.cert.X509Certificate; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.Base64; import java.util.Collections; -import java.util.Iterator; import java.util.List; import java.util.Map; -import javax.xml.crypto.dsig.Reference; -import javax.xml.crypto.dsig.SignatureProperties; -import javax.xml.crypto.dsig.SignatureProperty; -import javax.xml.crypto.dsig.SignedInfo; -import javax.xml.crypto.dsig.XMLObject; -import javax.xml.crypto.dsig.XMLSignature; -import javax.xml.crypto.dsig.XMLSignatureException; -import javax.xml.crypto.dsig.XMLSignatureFactory; -import javax.xml.transform.Source; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; /** * Class that builds a PC Client RIM. @@ -129,6 +126,7 @@ public PcClientRimBuilder() { /** * Generate a SWIDtag from a file. + * * @param filename path to the file */ public void generateSwidTag(final String filename) { @@ -177,6 +175,7 @@ public void generateSwidTag(final String filename) { /** * Assemble a composite payload from json config properties. + * * @param configProperties the json config * @return the assembled composite payload as a Document object */ @@ -187,10 +186,9 @@ private Document assembleCompositePayload(final JsonObject configProperties) thr Document dirDoc = this.convertToDocument(jaxbDirectory); JsonArray files = configProperties.getJsonObject("Payload").getJsonObject("Directory") .getJsonArray("File"); - Iterator itr = files.iterator(); - while (itr.hasNext()) { - File file = this.createFile((JsonObject) itr.next()); + for (jakarta.json.JsonValue jsonValue : files) { + File file = this.createFile((JsonObject) jsonValue); JAXBElement jaxbFile = this.objectFactory.createDirectoryFile(file); Document fileDoc = this.convertToDocument(jaxbFile); Node fileNode = dirDoc.importNode(fileDoc.getDocumentElement(), true); @@ -208,8 +206,9 @@ private Document assembleCompositePayload(final JsonObject configProperties) thr /** * Transform a SWIDtag Document to a string output. + * * @param swidTag the Document object with the SWIDtag - * @param output the output string + * @param output the output string */ public void writeSwidTagFile(final Document swidTag, final String output) { try { @@ -234,6 +233,7 @@ public void writeSwidTagFile(final Document swidTag, final String output) { /** * Create software identity from a json object. + * * @param jsonObject the object with the attributes * @return the created SoftwareIdentity object */ @@ -269,6 +269,7 @@ private SoftwareIdentity createSwidTag(final JsonObject jsonObject) { /** * Create entity from a json object. + * * @param jsonObject the object with the attributes * @return the created entity object */ @@ -285,9 +286,9 @@ private Entity createEntity(final JsonObject jsonObject) { String[] roles = jsonObject.getString("role", "").split(","); - for (int i = 0; i < roles.length; ++i) { - entity.getRole().add(roles[i]); - if (roles[i].equals("tagCreator")) { + for (String role : roles) { + entity.getRole().add(role); + if (role.equals("tagCreator")) { isTagCreator = true; } } @@ -312,6 +313,7 @@ private Entity createEntity(final JsonObject jsonObject) { /** * Create link from a json object. + * * @param jsonObject the object with the attributes * @return the created link object */ @@ -332,6 +334,7 @@ private Link createLink(final JsonObject jsonObject) { /** * Create software metadata from a json object. + * * @param jsonObject the object with the attributes * @return the created SoftwareMeta object */ @@ -379,6 +382,7 @@ protected SoftwareMeta createSoftwareMeta(final JsonObject jsonObject) { /** * Create a payload from a json object. + * * @param jsonObject the object with the attributes * @return the created ResourceCollection object that holds the payload */ @@ -401,6 +405,7 @@ private ResourceCollection createPayload(final JsonObject jsonObject) { /** * Create a directory from a json object. + * * @param jsonObject the object with the attributes * @return the created directory */ @@ -409,10 +414,12 @@ private Directory createDirectory(final JsonObject jsonObject) { directory.setName(jsonObject.getString(SwidTagConstants.NAME, "")); directory.setLocation(jsonObject.getString(SwidTagConstants.LOCATION, "")); Map attributes = directory.getOtherAttributes(); - String supportRimFormat = jsonObject.getString(SwidTagConstants.SUPPORT_RIM_FORMAT, "supportRIMFormat missing"); + String supportRimFormat = + jsonObject.getString(SwidTagConstants.SUPPORT_RIM_FORMAT, "supportRIMFormat missing"); if (!supportRimFormat.equals("supportRIMFormat missing")) { if (supportRimFormat.isEmpty()) { - attributes.put(SwidTagConstants.QNAME_SUPPORT_RIM_FORMAT, SwidTagConstants.TCG_EVENTLOG_ASSERTION); + attributes.put(SwidTagConstants.QNAME_SUPPORT_RIM_FORMAT, + SwidTagConstants.TCG_EVENTLOG_ASSERTION); } else { attributes.put(SwidTagConstants.QNAME_SUPPORT_RIM_FORMAT, supportRimFormat); } @@ -429,6 +436,7 @@ private Directory createDirectory(final JsonObject jsonObject) { /** * Create a file from a json object. + * * @param jsonObject the object with the attributes * @return the created file */ @@ -450,7 +458,8 @@ private File createFile(final JsonObject jsonObject) throws Exception { "supportRIMFormat missing"); if (!supportRimFormat.equals("supportRIMFormat missing")) { if (supportRimFormat.isEmpty()) { - attributes.put(SwidTagConstants.QNAME_SUPPORT_RIM_FORMAT, SwidTagConstants.TCG_EVENTLOG_ASSERTION); + attributes.put(SwidTagConstants.QNAME_SUPPORT_RIM_FORMAT, + SwidTagConstants.TCG_EVENTLOG_ASSERTION); } else { attributes.put(SwidTagConstants.QNAME_SUPPORT_RIM_FORMAT, supportRimFormat); } @@ -465,10 +474,11 @@ private File createFile(final JsonObject jsonObject) throws Exception { /** * Add an attribute. + * * @param attributes the map of attributes - * @param key key for the added attribute - * @param value value for the added attribute - * @param required true if the attribute is required + * @param key key for the added attribute + * @param value value for the added attribute + * @param required true if the attribute is required */ protected void addNonNullAttribute(final Map attributes, final QName key, final String value, final boolean required) { @@ -482,9 +492,10 @@ protected void addNonNullAttribute(final Map attributes, final QN /** * Add an attribute. + * * @param attributes the map of attributes - * @param key key for the added attribute - * @param value value for the added attribute + * @param key key for the added attribute + * @param value value for the added attribute */ protected void addNonNullAttribute(final Map attributes, final QName key, final String value) { @@ -495,6 +506,7 @@ protected void addNonNullAttribute(final Map attributes, final QN /** * Convert a JAXBElement to Document type. + * * @param element the element to convert * @return the created Document */ @@ -513,6 +525,7 @@ private Document convertToDocument(final JAXBElement element) { /** * Sign an XML document. + * * @param doc document to sign * @return the signed document */ @@ -616,7 +629,8 @@ private Document signXMLDocument(final Document doc) { /** * Create XML timestamp. - * @param doc data to be timestamped + * + * @param doc data to be timestamped * @param sigFactory class used for generating the signature * @return XMLObject the created timestamp */ @@ -666,6 +680,7 @@ private XMLObject createXmlTimestamp(final Document doc, final XMLSignatureFacto /** * Sets RIM config file. + * * @param configFile the RIM config file */ @Generated @@ -675,6 +690,7 @@ public void setConfigFile(final String configFile) { /** * Sets RIM default credentials. + * * @param defaultCredentials the RIM default credentials */ @Generated @@ -684,6 +700,7 @@ public void setDefaultCredentials(final boolean defaultCredentials) { /** * Sets RIM truststore file. + * * @param jksTruststoreFile the truststore file */ @Generated @@ -693,6 +710,7 @@ public void setJksTruststoreFile(final String jksTruststoreFile) { /** * Sets RIM private key file. + * * @param pemPrivateKeyFile the RIM private key file */ @Generated @@ -702,6 +720,7 @@ public void setPemPrivateKeyFile(final String pemPrivateKeyFile) { /** * Sets RIM certificate file. + * * @param pemCertificateFile the RIM certifcate file */ @Generated @@ -711,6 +730,7 @@ public void setPemCertificateFile(final String pemCertificateFile) { /** * Sets true/false for embedded certificate. + * * @param embeddedCert true if cert is embedded */ @Generated @@ -720,6 +740,7 @@ public void setEmbeddedCert(final boolean embeddedCert) { /** * Sets RIM event log. + * * @param rimEventLog the RIM event log */ @Generated @@ -729,6 +750,7 @@ public void setRimEventLog(final String rimEventLog) { /** * Sets timestamp format. + * * @param timestampFormat the timestamp format */ @Generated @@ -738,6 +760,7 @@ public void setTimestampFormat(final String timestampFormat) { /** * Sets timestamp. + * * @param timestampArgument the timestamp */ @Generated diff --git a/HIRS_Utils/src/main/java/hirs/utils/swid/SwidTagGateway.java b/HIRS_Utils/src/main/java/hirs/utils/swid/SwidTagGateway.java index d701d7ed9..e6ba1d053 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/swid/SwidTagGateway.java +++ b/HIRS_Utils/src/main/java/hirs/utils/swid/SwidTagGateway.java @@ -175,7 +175,7 @@ public SwidTagGateway() { /** * This method generates a base RIM from the values in a JSON file. * - * @param filename + * @param filename json filename */ public void generateSwidTag(final String filename) { Document swidtag = builder.newDocument(); @@ -261,7 +261,7 @@ private Document assembleCompositePayload(final JsonObject configProperties) thr * This method writes a Document object out to the file specified by generatedFile. * * @param swidTag the XML representing the SWID tag to write - * @param output the file path to write the SWID tag to + * @param output the file path to write the SWID tag to */ public void writeSwidTagFile(final Document swidTag, final String output) { try { @@ -571,6 +571,7 @@ private Document convertToDocument(final JAXBElement element) { /** * This method signs a SoftwareIdentity with an xmldsig in compatibility mode. * Current assumptions: digest method SHA256, signature method SHA256, enveloped signature + * * @param doc the XML {@link Document} representing the SoftwareIdentity to sign * @return the signed XML {@link Document} */ diff --git a/HIRS_Utils/src/main/java/hirs/utils/xjc/Directory.java b/HIRS_Utils/src/main/java/hirs/utils/xjc/Directory.java index 7133270a3..eff89c8e6 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/xjc/Directory.java +++ b/HIRS_Utils/src/main/java/hirs/utils/xjc/Directory.java @@ -70,6 +70,8 @@ public class Directory * Objects of the following type(s) are allowed in the list * {@link Directory } * {@link File } + * + * @return list of file system items */ public List getDirectoryOrFile() { if (directoryOrFile == null) { diff --git a/HIRS_Utils/src/main/java/hirs/utils/xjc/Entity.java b/HIRS_Utils/src/main/java/hirs/utils/xjc/Entity.java index 03adfadf5..076687cc7 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/xjc/Entity.java +++ b/HIRS_Utils/src/main/java/hirs/utils/xjc/Entity.java @@ -91,6 +91,8 @@ public class Entity *

    * Objects of the following type(s) are allowed in the list * {@link Meta } + * + * @return list of Meta objects */ public List getMeta() { if (meta == null) { @@ -132,6 +134,8 @@ public String getRegid() { *

    * Objects of the following type(s) are allowed in the list * {@link String } + * + * @return list of string roles */ public List getRole() { if (role == null) { diff --git a/HIRS_Utils/src/main/java/hirs/utils/xjc/KeyInfoType.java b/HIRS_Utils/src/main/java/hirs/utils/xjc/KeyInfoType.java index b1b6c0add..735ecaab9 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/xjc/KeyInfoType.java +++ b/HIRS_Utils/src/main/java/hirs/utils/xjc/KeyInfoType.java @@ -109,6 +109,8 @@ public class KeyInfoType { * {@link Element } * {@link JAXBElement }{@code <}{@link SPKIDataType }{@code >} * {@link JAXBElement }{@code <}{@link RetrievalMethodType }{@code >} + * + * @return list of objects */ public List getContent() { if (content == null) { diff --git a/HIRS_Utils/src/main/java/hirs/utils/xjc/KeyValueType.java b/HIRS_Utils/src/main/java/hirs/utils/xjc/KeyValueType.java index 283514808..80911ba43 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/xjc/KeyValueType.java +++ b/HIRS_Utils/src/main/java/hirs/utils/xjc/KeyValueType.java @@ -78,6 +78,8 @@ public class KeyValueType { * {@link String } * {@link JAXBElement }{@code <}{@link DSAKeyValueType }{@code >} * {@link Object } + * + * @return list of objects */ public List getContent() { if (content == null) { diff --git a/HIRS_Utils/src/main/java/hirs/utils/xjc/ManifestType.java b/HIRS_Utils/src/main/java/hirs/utils/xjc/ManifestType.java index ee1fdd1dc..9a3bf91d3 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/xjc/ManifestType.java +++ b/HIRS_Utils/src/main/java/hirs/utils/xjc/ManifestType.java @@ -78,6 +78,8 @@ public class ManifestType { *

    * Objects of the following type(s) are allowed in the list * {@link ReferenceType } + * + * @return list of {@link ReferenceType} */ public List getReference() { if (reference == null) { diff --git a/HIRS_Utils/src/main/java/hirs/utils/xjc/ObjectFactory.java b/HIRS_Utils/src/main/java/hirs/utils/xjc/ObjectFactory.java index 931083bc8..cd18da6b0 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/xjc/ObjectFactory.java +++ b/HIRS_Utils/src/main/java/hirs/utils/xjc/ObjectFactory.java @@ -109,13 +109,16 @@ public class ObjectFactory { new QName("http://www.w3.org/2000/09/xmldsig#", "PGPKeyPacket"); /** - * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: main.java.hirs.utils.xjc + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for + * package: main.java.hirs.utils.xjc */ public ObjectFactory() { } /** * Create an instance of {@link SoftwareIdentity } + * + * @return {@link SoftwareIdentity } */ public SoftwareIdentity createSoftwareIdentity() { return new SoftwareIdentity(); @@ -123,6 +126,8 @@ public SoftwareIdentity createSoftwareIdentity() { /** * Create an instance of {@link SoftwareMeta } + * + * @return {@link SoftwareMeta } */ public SoftwareMeta createSoftwareMeta() { return new SoftwareMeta(); @@ -130,6 +135,8 @@ public SoftwareMeta createSoftwareMeta() { /** * Create an instance of {@link Entity } + * + * @return {@link Entity } */ public Entity createEntity() { return new Entity(); @@ -137,6 +144,8 @@ public Entity createEntity() { /** * Create an instance of {@link Meta } + * + * @return {@link Meta } */ public Meta createMeta() { return new Meta(); @@ -144,6 +153,8 @@ public Meta createMeta() { /** * Create an instance of {@link FilesystemItem } + * + * @return {@link FilesystemItem } */ public FilesystemItem createFilesystemItem() { return new FilesystemItem(); @@ -151,6 +162,8 @@ public FilesystemItem createFilesystemItem() { /** * Create an instance of {@link Resource } + * + * @return {@link Resource } */ public Resource createResource() { return new Resource(); @@ -158,6 +171,8 @@ public Resource createResource() { /** * Create an instance of {@link Process } + * + * @return {@link Process } */ public Process createProcess() { return new Process(); @@ -165,6 +180,8 @@ public Process createProcess() { /** * Create an instance of {@link BaseElement } + * + * @return {@link BaseElement } */ public BaseElement createBaseElement() { return new BaseElement(); @@ -172,6 +189,8 @@ public BaseElement createBaseElement() { /** * Create an instance of {@link Evidence } + * + * @return {@link Evidence } */ public Evidence createEvidence() { return new Evidence(); @@ -179,6 +198,8 @@ public Evidence createEvidence() { /** * Create an instance of {@link File } + * + * @return {@link File} */ public File createFile() { return new File(); @@ -186,6 +207,8 @@ public File createFile() { /** * Create an instance of {@link Link } + * + * @return {@link Link} */ public Link createLink() { return new Link(); @@ -193,167 +216,213 @@ public Link createLink() { /** * Create an instance of {@link Directory } + * + * @return {@link Directory} */ public Directory createDirectory() { return new Directory(); } /** - * Create an instance of {@link ResourceCollection } + * Create an instance of {@link ResourceCollection }. + * + * @return {@link ResourceCollection } */ public ResourceCollection createResourceCollection() { return new ResourceCollection(); } /** - * Create an instance of {@link PGPDataType } + * Create an instance of {@link PGPDataType }. */ public PGPDataType createPGPDataType() { return new PGPDataType(); } /** - * Create an instance of {@link KeyValueType } + * Create an instance of {@link KeyValueType }. + * + * @return {@link KeyValueType } */ public KeyValueType createKeyValueType() { return new KeyValueType(); } /** - * Create an instance of {@link DSAKeyValueType } + * Create an instance of {@link DSAKeyValueType }. + * + * @return {@link DSAKeyValueType } */ public DSAKeyValueType createDSAKeyValueType() { return new DSAKeyValueType(); } /** - * Create an instance of {@link ReferenceType } + * Create an instance of {@link ReferenceType }. + * + * @return {@link ReferenceType } */ public ReferenceType createReferenceType() { return new ReferenceType(); } /** - * Create an instance of {@link RetrievalMethodType } + * Create an instance of {@link RetrievalMethodType }. + * + * @return {@link RetrievalMethodType } */ public RetrievalMethodType createRetrievalMethodType() { return new RetrievalMethodType(); } /** - * Create an instance of {@link TransformsType } + * Create an instance of {@link TransformsType }. + * + * @return {@link TransformsType } */ public TransformsType createTransformsType() { return new TransformsType(); } /** - * Create an instance of {@link CanonicalizationMethodType } + * Create an instance of {@link CanonicalizationMethodType }. + * + * @return {@link CanonicalizationMethodType }. */ public CanonicalizationMethodType createCanonicalizationMethodType() { return new CanonicalizationMethodType(); } /** - * Create an instance of {@link DigestMethodType } + * Create an instance of {@link DigestMethodType }. + * + * @return {@link DigestMethodType } */ public DigestMethodType createDigestMethodType() { return new DigestMethodType(); } /** - * Create an instance of {@link ManifestType } + * Create an instance of {@link ManifestType }. + * + * @return {@link ManifestType } */ public ManifestType createManifestType() { return new ManifestType(); } /** - * Create an instance of {@link SignaturePropertyType } + * Create an instance of {@link SignaturePropertyType }. + * + * @return {@link SignaturePropertyType } */ public SignaturePropertyType createSignaturePropertyType() { return new SignaturePropertyType(); } /** - * Create an instance of {@link X509DataType } + * Create an instance of {@link X509DataType }. + * + * @return {@link X509DataType } */ public X509DataType createX509DataType() { return new X509DataType(); } /** - * Create an instance of {@link SignedInfoType } + * Create an instance of {@link SignedInfoType }. + * + * @return {@link SignedInfoType } */ public SignedInfoType createSignedInfoType() { return new SignedInfoType(); } /** - * Create an instance of {@link RSAKeyValueType } + * Create an instance of {@link RSAKeyValueType }. + * + * @return {@link RSAKeyValueType } */ public RSAKeyValueType createRSAKeyValueType() { return new RSAKeyValueType(); } /** - * Create an instance of {@link SPKIDataType } + * Create an instance of {@link SPKIDataType }. + * + * @return {@link SPKIDataType } */ public SPKIDataType createSPKIDataType() { return new SPKIDataType(); } /** - * Create an instance of {@link SignatureValueType } + * Create an instance of {@link SignatureValueType }. + * + * @return {@link SignatureValueType } */ public SignatureValueType createSignatureValueType() { return new SignatureValueType(); } /** - * Create an instance of {@link KeyInfoType } + * Create an instance of {@link KeyInfoType }. + * + * @return {@link KeyInfoType } */ public KeyInfoType createKeyInfoType() { return new KeyInfoType(); } /** - * Create an instance of {@link SignatureType } + * Create an instance of {@link SignatureType }. + * + * @return {@link SignatureType } */ public SignatureType createSignatureType() { return new SignatureType(); } /** - * Create an instance of {@link SignaturePropertiesType } + * Create an instance of {@link SignaturePropertiesType }. + * + * @return {@link SignaturePropertiesType } */ public SignaturePropertiesType createSignaturePropertiesType() { return new SignaturePropertiesType(); } /** - * Create an instance of {@link SignatureMethodType } + * Create an instance of {@link SignatureMethodType }. + * + * @return {@link SignatureMethodType } */ public SignatureMethodType createSignatureMethodType() { return new SignatureMethodType(); } /** - * Create an instance of {@link ObjectType } + * Create an instance of {@link ObjectType }. + * + * @return {@link ObjectType } */ public ObjectType createObjectType() { return new ObjectType(); } /** - * Create an instance of {@link TransformType } + * Create an instance of {@link TransformType }. + * + * @return {@link TransformType } */ public TransformType createTransformType() { return new TransformType(); } /** - * Create an instance of {@link X509IssuerSerialType } + * Create an instance of {@link X509IssuerSerialType }. + * + * @return {@link X509IssuerSerialType } */ public X509IssuerSerialType createX509IssuerSerialType() { return new X509IssuerSerialType(); @@ -361,6 +430,9 @@ public X509IssuerSerialType createX509IssuerSerialType() { /** * Create an instance of {@link JAXBElement }{@code <}{@link SPKIDataType }{@code >}} + * + * @param value {@link SPKIDataType } representation of the value + * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "SPKIData") public JAXBElement createSPKIData(SPKIDataType value) { @@ -369,6 +441,9 @@ public JAXBElement createSPKIData(SPKIDataType value) { /** * Create an instance of {@link JAXBElement }{@code <}{@link KeyInfoType }{@code >}} + * + * @param value {@link KeyInfoType } representation of the value + * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "KeyInfo") public JAXBElement createKeyInfo(KeyInfoType value) { @@ -377,6 +452,9 @@ public JAXBElement createKeyInfo(KeyInfoType value) { /** * Create an instance of {@link JAXBElement }{@code <}{@link SignatureValueType }{@code >}} + * + * @param value {@link SignatureValueType } representation of the value + * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "SignatureValue") public JAXBElement createSignatureValue(SignatureValueType value) { @@ -386,6 +464,9 @@ public JAXBElement createSignatureValue(SignatureValueType v /** * Create an instance of {@link JAXBElement }{@code <}{@link KeyValueType }{@code >}} + * + * @param value {@link KeyValueType } representation of the value + * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "KeyValue") public JAXBElement createKeyValue(KeyValueType value) { @@ -394,6 +475,9 @@ public JAXBElement createKeyValue(KeyValueType value) { /** * Create an instance of {@link JAXBElement }{@code <}{@link TransformsType }{@code >}} + * + * @param value {@link TransformsType } representation of the value + * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "Transforms") public JAXBElement createTransforms(TransformsType value) { @@ -402,6 +486,9 @@ public JAXBElement createTransforms(TransformsType value) { /** * Create an instance of {@link JAXBElement }{@code <}{@link DigestMethodType }{@code >}} + * + * @param value {@link DigestMethodType } representation of the value + * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "DigestMethod") public JAXBElement createDigestMethod(DigestMethodType value) { @@ -410,6 +497,9 @@ public JAXBElement createDigestMethod(DigestMethodType value) /** * Create an instance of {@link JAXBElement }{@code <}{@link X509DataType }{@code >}} + * + * @param value {@link X509DataType } representation of the value + * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "X509Data") public JAXBElement createX509Data(X509DataType value) { @@ -418,6 +508,9 @@ public JAXBElement createX509Data(X509DataType value) { /** * Create an instance of {@link JAXBElement }{@code <}{@link SignaturePropertyType }{@code >}} + * + * @param value {@link SignaturePropertyType } representation of the value + * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "SignatureProperty") public JAXBElement createSignatureProperty(SignaturePropertyType value) { @@ -427,6 +520,10 @@ public JAXBElement createSignatureProperty(SignaturePrope /** * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}} + *

    + * * @param value string representation of the value + * + * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "KeyName") public JAXBElement createKeyName(String value) { @@ -435,6 +532,9 @@ public JAXBElement createKeyName(String value) { /** * Create an instance of {@link JAXBElement }{@code <}{@link RSAKeyValueType }{@code >}} + * + * @param value {@link RSAKeyValueType } representation of the value + * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "RSAKeyValue") public JAXBElement createRSAKeyValue(RSAKeyValueType value) { @@ -443,6 +543,9 @@ public JAXBElement createRSAKeyValue(RSAKeyValueType value) { /** * Create an instance of {@link JAXBElement }{@code <}{@link SoftwareIdentity }{@code >}} + * + * @param value {@link SoftwareIdentity } representation of the value + * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://standards.iso.org/iso/19770/-2/2015/schema.xsd", name = "SoftwareIdentity") public JAXBElement createSoftwareIdentity(SoftwareIdentity value) { @@ -452,6 +555,9 @@ public JAXBElement createSoftwareIdentity(SoftwareIdentity val /** * Create an instance of {@link JAXBElement }{@code <}{@link SignatureType }{@code >}} + * + * @param value {@link SignatureType } representation of the value + * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "Signature") public JAXBElement createSignature(SignatureType value) { @@ -460,6 +566,9 @@ public JAXBElement createSignature(SignatureType value) { /** * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}} + * + * @param value string representation of the value + * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "MgmtData") public JAXBElement createMgmtData(String value) { @@ -468,6 +577,9 @@ public JAXBElement createMgmtData(String value) { /** * Create an instance of {@link JAXBElement }{@code <}{@link SignatureMethodType }{@code >}} + * + * @param value {@link SignatureMethodType } representation of the value + * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "SignatureMethod") public JAXBElement createSignatureMethod(SignatureMethodType value) { @@ -477,6 +589,8 @@ public JAXBElement createSignatureMethod(SignatureMethodTyp /** * Create an instance of {@link JAXBElement }{@code <}{@link ObjectType }{@code >}} + * + * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "Object") public JAXBElement createObject(ObjectType value) { @@ -485,6 +599,8 @@ public JAXBElement createObject(ObjectType value) { /** * Create an instance of {@link JAXBElement }{@code <}{@link SignaturePropertiesType }{@code >}} + * + * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "SignatureProperties") public JAXBElement createSignatureProperties(SignaturePropertiesType value) { @@ -494,6 +610,8 @@ public JAXBElement createSignatureProperties(SignatureP /** * Create an instance of {@link JAXBElement }{@code <}{@link TransformType }{@code >}} + * + * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "Transform") public JAXBElement createTransform(TransformType value) { @@ -502,6 +620,8 @@ public JAXBElement createTransform(TransformType value) { /** * Create an instance of {@link JAXBElement }{@code <}{@link PGPDataType }{@code >}} + * + * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "PGPData") public JAXBElement createPGPData(PGPDataType value) { @@ -510,6 +630,8 @@ public JAXBElement createPGPData(PGPDataType value) { /** * Create an instance of {@link JAXBElement }{@code <}{@link ReferenceType }{@code >}} + * + * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "Reference") public JAXBElement createReference(ReferenceType value) { @@ -518,6 +640,8 @@ public JAXBElement createReference(ReferenceType value) { /** * Create an instance of {@link JAXBElement }{@code <}{@link RetrievalMethodType }{@code >}} + * + * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "RetrievalMethod") public JAXBElement createRetrievalMethod(RetrievalMethodType value) { @@ -527,6 +651,8 @@ public JAXBElement createRetrievalMethod(RetrievalMethodTyp /** * Create an instance of {@link JAXBElement }{@code <}{@link DSAKeyValueType }{@code >}} + * + * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "DSAKeyValue") public JAXBElement createDSAKeyValue(DSAKeyValueType value) { @@ -534,7 +660,10 @@ public JAXBElement createDSAKeyValue(DSAKeyValueType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link byte[]}{@code >}} + * Create an instance of {@link JAXBElement } using the provided byte array for the digest value. + * + * @param value byte array representation of the value. + * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "DigestValue") public JAXBElement createDigestValue(byte[] value) { @@ -542,7 +671,10 @@ public JAXBElement createDigestValue(byte[] value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link CanonicalizationMethodType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link CanonicalizationMethodType }{@code >}. + * + * @param value + * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "CanonicalizationMethod") public JAXBElement createCanonicalizationMethod( @@ -552,7 +684,10 @@ public JAXBElement createCanonicalizationMethod( } /** - * Create an instance of {@link JAXBElement }{@code <}{@link SignedInfoType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link SignedInfoType }{@code >}. + * + * @param value + * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "SignedInfo") public JAXBElement createSignedInfo(SignedInfoType value) { @@ -560,7 +695,9 @@ public JAXBElement createSignedInfo(SignedInfoType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link ManifestType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link ManifestType }{@code >}. + * + * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "Manifest") public JAXBElement createManifest(ManifestType value) { @@ -568,7 +705,9 @@ public JAXBElement createManifest(ManifestType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}. + * + * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "XPath", scope = TransformType.class) public JAXBElement createTransformTypeXPath(String value) { @@ -576,7 +715,10 @@ public JAXBElement createTransformTypeXPath(String value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link X509IssuerSerialType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link X509IssuerSerialType }{@code >}. + * + * @param value {@link X509IssuerSerialType } representation of the value + * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "X509IssuerSerial", scope = X509DataType.class) public JAXBElement createX509DataTypeX509IssuerSerial(X509IssuerSerialType value) { @@ -585,7 +727,10 @@ public JAXBElement createX509DataTypeX509IssuerSerial(X509 } /** - * Create an instance of {@link JAXBElement }{@code <}{@link byte[]}{@code >}} + * Create an instance of {@link JAXBElement } using the provided byte array for X509 CRL. + * + * @param value byte array representation of the value. + * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "X509CRL", scope = X509DataType.class) public JAXBElement createX509DataTypeX509CRL(byte[] value) { @@ -594,7 +739,10 @@ public JAXBElement createX509DataTypeX509CRL(byte[] value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}} + * Create an instance of {@link JAXBElement } using the provided string value for the X509 Subject Name. + * + * @param value string representation of the value. + * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "X509SubjectName", scope = X509DataType.class) public JAXBElement createX509DataTypeX509SubjectName(String value) { @@ -603,7 +751,10 @@ public JAXBElement createX509DataTypeX509SubjectName(String value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link byte[]}{@code >}} + * Create an instance of {@link JAXBElement } using the provided byte array for the X509 SKI. + * + * @param value byte array representation of the value. + * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "X509SKI", scope = X509DataType.class) public JAXBElement createX509DataTypeX509SKI(byte[] value) { @@ -612,7 +763,10 @@ public JAXBElement createX509DataTypeX509SKI(byte[] value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link byte[]}{@code >}} + * Create an instance of {@link JAXBElement } using the provided byte array for the X509 Certificate. + * + * @param value byte array representation of the value. + * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "X509Certificate", scope = X509DataType.class) public JAXBElement createX509DataTypeX509Certificate(byte[] value) { @@ -621,7 +775,7 @@ public JAXBElement createX509DataTypeX509Certificate(byte[] value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link Link }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link Link }{@code >}. */ @XmlElementDecl(namespace = "http://standards.iso.org/iso/19770/-2/2015/schema.xsd", name = "Link", scope = SoftwareIdentity.class) public JAXBElement createSoftwareIdentityLink(Link value) { @@ -629,7 +783,7 @@ public JAXBElement createSoftwareIdentityLink(Link value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link Evidence }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link Evidence }{@code >}. */ @XmlElementDecl(namespace = "http://standards.iso.org/iso/19770/-2/2015/schema.xsd", name = "Evidence", scope = SoftwareIdentity.class) public JAXBElement createSoftwareIdentityEvidence(Evidence value) { @@ -638,7 +792,10 @@ public JAXBElement createSoftwareIdentityEvidence(Evidence value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link ResourceCollection }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link ResourceCollection }{@code >}. + * + * @param value {@link ResourceCollection} representation of the value + * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://standards.iso.org/iso/19770/-2/2015/schema.xsd", name = "Payload", scope = SoftwareIdentity.class) public JAXBElement createSoftwareIdentityPayload(ResourceCollection value) { @@ -648,6 +805,9 @@ public JAXBElement createSoftwareIdentityPayload(ResourceCol /** * Create an instance of {@link JAXBElement }{@code <}{@link FilesystemItem }{@code >}} + * + * @param value {@link FilesystemItem } representation of the value + * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://standards.iso.org/iso/19770/-2/2015/schema.xsd", name = "Directory", scope = ResourceCollection.class) public JAXBElement createPayloadDirectory(FilesystemItem value) { @@ -657,6 +817,9 @@ public JAXBElement createPayloadDirectory(FilesystemItem value) /** * Create an instance of {@link JAXBElement }{@code <}{@link FilesystemItem }{@code >}} + * + * @param value {@link FilesystemItem} representation of the value + * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://standards.iso.org/iso/19770/-2/2015/schema.xsd", name = "File", scope = ResourceCollection.class) public JAXBElement createDirectoryFile(FilesystemItem value) { @@ -666,6 +829,9 @@ public JAXBElement createDirectoryFile(FilesystemItem value) { /** * Create an instance of {@link JAXBElement }{@code <}{@link Entity }{@code >}} + * + * @param value {@link Entity} representation of the value + * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://standards.iso.org/iso/19770/-2/2015/schema.xsd", name = "Entity", scope = SoftwareIdentity.class) public JAXBElement createSoftwareIdentityEntity(Entity value) { @@ -674,7 +840,10 @@ public JAXBElement createSoftwareIdentityEntity(Entity value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link SoftwareMeta }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link SoftwareMeta }{@code >}. + * + * @param value SoftwareMeta object representation of the value + * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://standards.iso.org/iso/19770/-2/2015/schema.xsd", name = "Meta", scope = SoftwareIdentity.class) public JAXBElement createSoftwareIdentityMeta(SoftwareMeta value) { @@ -683,7 +852,10 @@ public JAXBElement createSoftwareIdentityMeta(SoftwareMeta value) } /** - * Create an instance of {@link JAXBElement }{@code <}{@link BigInteger }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link BigInteger }{@code >}. + * + * @param value big integer representation of the value + * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "HMACOutputLength", scope = SignatureMethodType.class) public JAXBElement createSignatureMethodTypeHMACOutputLength(BigInteger value) { @@ -692,7 +864,10 @@ public JAXBElement createSignatureMethodTypeHMACOutputLength(BigInte } /** - * Create an instance of {@link JAXBElement }{@code <}{@link byte[]}{@code >}} + * Create an instance of {@link JAXBElement } using the provided byte array for the SPKISexp. + * + * @param value byte array representation of the value. + * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "SPKISexp", scope = SPKIDataType.class) public JAXBElement createSPKIDataTypeSPKISexp(byte[] value) { @@ -701,7 +876,10 @@ public JAXBElement createSPKIDataTypeSPKISexp(byte[] value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link byte[]}{@code >}} + * Create an instance of {@link JAXBElement } using the provided byte array for the PGPKeyID. + * + * @param value byte array representation of the value. + * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "PGPKeyID", scope = PGPDataType.class) public JAXBElement createPGPDataTypePGPKeyID(byte[] value) { @@ -710,7 +888,10 @@ public JAXBElement createPGPDataTypePGPKeyID(byte[] value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link byte[]}{@code >}} + * Create an instance of {@link JAXBElement } using the provided byte array for the PGPKeyPacket. + * + * @param value byte array representation of the value. + * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "PGPKeyPacket", scope = PGPDataType.class) public JAXBElement createPGPDataTypePGPKeyPacket(byte[] value) { diff --git a/HIRS_Utils/src/main/java/hirs/utils/xjc/ObjectType.java b/HIRS_Utils/src/main/java/hirs/utils/xjc/ObjectType.java index c7e5afa0a..d650e98a8 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/xjc/ObjectType.java +++ b/HIRS_Utils/src/main/java/hirs/utils/xjc/ObjectType.java @@ -95,6 +95,8 @@ public class ObjectType { * {@link Object } * {@link Element } * {@link String } + * + * @return list of objects */ public List getContent() { if (content == null) { diff --git a/HIRS_Utils/src/main/java/hirs/utils/xjc/PGPDataType.java b/HIRS_Utils/src/main/java/hirs/utils/xjc/PGPDataType.java index bd223f5ae..447c95978 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/xjc/PGPDataType.java +++ b/HIRS_Utils/src/main/java/hirs/utils/xjc/PGPDataType.java @@ -86,11 +86,9 @@ public class PGPDataType { * * *

    - * Objects of the following type(s) are allowed in the list - * {@link JAXBElement }{@code <}{@link byte[]}{@code >} - * {@link JAXBElement }{@code <}{@link byte[]}{@code >} - * {@link Element } - * {@link Object } + * Objects of the following type(s) are allowed in the list: + * Byte array and string representations of {@link JAXBElement }, + * {@link Element }, and {@link Object } * * @return list of objects */ diff --git a/HIRS_Utils/src/main/java/hirs/utils/xjc/ResourceCollection.java b/HIRS_Utils/src/main/java/hirs/utils/xjc/ResourceCollection.java index 6a5bdeb9a..7f0cef4ea 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/xjc/ResourceCollection.java +++ b/HIRS_Utils/src/main/java/hirs/utils/xjc/ResourceCollection.java @@ -80,6 +80,8 @@ public class ResourceCollection * {@link File } * {@link Process } * {@link Resource } + * + * @return list of {@link Meta} objects */ public List getDirectoryOrFileOrProcess() { if (directoryOrFileOrProcess == null) { diff --git a/HIRS_Utils/src/main/java/hirs/utils/xjc/SPKIDataType.java b/HIRS_Utils/src/main/java/hirs/utils/xjc/SPKIDataType.java index 9eceb40eb..1315a9f58 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/xjc/SPKIDataType.java +++ b/HIRS_Utils/src/main/java/hirs/utils/xjc/SPKIDataType.java @@ -65,10 +65,9 @@ public class SPKIDataType { * * *

    - * Objects of the following type(s) are allowed in the list - * {@link JAXBElement }{@code <}{@link byte[]}{@code >} - * {@link Object } - * {@link Element } + * Objects of the following type(s) are allowed in the list: + * Byte array representation of {@link JAXBElement }, + * {@link Object }, and {@link Element } * * @return list of objects */ diff --git a/HIRS_Utils/src/main/java/hirs/utils/xjc/SignaturePropertyType.java b/HIRS_Utils/src/main/java/hirs/utils/xjc/SignaturePropertyType.java index 07b44af01..03895eb00 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/xjc/SignaturePropertyType.java +++ b/HIRS_Utils/src/main/java/hirs/utils/xjc/SignaturePropertyType.java @@ -91,6 +91,8 @@ public class SignaturePropertyType { * {@link Object } * {@link Element } * {@link String } + * + * @return list of objects */ public List getContent() { if (content == null) { diff --git a/HIRS_Utils/src/main/java/hirs/utils/xjc/SignedInfoType.java b/HIRS_Utils/src/main/java/hirs/utils/xjc/SignedInfoType.java index 98f27e337..3cfa26b7a 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/xjc/SignedInfoType.java +++ b/HIRS_Utils/src/main/java/hirs/utils/xjc/SignedInfoType.java @@ -91,6 +91,8 @@ public class SignedInfoType { *

    * Objects of the following type(s) are allowed in the list * {@link ReferenceType } + * + * @return list of reference types */ public List getReference() { if (reference == null) { diff --git a/HIRS_Utils/src/main/java/hirs/utils/xjc/SoftwareIdentity.java b/HIRS_Utils/src/main/java/hirs/utils/xjc/SoftwareIdentity.java index c7614dee1..ee4e99934 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/xjc/SoftwareIdentity.java +++ b/HIRS_Utils/src/main/java/hirs/utils/xjc/SoftwareIdentity.java @@ -170,6 +170,8 @@ public class SoftwareIdentity * {@link JAXBElement }{@code <}{@link ResourceCollection }{@code >} * {@link Element } * {@link JAXBElement }{@code <}{@link Evidence }{@code >} + * + * @return list of objects */ public List getEntityOrEvidenceOrLink() { if (entityOrEvidenceOrLink == null) { diff --git a/HIRS_Utils/src/main/java/hirs/utils/xjc/X509DataType.java b/HIRS_Utils/src/main/java/hirs/utils/xjc/X509DataType.java index 520a58b2b..2523d209a 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/xjc/X509DataType.java +++ b/HIRS_Utils/src/main/java/hirs/utils/xjc/X509DataType.java @@ -79,13 +79,10 @@ public class X509DataType { * *

    * Objects of the following type(s) are allowed in the list - * {@link JAXBElement }{@code <}{@link String }{@code >} - * {@link JAXBElement }{@code <}{@link byte[]}{@code >} - * {@link JAXBElement }{@code <}{@link X509IssuerSerialType }{@code >} - * {@link Object } - * {@link JAXBElement }{@code <}{@link byte[]}{@code >} - * {@link Element } - * {@link JAXBElement }{@code <}{@link byte[]}{@code >} + * String, byte array, and X509 IssuerSerial Type representations of + * {@link JAXBElement }. {@link Object }, and {@link Element } + * + * @return list of objects */ public List getX509IssuerSerialOrX509SKIOrX509SubjectName() { if (x509IssuerSerialOrX509SKIOrX509SubjectName == null) { diff --git a/build.gradle b/build.gradle index a630a8541..9662fe018 100644 --- a/build.gradle +++ b/build.gradle @@ -72,7 +72,7 @@ subprojects { if (project.name == 'HIRS_AttestationCA') { // Remove the generated files from the source set source = source.filter { file -> - !file.path.contains('build/generated/source/proto/main/java') + !file.path.contains('build/generated/sources/proto/main/java') } } options.addStringOption('Xmaxwarns', '0') // Show unlimited warnings todo From d38bd6f831cef6aaeab681134aac253e51088265 Mon Sep 17 00:00:00 2001 From: ThatSilentCoder <184309164+ThatSilentCoder@users.noreply.github.com> Date: Tue, 17 Feb 2026 16:30:15 -0500 Subject: [PATCH 11/20] v3.1_issue_1101: Fixed all major warnings in HIRS_UTILS. PR ready. --- .../java/hirs/utils/xjc/ObjectFactory.java | 55 +++++++++++-------- 1 file changed, 33 insertions(+), 22 deletions(-) diff --git a/HIRS_Utils/src/main/java/hirs/utils/xjc/ObjectFactory.java b/HIRS_Utils/src/main/java/hirs/utils/xjc/ObjectFactory.java index cd18da6b0..3f83677ed 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/xjc/ObjectFactory.java +++ b/HIRS_Utils/src/main/java/hirs/utils/xjc/ObjectFactory.java @@ -17,17 +17,12 @@ /** - * This object contains factory methods for each - * Java content interface and Java element interface + * This object contains factory methods for each Java content interface and Java element interface * generated in the main.java.hirs.utils.xjc package. - *

    An ObjectFactory allows you to programatically - * construct new instances of the Java representation - * for XML content. The Java representation of XML - * content can consist of schema derived interfaces - * and classes representing the binding of schema - * type definitions, element declarations and model - * groups. Factory methods for each of these are - * provided in this class. + *

    An ObjectFactory allows you to programmatically construct new instances of the Java representation + * for XML content. The Java representation of XML content can consist of schema derived interfaces + * and classes representing the binding of schema type definitions, element declarations and model + * groups. Factory methods for each of these are provided in this class. */ @XmlRegistry public class ObjectFactory { @@ -234,6 +229,8 @@ public ResourceCollection createResourceCollection() { /** * Create an instance of {@link PGPDataType }. + * + * @return {@link PGPDataType } */ public PGPDataType createPGPDataType() { return new PGPDataType(); @@ -519,10 +516,9 @@ public JAXBElement createSignatureProperty(SignaturePrope } /** - * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}} - *

    - * * @param value string representation of the value + * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}. * + * @param value string representation of the value * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "KeyName") @@ -531,7 +527,7 @@ public JAXBElement createKeyName(String value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link RSAKeyValueType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link RSAKeyValueType }{@code >}. * * @param value {@link RSAKeyValueType } representation of the value * @return {@link JAXBElement } @@ -588,8 +584,9 @@ public JAXBElement createSignatureMethod(SignatureMethodTyp } /** - * Create an instance of {@link JAXBElement }{@code <}{@link ObjectType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link ObjectType }{@code >}. * + * @param value {@link ObjectType } representation of the value * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "Object") @@ -598,8 +595,9 @@ public JAXBElement createObject(ObjectType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link SignaturePropertiesType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link SignaturePropertiesType }{@code >}. * + * @param value {@link SignaturePropertiesType } representation of the value * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "SignatureProperties") @@ -609,8 +607,9 @@ public JAXBElement createSignatureProperties(SignatureP } /** - * Create an instance of {@link JAXBElement }{@code <}{@link TransformType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link TransformType }{@code >}. * + * @param value {@link TransformType } representation of the value * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "Transform") @@ -619,8 +618,9 @@ public JAXBElement createTransform(TransformType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link PGPDataType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link PGPDataType }{@code >}. * + * @param value {@link PGPDataType } representation of the value * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "PGPData") @@ -631,6 +631,7 @@ public JAXBElement createPGPData(PGPDataType value) { /** * Create an instance of {@link JAXBElement }{@code <}{@link ReferenceType }{@code >}} * + * @param value {@link ReferenceType } representation of the value * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "Reference") @@ -639,8 +640,9 @@ public JAXBElement createReference(ReferenceType value) { } /** - * Create an instance of {@link JAXBElement }{@code <}{@link RetrievalMethodType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link RetrievalMethodType }{@code >}. * + * @param value {@link RetrievalMethodType } representation of the value * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "RetrievalMethod") @@ -650,8 +652,9 @@ public JAXBElement createRetrievalMethod(RetrievalMethodTyp } /** - * Create an instance of {@link JAXBElement }{@code <}{@link DSAKeyValueType }{@code >}} + * Create an instance of {@link JAXBElement }{@code <}{@link DSAKeyValueType }{@code >}. * + * @param value {@link DSAKeyValueType } representation of the value * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "DSAKeyValue") @@ -673,7 +676,7 @@ public JAXBElement createDigestValue(byte[] value) { /** * Create an instance of {@link JAXBElement }{@code <}{@link CanonicalizationMethodType }{@code >}. * - * @param value + * @param value {@link CanonicalizationMethodType } representation of the value. * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "CanonicalizationMethod") @@ -686,7 +689,7 @@ public JAXBElement createCanonicalizationMethod( /** * Create an instance of {@link JAXBElement }{@code <}{@link SignedInfoType }{@code >}. * - * @param value + * @param value {@link SignedInfoType } representation of the value. * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "SignedInfo") @@ -697,6 +700,7 @@ public JAXBElement createSignedInfo(SignedInfoType value) { /** * Create an instance of {@link JAXBElement }{@code <}{@link ManifestType }{@code >}. * + * @param value {@link ManifestType } representation of the value. * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "Manifest") @@ -707,6 +711,7 @@ public JAXBElement createManifest(ManifestType value) { /** * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}. * + * @param value string representation of the value. * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://www.w3.org/2000/09/xmldsig#", name = "XPath", scope = TransformType.class) @@ -776,6 +781,9 @@ public JAXBElement createX509DataTypeX509Certificate(byte[] value) { /** * Create an instance of {@link JAXBElement }{@code <}{@link Link }{@code >}. + * + * @param value {@link Link } representation of the value + * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://standards.iso.org/iso/19770/-2/2015/schema.xsd", name = "Link", scope = SoftwareIdentity.class) public JAXBElement createSoftwareIdentityLink(Link value) { @@ -784,6 +792,9 @@ public JAXBElement createSoftwareIdentityLink(Link value) { /** * Create an instance of {@link JAXBElement }{@code <}{@link Evidence }{@code >}. + * + * @param value {@link Evidence } representation of the value + * @return {@link JAXBElement } */ @XmlElementDecl(namespace = "http://standards.iso.org/iso/19770/-2/2015/schema.xsd", name = "Evidence", scope = SoftwareIdentity.class) public JAXBElement createSoftwareIdentityEvidence(Evidence value) { From 3204e9e65698fde7d49e5d37ce1d5b7cecce92d8 Mon Sep 17 00:00:00 2001 From: ThatSilentCoder <184309164+ThatSilentCoder@users.noreply.github.com> Date: Tue, 17 Feb 2026 16:36:14 -0500 Subject: [PATCH 12/20] v3.1_issue_1101: Commented the line that allows gradle to print unlimited warning lines. --- build.gradle | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 9662fe018..4465f0fdf 100644 --- a/build.gradle +++ b/build.gradle @@ -75,7 +75,9 @@ subprojects { !file.path.contains('build/generated/sources/proto/main/java') } } - options.addStringOption('Xmaxwarns', '0') // Show unlimited warnings todo + + // Uncomment this line if you wish to see all the warning signs produced by the JavaDoc command + // options.addStringOption('Xmaxwarns', '0') } tasks.withType(Checkstyle).configureEach { From d2837b83d6bbccb8f66674999ee989e6b907ff0c Mon Sep 17 00:00:00 2001 From: ThatSilentCoder <184309164+ThatSilentCoder@users.noreply.github.com> Date: Thu, 19 Feb 2026 08:18:49 -0500 Subject: [PATCH 13/20] v3.1_issue_1101: Removed unused code found during PR --- .../utils/rim/unsignedRim/cbor/ietfCoswid/CoswidBuilder.java | 1 - 1 file changed, 1 deletion(-) diff --git a/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/cbor/ietfCoswid/CoswidBuilder.java b/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/cbor/ietfCoswid/CoswidBuilder.java index 3659add05..5213009f8 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/cbor/ietfCoswid/CoswidBuilder.java +++ b/HIRS_Utils/src/main/java/hirs/utils/rim/unsignedRim/cbor/ietfCoswid/CoswidBuilder.java @@ -422,7 +422,6 @@ protected void prepFile(final JsonNode node, final ByteArrayOutputStream out) th */ protected void createFileHash(final ByteArrayOutputStream out, final String hash, final IanaHashAlg alg) { HexFormat hexTool = HexFormat.of(); - int size = hash.length() / 2; byte[] hashByteArray = hexTool.parseHex(hash); From 93eb2c6008edbad48ab3c7757d6df836bf1cd467 Mon Sep 17 00:00:00 2001 From: ThatSilentCoder <184309164+ThatSilentCoder@users.noreply.github.com> Date: Thu, 26 Feb 2026 12:37:10 -0500 Subject: [PATCH 14/20] v3.1_issue_1105: Merged main into local branch. --- .../PersistenceConfiguration.java | 31 ------------------- .../persist/configuration/package-info.java | 4 --- 2 files changed, 35 deletions(-) delete mode 100644 HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/configuration/PersistenceConfiguration.java delete mode 100644 HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/configuration/package-info.java diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/configuration/PersistenceConfiguration.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/configuration/PersistenceConfiguration.java deleted file mode 100644 index d762381bc..000000000 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/configuration/PersistenceConfiguration.java +++ /dev/null @@ -1,31 +0,0 @@ -package hirs.attestationca.persist.configuration; - -import hirs.structs.converters.SimpleStructConverter; -import hirs.structs.converters.StructConverter; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Scope; - -/** - * Persistence Configuration for Spring enabled applications. Constructs a Hibernate SessionFactory - * backed powered by a HikariCP connection pooled data source. Module-specific settings - * need to be set in the persistence-extended.properties file on the classpath. If another module - * such as the HIRS_Portal uses this class and doesn't have a persistence-extended.properties - * file, the default persistence file will be used instead. - */ -@Configuration -public class PersistenceConfiguration { - - /** - * Prototyped {@link StructConverter}. In other words, all instances - * returned by this method will be configured identically, but subsequent - * invocations will return a new instance. - * - * @return ready to use {@link StructConverter}. - */ - @Bean - @Scope("prototype") - public static StructConverter structConverter() { - return new SimpleStructConverter(); - } -} diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/configuration/package-info.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/configuration/package-info.java deleted file mode 100644 index 243c55c50..000000000 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/configuration/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Contains all the configuration files used in this module. - */ -package hirs.attestationca.persist.configuration; From d6c5108de5c09c1a9fd9879d46d34a72a31a8a34 Mon Sep 17 00:00:00 2001 From: ThatSilentCoder <184309164+ThatSilentCoder@users.noreply.github.com> Date: Thu, 26 Feb 2026 12:43:12 -0500 Subject: [PATCH 15/20] v3.1_issue_1105: Fixed build errors. --- .../persist/AttestationCertificateAuthorityTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/AttestationCertificateAuthorityTest.java b/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/AttestationCertificateAuthorityTest.java index 06b242325..544f19743 100644 --- a/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/AttestationCertificateAuthorityTest.java +++ b/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/AttestationCertificateAuthorityTest.java @@ -2,6 +2,7 @@ import com.google.protobuf.ByteString; import hirs.attestationca.persist.provision.AbstractProcessor; +import hirs.attestationca.persist.provision.AttestationCertificateAuthority; import hirs.attestationca.persist.provision.helper.ProvisionUtils; import hirs.utils.HexUtils; import org.apache.commons.codec.binary.Hex; From 05b1bdac583023ba44c712c8a66ec50fde25f785 Mon Sep 17 00:00:00 2001 From: ThatSilentCoder <184309164+ThatSilentCoder@users.noreply.github.com> Date: Mon, 30 Mar 2026 12:19:54 -0400 Subject: [PATCH 16/20] Forgot to include this in the just recently merged in PR --- .../entity/tpm/TPM2ProvisionerState.java | 35 +----- ...a => TPM2ProvisionerStateServiceTest.java} | 106 +++++++++++------- 2 files changed, 66 insertions(+), 75 deletions(-) rename HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/entity/tpm/{TPM2ProvisionerStateTest.java => TPM2ProvisionerStateServiceTest.java} (60%) diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/tpm/TPM2ProvisionerState.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/tpm/TPM2ProvisionerState.java index 6a6a4f72d..c55d8d6fc 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/tpm/TPM2ProvisionerState.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/tpm/TPM2ProvisionerState.java @@ -1,6 +1,5 @@ package hirs.attestationca.persist.entity.tpm; -import hirs.attestationca.persist.entity.manager.TPM2ProvisionerStateRepository; import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.Id; @@ -23,6 +22,9 @@ @Entity public class TPM2ProvisionerState { private static final int MAX_BLOB_SIZE = 16777215; + + @Column(nullable = false) + private final Date timestamp = new Date(); @Id private Long firstPartOfNonce; @@ -34,9 +36,6 @@ public class TPM2ProvisionerState { @Column(nullable = false, length = MAX_BLOB_SIZE) private byte[] identityClaim; - @Column(nullable = false) - private final Date timestamp = new Date(); - /** * Constructor. * @@ -69,34 +68,6 @@ public TPM2ProvisionerState(final byte[] nonce, final byte[] identityClaim) { } } - /** - * Convenience method for finding the {@link TPM2ProvisionerState} associated with the nonce. - * - * @param tpm2ProvisionerStateRepository the {@link TPM2ProvisionerStateRepository} - * to use when looking for the - * {@link TPM2ProvisionerState} - * @param nonce the nonce to use as the key for the {@link TPM2ProvisionerState} - * @return the {@link TPM2ProvisionerState} associated with the nonce; - * null if a match is not found - */ - public static TPM2ProvisionerState getTPM2ProvisionerState( - final TPM2ProvisionerStateRepository tpm2ProvisionerStateRepository, - final byte[] nonce) { - try (DataInputStream dis - = new DataInputStream(new ByteArrayInputStream(nonce))) { - long firstPartOfNonce = dis.readLong(); - TPM2ProvisionerState stateFound = tpm2ProvisionerStateRepository - .findByFirstPartOfNonce(firstPartOfNonce); - if (stateFound != null && Arrays.areEqual(stateFound.getNonce(), nonce)) { - return stateFound; - } - } catch (IOException ioEx) { - log.error(ioEx.getMessage()); - return null; - } - return null; - } - /** * Get the nonce. * diff --git a/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/entity/tpm/TPM2ProvisionerStateTest.java b/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/entity/tpm/TPM2ProvisionerStateServiceTest.java similarity index 60% rename from HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/entity/tpm/TPM2ProvisionerStateTest.java rename to HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/entity/tpm/TPM2ProvisionerStateServiceTest.java index 6ce900c9d..f461e7204 100644 --- a/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/entity/tpm/TPM2ProvisionerStateTest.java +++ b/HIRS_AttestationCA/src/test/java/hirs/attestationca/persist/entity/tpm/TPM2ProvisionerStateServiceTest.java @@ -1,7 +1,13 @@ package hirs.attestationca.persist.entity.tpm; import hirs.attestationca.persist.entity.manager.TPM2ProvisionerStateRepository; +import hirs.attestationca.persist.provision.service.Tpm2ProvisionerStateService; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; import java.io.ByteArrayInputStream; import java.io.DataInputStream; @@ -12,16 +18,44 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; /** - * Contains unit tests for {@link TPM2ProvisionerState}. + * Contains unit tests for {@link TPM2ProvisionerState} and {@link Tpm2ProvisionerStateService}. */ -public class TPM2ProvisionerStateTest { +public class TPM2ProvisionerStateServiceTest { private static final Random RANDOM_GENERATOR = new Random(); + @InjectMocks + private Tpm2ProvisionerStateService tpm2ProvisionerStateService; + + @Mock + private TPM2ProvisionerStateRepository tpm2ProvisionerStateRepository; + + private AutoCloseable mocks; + + /** + * Setups configuration prior to each test method. + */ + @BeforeEach + public void setupTests() { + // Initializes mocks before each test + mocks = MockitoAnnotations.openMocks(this); + } + + /** + * Closes mocks after the completion of each test method. + * + * @throws Exception if any issues arise while closing mocks. + */ + @AfterEach + public void afterEach() throws Exception { + if (mocks != null) { + mocks.close(); + } + } + /** * Tests that the values passed to the constructor are equal to the values * returned by the getters. @@ -36,7 +70,7 @@ public final void testTPM2ProvisionerState() { RANDOM_GENERATOR.nextBytes(nonce); RANDOM_GENERATOR.nextBytes(identityClaim); - TPM2ProvisionerState state = new TPM2ProvisionerState(nonce, identityClaim); + final TPM2ProvisionerState state = new TPM2ProvisionerState(nonce, identityClaim); assertArrayEquals(nonce, state.getNonce()); assertArrayEquals(identityClaim, state.getIdentityClaim()); @@ -46,7 +80,7 @@ public final void testTPM2ProvisionerState() { * Test that the constructor throws an {@link IllegalArgumentException} when a null is * passed in for the nonce. * - * @throws IllegalArgumentException this will never happen + * @throws IllegalArgumentException if any issues any arise while retrieving the TPM Provisioner State */ @Test public final void testNullNonce() throws IllegalArgumentException { @@ -54,15 +88,14 @@ public final void testNullNonce() throws IllegalArgumentException { byte[] identityClaim = new byte[identityClaimSize]; RANDOM_GENERATOR.nextBytes(identityClaim); - assertThrows(IllegalArgumentException.class, () -> - new TPM2ProvisionerState(null, identityClaim)); + assertThrows(IllegalArgumentException.class, () -> new TPM2ProvisionerState(null, identityClaim)); } /** * Test that the constructor throws an {@link IllegalArgumentException} when a null is * passed in for the identity claim. * - * @throws IllegalArgumentException this will never happen + * @throws IllegalArgumentException if any issues any arise while retrieving the TPM Provisioner State */ @Test public final void testNullIdentityClaim() throws IllegalArgumentException { @@ -71,15 +104,14 @@ public final void testNullIdentityClaim() throws IllegalArgumentException { RANDOM_GENERATOR.nextBytes(nonce); - assertThrows(IllegalArgumentException.class, () -> - new TPM2ProvisionerState(nonce, null)); + assertThrows(IllegalArgumentException.class, () -> new TPM2ProvisionerState(nonce, null)); } /** * Test that the constructor throws an {@link IllegalArgumentException} when a nonce is * passed in that is less than 8 bytes. * - * @throws IllegalArgumentException this will never happen + * @throws IllegalArgumentException if any issues any arise while retrieving the TPM Provisioner State */ @Test public final void testNonceToSmall() throws IllegalArgumentException { @@ -90,23 +122,17 @@ public final void testNonceToSmall() throws IllegalArgumentException { RANDOM_GENERATOR.nextBytes(nonce); RANDOM_GENERATOR.nextBytes(identityClaim); - assertThrows(IllegalArgumentException.class, () -> - new TPM2ProvisionerState(nonce, identityClaim)); + assertThrows(IllegalArgumentException.class, () -> new TPM2ProvisionerState(nonce, identityClaim)); } - /** - * Test that {@link TPM2ProvisionerState#getTPM2ProvisionerState( - *TPM2ProvisionerStateRepository, byte[])} works. - * {@link TPM2ProvisionerState#getTPM2ProvisionerState( - *TPM2ProvisionerStateRepository, byte[])}, null is returned. + * Test the {@link Tpm2ProvisionerStateService#getTPM2ProvisionerState(byte[])} function call. * - * @throws IOException this will never happen + * @throws IOException if any issues any arise while retrieving the TPM Provisioner State */ @Test public final void testGetTPM2ProvisionerStateNominal() throws IOException { - TPM2ProvisionerStateRepository tpm2ProvisionerStateRepository = - mock(TPM2ProvisionerStateRepository.class); + final int nonceSize = 32; final int identityClaimSize = 360; byte[] nonce = new byte[nonceSize]; @@ -118,25 +144,23 @@ public final void testGetTPM2ProvisionerStateNominal() throws IOException { DataInputStream dis = new DataInputStream(new ByteArrayInputStream(nonce)); Long index = dis.readLong(); dis.close(); - TPM2ProvisionerState value = new TPM2ProvisionerState(nonce, identityClaim); + + final TPM2ProvisionerState value = new TPM2ProvisionerState(nonce, identityClaim); when(tpm2ProvisionerStateRepository.findByFirstPartOfNonce(index)).thenReturn(value); - TPM2ProvisionerState tpm2ProvisionerState - = TPM2ProvisionerState.getTPM2ProvisionerState(tpm2ProvisionerStateRepository, nonce); + + final TPM2ProvisionerState tpm2ProvisionerState = tpm2ProvisionerStateService.getTPM2ProvisionerState(nonce); assertNotNull(tpm2ProvisionerState); assertArrayEquals(value.getIdentityClaim(), tpm2ProvisionerState.getIdentityClaim()); } /** * Test that if a null is passed as a nonce to - * {@link TPM2ProvisionerState#getTPM2ProvisionerState( - *TPM2ProvisionerStateRepository, byte[])}, null is returned. + * {@link Tpm2ProvisionerStateService#getTPM2ProvisionerState(byte[])}, null is returned. * - * @throws IOException this will never happen + * @throws IOException if any issues any arise while retrieving the TPM Provisioner State */ @Test public final void testGetTPM2ProvisionerStateNullNonce() throws IOException { - TPM2ProvisionerStateRepository tpm2ProvisionerStateRepository = - mock(TPM2ProvisionerStateRepository.class); final int nonceSize = 32; final int identityClaimSize = 360; byte[] nonce = new byte[nonceSize]; @@ -148,23 +172,21 @@ public final void testGetTPM2ProvisionerStateNullNonce() throws IOException { DataInputStream dis = new DataInputStream(new ByteArrayInputStream(nonce)); Long index = dis.readLong(); dis.close(); - TPM2ProvisionerState value = new TPM2ProvisionerState(nonce, identityClaim); + + final TPM2ProvisionerState value = new TPM2ProvisionerState(nonce, identityClaim); when(tpm2ProvisionerStateRepository.findByFirstPartOfNonce(index)).thenReturn(value); - assertThrows(NullPointerException.class, () -> - TPM2ProvisionerState.getTPM2ProvisionerState(tpm2ProvisionerStateRepository, null)); + + assertThrows(NullPointerException.class, () -> tpm2ProvisionerStateService.getTPM2ProvisionerState(null)); } /** * Test that if a nonce that is less than 8 bytes is passed to - * {@link TPM2ProvisionerState#getTPM2ProvisionerState( - *TPM2ProvisionerStateRepository, byte[])}, null is returned. + * {@link Tpm2ProvisionerStateService#getTPM2ProvisionerState(byte[])}, null is returned. * - * @throws IOException this will never happen + * @throws IOException if any issues any arise while retrieving the TPM Provisioner State */ @Test public final void testGetTPM2ProvisionerStateNonceTooSmall() throws IOException { - TPM2ProvisionerStateRepository tpm2ProvisionerStateRepository = - mock(TPM2ProvisionerStateRepository.class); final int nonceSize = 32; final int identityClaimSize = 360; byte[] nonce = new byte[nonceSize]; @@ -177,14 +199,12 @@ public final void testGetTPM2ProvisionerStateNonceTooSmall() throws IOException Long index = dis.readLong(); dis.close(); - TPM2ProvisionerState value = new TPM2ProvisionerState(nonce, identityClaim); + final int nonce2Size = 7; + final TPM2ProvisionerState value = new TPM2ProvisionerState(nonce, identityClaim); when(tpm2ProvisionerStateRepository.findByFirstPartOfNonce(index)).thenReturn(value); - - final int nonce2Size = 7; - TPM2ProvisionerState tpm2ProvisionerState = - TPM2ProvisionerState.getTPM2ProvisionerState(tpm2ProvisionerStateRepository, - new byte[nonce2Size]); + final TPM2ProvisionerState tpm2ProvisionerState = + tpm2ProvisionerStateService.getTPM2ProvisionerState(new byte[nonce2Size]); assertNull(tpm2ProvisionerState); } From a8384bd4f0a2508db45296d50de6a520880ac900 Mon Sep 17 00:00:00 2001 From: ThatSilentCoder <184309164+ThatSilentCoder@users.noreply.github.com> Date: Mon, 30 Mar 2026 12:35:38 -0400 Subject: [PATCH 17/20] v3.1_issue_1105: Merged main into local branch. --- .../hirs/attestationca/persist/provision/RestfulInterface.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/provision/RestfulInterface.java diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/provision/RestfulInterface.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/provision/RestfulInterface.java deleted file mode 100644 index e69de29bb..000000000 From 31216842607431b04da93a1f8190aceb2c329282 Mon Sep 17 00:00:00 2001 From: ThatSilentCoder <184309164+ThatSilentCoder@users.noreply.github.com> Date: Mon, 30 Mar 2026 13:40:21 -0400 Subject: [PATCH 18/20] v3.1_issue_1105: Added more javadocs to the repo, service classes. --- .../entity/manager/CertificateRepository.java | 40 ++++------ .../manager/ComponentAttributeRepository.java | 18 +---- .../manager/ComponentInfoRepository.java | 14 +--- .../entity/manager/DeviceRepository.java | 4 +- .../entity/manager/PolicyRepository.java | 4 +- .../ReferenceDigestValueRepository.java | 32 ++------ .../SupplyChainValidationRepository.java | 17 ----- .../TPM2ProvisionerStateRepository.java | 4 +- .../service/CertificatePageService.java | 53 +++++++------ .../persist/service/DevicePageService.java | 20 ++--- .../service/IDevIdCertificatePageService.java | 14 ++-- .../ReferenceDigestValuePageService.java | 33 ++++---- .../service/ValidationSummaryPageService.java | 10 +-- .../SupplyChainValidationService.java | 3 - .../controllers/DevicePageController.java | 24 +++--- .../IDevIdCertificatePageController.java | 43 ++++++----- .../IssuedCertificatePageController.java | 75 ++++++++++--------- .../controllers/PolicyPageController.java | 34 ++++----- .../ReferenceManifestPageController.java | 45 +++++------ .../RimDatabasePageController.java | 30 ++++---- .../ValidationReportsPageController.java | 14 ++-- .../utils/CertificateStringMapBuilder.java | 3 +- .../hirs/utils/digest/AbstractDigest.java | 3 +- 23 files changed, 241 insertions(+), 296 deletions(-) diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/CertificateRepository.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/CertificateRepository.java index 493b51aee..e826c4572 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/CertificateRepository.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/CertificateRepository.java @@ -26,49 +26,49 @@ public interface CertificateRepository extends JpaRepository { /** - * Query that retrieves a certificate using the provided uuid. + * Query that retrieves a {@link Certificate} object using the provided uuid. * * @param uuid uuid - * @return a certificate + * @return a {@link Certificate} object */ @Query(value = "SELECT * FROM Certificate where id = ?1", nativeQuery = true) Certificate getCertificate(UUID uuid); /** - * Query that retrieves a list of certificates using the provided subject and dtype. + * Query that retrieves a list of {@link Certificate} objects using the provided subject and dtype. * * @param subject subject * @param dType dtype - * @return a list of certificates + * @return a list of {@link Certificate} objects */ @Query(value = "SELECT * FROM Certificate where subject = ?1 AND DTYPE = ?2", nativeQuery = true) List findBySubject(String subject, String dType); /** - * Query that retrieves a sorted list of certificates using the provided subject and dtype. + * Query that retrieves a sorted list of {@link Certificate} objects using the provided subject and dtype. * * @param subjectSorted subject * @param dType dtype - * @return a list of sorted certificates + * @return a list of sorted {@link Certificate} objects */ @Query(value = "SELECT * FROM Certificate where subjectSorted = ?1 AND DTYPE = ?2", nativeQuery = true) List findBySubjectSorted(String subjectSorted, String dType); /** - * Query that retrieves a list of certificates using the provided dtype. + * Query that retrieves a list of {@link Certificate} objects using the provided dtype. * * @param dType dtype - * @return a list of certificates + * @return a list of {@link Certificate} objects */ @Query(value = "SELECT * FROM Certificate where DTYPE = ?1", nativeQuery = true) List findByType(String dType); /** - * Query that retrieves a list of certificates using the provided serial number and dtype. + * Query that retrieves a list of {@link Certificate} objects using the provided serial number and dtype. * * @param serialNumber serial number * @param dType dtype - * @return a certificate + * @return a {@link Certificate} object */ @Query(value = "SELECT * FROM Certificate where serialNumber = ?1 AND DTYPE = ?2", nativeQuery = true) Certificate findBySerialNumber(BigInteger serialNumber, String dType); @@ -107,11 +107,11 @@ public interface CertificateRepository extends JpaRepository List getByHolderSerialNumber(BigInteger holderSerialNumber); /** - * Query that retrieves a certificate using the provided certificate hash and dtype. + * Query that retrieves a {@link Certificate} object using the provided certificate hash and dtype. * * @param certificateHash integer certificate hash * @param dType dtype - * @return a certificate + * @return a {@link Certificate} object */ @Query(value = "SELECT * FROM Certificate where certificateHash = ?1 AND DTYPE = ?2", nativeQuery = true) Certificate findByCertificateHashAndDType(int certificateHash, String dType); @@ -125,29 +125,21 @@ public interface CertificateRepository extends JpaRepository EndorsementCredential findByPublicKeyModulusHexValue(String publicKeyModulusHexValue); /** - * Query that retrieves an issued attestation certificate using the provided device id. - * - * @param deviceId uuid representation of the device id - * @return an issued attestation certificate - */ - IssuedAttestationCertificate findByDeviceId(UUID deviceId); - - /** - * Query that retrieves a list of issued attestation certificates using the provided device id, + * Query that retrieves a list of {@link IssuedAttestationCertificate} objects using the provided device id, * ldevID value and sort value. * * @param deviceId device id * @param ldevID is it a LDevId * @param sort sort - * @return a list of issued attestation certificates + * @return a list of {@link IssuedAttestationCertificate} objects */ List findByDeviceIdAndLdevID(UUID deviceId, boolean ldevID, Sort sort); /** - * Query that retrieves a certificates using the provided certificate hash. + * Query that retrieves a {@link Certificate} object using the provided certificate hash. * * @param certificateHash integer certificate hash - * @return a certificate + * @return a {@link Certificate} object */ Certificate findByCertificateHash(int certificateHash); } diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ComponentAttributeRepository.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ComponentAttributeRepository.java index fc4b520f7..6874f0a23 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ComponentAttributeRepository.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ComponentAttributeRepository.java @@ -17,29 +17,19 @@ */ public interface ComponentAttributeRepository extends JpaRepository { /** - * Query to look up Attribute Results based on the PlatformCredential's + * Query to retrieves a list of {@link ComponentAttributeResult} objects based on the PlatformCredential's * db component id. * * @param componentId the unique id for the component identifier - * @return a list of attribute results + * @return a list of {@link ComponentAttributeResult} objects */ List findByComponentId(UUID componentId); /** - * Query to look up Attribute Results based on the validation id. + * Query that retrieves a list of {@link ComponentAttributeResult} objects based on the validation id. * * @param provisionSessionId unique id generated to link supply chain summary - * @return a list of attribute results + * @return a list of {@link ComponentAttributeResult} objects */ List findByProvisionSessionId(UUID provisionSessionId); - - /** - * Query to look up Attribute Results based on the component id and the session id. - * - * @param componentId the unique id for the component identifier - * @param provisionSessionId unique id generated to link supply chain summary - * @return a list of attribute results - */ - List findByComponentIdAndProvisionSessionId(UUID componentId, - UUID provisionSessionId); } diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ComponentInfoRepository.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ComponentInfoRepository.java index 6e9ab5a63..9ec614b34 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ComponentInfoRepository.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ComponentInfoRepository.java @@ -17,20 +17,10 @@ */ public interface ComponentInfoRepository extends JpaRepository { /** - * Query that retrieves device components by device name. + * Query that retrieves a list of {@link ComponentInfo} objects (device components) by device name. * * @param deviceName string for the host name - * @return a list of device components + * @return a list of {@link ComponentInfo} objects (device components) */ List findByDeviceName(String deviceName); - - /** - * Query that retrieves device components by device name and - * the component serial number. - * - * @param deviceName string for the host name - * @param componentSerial string for the component serial - * @return a list of device components - */ - List findByDeviceNameAndComponentSerial(String deviceName, String componentSerial); } diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/DeviceRepository.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/DeviceRepository.java index f6efc801c..72959b055 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/DeviceRepository.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/DeviceRepository.java @@ -18,10 +18,10 @@ @Repository public interface DeviceRepository extends JpaRepository { /** - * Query that retrieves a device using the provided device name. + * Query that retrieves a {@link Device} object using the provided device name. * * @param deviceName device name - * @return a device + * @return a {@link Device} object */ Device findByName(String deviceName); } diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/PolicyRepository.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/PolicyRepository.java index 65d5708a2..9b8282e68 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/PolicyRepository.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/PolicyRepository.java @@ -19,10 +19,10 @@ public interface PolicyRepository extends JpaRepository { /** - * Query that retrieves policy settings using the provided name. + * Query that retrieves a {@link PolicySettings} object using the provided name. * * @param name name - * @return policy settings + * @return a {@link PolicySettings} object */ PolicySettings findByName(String name); } diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ReferenceDigestValueRepository.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ReferenceDigestValueRepository.java index 3fcd5e01f..a594d3257 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ReferenceDigestValueRepository.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ReferenceDigestValueRepository.java @@ -20,51 +20,35 @@ public interface ReferenceDigestValueRepository extends JpaRepository { /** - * Query that retrieves a list of reference digest values using the provided model. - * - * @param model string representation of the model - * @return a list of reference digest values - */ - List findByModel(String model); - - /** - * Query that retrieves a list of reference digest values using the provided manufacturer. - * - * @param manufacturer string representation of the manufacturer - * @return a list of reference digest values - */ - List findByManufacturer(String manufacturer); - - /** - * Query that retrieves a list of reference digest values using the provided associated rim id. + * Query that retrieves a list of {@link ReferenceDigestValue} object using the provided associated rim id. * * @param associatedRimId uuid representation of the associated rim ID - * @return a list of reference digest values + * @return a list of {@link ReferenceDigestValue} object */ List findValuesByBaseRimId(UUID associatedRimId); /** - * Query that retrieves a list of reference digest values using the provided support rim id. + * Query that retrieves a list of {@link ReferenceDigestValue} object using the provided support rim id. * * @param supportRimId uuid representation of the support rim ID - * @return a list of reference digest values + * @return a list of {@link ReferenceDigestValue} object */ List findBySupportRimId(UUID supportRimId); /** - * Query that retrieves a list of reference digest values using the provided support rim hash. + * Query that retrieves a list of {@link ReferenceDigestValue} object using the provided support rim hash. * * @param supportRimHash a string representation of the support rim hash - * @return a list of reference digest values + * @return a list of {@link ReferenceDigestValue} object */ List findBySupportRimHash(String supportRimHash); /** - * Query that retrieves a list of reference digest values using the provided manufacturer and model. + * Query that retrieves a list of {@link ReferenceDigestValue} object using the provided manufacturer and model. * * @param manufacturer string representation of the manufacturer * @param model string representation of the model - * @return a list of reference digest values + * @return a list of {@link ReferenceDigestValue} object */ List findByManufacturerAndModel(String manufacturer, String model); } diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/SupplyChainValidationRepository.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/SupplyChainValidationRepository.java index 906fc50f3..c69228f5e 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/SupplyChainValidationRepository.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/SupplyChainValidationRepository.java @@ -1,11 +1,9 @@ package hirs.attestationca.persist.entity.manager; import hirs.attestationca.persist.entity.userdefined.SupplyChainValidation; -import hirs.attestationca.persist.enums.AppraisalStatus; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; -import java.util.List; import java.util.UUID; /** @@ -19,19 +17,4 @@ */ @Repository public interface SupplyChainValidationRepository extends JpaRepository { - /** - * Query that retrieves a list of supply chain validation using the provided validate type. - * - * @param validationType string representation of the validate type - * @return a list of supply chain validation - */ - List findByValidationType(SupplyChainValidation.ValidationType validationType); - - /** - * Query that retrieves a list of supply chain validation using the provided validation result. - * - * @param validationResult string representation of the validation result - * @return a list of supply chain validation - */ - List findByValidationResult(AppraisalStatus.Status validationResult); } diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/TPM2ProvisionerStateRepository.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/TPM2ProvisionerStateRepository.java index 48f58a263..bb3af76f5 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/TPM2ProvisionerStateRepository.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/TPM2ProvisionerStateRepository.java @@ -17,10 +17,10 @@ public interface TPM2ProvisionerStateRepository extends JpaRepository { /** - * Query that retrieves the TPM2 Provisioner State using the provided first part of nonce. + * Query that retrieves the {@link TPM2ProvisionerState} object using the provided first part of nonce. * * @param findByFirstPartOfNonce long representation of the first part of nonce - * @return TPM2 Provisioner State + * @return a {@link TPM2ProvisionerState} object */ TPM2ProvisionerState findByFirstPartOfNonce(Long findByFirstPartOfNonce); } diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/CertificatePageService.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/CertificatePageService.java index 471f56125..fcd4e1a0d 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/CertificatePageService.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/CertificatePageService.java @@ -78,15 +78,15 @@ public CertificatePageService(final CertificateRepository certificateRepository, /** * Takes the provided column names, the search term that the user entered and attempts to find - * certificates whose field values matches the provided search term. + * {@link Certificate} objects whose field values matches the provided search term. * * @param entityClass generic certificate entity class * @param searchableColumnNames list of the searchable column names * @param globalSearchTerm text that was input in the global search textbox * @param archiveFlag archive flag * @param pageable pageable - * @param generic entity class that extends from certificate - * @return page full of the generic certificates. + * @param generic entity class that extends from {@link Certificate} + * @return page full of the generic {@link Certificate} objects. */ public Page findCertificatesByGlobalSearchTermAndArchiveFlag( final Class entityClass, @@ -124,14 +124,14 @@ public Page findCertificatesByGlobalSearchTermAndArch /** * Takes the provided columns that come with a search criteria and attempts to find - * certificates that match the column's specific search criteria's search value. + * {@link Certificate} objects that match the column's specific search criteria's search value. * * @param entityClass generic certificate entity class * @param columnsWithSearchCriteria columns that have a search criteria applied to them * @param archiveFlag archive flag * @param pageable pageable - * @param generic entity class that extends from certificate - * @return page full of the generic certificates. + * @param generic entity class that extends from {@link Certificate} + * @return page full of the generic {@link Certificate} objects. */ public Page findCertificatesByColumnSpecificSearchTermAndArchiveFlag( final Class entityClass, @@ -167,7 +167,7 @@ public Page findCertificatesByColumnSpecificSearchTer } /** - * Finds certificates based on both global search and column-specific search criteria. + * Finds {@link Certificate} objects based on both global search and column-specific search criteria. * The method applies the provided global search term across all searchable columns * and also applies column-specific filters based on the individual column search criteria. * The results are returned with pagination support. @@ -185,8 +185,8 @@ public Page findCertificatesByColumnSpecificSearchTer * @param columnsWithSearchCriteria columns that have a search criteria applied to them * @param pageable pageable * @param archiveFlag archive flag - * @param generic entity class that extends from certificate - * @return page full of the generic certificates. + * @param generic entity class that extends from {@link Certificate} + * @return page full of the generic {@link Certificate} objects. */ public Page findCertificatesByGlobalAndColumnSpecificSearchTerm( final Class entityClass, @@ -231,24 +231,23 @@ public Page findCertificatesByGlobalAndColumnSpecific } /** - * Attempts to find a certificate whose uuid matches the provided uuid. + * Attempts to find a {@link Certificate} object whose uuid matches the provided uuid. * * @param uuid certificate uuid - * @return certificate + * @return a {@link Certificate} object */ public Certificate findCertificate(final UUID uuid) { return this.certificateRepository.getCertificate(uuid); } /** - * Stores the given certificate in the database. + * Stores the given {@link Certificate} object in the database. * * @param certificateType String containing the certificate type - * @param fileName contain the name of the file of the certificate to - * be stored + * @param fileName contain the name of the file of the certificate to be stored * @param successMessages contains any success messages that will be displayed on the page * @param errorMessages contains any error messages that will be displayed on the page - * @param certificate the certificate to store + * @param certificate the {@link Certificate} object to store */ public void storeCertificate(final CertificateType certificateType, final String fileName, @@ -349,7 +348,7 @@ public void storeCertificate(final CertificateType certificateType, } /** - * Soft deletes the provided certificate from the database. + * Soft deletes the provided {@link Certificate} object from the database. * * @param uuid the UUID of the cert to delete * @param successMessages contains any success messages that will be displayed on the page @@ -394,7 +393,7 @@ public void deleteCertificate(final UUID uuid, } /** - * Bulk deletes the provided list of certificates from the database. + * Bulk deletes the provided list of {@link Certificate} objects from the database. * * @param ids the list of certificate ids to delete * @param successMessages contains any success messages that will be displayed on the page @@ -413,7 +412,7 @@ public void bulkDeleteCertificates(final List ids, } /** - * Packages a collection of certificates into a zip file for download. + * Packages a collection of {@link Certificate} objects into a zip file for download. * * @param zipOut zip outputs stream * @param singleFileName zip file name @@ -442,12 +441,12 @@ public void bulkDownloadCertificates(final ZipOutputStream zipOut, } /** - * Retrieves a certificate from the database and prepares its contents for download. + * Retrieves a {@link Certificate} object from the database and prepares its contents for download. * * @param certificateClass generic certificate class * @param uuid certificate uuid * @param certificate type - * @return download file of a certificate + * @return download file of a {@link Certificate} object */ public DownloadFile downloadCertificate(final Class certificateClass, final UUID uuid) { @@ -592,7 +591,7 @@ private List getSortingOrders(final CriteriaBuild * * @param searchableColumnNames the columns to be searched globally * @param criteriaBuilder the criteria builder to construct the predicates - * @param certificateRoot the root entity representing the certificate + * @param certificateRoot the root entity representing the {@link Certificate} object * @param globalSearchTerm the term to search for across columns * @param the entity type that extends `Certificate` * @return a combined `Predicate` representing the global search conditions @@ -641,7 +640,7 @@ private Predicate createPredicatesForGlobalSearch( * * @param columnsWithSearchCriteria the columns and their associated search criteria * @param criteriaBuilder the criteria builder to construct the predicates - * @param certificateRoot the root entity representing the certificate + * @param certificateRoot the root entity representing the {@link Certificate} object * @param the entity type that extends `Certificate` * @return a combined `Predicate` representing the column-specific search conditions */ @@ -688,10 +687,10 @@ private Predicate createPredicatesForColumnSpecificSearc } /** - * Retrieves the platform certificate by the platform serial number. + * Retrieves the {@link PlatformCredential} object by the platform serial number. * * @param serialNumber the platform serial number - * @return the certificate or null if none is found + * @return the list of {@link PlatformCredential} objects or null if none is found */ private List getPlatformCertificateByBoardSN(final String serialNumber) { List associatedCertificates = new ArrayList<>(); @@ -703,10 +702,10 @@ private List getPlatformCertificateByBoardSN(final String se } /** - * Helper method that utilizes the components of the provided platform certificate to generate - * a collection of component results and subsequently stores these results in the database. + * Helper method that utilizes the components of the provided {@link PlatformCredential} object to generate + * a list of {@link ComponentResult} objects and subsequently stores these results in the database. * - * @param platformCredential certificate + * @param platformCredential platform certificate */ private void parseAndSaveComponentResults(final PlatformCredential platformCredential) throws IOException { diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/DevicePageService.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/DevicePageService.java index 0e51e029f..d47733642 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/DevicePageService.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/DevicePageService.java @@ -70,7 +70,7 @@ public DevicePageService(final DeviceRepository deviceRepository, /** * Takes the provided column names, the search term that the user entered and attempts to find - * devices whose field values matches the provided search term. + * {@link Device} objects whose field values matches the provided search term. * * @param searchableColumnNames list of the searchable column name * @param globalSearchTerm text that was input in the global search textbox @@ -109,7 +109,7 @@ public Page findDevicesByGlobalSearchTerm( /** * Takes the provided columns that come with a search criteria and attempts to find - * devices that match the column's specific search criteria's search value. + * {@link Device} objects that match the column's specific search criteria's search value. * * @param columnsWithSearchCriteria columns that have a search criteria applied to them * @param pageable pageable @@ -145,7 +145,7 @@ public Page findDevicesByColumnSpecificSearchTerm( /** - * Finds devices based on both global search and column-specific search criteria. + * Finds {@link Device} objects based on both global search and column-specific search criteria. * The method applies the provided global search term across all searchable columns * and also applies column-specific filters based on the individual column search criteria. * The results are returned with pagination support. @@ -161,7 +161,7 @@ public Page findDevicesByColumnSpecificSearchTerm( * @param globalSearchTerm The term that the user enters in the global search box. * @param columnsWithSearchCriteria columns that have a search criteria applied to them * @param pageable pageable - * @return A Page containing a list of devices that match both the global search term and + * @return A Page containing a list of {@link Device} objects that match both the global search term and * the column-specific search criteria. */ public Page findDevicesByGlobalAndColumnSpecificSearchTerm( @@ -202,28 +202,28 @@ public Page findDevicesByGlobalAndColumnSpecificSearchTerm( /** - * Retrieves all devices from the database. + * Retrieves all {@link Device} objects from the database. * * @param pageable pageable - * @return a page of all devices + * @return a page of all {@link Device} objects */ public Page findAllDevices(final Pageable pageable) { return deviceRepository.findAll(pageable); } /** - * Retrieves the total number of records in the device repository. + * Retrieves the total number of records stored in the {@link DeviceRepository}. * - * @return total number of records in the device repository. + * @return total number of records stored in the {@link DeviceRepository} */ public long findDeviceRepositoryCount() { return deviceRepository.count(); } /** - * Returns the list of devices associated with the platform and endorsement certificates. + * Returns the list of {@link Device} objects associated with the platform and endorsement certificates. * - * @param deviceList list containing the devices + * @param deviceList list containing the {@link Device} objects * @return a record list after the device and certificate was mapped together. */ public FilteredRecordsList> retrieveDevicesAndAssociatedCertificates( diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/IDevIdCertificatePageService.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/IDevIdCertificatePageService.java index 2c1903f34..a600d9b29 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/IDevIdCertificatePageService.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/IDevIdCertificatePageService.java @@ -24,7 +24,7 @@ public class IDevIdCertificatePageService { /** * Constructor for the IDevId Certificate Page Service. * - * @param iDevIDCertificateRepository idevid certificate repository + * @param iDevIDCertificateRepository IDevId Certificate Repository */ @Autowired public IDevIdCertificatePageService(final IDevIDCertificateRepository iDevIDCertificateRepository) { @@ -32,11 +32,11 @@ public IDevIdCertificatePageService(final IDevIDCertificateRepository iDevIDCert } /** - * Retrieves a page of idevid certificates using the provided archive flag and pageable value. + * Retrieves a page of {@link IDevIDCertificate} objects using the provided archive flag and pageable value. * * @param archiveFlag archive flag * @param pageable pageable - * @return page of idevid certificates + * @return page of {@link IDevIDCertificate} objects */ public Page findIDevCertificatesByArchiveFlag(final boolean archiveFlag, final Pageable pageable) { @@ -44,20 +44,20 @@ public Page findIDevCertificatesByArchiveFlag(final boolean a } /** - * Retrieves the total number of records in the idevid certificate repository. + * Retrieves the total number of records stored in the {@link IDevIDCertificateRepository}. * - * @return total number of records in the idevid certificate repository. + * @return total number of records stored in the {@link IDevIDCertificateRepository}. */ public long findIDevIdCertificateRepositoryCount() { return iDevIDCertificateRepository.countByArchiveFlag(false); } /** - * Attempts to parse the provided file in order to create an IDevId Certificate. + * Attempts to parse the provided file in order to create an {@link IDevIDCertificate} object. * * @param file file * @param errorMessages contains any error messages that will be displayed on the page - * @return IDevId certificate + * @return an {@link IDevIDCertificate} object */ public IDevIDCertificate parseIDevIDCertificate(final MultipartFile file, final List errorMessages) { log.info("Received IDevId certificate file of size: {}", file.getSize()); diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/ReferenceDigestValuePageService.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/ReferenceDigestValuePageService.java index a9c19f06e..29be4b12d 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/ReferenceDigestValuePageService.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/ReferenceDigestValuePageService.java @@ -56,13 +56,13 @@ public ReferenceDigestValuePageService(final ReferenceManifestRepository referen /** * Takes the provided column names, the search term that the user entered and attempts to find - * reference digest values whose field values matches the provided search term. + * {@link ReferenceDigestValue} objects whose field values matches the provided search term. * * @param searchableColumnNames list of the searchable column names * @param globalSearchTerm text that was input in the global search textbox * @param pageable pageable - * @return A Page containing a list of reference digest values that match the global search term entered - * in the global search textbox + * @return A Page containing a list of {@link ReferenceDigestValue} objects that match the global search term + * entered in the global search textbox */ public Page findReferenceDigestValuesByGlobalSearchTerm( final Set searchableColumnNames, @@ -96,11 +96,11 @@ public Page findReferenceDigestValuesByGlobalSearchTerm( /** * Takes the provided columns that come with a search criteria and attempts to find - * reference digest values that match the column's specific search criteria's search value. + * {@link ReferenceDigestValue} objects that match the column's specific search criteria's search value. * * @param columnsWithSearchCriteria columns that have a search criteria applied to them * @param pageable pageable - * @return A Page containing a list of reference digest values that match the column specific search + * @return A Page containing a list of {@link ReferenceDigestValue} objects that match the column specific search * criteria */ public Page findReferenceDigestValuesByColumnSpecificSearchTerm( @@ -132,7 +132,7 @@ public Page findReferenceDigestValuesByColumnSpecificSearc } /** - * Finds reference digest values based on both global search and column-specific search criteria. + * Finds {@link ReferenceDigestValue} objects based on both global search and column-specific search criteria. * The method applies the provided global search term across all searchable columns * and also applies column-specific filters based on the individual column search criteria. * The results are returned with pagination support. @@ -148,8 +148,8 @@ public Page findReferenceDigestValuesByColumnSpecificSearc * @param globalSearchTerm text that was input in the global search textbox * @param columnsWithSearchCriteria columns that have a search criteria applied to them * @param pageable pageable - * @return A Page containing a list of reference digest values that match both the global search term and - * the column-specific search criteria. + * @return A Page containing a list of {@link ReferenceDigestValue} objects that match both the global search term + * and the column-specific search criteria. */ public Page findReferenceDigestValuesByGlobalAndColumnSpecificSearchTerm( final Set searchableColumnNames, @@ -190,17 +190,17 @@ public Page findReferenceDigestValuesByGlobalAndColumnSpec } /** - * Retrieves a page full of reference digest values using the provided pageable value. + * Retrieves a page full of {@link ReferenceDigestValue} objects using the provided pageable value. * * @param pageable pageable - * @return page full of reference digest values + * @return page full of {@link ReferenceDigestValue} objects */ public Page findAllReferenceDigestValues(final Pageable pageable) { return referenceDigestValueRepository.findAll(pageable); } /** - * Saves the provided reference digest value in the reference digest value repository. + * Saves the provided {@link ReferenceDigestValue} object in the reference digest value repository. * * @param referenceDigestValue reference digest value */ @@ -209,16 +209,16 @@ public void saveReferenceDigestValue(final ReferenceDigestValue referenceDigestV } /** - * Retrieves the total number of records in the reference digest value repository. + * Retrieves the total number of records stored in the {@link ReferenceDigestValueRepository}. * - * @return total number of records in the reference digest value repository. + * @return total number of records stored in the {@link ReferenceDigestValueRepository}. */ public long findReferenceDigestValueRepositoryCount() { return referenceDigestValueRepository.count(); } /** - * Determines if the RIM, using the provided id, exists in the repository. + * Determines if the RIM, using the provided id, exists in the {@link ReferenceManifestRepository}. * * @param uuid uuid representation of the reference manifest id * @return true if the provided RIM exists in the database, @@ -229,10 +229,11 @@ public boolean doesRIMExist(final UUID uuid) { } /** - * Retrieves the Reference Manifest in the repository using the provided id. + * Retrieves the {@link ReferenceManifest} object from the {@link ReferenceManifestRepository} using the + * provided id. * * @param uuid uuid representation of the RIM - * @return the found Reference Manifest + * @return the found {@link ReferenceManifest} object */ public ReferenceManifest findRIMById(final UUID uuid) { return referenceManifestRepository.getReferenceById(uuid); diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/ValidationSummaryPageService.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/ValidationSummaryPageService.java index 6136e5439..15cea0f9c 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/ValidationSummaryPageService.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/service/ValidationSummaryPageService.java @@ -97,7 +97,7 @@ public ValidationSummaryPageService(final SupplyChainValidationSummaryRepository /** * Takes the provided column names, the search term that the user entered and attempts to find - * validation summaries whose field values matches the provided search term. + * {@link SupplyChainValidationSummary} objects whose field values matches the provided search term. * * @param searchableColumnNames list of the searchable column name * @param globalSearchTerm text that was input in the global search textbox @@ -144,7 +144,7 @@ public Page findValidationReportsByGlobalSearchTer /** * Takes the provided columns that come with a search criteria and attempts to find - * supply chain validation summary reports that match the column's specific search criteria's search + * {@link SupplyChainValidationSummary} objects that match the column's specific search criteria's search * value. * * @param columnsWithSearchCriteria columns that have a search criteria applied to them @@ -187,7 +187,7 @@ public Page findValidationReportsByGlobalSearchTer /** - * Finds supply chain validation summaries based on both global search and + * Finds {@link SupplyChainValidationSummary} objects based on both global search and * column-specific search criteria. * The method applies the provided global search term across all searchable columns * and also applies column-specific filters based on the individual column search criteria. @@ -263,9 +263,9 @@ public Page findValidationSummaryReportsByPageable } /** - * Retrieves the total number of records in the supply chain validation summary repository. + * Retrieves the total number of records stored in the {@link SupplyChainValidationSummaryRepository}. * - * @return total number of records in the supply chain validation summary repository + * @return total number of records stored in the {@link SupplyChainValidationSummaryRepository} */ public long findValidationSummaryRepositoryCount() { return supplyChainValidationSummaryRepository.count(); diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/SupplyChainValidationService.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/SupplyChainValidationService.java index a3a7d98fa..f602177ac 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/SupplyChainValidationService.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/SupplyChainValidationService.java @@ -8,7 +8,6 @@ import hirs.attestationca.persist.entity.manager.PolicyRepository; import hirs.attestationca.persist.entity.manager.ReferenceDigestValueRepository; import hirs.attestationca.persist.entity.manager.ReferenceManifestRepository; -import hirs.attestationca.persist.entity.manager.SupplyChainValidationRepository; import hirs.attestationca.persist.entity.manager.SupplyChainValidationSummaryRepository; import hirs.attestationca.persist.entity.userdefined.Device; import hirs.attestationca.persist.entity.userdefined.PolicySettings; @@ -69,7 +68,6 @@ public class SupplyChainValidationService { * @param componentResultRepository the comp result manager * @param componentAttributeRepository component attribute repository * @param referenceManifestRepository the RIM manager - * @param supplyChainValidationRepository the scv manager * @param supplyChainValidationSummaryRepository the summary manager * @param referenceDigestValueRepository the even manager */ @@ -81,7 +79,6 @@ public SupplyChainValidationService( final ComponentResultRepository componentResultRepository, final ComponentAttributeRepository componentAttributeRepository, final ReferenceManifestRepository referenceManifestRepository, - final SupplyChainValidationRepository supplyChainValidationRepository, final SupplyChainValidationSummaryRepository supplyChainValidationSummaryRepository, final ReferenceDigestValueRepository referenceDigestValueRepository) { this.caCredentialRepository = caCredentialRepository; diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/DevicePageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/DevicePageController.java index 01c99a5cb..a67b16b33 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/DevicePageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/DevicePageController.java @@ -60,8 +60,8 @@ public ModelAndView initPage(final NoPageParams params, final Model model) { } /** - * Processes the request to retrieve a list of devices and device related information for display on the - * devices page. + * Processes the request to retrieve a list of {@link Device} and device related information for display on the + * Devices page. * * @param dataTableInput data table input. * @return data table of devices @@ -117,29 +117,31 @@ public DataTableResponse> getDevicesTableData( /** - * Helper method that retrieves a filtered and paginated list of devices based on the provided search criteria. + * Helper method that retrieves a filtered and paginated list of {@link Device} objects based on the provided + * search criteria. + *

    > * The method allows filtering based on a global search term and column-specific search criteria, * and returns the result in a paginated format. - * *

    * The method handles four cases: *

      *
    1. If no global search term and no column-specific search criteria are provided, - * all devices are returned.
    2. + * all {@link Device} objects are returned. *
    3. If both a global search term and column-specific search criteria are provided, - * it performs filtering on both.
    4. - *
    5. If only column-specific search criteria are provided, it filters based on the column-specific - * criteria.
    6. - *
    7. If only a global search term is provided, it filters based on the global search term.
    8. + * {@link Device} objects are filtered based on both criteria. + *
    9. If only column-specific search criteria are provided, {@link Device} objects + * are filtered according to the column-specific criteria.
    10. + *
    11. If only a global search term is provided, {@link Device} objects + * are filtered according to the global search term.
    12. *
    *

    * - * @param globalSearchTerm A global search term that will be used to filter the devices by the + * @param globalSearchTerm A global search term that will be used to filter the {@link Device} by the * searchable fields. * @param columnsWithSearchCriteria A set of columns with specific search criteria entered by the user. * @param searchableColumnNames A set of searchable column names that are for the global search term. * @param pageable pageable - * @return A {@link FilteredRecordsList} containing the filtered and paginated list of devices, + * @return A {@link FilteredRecordsList} containing the filtered and paginated list of {@link Device} objects * along with the total number of records and the number of records matching the filter criteria. */ private FilteredRecordsList getFilteredDeviceList( diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/IDevIdCertificatePageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/IDevIdCertificatePageController.java index 4f76718c3..0f62408f1 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/IDevIdCertificatePageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/IDevIdCertificatePageController.java @@ -81,7 +81,8 @@ public ModelAndView initPage(final NoPageParams params, final Model model) { } /** - * Processes the request to retrieve a list of idevid certificates for display on the idevid certificates page. + * Processes the request to retrieve a list of {@link IDevIDCertificate} objects for display on the + * idevid certificates page. * * @param dataTableInput data table input received from the front-end * @return data table of idevid certificates @@ -128,9 +129,9 @@ public DataTableResponse getIDevIdCertificatesTableData( } /** - * Processes the request to download the specified IDevId certificate. + * Processes the request to download the specified {@link IDevIDCertificate} object. * - * @param id the UUID of the idevid certificate to download + * @param id the UUID of the {@link IDevIDCertificate} object to download * @param response the response object (needed to update the header with the * file name) * @throws IOException when writing to response output stream @@ -154,7 +155,7 @@ public void downloadIDevIdCertificate(@RequestParam final String id, final HttpS } /** - * Processes the request to bulk download all the IDevID Certificates. + * Processes the request to bulk download all the {@link IDevIDCertificate} objects. * * @param response the response object (needed to update the header with the * file name) @@ -181,11 +182,11 @@ public void bulkDownloadIDevIdCertificates(final HttpServletResponse response) t } /** - * Processes the request to upload one or more idevid certificates to the ACA. + * Processes the request to upload one or more {@link IDevIDCertificate} objects to the ACA. * * @param files the files to process * @param redirectAttributes RedirectAttributes used to forward data back to the original page. - * @return the redirection view + * @return a redirect to the IDevID Certificate Page * @throws URISyntaxException if malformed URI */ @PostMapping("/upload") @@ -218,12 +219,12 @@ protected RedirectView uploadIDevIdCertificate(@RequestParam("file") final Multi } /** - * Processes the request to archive/soft delete the provided idevid certificate. + * Processes the request to archive/soft delete the provided {@link IDevIDCertificate} object. * - * @param id the UUID of the idevid certificate to delete + * @param id the UUID of the {@link IDevIDCertificate} object to delete * @param redirectAttributes RedirectAttributes used to forward data back to the original * page. - * @return redirect to this page + * @return a redirect to the IDevID Certificate Page * @throws URISyntaxException if malformed URI */ @PostMapping("/delete") @@ -255,9 +256,9 @@ public RedirectView deleteIdevIdCertificate(@RequestParam final String id, } /** - * Processes the request to delete multiple idevid certificates. + * Processes the request to delete multiple {@link IDevIDCertificate} objects. * - * @param ids the list of UUIDs of the idevid certificates to be deleted + * @param ids the list of UUIDs of the {@link IDevIDCertificate} objects to be deleted * @param redirectAttributes used to pass data back to the original page after the operation * @return a redirect to the IDevId certificate page * @throws URISyntaxException if the URI is malformed @@ -290,8 +291,9 @@ public RedirectView bulkDeleteIDevIdCertificates(@RequestParam final List * The method allows filtering based on a global search term and column-specific search criteria, * and returns the result in a paginated format. * @@ -299,22 +301,23 @@ public RedirectView bulkDeleteIDevIdCertificates(@RequestParam final List *
  • If no global search term and no column-specific search criteria are provided, - * all idevid certificates are returned.
  • + * all {@link IDevIDCertificate} objects are returned. *
  • If both a global search term and column-specific search criteria are provided, - * it performs filtering on both.
  • - *
  • If only column-specific search criteria are provided, it filters based on the column-specific - * criteria.
  • - *
  • If only a global search term is provided, it filters based on the global search term.
  • + * {@link IDevIDCertificate} objects are filtered based on both criteria. + *
  • If only column-specific search criteria are provided, {@link IDevIDCertificate} objects + * are filtered according to the column-specific criteria.
  • + *
  • If only a global search term is provided, {@link IDevIDCertificate} objects + * are filtered according to the global search term.
  • * *

    * - * @param globalSearchTerm A global search term that will be used to filter the idevid certificates - * by the searchable fields. + * @param globalSearchTerm A global search term that will be used to filter the + * {@link IDevIDCertificate} objects by the searchable fields. * @param columnsWithSearchCriteria A set of columns with specific search criteria entered by the user. * @param searchableColumnNames A set of searchable column names that are for the global search term. * @param pageable pageable * @return A {@link FilteredRecordsList} containing the filtered and paginated list of - * idevid certificates, along with the total number of records and the number of records matching the + * {@link IDevIDCertificate} objects, along with the total number of records and the number of records matching the * filter criteria. */ private FilteredRecordsList getFilteredIDevIdCertificateList( diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/IssuedCertificatePageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/IssuedCertificatePageController.java index 17d3c7132..50ebe3096 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/IssuedCertificatePageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/IssuedCertificatePageController.java @@ -49,11 +49,11 @@ @RequestMapping("/HIRS_AttestationCAPortal/portal/certificate-request/issued-certificates") @Log4j2 public class IssuedCertificatePageController extends PageController { - private final IssuedCertificatePageService issuedAttestationCertificateService; + private final IssuedCertificatePageService issuedCertificatePageService; private final CertificatePageService certificatePageService; /** - * Constructor for the Issued Attestation Certificate page. + * Constructor for the Issued Certificate page. * * @param issuedCertificatePageService issued certificate page service * @param certificatePageService certificate page service @@ -63,17 +63,17 @@ public IssuedCertificatePageController( final IssuedCertificatePageService issuedCertificatePageService, final CertificatePageService certificatePageService) { super(Page.ISSUED_CERTIFICATES); - this.issuedAttestationCertificateService = issuedCertificatePageService; + this.issuedCertificatePageService = issuedCertificatePageService; this.certificatePageService = certificatePageService; } /** - * Returns the path for the view and the data model for the Issued Attestation Certificate page. + * Returns the path for the view and the data model for the Issued Certificate page. * * @param params The object to map url parameters into. * @param model The data model for the request. Can contain data from * redirect. - * @return the path for the view and data model for the Issued Attestation Certificate page. + * @return the path for the view and data model for the Issued Certificate page. */ @RequestMapping public ModelAndView initPage(final NoPageParams params, final Model model) { @@ -81,8 +81,8 @@ public ModelAndView initPage(final NoPageParams params, final Model model) { } /** - * Processes the request to retrieve a list of issued attestation certificates for display on the issued - * certificates page. + * Processes the request to retrieve a list of {@link IssuedAttestationCertificate} objects for display on the + * issued certificates page. * * @param dataTableInput data table input received from the front-end * @return data table of issued certificates @@ -91,8 +91,8 @@ public ModelAndView initPage(final NoPageParams params, final Model model) { @GetMapping(value = "/list", produces = MediaType.APPLICATION_JSON_VALUE) public DataTableResponse getIssuedCertificatesTableData( final DataTableInput dataTableInput) { - log.info("Received request to display list of issued attestation certificates"); - log.debug("Request received a datatable input object for the issued attestation" + log.info("Received request to display list of issued certificates"); + log.debug("Request received a datatable input object for the issued" + " certificate page: {}", dataTableInput); // grab the column to which ordering has been applied @@ -130,9 +130,9 @@ public DataTableResponse getIssuedCertificatesTabl } /** - * Processes the request to download the specified issued attestation certificate. + * Processes the request to download the specified {@link IssuedAttestationCertificate} object. * - * @param id the UUID of the issued attestation certificate to download + * @param id the UUID of the {@link IssuedAttestationCertificate} object to download * @param response the response object (needed to update the header with the * file name) * @throws IOException when writing to response output stream @@ -150,13 +150,13 @@ public void downloadIssuedCertificate(@RequestParam final String id, final HttpS response.getOutputStream().write(downloadFile.getFileBytes()); } catch (Exception exception) { log.error("An exception was thrown while attempting to download the" - + " specified issued attestation certificate", exception); + + " specified issued certificate", exception); response.sendError(HttpServletResponse.SC_NOT_FOUND); } } /** - * Processes the request to bulk download all the issued attestation certificates. + * Processes the request to bulk download all the {@link IssuedAttestationCertificate} objects. * * @param response the response object (needed to update the header with the * file name) @@ -178,25 +178,25 @@ public void bulkDownloadIssuedCertificates(final HttpServletResponse response) singleFileName); } catch (Exception exception) { log.error("An exception was thrown while attempting to bulk download all the " - + "issued attestation certificates", exception); + + "issued certificates", exception); response.sendError(HttpServletResponse.SC_NOT_FOUND); } } /** - * Processes the request to archive/soft delete the specified issued attestation certificate. + * Processes the request to archive/soft delete the specified {@link IssuedAttestationCertificate} object. * - * @param id the UUID of the issued attestation certificate to delete + * @param id the UUID of the {@link IssuedAttestationCertificate} object to delete * @param redirectAttributes RedirectAttributes used to forward data back to the original * page. - * @return redirect to this page + * @return a redirect to the Issued Certificate Page * @throws URISyntaxException if malformed URI */ @PostMapping("/delete") public RedirectView deleteIssuedCertificate(@RequestParam final String id, final RedirectAttributes redirectAttributes) throws URISyntaxException { - log.info("Received request to delete issued attestation certificate id {}", id); + log.info("Received request to delete issued certificate id {}", id); Map model = new HashMap<>(); PageMessages messages = new PageMessages(); @@ -210,7 +210,7 @@ public RedirectView deleteIssuedCertificate(@RequestParam final String id, messages.addErrorMessages(errorMessages); } catch (Exception exception) { final String errorMessage = "An exception was thrown while attempting to delete" - + " the specified issued attestation certificate"; + + " the specified issued certificate"; messages.addErrorMessage(errorMessage); log.error(errorMessage, exception); } @@ -220,18 +220,18 @@ public RedirectView deleteIssuedCertificate(@RequestParam final String id, } /** - * Processes the request to delete multiple issued attestation certificates. + * Processes the request to delete multiple {@link IssuedAttestationCertificate} objects. * - * @param ids the list of UUIDs of the issued attestation certificates to be deleted + * @param ids the list of UUIDs of the {@link IssuedAttestationCertificate} objects to be deleted * @param redirectAttributes used to pass data back to the original page after the operation - * @return a redirect to the issued attestation certificate page + * @return a redirect to the Issued Certificate Page * @throws URISyntaxException if the URI is malformed */ @PostMapping("/bulk-delete") public RedirectView bulkDeleteIssuedCertificates(@RequestParam final List ids, final RedirectAttributes redirectAttributes) throws URISyntaxException { - log.info("Received request to delete multiple issued attestation certificates"); + log.info("Received request to delete multiple issued certificates"); Map model = new HashMap<>(); PageMessages messages = new PageMessages(); @@ -245,7 +245,7 @@ public RedirectView bulkDeleteIssuedCertificates(@RequestParam final List *
  • If no global search term and no column-specific search criteria are provided, - * all issued certificates are returned.
  • + * all {@link IssuedAttestationCertificate} objects are returned. *
  • If both a global search term and column-specific search criteria are provided, - * it performs filtering on both.
  • - *
  • If only column-specific search criteria are provided, it filters based on the column-specific - * criteria.
  • - *
  • If only a global search term is provided, it filters based on the global search term.
  • + * {@link IssuedAttestationCertificate} objects are filtered based on both criteria. + *
  • If only column-specific search criteria are provided, {@link IssuedAttestationCertificate} objects + * are filtered according to the column-specific criteria.
  • + *
  • If only a global search term is provided, {@link IssuedAttestationCertificate} objects + * are filtered according to the global search term.
  • * *

    * - * @param globalSearchTerm A global search term that will be used to filter the issued certificates - * by the searchable fields. + * @param globalSearchTerm A global search term that will be used to filter the + * {@link IssuedAttestationCertificate} objects by the searchable fields. * @param columnsWithSearchCriteria A set of columns with specific search criteria entered by the user. * @param searchableColumnNames A set of searchable column names that are for the global search term. * @param pageable pageable * @return A {@link FilteredRecordsList} containing the filtered and paginated list of - * issued certificates, along with the total number of records and the number of records matching the - * filter criteria. + * {@link IssuedAttestationCertificate} objects, along with the total number of records and the number of records + * matching the filter criteria. */ private FilteredRecordsList getFilteredIssuedCertificateList( final String globalSearchTerm, @@ -292,7 +293,7 @@ private FilteredRecordsList getFilteredIssuedCerti // if no value has been entered in the global search textbox and in the column search dropdown if (StringUtils.isBlank(globalSearchTerm) && columnsWithSearchCriteria.isEmpty()) { pagedResult = - issuedAttestationCertificateService.findIssuedCertificatesByArchiveFlag(false, pageable); + issuedCertificatePageService.findIssuedCertificatesByArchiveFlag(false, pageable); } else if (!StringUtils.isBlank(globalSearchTerm) && !columnsWithSearchCriteria.isEmpty()) { // if a value has been entered in both the global search textbox and in the column search dropdown pagedResult = @@ -330,7 +331,7 @@ private FilteredRecordsList getFilteredIssuedCerti issuedCertificateFilteredRecordsList.setRecordsFiltered(pagedResult.getTotalElements()); issuedCertificateFilteredRecordsList.setRecordsTotal( - issuedAttestationCertificateService.findIssuedCertificateRepoCount()); + issuedCertificatePageService.findIssuedCertificateRepoCount()); return issuedCertificateFilteredRecordsList; } diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/PolicyPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/PolicyPageController.java index 3478647ce..e835c3dd7 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/PolicyPageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/PolicyPageController.java @@ -77,7 +77,7 @@ public ModelAndView initPage(final NoPageParams params, final Model model) { * @param ppModel The data posted by the form mapped into an object. * @param redirectAttributes RedirectAttributes used to forward data back to the original * page. - * @return View containing the url and parameters + * @return a redirect to the Policy Page * @throws URISyntaxException if malformed URI */ @PostMapping("update-ec-validation") @@ -124,7 +124,7 @@ public RedirectView updateECValidationPolicy(@ModelAttribute final PolicyPageMod * @param ppModel The data posted by the form mapped into an object. * @param redirectAttributes RedirectAttributes used to forward data back to the original * page. - * @return View containing the url and parameters + * @return a redirect to the Policy Page * @throws URISyntaxException if malformed URI */ @PostMapping("update-pc-validation") @@ -170,7 +170,7 @@ public RedirectView updatePCValidationPolicy(@ModelAttribute final PolicyPageMod * @param ppModel The data posted by the form mapped into an object. * @param redirectAttributes RedirectAttributes used to forward data back to the original * page. - * @return View containing the url and parameters + * @return a redirect to the Policy Page * @throws URISyntaxException if malformed URI */ @PostMapping("update-pc-attribute-validation") @@ -220,7 +220,7 @@ public RedirectView updatePCAttributeValPolicy(@ModelAttribute final PolicyPageM * @param ppModel The data posted by the form mapped into an object. * @param redirectAttributes RedirectAttributes used to forward data back to the original * page. - * @return View containing the url and parameters + * @return a redirect to the Policy Page * @throws URISyntaxException if malformed URI */ @PostMapping("update-revision-ignore") @@ -269,7 +269,7 @@ public RedirectView updateIgnoreRevisionAttributePolicy(@ModelAttribute final Po * @param ppModel The data posted by the form mapped into an object. * @param redirectAttributes RedirectAttributes used to forward data back to the original * page. - * @return View containing the url and parameters + * @return a redirect to the Policy Page * @throws URISyntaxException if malformed URI */ @PostMapping("update-pcie-vpd-ignore") @@ -317,7 +317,7 @@ public RedirectView updateIgnorePCIEVpdAttributePolicy(@ModelAttribute final Pol * @param ppModel The data posted by the form mapped into an object. * @param redirectAttributes RedirectAttributes used to forward data back to the original * page. - * @return View containing the url and parameters + * @return a redirect to the Policy Page * @throws URISyntaxException if malformed URI */ @PostMapping("update-firmware-validation") @@ -364,7 +364,7 @@ public RedirectView updateFirmwareValidationPolicy(@ModelAttribute final PolicyP * @param ppModel The data posted by the form mapped into an object. * @param redirectAttributes RedirectAttributes used to forward data back to the original * page. - * @return View containing the url and parameters + * @return a redirect to the Policy Page * @throws URISyntaxException if malformed URI */ @PostMapping("update-ima-ignore") @@ -410,7 +410,7 @@ public RedirectView updateIgnoreImaPolicy(@ModelAttribute final PolicyPageModel * @param ppModel The data posted by the form mapped into an object. * @param redirectAttributes RedirectAttributes used to forward data back to the original * page. - * @return View containing the url and parameters + * @return a redirect to the Policy Page * @throws URISyntaxException if malformed URI */ @PostMapping("update-tboot-ignore") @@ -457,7 +457,7 @@ public RedirectView updateIgnoreTbootPolicy(@ModelAttribute final PolicyPageMode * @param ppModel The data posted by the form mapped into an object. * @param redirectAttributes RedirectAttributes used to forward data back to the original * page. - * @return View containing the url and parameters + * @return a redirect to the Policy Page * @throws URISyntaxException if malformed URI */ @PostMapping("update-gpt-ignore") @@ -503,7 +503,7 @@ public RedirectView updateIgnoreGptEventsPolicy(@ModelAttribute final PolicyPage * @param ppModel The data posted by the form mapped into an object. * @param redirectAttributes RedirectAttributes used to forward data back to the original * page. - * @return View containing the url and parameters + * @return a redirect to the Policy Page * @throws URISyntaxException if malformed URI */ @PostMapping("update-os-events-ignore") @@ -548,7 +548,7 @@ public RedirectView updateIgnoreOsEventsPolicy(@ModelAttribute final PolicyPageM * * @param ppModel The data posted by the form mapped into an object. * @param redirectAttributes RedirectAttributes used to forward data back to the Policy Settings page. - * @return View containing the url and parameters + * @return a redirect to the Policy Page * @throws URISyntaxException if malformed URI */ @PostMapping("update-issued-attestation-generation") @@ -585,7 +585,7 @@ public RedirectView updateAttestationCertGenerationPolicy(@ModelAttribute final * * @param ppModel The data posted by the form mapped into an object. * @param redirectAttributes RedirectAttributes used to forward data back to the Policy Settings page. - * @return View containing the url and parameters + * @return a redirect to the Policy Page * @throws URISyntaxException if malformed URI */ @PostMapping("update-attestation-certificate-expiration") @@ -637,7 +637,7 @@ public RedirectView updateAttestationCertExpirationPolicy(@ModelAttribute final * * @param ppModel The data posted by the form mapped into an object. * @param redirectAttributes RedirectAttributes used to forward data back to the Policy Settings page. - * @return View containing the url and parameters + * @return a redirect to the Policy Page * @throws URISyntaxException if malformed URI */ @PostMapping("update-issued-cert-threshold") @@ -688,7 +688,7 @@ public RedirectView updateAttestationCertThresholdPolicy(@ModelAttribute final P * * @param ppModel The data posted by the form mapped into an object. * @param redirectAttributes RedirectAttributes used to forward data back to the Policy Settings page. - * @return View containing the url and parameters + * @return a redirect to the Policy Page * @throws URISyntaxException if malformed URI */ @PostMapping("update-issued-ldevid-generation") @@ -726,7 +726,7 @@ public RedirectView updateLDevIdGenerationPolicy(@ModelAttribute final PolicyPag * * @param ppModel The data posted by the form mapped into an object. * @param redirectAttributes RedirectAttributes used to forward data back to the Policy Settings page. - * @return View containing the url and parameters + * @return a redirect to the Policy Page * @throws URISyntaxException if malformed URI */ @PostMapping("update-ldevid-certificate-expiration") @@ -778,7 +778,7 @@ public RedirectView updateLDevIDCertExpirationPolicy(@ModelAttribute final Polic * * @param ppModel The data posted by the form mapped into an object. * @param redirectAttributes RedirectAttributes used to forward data back to the Policy Settings page. - * @return View containing the url and parameters + * @return a redirect to the Policy Page * @throws URISyntaxException if malformed URI */ @PostMapping("update-ldevid-threshold") @@ -830,7 +830,7 @@ public RedirectView updateLDevIDThresholdValPolicy(@ModelAttribute final PolicyP * @param ppModel The data posted by the form mapped into an object. * @param redirectAttributes RedirectAttributes used to forward data back to the original * page. - * @return View containing the url and parameters + * @return a redirect to the Policy Page * @throws URISyntaxException if malformed URI */ @PostMapping("update-save-protobuf-data-to-log") diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestPageController.java index e9d6b60cd..3a2c0d11b 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestPageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ReferenceManifestPageController.java @@ -83,10 +83,10 @@ public ModelAndView initPage(final NoPageParams params, final Model model) { } /** - * Processes the request to retrieve a list of RIMs for display on the RIM page. + * Processes the request to retrieve a list of {@link ReferenceManifest} objects for display on the RIM page. * * @param dataTableInput data table input - * @return data table of RIMs + * @return data table of {@link ReferenceManifest} objects */ @ResponseBody @GetMapping(value = "/list", produces = MediaType.APPLICATION_JSON_VALUE) @@ -129,11 +129,11 @@ public DataTableResponse getRIMTableData(@Valid final DataTab } /** - * Processes the request to upload one or more reference manifest(s) to the ACA. + * Processes the request to upload one or more {@link ReferenceManifest} objects to the ACA. * * @param files the files to process * @param redirectAttributes RedirectAttributes used to forward data back to the original page. - * @return the redirection view + * @return a redirect to the Reference Manifest Page * @throws URISyntaxException if malformed URI */ @PostMapping("/upload") @@ -193,9 +193,9 @@ protected RedirectView uploadRIMs(@RequestParam("file") final MultipartFile[] fi } /** - * Processes the request to download the RIM . + * Processes the request to download the {@link ReferenceManifest} object. * - * @param id the UUID of the rim to download + * @param id the UUID of the {@link ReferenceManifest} object to download * @param response the response object (needed to update the header with the * file name) * @throws java.io.IOException when writing to response output stream @@ -219,7 +219,7 @@ public void downloadRIM(@RequestParam final String id, final HttpServletResponse } /** - * Processes the request to bulk download RIMs . + * Processes the request to bulk download {@link ReferenceManifest} objects. * * @param response the response object (needed to update the header with the * file name) @@ -243,12 +243,12 @@ public void bulkDownloadRIMs(final HttpServletResponse response) throws IOExcept } /** - * Processes the request to archive/soft delete the provided Reference Integrity Manifest. + * Processes the request to archive/soft delete the provided {@link ReferenceManifest} object. * - * @param id the UUID of the rim to delete + * @param id the UUID of the {@link ReferenceManifest} object to delete * @param redirectAttributes RedirectAttributes used to forward data back to the original * page. - * @return redirect to this page + * @return a redirect to the Reference Manifest Page * @throws URISyntaxException if malformed URI */ @PostMapping("/delete") @@ -278,11 +278,11 @@ public RedirectView deleteRIM(@RequestParam final String id, final RedirectAttri } /** - * Processes the request to delete multiple RIMs. + * Processes the request to delete multiple {@link ReferenceManifest} objects. * - * @param ids the list of UUIDs of the RIMs to be deleted + * @param ids the list of UUIDs of the {@link ReferenceManifest} objects to be deleted * @param redirectAttributes used to pass data back to the original page after the operation - * @return a redirect to the trust chain certificate page + * @return a redirect to the reference manifest page * @throws URISyntaxException if the URI is malformed */ @PostMapping("/bulk-delete") @@ -313,7 +313,7 @@ public RedirectView bulkDeleteRIMs(@RequestParam final List ids, } /** - * Helper method that retrieves a filtered and paginated list of reference manifests based on the + * Helper method that retrieves a filtered and paginated list of {@link ReferenceManifest} objects based on the * provided search criteria. * The method allows filtering based on a global search term and column-specific search criteria, * and returns the result in a paginated format. @@ -322,22 +322,23 @@ public RedirectView bulkDeleteRIMs(@RequestParam final List ids, * The method handles four cases: *
      *
    1. If no global search term and no column-specific search criteria are provided, - * all reference manifests are returned.
    2. + * all {@link ReferenceManifest} objects are returned. *
    3. If both a global search term and column-specific search criteria are provided, - * it performs filtering on both.
    4. - *
    5. If only column-specific search criteria are provided, it filters based on the column-specific - * criteria.
    6. - *
    7. If only a global search term is provided, it filters based on the global search term.
    8. + * {@link ReferenceManifest} objects are filtered based on both criteria. + *
    9. If only column-specific search criteria are provided, {@link ReferenceManifest} objects + * are filtered according to the column-specific criteria.
    10. + *
    11. If only a global search term is provided, {@link ReferenceManifest} objects + * are filtered according to the global search term.
    12. *
    *

    * - * @param globalSearchTerm A global search term that will be used to filter the endorsement - * credentials by the searchable fields. + * @param globalSearchTerm A global search term that will be used to filter the {@link ReferenceManifest} + * objects by the searchable fields. * @param columnsWithSearchCriteria A set of columns with specific search criteria entered by the user. * @param searchableColumnNames A set of searchable column names that are for the global search term. * @param pageable pageable * @return A {@link FilteredRecordsList} containing the filtered and paginated list of - * reference manifests, along with the total number of records and the number of records matching the + * {@link ReferenceManifest} objects, along with the total number of records and the number of records matching the * filter criteria. */ private FilteredRecordsList getFilteredReferenceManifestList( diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/RimDatabasePageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/RimDatabasePageController.java index eba1dcaf7..95a713c59 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/RimDatabasePageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/RimDatabasePageController.java @@ -28,7 +28,7 @@ import java.util.Set; /** - * Controller for the TPM Events page. + * Controller for the RIM Database page. */ @Controller @RequestMapping("/HIRS_AttestationCAPortal/portal/rim-database") @@ -61,8 +61,8 @@ public ModelAndView initPage(final NoPageParams params, final Model model) { } /** - * Processes the request to retrieve a list of reference digest values for display - * on the rim database page. + * Processes the request to retrieve a list of {@link ReferenceDigestValue} objects for display + * on the RIM Database page. * * @param dataTableInput the data tables input * @return the data tables response, including the result set and paging @@ -125,8 +125,9 @@ public DataTableResponse getRDVTableData( } /** - * Helper method that retrieves a filtered and paginated list of reference digest values based on the - * provided search criteria. + * Helper method that retrieves a filtered and paginated list of {@link ReferenceDigestValue} objects based on + * the provided search criteria. + *

    * The method allows filtering based on a global search term and column-specific search criteria, * and returns the result in a paginated format. * @@ -134,23 +135,24 @@ public DataTableResponse getRDVTableData( * The method handles four cases: *

      *
    1. If no global search term and no column-specific search criteria are provided, - * all reference digest values are returned.
    2. + * all {@link ReferenceDigestValue} objects are returned. *
    3. If both a global search term and column-specific search criteria are provided, - * it performs filtering on both.
    4. - *
    5. If only column-specific search criteria are provided, it filters based on the column-specific - * criteria.
    6. - *
    7. If only a global search term is provided, it filters based on the global search term.
    8. + * {@link ReferenceDigestValue} objects are filtered based on both criteria. + *
    9. If only column-specific search criteria are provided, {@link ReferenceDigestValue} objects + * are filtered according to the column-specific criteria.
    10. + *
    11. If only a global search term is provided, {@link ReferenceDigestValue} objects + * are filtered according to the global search term.
    12. *
    *

    * - * @param globalSearchTerm A global search term that will be used to filter the endorsement - * credentials by the searchable fields. + * @param globalSearchTerm A global search term that will be used to filter the + * {@link ReferenceDigestValue} objects by the searchable fields. * @param columnsWithSearchCriteria A set of columns with specific search criteria entered by the user. * @param searchableColumnNames A set of searchable column names that are for the global search term. * @param pageable pageable * @return A {@link FilteredRecordsList} containing the filtered and paginated list of - * reference digest values , along with the total number of records and the number of records matching the - * filter criteria. + * {@link ReferenceDigestValue} objects , along with the total number of records and the number of records + * matching the filter criteria. */ private FilteredRecordsList getFilteredRDVList( final String globalSearchTerm, diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ValidationReportsPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ValidationReportsPageController.java index 9166ef99a..317a1403a 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ValidationReportsPageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ValidationReportsPageController.java @@ -126,8 +126,8 @@ public void downloadValidationReports(final HttpServletRequest request, } /** - * Helper method that retrieves a filtered and paginated list of endorsement credentials based on the - * provided search criteria. + * Helper method that retrieves a filtered and paginated list of {@link SupplyChainValidationSummary} objects + * based on the provided search criteria. * The method allows filtering based on a global search term and column-specific search criteria, * and returns the result in a paginated format. * @@ -135,7 +135,7 @@ public void downloadValidationReports(final HttpServletRequest request, * The method handles four cases: *
      *
    1. If no global search term and no column-specific search criteria are provided, - * all endorsement credentials are returned.
    2. + * all {@link SupplyChainValidationSummary} objects are returned. *
    3. If both a global search term and column-specific search criteria are provided, * it performs filtering on both.
    4. *
    5. If only column-specific search criteria are provided, it filters based on the column-specific @@ -144,14 +144,14 @@ public void downloadValidationReports(final HttpServletRequest request, *
    *

    * - * @param globalSearchTerm A global search term that will be used to filter the endorsement - * credentials by the searchable fields. + * @param globalSearchTerm A global search term that will be used to filter the + * {@link SupplyChainValidationSummary} objects by the searchable fields. * @param columnsWithSearchCriteria A set of columns with specific search criteria entered by the user. * @param searchableColumnNames A set of searchable column names that are for the global search term. * @param pageable pageable * @return A {@link FilteredRecordsList} containing the filtered and paginated list of - * endorsement credentials, along with the total number of records and the number of records matching the - * filter criteria. + * {@link SupplyChainValidationSummary} objects, along with the total number of records and the number of records + * matching the filter criteria. */ private FilteredRecordsList getFilteredValidationSummaryList( final String globalSearchTerm, diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/utils/CertificateStringMapBuilder.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/utils/CertificateStringMapBuilder.java index 7934080e1..cda87012f 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/utils/CertificateStringMapBuilder.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/utils/CertificateStringMapBuilder.java @@ -654,8 +654,7 @@ private static HashMap convertStringToHash(final String str) { key = Character.toUpperCase(key.charAt(0)) + key.substring(1); // Handle nested object recursively if it contains braces or parentheses - if ((value.contains("{") && value.contains("}")) || - (value.contains("(") && value.contains(")"))) { + if ((value.contains("{") && value.contains("}")) || (value.contains("(") && value.contains(")"))) { HashMap nestedMap = convertStringToHash(value); // Prefix nested keys with parent key map.putAll(nestedMap); diff --git a/HIRS_Utils/src/main/java/hirs/utils/digest/AbstractDigest.java b/HIRS_Utils/src/main/java/hirs/utils/digest/AbstractDigest.java index 01f4f3321..6be803b93 100644 --- a/HIRS_Utils/src/main/java/hirs/utils/digest/AbstractDigest.java +++ b/HIRS_Utils/src/main/java/hirs/utils/digest/AbstractDigest.java @@ -20,6 +20,7 @@ */ @Log4j2 public abstract class AbstractDigest { + /** * Length of MD2 digest. */ @@ -44,7 +45,7 @@ public abstract class AbstractDigest { * Length of SHA384 digest. */ public static final int SHA384_DIGEST_LENGTH = 48; - + /** * Length of SHA512 digest. */ From 7497cba05e617e0b51f779bb8446ab94efb8339b Mon Sep 17 00:00:00 2001 From: ThatSilentCoder <184309164+ThatSilentCoder@users.noreply.github.com> Date: Mon, 30 Mar 2026 13:48:08 -0400 Subject: [PATCH 19/20] v3.1_issue_1105: Fixed comments made in the javadocs. --- .../manager/ComponentResultRepository.java | 14 ++++++++------ .../manager/ReferenceDigestValueRepository.java | 16 ++++++++-------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ComponentResultRepository.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ComponentResultRepository.java index be5c9958c..d21abd1e4 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ComponentResultRepository.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ComponentResultRepository.java @@ -20,28 +20,30 @@ public interface ComponentResultRepository extends JpaRepository { /** - * Query based on the device serial number. + * Query that retrieves a list of {@link ComponentResult} objects based on the device serial number. * * @param boardSerialNumber variable holding the device serial number - * @return a list of component result. + * @return a list of {@link ComponentResult} objects */ List findByBoardSerialNumber(String boardSerialNumber); /** - * Query based on the device serial number. + * Query that retrieves a list of {@link ComponentResult} objects based on the device serial number and a boolean + * value. * * @param boardSerialNumber variable holding the device serial number * @param delta flag indicating if the component is associated with a delta certificate - * @return a list of component result. + * @return a list of {@link ComponentResult} objects */ List findByBoardSerialNumberAndDelta(String boardSerialNumber, boolean delta); /** - * Query based on certificate serial number and device serial number. + * Query that retrieves a list of {@link ComponentResult} objects based on certificate serial number + * and device serial number. * * @param certificateSerialNumber certificate specific serial number * @param boardSerialNumber variable holding the device serial number - * @return a list of component result. + * @return a list of {@link ComponentResult} objects */ List findByCertificateSerialNumberAndBoardSerialNumber( String certificateSerialNumber, String boardSerialNumber); diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ReferenceDigestValueRepository.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ReferenceDigestValueRepository.java index a594d3257..9cbc329d4 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ReferenceDigestValueRepository.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/ReferenceDigestValueRepository.java @@ -20,35 +20,35 @@ public interface ReferenceDigestValueRepository extends JpaRepository { /** - * Query that retrieves a list of {@link ReferenceDigestValue} object using the provided associated rim id. + * Query that retrieves a list of {@link ReferenceDigestValue} objects using the provided associated rim id. * * @param associatedRimId uuid representation of the associated rim ID - * @return a list of {@link ReferenceDigestValue} object + * @return a list of {@link ReferenceDigestValue} objects */ List findValuesByBaseRimId(UUID associatedRimId); /** - * Query that retrieves a list of {@link ReferenceDigestValue} object using the provided support rim id. + * Query that retrieves a list of {@link ReferenceDigestValue} objects using the provided support rim id. * * @param supportRimId uuid representation of the support rim ID - * @return a list of {@link ReferenceDigestValue} object + * @return a list of {@link ReferenceDigestValue} objects */ List findBySupportRimId(UUID supportRimId); /** - * Query that retrieves a list of {@link ReferenceDigestValue} object using the provided support rim hash. + * Query that retrieves a list of {@link ReferenceDigestValue} objects using the provided support rim hash. * * @param supportRimHash a string representation of the support rim hash - * @return a list of {@link ReferenceDigestValue} object + * @return a list of {@link ReferenceDigestValue} objects */ List findBySupportRimHash(String supportRimHash); /** - * Query that retrieves a list of {@link ReferenceDigestValue} object using the provided manufacturer and model. + * Query that retrieves a list of {@link ReferenceDigestValue} objects using the provided manufacturer and model. * * @param manufacturer string representation of the manufacturer * @param model string representation of the model - * @return a list of {@link ReferenceDigestValue} object + * @return a list of {@link ReferenceDigestValue} objects */ List findByManufacturerAndModel(String manufacturer, String model); } From 58d7382167971a92737fd87311da47df78a582be Mon Sep 17 00:00:00 2001 From: ThatSilentCoder <184309164+ThatSilentCoder@users.noreply.github.com> Date: Mon, 30 Mar 2026 14:07:23 -0400 Subject: [PATCH 20/20] v3.1_issue_1105: Addressed remaining javadoc warnings. --- .../certificate/ComponentResult.java | 2 + .../validation/FirmwareScvValidator.java | 2 + .../ValidationReportsPageController.java | 10 ++- .../main/java/hirs/swid/CredentialParser.java | 35 ++++---- .../src/main/java/hirs/swid/Main.java | 9 +- .../utils/CredentialArgumentValidator.java | 52 +++++------ .../main/java/hirs/swid/utils/CsvParser.java | 88 ++++++++++--------- .../swid/utils/FileArgumentValidator.java | 9 +- .../main/java/hirs/swid/utils/HashSwid.java | 52 ++++++----- 9 files changed, 137 insertions(+), 122 deletions(-) diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/ComponentResult.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/ComponentResult.java index 118b8228d..d9d36244e 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/ComponentResult.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/certificate/ComponentResult.java @@ -128,6 +128,8 @@ public ComponentResult(final String boardSerialNumber, final String certificateS } /** + * Constructor. + * * @param boardSerialNumber associated platform certificate serial number * @param certificateSerialNumber unique number associated with header info * @param certificateType type of certificate. Parameter holds version 1.2 or 2.0. diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/FirmwareScvValidator.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/FirmwareScvValidator.java index 261995ddd..c6a02683a 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/FirmwareScvValidator.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/validation/FirmwareScvValidator.java @@ -46,6 +46,8 @@ public class FirmwareScvValidator extends SupplyChainCredentialValidator { private static ReferenceManifest supportReferenceManifest; /** + * Validates the firmware and returns an {@link AppraisalStatus}. + * * @param device device * @param policySettings policy settings * @param referenceManifestRepository reference manifest repository diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ValidationReportsPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ValidationReportsPageController.java index 317a1403a..c7a3e5a41 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ValidationReportsPageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/ValidationReportsPageController.java @@ -128,6 +128,7 @@ public void downloadValidationReports(final HttpServletRequest request, /** * Helper method that retrieves a filtered and paginated list of {@link SupplyChainValidationSummary} objects * based on the provided search criteria. + *

    * The method allows filtering based on a global search term and column-specific search criteria, * and returns the result in a paginated format. * @@ -137,10 +138,11 @@ public void downloadValidationReports(final HttpServletRequest request, *

  • If no global search term and no column-specific search criteria are provided, * all {@link SupplyChainValidationSummary} objects are returned.
  • *
  • If both a global search term and column-specific search criteria are provided, - * it performs filtering on both.
  • - *
  • If only column-specific search criteria are provided, it filters based on the column-specific - * criteria.
  • - *
  • If only a global search term is provided, it filters based on the global search term.
  • + * {@link SupplyChainValidationSummary} objects are filtered based on both criteria. + *
  • If only column-specific search criteria are provided, {@link SupplyChainValidationSummary} objects + * are filtered according to the column-specific criteria.
  • + *
  • If only a global search term is provided, {@link SupplyChainValidationSummary} objects + * are filtered according to the global search term.
  • * *

    * diff --git a/tools/tcg_rim_tool/src/main/java/hirs/swid/CredentialParser.java b/tools/tcg_rim_tool/src/main/java/hirs/swid/CredentialParser.java index 986b6b584..7a3dc3b2f 100644 --- a/tools/tcg_rim_tool/src/main/java/hirs/swid/CredentialParser.java +++ b/tools/tcg_rim_tool/src/main/java/hirs/swid/CredentialParser.java @@ -64,7 +64,8 @@ public class CredentialParser { /** * Parses C.509 Certificates within a JKS Keystore. - * @param jksKeystore + * + * @param jksKeystore jks keystore */ public void parseJKSCredentials(final String jksKeystore) { KeyStore.PrivateKeyEntry privateKeyEntry = @@ -78,12 +79,12 @@ public void parseJKSCredentials(final String jksKeystore) { /** * Parses PEM formatted X.509 Certificates. - * @param certificateFile - * @param privateKeyFile - * @throws Exception + * + * @param certificateFile certificate file + * @param privateKeyFile private key file + * @throws Exception if any issues arise parsing the PEM credentials */ - public void parsePEMCredentials(final String certificateFile, final String privateKeyFile) - throws Exception { + public void parsePEMCredentials(final String certificateFile, final String privateKeyFile) throws Exception { certificate = parsePEMCertificates(certificateFile).get(0); if (certificate.getIssuerX500Principal().equals(certificate.getSubjectX500Principal())) { throw new CertificateException("Signing certificate cannot be self-signed!"); @@ -118,12 +119,10 @@ public X509Certificate parseCertFromPEMString(final String pemString) throws Cer /** * This method returns the X509Certificate object from a PEM certificate file. * - * @param certificateFile + * @param certificateFile certificate file * @return list of x509 Certificates - * @throws FileNotFoundException */ - public List parseCertsFromPEM(final String certificateFile) - throws FileNotFoundException { + public List parseCertsFromPEM(final String certificateFile) { return parsePEMCertificates(certificateFile); } @@ -180,7 +179,7 @@ private List parsePEMCertificates(final String filename) { * Algorithm argument is present to allow handling of multiple encryption algorithms, * but for now it is always RSA. * - * @param filename name of the file holding the key + * @param filename name of the file holding the key * @param algorithm algorithm of the key * @return private key */ @@ -242,7 +241,7 @@ private PrivateKey parsePEMPrivateKey(final String filename, final String algori /** * This method reads a PKCS1 keypair from a PEM file. * - * @param filename + * @param filename file name * @return a key pair */ private KeyPair getPKCS1KeyPair(final String filename) throws IOException { @@ -257,9 +256,9 @@ private KeyPair getPKCS1KeyPair(final String filename) throws IOException { /** * This method returns the private key from a JKS keystore. * - * @param keystoreFile - * @param alias - * @param password + * @param keystoreFile keystore file + * @param alias alias + * @param password password * @return KeyStore.PrivateKeyEntry */ private KeyStore.PrivateKeyEntry parseKeystorePrivateKey(final String keystoreFile, final String alias, @@ -285,7 +284,7 @@ private KeyStore.PrivateKeyEntry parseKeystorePrivateKey(final String keystoreFi * This method returns the authorityInfoAccess from an X509Certificate. * * @return authority Info Access text - * @throws IOException + * @throws IOException if any issues arise from retrieving the certificate's authority info access */ public String getCertificateAuthorityInfoAccess() throws IOException { StringBuilder sb = new StringBuilder("Authority Info Access:\n"); @@ -309,7 +308,7 @@ public String getCertificateAuthorityInfoAccess() throws IOException { * This method returns the subjectKeyIdentifier from the local X509Certificate. * * @return the String representation of the subjectKeyIdentifier - * @throws IOException + * @throws IOException if any issues arise from retrieving the certificate's subject key identifier */ public String getCertificateSubjectKeyIdentifier() throws IOException { String decodedValue = null; @@ -327,7 +326,7 @@ public String getCertificateSubjectKeyIdentifier() throws IOException { * * @param certificate the cert to pull the subjectKeyIdentifier from * @return the String representation of the subjectKeyIdentifier - * @throws IOException + * @throws IOException if any issues arise from retrieving the certificate's subject key identifier */ public String getCertificateSubjectKeyIdentifier(final X509Certificate certificate) throws IOException { String decodedValue = null; diff --git a/tools/tcg_rim_tool/src/main/java/hirs/swid/Main.java b/tools/tcg_rim_tool/src/main/java/hirs/swid/Main.java index 07ee6fdb6..0f5181d3b 100644 --- a/tools/tcg_rim_tool/src/main/java/hirs/swid/Main.java +++ b/tools/tcg_rim_tool/src/main/java/hirs/swid/Main.java @@ -1,9 +1,9 @@ package hirs.swid; +import com.beust.jcommander.JCommander; import hirs.swid.utils.Commander; import hirs.swid.utils.TimestampArgumentValidator; import hirs.utils.rim.ReferenceManifestValidator; -import com.beust.jcommander.JCommander; import lombok.extern.log4j.Log4j2; import java.io.File; @@ -13,12 +13,14 @@ import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; + @Log4j2 public class Main { /** * Processes tcg_rim_tool commands. - * @param args + * + * @param args args */ public static void main(final String[] args) { Commander commander = new Commander(); @@ -69,7 +71,7 @@ public static void main(final String[] args) { } else { gateway = new SwidTagGateway(); if (commander.isVerbose()) { - System.out.println(commander.toString()); + System.out.println(commander); } String createType = commander.getCreateType().toUpperCase(); String attributesFile = commander.getAttributesFile(); @@ -116,6 +118,7 @@ public static void main(final String[] args) { /** * Use cases that exit with an error code are redirected here. + * * @param errorMessage */ private static void exitWithErrorCode(final String errorMessage) { diff --git a/tools/tcg_rim_tool/src/main/java/hirs/swid/utils/CredentialArgumentValidator.java b/tools/tcg_rim_tool/src/main/java/hirs/swid/utils/CredentialArgumentValidator.java index 3b46f2b92..b8e285040 100644 --- a/tools/tcg_rim_tool/src/main/java/hirs/swid/utils/CredentialArgumentValidator.java +++ b/tools/tcg_rim_tool/src/main/java/hirs/swid/utils/CredentialArgumentValidator.java @@ -1,20 +1,32 @@ package hirs.swid.utils; +import lombok.AccessLevel; +import lombok.Getter; + +@Getter public class CredentialArgumentValidator { - private String truststoreFile; - private String certificateFile; - private String privateKeyFile; + private static final String PEM = "PEM"; + + private final String truststoreFile; + + private final String certificateFile; + + private final String privateKeyFile; + + @Getter(AccessLevel.NONE) + private final boolean isValidating; + private String format; - private boolean isValidating; + private String errorMessage; - private static final String PEM = "PEM"; /** * Validates Certificate based arguments. - * @param truststoreFile - * @param certificateFile - * @param privateKeyFile - * @param isValidating + * + * @param truststoreFile trust store file + * @param certificateFile certificate file + * @param privateKeyFile private key file + * @param isValidating isValidating */ public CredentialArgumentValidator(final String truststoreFile, final String certificateFile, @@ -27,24 +39,6 @@ public CredentialArgumentValidator(final String truststoreFile, errorMessage = ""; } - /** - * Getter for format property. - * - * @return string - */ - public String getFormat() { - return format; - } - - /** - * Getter for error message. - * - * @return string - */ - public String getErrorMessage() { - return errorMessage; - } - /** * This method checks for the following valid configurations of input arguments. * 1. truststore only for validating (PEM format) @@ -67,11 +61,11 @@ public boolean isValid() { return true; } else { if (certificateFile.isEmpty()) { - errorMessage = "A public certificate must be specified by \'-p\' " + errorMessage = "A public certificate must be specified by '-p' " + "for signing operations."; } if (privateKeyFile.isEmpty()) { - errorMessage = "A private key must be specified by \'-k\' " + errorMessage = "A private key must be specified by '-k' " + "for signing operations."; } return false; diff --git a/tools/tcg_rim_tool/src/main/java/hirs/swid/utils/CsvParser.java b/tools/tcg_rim_tool/src/main/java/hirs/swid/utils/CsvParser.java index d4e8fdee6..44935f37c 100644 --- a/tools/tcg_rim_tool/src/main/java/hirs/swid/utils/CsvParser.java +++ b/tools/tcg_rim_tool/src/main/java/hirs/swid/utils/CsvParser.java @@ -16,10 +16,11 @@ public class CsvParser { private static final char DEFAULT_SEPARATOR = ','; private static final char DEFAULT_QUOTE = '"'; - private List content; + private final List content; /** * CsvParser constructor. + * * @param file name of the file contains the CSV data. */ public CsvParser(final File file) { @@ -28,49 +29,17 @@ public CsvParser(final File file) { /** * CsvParser constructor. + * * @param csvfile Sting containing the contents of the SCV file. */ public CsvParser(final String csvfile) { content = readerCsv(csvfile); } - /** - * This method takes an existing csv file and reads the file by line and - * adds the contents to a list of Strings. - * - * @param file valid path to a csv file. - * @return List of Strings. - */ - private List readerCsv(final String file) { - String line = ""; - String csvSplitBy = ","; - List tempList = new LinkedList<>(); - - try (BufferedReader br = new BufferedReader(new FileReader(file))) { - while ((line = br.readLine()) != null) { - if (line.length() > 0 - && line.contains(csvSplitBy)) { - tempList.add(line); - } - } - } catch (IOException ioEx) { - System.out.println(String.format("Error reading in CSV file...(%s)", file)); - System.exit(1); - } - return tempList; - } - - /** - * Gets content as a list of Stings. - * @return List of Strings. - */ - public final List getContent() { - return Collections.unmodifiableList(content); - } - /** * Gets a list of parsed lines. - * @param csvLine + * + * @param csvLine csv line * @return List of Strings. */ public static List parseLine(final String csvLine) { @@ -79,8 +48,9 @@ public static List parseLine(final String csvLine) { /** * Parses a CSV Line. - * @param csvLine - * @param separators + * + * @param csvLine csv line + * @param separators separators * @return List of Strings. */ public static List parseLine(final String csvLine, final char separators) { @@ -89,9 +59,10 @@ public static List parseLine(final String csvLine, final char separators /** * Parses a CSV Line. - * @param csvLine - * @param separators - * @param customQuote + * + * @param csvLine csv line + * @param separators separators + * @param customQuote custom quote * @return List of Stings. */ public static List parseLine(final String csvLine, final char separators, final char customQuote) { @@ -159,4 +130,39 @@ public static List parseLine(final String csvLine, final char separators result.add(currVal.toString()); return result; } + + /** + * This method takes an existing csv file and reads the file by line and + * adds the contents to a list of Strings. + * + * @param file valid path to a csv file. + * @return List of Strings. + */ + private List readerCsv(final String file) { + String line = ""; + String csvSplitBy = ","; + List tempList = new LinkedList<>(); + + try (BufferedReader br = new BufferedReader(new FileReader(file))) { + while ((line = br.readLine()) != null) { + if (line.length() > 0 + && line.contains(csvSplitBy)) { + tempList.add(line); + } + } + } catch (IOException ioEx) { + System.out.printf("Error reading in CSV file...(%s)%n", file); + System.exit(1); + } + return tempList; + } + + /** + * Gets content as a list of Stings. + * + * @return List of Strings. + */ + public final List getContent() { + return Collections.unmodifiableList(content); + } } diff --git a/tools/tcg_rim_tool/src/main/java/hirs/swid/utils/FileArgumentValidator.java b/tools/tcg_rim_tool/src/main/java/hirs/swid/utils/FileArgumentValidator.java index 7d852932d..fade02692 100644 --- a/tools/tcg_rim_tool/src/main/java/hirs/swid/utils/FileArgumentValidator.java +++ b/tools/tcg_rim_tool/src/main/java/hirs/swid/utils/FileArgumentValidator.java @@ -2,9 +2,9 @@ import com.beust.jcommander.IParameterValidator; import com.beust.jcommander.ParameterException; +import lombok.extern.log4j.Log4j2; import java.io.File; -import lombok.extern.log4j.Log4j2; /** * This class validates arguments that take a String path to a file. @@ -15,9 +15,10 @@ public class FileArgumentValidator implements IParameterValidator { /** * Validates file arguments. - * @param name - * @param value - * @throws ParameterException + * + * @param name name + * @param value value + * @throws ParameterException if any issues arise from validating the file arguments */ public void validate(final String name, final String value) throws ParameterException { try { diff --git a/tools/tcg_rim_tool/src/main/java/hirs/swid/utils/HashSwid.java b/tools/tcg_rim_tool/src/main/java/hirs/swid/utils/HashSwid.java index 748ec447a..5877ea80e 100644 --- a/tools/tcg_rim_tool/src/main/java/hirs/swid/utils/HashSwid.java +++ b/tools/tcg_rim_tool/src/main/java/hirs/swid/utils/HashSwid.java @@ -23,6 +23,7 @@ public class HashSwid { /** * Getter method for the hash that uses 256 bit hash. + * * @param filepath the file to hash. * @return Sha256 hash. */ @@ -30,34 +31,16 @@ public static String get256Hash(final String filepath) throws Exception { return getHashValue(filepath, SHA256); } - /** - * Getter method for the hash that uses 384 bit hash. - * @param filepath the file to hash. - * @return sha384 hash. - */ - public String get384Hash(final String filepath) throws Exception { - return getHashValue(filepath, SHA384); - } - - /** - * Getter method for the hash that uses 512 bit hash. - * @param filepath the file to hash. - * @return sha512 hash. - */ - public String get512Hash(final String filepath) throws Exception { - return getHashValue(filepath, SHA512); - } - /** * This method creates the hash based on the provided algorithm * only accessible through helper methods. - * + *

    * This method assumes an input file that is small enough to read in its * entirety. Large files should be handled similarly to the public static * getHashValue() below. * * @param filepath file contents to hash - * @param sha the algorithm to use for the hash + * @param sha the algorithm to use for the hash * @return hash value. */ private static String getHashValue(final String filepath, final String sha) throws Exception { @@ -75,7 +58,7 @@ private static String getHashValue(final String filepath, final String sha) thro String errorMessage = "Error hashing file " + filepath + ": "; if (e instanceof UnsupportedEncodingException || e instanceof NoSuchAlgorithmException) { - errorMessage += ((Exception) e).getMessage(); + errorMessage += e.getMessage(); } else if (e instanceof IOException) { errorMessage += "error reading file."; } @@ -88,6 +71,7 @@ private static String getHashValue(final String filepath, final String sha) thro /** * This method is a public access hash function that operates on a string * value and uses default assumptions on the salt and algorithm. + * * @param value string object to hash * @return hash value. */ @@ -108,8 +92,8 @@ public static String getHashValue(final String value) { } catch (UnsupportedEncodingException | NoSuchAlgorithmException grex) { System.out.println(grex.getMessage()); } catch (IOException ioEx) { - System.out.println(String.format("%s: \n%s is not valid...", - ioEx.getMessage(), value)); + System.out.printf("%s: \n%s is not valid...%n", + ioEx.getMessage(), value); } finally { try { if (bis != null) { @@ -125,4 +109,26 @@ public static String getHashValue(final String value) { return Base64.getEncoder().encodeToString(hash); } + + /** + * Getter method for the hash that uses 384 bit hash. + * + * @param filepath the file to hash. + * @return sha384 hash. + * @throws Exception if any issues arise trying to retrieve the hash of the provided filepath + */ + public String get384Hash(final String filepath) throws Exception { + return getHashValue(filepath, SHA384); + } + + /** + * Getter method for the hash that uses 512 bit hash. + * + * @param filepath the file to hash. + * @return sha512 hash. + * @throws Exception if any issues arise trying to retrieve the hash of the provided filepath + */ + public String get512Hash(final String filepath) throws Exception { + return getHashValue(filepath, SHA512); + } }