Skip to content

Commit

Permalink
issue_847: Applied formatting changes to entire CA module_portal modu…
Browse files Browse the repository at this point in the history
…le. Reduced errors in CA module to less than 180
  • Loading branch information
ThatSilentCoder committed Oct 22, 2024
1 parent b3d1bd8 commit 64c74ea
Show file tree
Hide file tree
Showing 75 changed files with 1,662 additions and 1,315 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public interface OrderedListQuerier<T> {
* @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.
* 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
*/
Expand All @@ -50,13 +50,12 @@ FilteredRecordsList getOrderedList(
* @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.
* 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
*/
@SuppressWarnings("checkstyle:parameternumber")
FilteredRecordsList<T> getOrderedList(
Class<? extends T> clazz, String columnToOrder,
boolean ascending, int firstResult,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,28 @@
import jakarta.persistence.Table;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.Objects;

@Entity
@Table(name = "Device")
@Setter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class Device extends AbstractEntity {

@Getter
@Column(name = "name", unique = true)
private String name;

@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER,
optional = true, orphanRemoval = true)
orphanRemoval = true)
private DeviceInfoReport deviceInfo;

@Getter
Expand Down Expand Up @@ -113,7 +114,7 @@ public Timestamp getLastReportTimestamp() {
/**
* Setter for the report time stamp.
*
* @param lastReportTimestamp
* @param lastReportTimestamp last reported time
*/
public void setLastReportTimestamp(final Timestamp lastReportTimestamp) {
this.lastReportTimestamp = (Timestamp) lastReportTimestamp.clone();
Expand All @@ -122,32 +123,7 @@ public void setLastReportTimestamp(final Timestamp lastReportTimestamp) {
@Override
public String toString() {
return String.format("Device Name: %s%nStatus: %s%nSummary: %s%n",
name, (healthStatus == null ? "N/A" : healthStatus.getStatus()),
name, (healthStatus == null ? "N/A" : healthStatus.getHealthStatus()),
(supplyChainValidationStatus == null ? "N/A" : supplyChainValidationStatus.toString()));
}

@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (!(o instanceof Device device)) {
return false;
}

return isStateOverridden == device.isStateOverridden
&& Objects.equals(name, device.name)
&& healthStatus == device.healthStatus
&& supplyChainValidationStatus == device.supplyChainValidationStatus
&& Objects.equals(lastReportTimestamp, device.lastReportTimestamp)
&& Objects.equals(overrideReason, device.overrideReason)
&& Objects.equals(summaryId, device.summaryId);
}

@Override
public int hashCode() {
return Objects.hash(super.hashCode(), name, healthStatus,
supplyChainValidationStatus, lastReportTimestamp,
isStateOverridden, overrideReason, summaryId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import jakarta.persistence.Inheritance;
import jakarta.persistence.InheritanceType;
import jakarta.persistence.Table;
import lombok.AccessLevel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
Expand All @@ -29,6 +30,7 @@
* loaded into the DB and displayed in the ACA.
*/
@Getter
@Setter
@ToString
@EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = false)
@Log4j2
Expand Down Expand Up @@ -73,73 +75,59 @@ public class ReferenceManifest extends ArchivableEntity {
*/
public static final String SCHEMA_PACKAGE = "hirs.utils.xjc";

@Setter(AccessLevel.NONE)
@EqualsAndHashCode.Include
@Column(columnDefinition = "mediumblob", nullable = false)
private final byte[] rimBytes;
@Setter

@EqualsAndHashCode.Include
@Column(nullable = false)
private String rimType = "Base";

@Setter
@Column
private String tagId = null;

@Setter
@Column
private boolean swidPatch = false;

@Setter
@Column
private boolean swidSupplemental = false;

@Setter
@Column
private String platformManufacturer = null;

@Setter
@Column
private String platformManufacturerId = null;

@Setter
@Column
private String swidTagVersion = null;

@Setter
@Column
private String swidVersion = null;

@Setter
@Column
private String platformModel = null;

@Setter
@Column(nullable = false)
private String fileName = null;

@Setter
@JdbcTypeCode(java.sql.Types.VARCHAR)
@Column
private UUID associatedRim;

@Setter
@Column
private String deviceName;

@Setter
@Column
private String hexDecHash = "";

@Setter
@Column
private String eventLogHash = "";

@Setter
@Column
@JsonIgnore
private String base64Hash = "";


/**
* Default constructor necessary for Hibernate.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ public class IssuedAttestationCertificate extends DeviceAssociatedCertificate {
* @param certificateBytes the issued certificate bytes
* @param endorsementCredential the endorsement credential
* @param platformCredentials the platform credentials
* @param isLDevID is LDevId
* @throws IOException if there is a problem extracting information from the certificate
*/
public IssuedAttestationCertificate(final byte[] certificateBytes,
final EndorsementCredential endorsementCredential,
final List<PlatformCredential> platformCredentials, boolean isLDevID)
final List<PlatformCredential> platformCredentials,
final boolean isLDevID)
throws IOException {
super(certificateBytes);
this.endorsementCredential = endorsementCredential;
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
package hirs.attestationca.persist.entity.userdefined.certificate.attributes.V2;
package hirs.attestationca.persist.entity.userdefined.certificate.attributes.V2;
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public final class TPMMeasurementRecord extends ExaminableRecord {
@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
@@ -0,0 +1 @@
package hirs.attestationca.persist.entity.userdefined.record;
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,24 @@
import jakarta.persistence.Entity;
import jakarta.persistence.Transient;
import jakarta.xml.bind.annotation.XmlElement;
import lombok.AccessLevel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.extern.log4j.Log4j2;

import java.io.Serializable;
import java.net.InetAddress;
import java.util.Objects;

/**
* A <code>DeviceInfoReport</code> is a <code>Report</code> used to transfer the
* information about the device. This <code>Report</code> includes the network,
* OS, and TPM information.
*/
@Log4j2
@NoArgsConstructor
@Getter
@EqualsAndHashCode(callSuper = false)
@Log4j2
@Entity
public class DeviceInfoReport extends AbstractEntity implements Serializable {

Expand All @@ -49,14 +50,18 @@ public class DeviceInfoReport extends AbstractEntity implements Serializable {
@Embedded
private HardwareInfo hardwareInfo;

@Setter(AccessLevel.PRIVATE)
@Getter
@XmlElement
@Embedded
private TPMInfo tpmInfo;

@Getter
@XmlElement
@Column(nullable = false)
private String clientApplicationVersion;

@Getter
@Setter
@XmlElement
@Transient
Expand Down Expand Up @@ -91,8 +96,8 @@ public DeviceInfoReport(final NetworkInfo networkInfo, final OSInfo osInfo,
* @param hardwareInfo HardwareInfo object, cannot be null
* @param tpmInfo TPMInfo object, may be null if a TPM is not available on the
* device
* @param clientApplicationVersion string representing the version of the client that submitted this report,
* cannot be null
* @param clientApplicationVersion string representing the version of the client that submitted this
* report, cannot be null
*/
public DeviceInfoReport(final NetworkInfo networkInfo, final OSInfo osInfo,
final FirmwareInfo firmwareInfo, final HardwareInfo hardwareInfo,
Expand All @@ -101,7 +106,7 @@ public DeviceInfoReport(final NetworkInfo networkInfo, final OSInfo osInfo,
setOSInfo(osInfo);
setFirmwareInfo(firmwareInfo);
setHardwareInfo(hardwareInfo);
setTPMInfo(tpmInfo);
setTpmInfo(tpmInfo);
this.clientApplicationVersion = clientApplicationVersion;
}

Expand Down Expand Up @@ -216,32 +221,6 @@ private void setHardwareInfo(final HardwareInfo hardwareInfo) {
}
this.hardwareInfo = hardwareInfo;
}
}

private void setTPMInfo(final TPMInfo tpmInfo) {
this.tpmInfo = tpmInfo;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof DeviceInfoReport that)) {
return false;
}
return Objects.equals(networkInfo, that.networkInfo)
&& Objects.equals(osInfo, that.osInfo)
&& Objects.equals(firmwareInfo, that.firmwareInfo)
&& Objects.equals(hardwareInfo, that.hardwareInfo)
&& Objects.equals(tpmInfo, that.tpmInfo)
&& Objects.equals(clientApplicationVersion, that.clientApplicationVersion)
&& Objects.equals(paccorOutputString, that.paccorOutputString);
}

@Override
public int hashCode() {
return Objects.hash(super.hashCode(), networkInfo, osInfo,
firmwareInfo, hardwareInfo, tpmInfo,
clientApplicationVersion, paccorOutputString);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package hirs.attestationca.persist.entity.userdefined.report;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package hirs.attestationca.persist.entity.userdefined.result;
Loading

0 comments on commit 64c74ea

Please sign in to comment.