From d008f2d2f98773fbd27ea2458c02375fa2dfc8e4 Mon Sep 17 00:00:00 2001 From: Cyrus <24922493+cyrus-dev@users.noreply.github.com> Date: Thu, 25 May 2023 14:54:21 -0400 Subject: [PATCH] Two of the policy files were missing [no ci] --- .../entity/manager/PolicyRepository.java | 12 ++ .../entity/userdefined/PolicySettings.java | 123 ++++++++++++++++++ 2 files changed, 135 insertions(+) create mode 100644 HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/PolicyRepository.java create mode 100644 HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/PolicySettings.java 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 new file mode 100644 index 00000000..5dc75115 --- /dev/null +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/manager/PolicyRepository.java @@ -0,0 +1,12 @@ +package hirs.attestationca.persist.entity.manager; + +import hirs.attestationca.persist.entity.userdefined.PolicySettings; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.UUID; + +@Repository +public interface PolicyRepository extends JpaRepository { +// PolicySettings findByName(String name); +} diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/PolicySettings.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/PolicySettings.java new file mode 100644 index 00000000..a076dc6f --- /dev/null +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/persist/entity/userdefined/PolicySettings.java @@ -0,0 +1,123 @@ +package hirs.attestationca.persist.entity.userdefined; + +import hirs.attestationca.persist.entity.UserDefinedEntity; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Table; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + * Class represents Supply Chain policy. Supply Chain Policy identifies the methods in + * SupplyChainValidator that should be used in order to validate a supply chain. + * By default, the policy does not enable any validations. + */ +@Table(name = "PolicySettings") +@Getter +@Setter +@Entity +@ToString(callSuper = true) +public class PolicySettings extends UserDefinedEntity { + /** + * Name of the default Supply Chain Policy. + */ + public static final String DEFAULT_POLICY = "Default Supply Chain Policy"; + /** + * Number of days in 10 years. + */ + public static final String TEN_YEARS = "3651"; + /** + * Number of days in 1 year. + */ + public static final String YEAR = "365"; + + @Column(nullable = false, columnDefinition = "boolean default false") + private boolean ecValidationEnabled = false; + + @Column(nullable = false, columnDefinition = "boolean default false") + private boolean pcValidationEnabled = false; + + @Column(nullable = false, columnDefinition = "boolean default false") + private boolean pcAttributeValidationEnabled = false; + + @Column(nullable = false, columnDefinition = "boolean default false") + private boolean firmwareValidationEnabled = false; + + @Column(nullable = false, columnDefinition = "boolean default false") + private boolean utcValidationEnabled = false; + + @Column(nullable = false, columnDefinition = "boolean default false") + private boolean expiredCertificateValidationEnabled = false; + + @Column(nullable = false, columnDefinition = "boolean default false") + private boolean replaceEC = false; + + @Column(nullable = false, columnDefinition = "boolean default true") + private boolean issueAttestationCertificate = true; + + @Column(nullable = false, columnDefinition = "boolean default true") + private boolean issueDevIdCertificate = true; + + @Column(nullable = false) + private String validityDays = TEN_YEARS; + + @Column(nullable = false) + private String devIdValidityDays = TEN_YEARS; + + @Column(nullable = false) + private String reissueThreshold = YEAR; + + @Column(nullable = false) + private String devIdReissueThreshold = YEAR; + + @Column(nullable = false, columnDefinition = "boolean default false") + private boolean generateOnExpiration = false; + + @Column(nullable = false, columnDefinition = "boolean default false") + private boolean devIdExpirationFlag = false; + + @Column(nullable = false, columnDefinition = "boolean default false") + private boolean ignoreImaEnabled = false; + + @Column(nullable = false, columnDefinition = "boolean default false") + private boolean ignoretBootEnabled = false; + + @Column(nullable = false, columnDefinition = "boolean default false") + private boolean linuxOs = false; + + @Column(nullable = false, columnDefinition = "boolean default true") + private boolean ignoreGptEnabled = true; + + @Column(nullable = false, columnDefinition = "boolean default false") + private boolean ignoreOsEvtEnabled = false; + + /** + * Default constructor necessary for Hibernate. + */ + protected PolicySettings() { + super(); + } + + /** + * Constructor used to initialize PolicySettings object. + * + * @param name + * A name used to uniquely identify and reference the Supply Chain policy. + */ + public PolicySettings(final String name) { + super(name); + } + + /** + * Constructor used to initialize PolicySettings object. + * + * @param name + * A name used to uniquely identify and reference the supply chain policy. + * @param description + * Optional description of the policy that can be added by the user + */ + public PolicySettings(final String name, final String description) { + super(name, description); + } +}