Skip to content

Commit

Permalink
issue_847: Fixed ALL checkstyle errors in CA test module.
Browse files Browse the repository at this point in the history
  • Loading branch information
ThatSilentCoder committed Oct 24, 2024
1 parent 571d107 commit 7959a16
Show file tree
Hide file tree
Showing 15 changed files with 128 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ public void setLastReportTimestamp(final Timestamp lastReportTimestamp) {
this.lastReportTimestamp = (Timestamp) lastReportTimestamp.clone();
}

/**
* Creates a string representation of the Device object.
*
* @return a string representation of the Device object.
*/
@Override
public String toString() {
return String.format("Device Name: %s%nStatus: %s%nSummary: %s%n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,20 @@ public class SupplyChainValidation extends ArchivableEntity {
@Getter
@Column
private final ValidationType validationType;

@Getter
@Column
private final AppraisalStatus.Status validationResult;

@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(name = "CertificatesUsedToValidate",
joinColumns = {@JoinColumn(name = "validation_id", nullable = false)})
private final List<Certificate> certificatesUsed;

@Getter
@Column(length = RESULT_MESSAGE_LENGTH)
private final String message;

@Getter
@Column
private String rimId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public class PlatformProperty {
* Number of identifiers for version 1.
*/
protected static final int IDENTIFIER_NUMBER = 2;

private static final String NOT_SPECIFIED = "Not Specified";

private ASN1UTF8String propertyName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@
public class TBBSecurityAssertion {

private static final int CCINFO = 0;

private static final int FIPSLEVEL = 1;

private static final int RTMTYPE = 2;

private ASN1Integer version;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,9 @@ public final class TPMMeasurementRecord extends ExaminableRecord {
*/
public static final int SHA_256_BYTE_LENGTH = 64;


@Column(name = "pcr", nullable = false)
@XmlAttribute(name = "PcrNumber", required = true)
private final int pcrId;

@Embedded
@XmlElement
private final Digest hash;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public final class ProvisionUtils {
private static final SecureRandom SECURE_RANDOM = new SecureRandom();

/**
* This private constructor was created to silence one of checkstyle errors.
* This private constructor was created to silence checkstyle errors.
*/
private ProvisionUtils() {
}
Expand All @@ -109,7 +109,7 @@ private ProvisionUtils() {
* @param identityClaim byte array that should be converted to a Protobuf IdentityClaim
* object
* @return the Protobuf generated Identity Claim object
* @throws {@link IdentityProcessingException} if byte array could not be parsed
* @throws {@link InvalidProtocolBufferException} if byte array could not be parsed
*/
public static ProvisionerTpm2.IdentityClaim parseIdentityClaim(final byte[] identityClaim) {
try {
Expand Down Expand Up @@ -695,7 +695,7 @@ public static int daysBetween(final Date date1, final Date date2) {
final int hoursInADay = 24;
final int secondsInAnHour = 3600;
final int millisecondsInASecond = 1000;
return (int) ((date2.getTime() - date1.getTime()) /
(millisecondsInASecond * secondsInAnHour * hoursInADay));
return (int) ((date2.getTime() - date1.getTime())
/ (millisecondsInASecond * secondsInAnHour * hoursInADay));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public class SupplyChainValidationService {
* @param policyRepository the policy manager
* @param certificateRepository the cert manager
* @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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@
import java.util.UUID;

@Log4j2
public class ValidationService {
public final class ValidationService {

/**
* This private constructor was created to silence checkstyle errors.
*/
private ValidationService() {
}

/**
* Evaluates the provided endorsement credential status.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,28 @@ public abstract class ReferenceManifestSelector<T extends ReferenceManifest> {
* String representing the database field for the manufacturer.
*/
public static final String PLATFORM_MANUFACTURER = "platformManufacturer";

/**
* String representing the database field for the manufacturer id.
*/
public static final String PLATFORM_MANUFACTURER_ID = "platformManufacturerId";

/**
* String representing the database field for the model.
*/
public static final String PLATFORM_MODEL = "platformModel";

/**
* String representing the database field for the filename.
*/
public static final String RIM_FILENAME_FIELD = "fileName";

private static final String RIM_TYPE_FIELD = "rimType";

private final Class<T> referenceTypeClass;

private final Map<String, Object> fieldValueSelections;

private boolean excludeArchivedRims;

/**
Expand Down Expand Up @@ -142,8 +147,9 @@ protected void setFieldValue(final String name, final Object value) {

/**
* Construct the criterion that can be used to query for rims matching the
* configuration of this {@link ReferenceManifestSelector}.
* + * configuration of this {@link ReferenceManifestSelector}.
*
* @param criteriaBuilder criteria builder
* @return a Criterion that can be used to query for rims matching the
* configuration of this instance
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,23 @@ public final class AcaPciIds {
* The Component Class TCG Registry OID.
*/
public static final String COMPCLASS_TCG_OID = "2.23.133.18.3.1";

/**
* The Component Class Value mask for NICs.
*/
public static final String COMPCLASS_TCG_CAT_NIC = "00090000";

/**
* The Component Class Value mask for GFX cards.
*/
public static final String COMPCLASS_TCG_CAT_GFX = "00050000";

/**
* Private constructor created to silence checkstyle error.
*/
private AcaPciIds() {
}

/**
* Iterate through all components and translate PCI hardware IDs as necessary. It will only
* translate ComponentIdentifierV2+ objects as it relies on Component Class information.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
@Log4j2
public final class CredentialHelper {

/**
* Private constructor was created to silence checkstyle.
*/
private CredentialHelper() {
}

/**
* Small method to check if the certificate is a PEM.
*
Expand All @@ -25,7 +31,7 @@ public static boolean isPEM(final String possiblePEM) {
}

/**
* Small method to check if there are multi pem files
* Small method to check if there are multi pem files.
*
* @param possiblePEM header information
* @return true if it is.
Expand All @@ -44,7 +50,7 @@ public static boolean isMultiPEM(final String possiblePEM) {
}

/**
* Method to remove header footer information from PEM
* Method to remove header footer information from PEM.
*
* @param pemFile string representation of the file
* @return a cleaned up raw byte object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import hirs.attestationca.persist.entity.userdefined.info.ComponentInfo;
import lombok.NoArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.lang3.StringUtils;
import org.bouncycastle.asn1.x500.X500Name;
Expand Down Expand Up @@ -35,7 +34,6 @@
import java.util.Set;

@Log4j2
@NoArgsConstructor
public class SupplyChainCredentialValidator {

/**
Expand All @@ -46,18 +44,15 @@ public class SupplyChainCredentialValidator {
* AppraisalStatus message for a valid endorsement credential appraisal.
*/
public static final String ENDORSEMENT_VALID = "Endorsement credential validated";

/**
* AppraisalStatus message for a valid platform credential appraisal.
*/
public static final String PLATFORM_VALID = "Platform credential validated";

/**
* AppraisalStatus message for a valid platform credential attributes appraisal.
*/
public static final String PLATFORM_ATTRIBUTES_VALID =
"Platform credential attributes validated";

/**
* AppraisalStatus message for a valid firmware appraisal.
*/
Expand All @@ -71,6 +66,12 @@ public class SupplyChainCredentialValidator {
Security.addProvider(new BouncyCastleProvider());
}

/**
* Protected constructor was created to silence checkstyle.
*/
protected SupplyChainCredentialValidator() {
}

/**
* Attempts to check if the certificate is validated by certificates in a cert chain. The cert
* chain is expected to be stored in a non-ordered KeyStore (trust store). If the signing
Expand Down
Loading

0 comments on commit 7959a16

Please sign in to comment.