diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/AcaDbInit.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/AcaDbInit.java index 32e9f2d1..92655476 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/AcaDbInit.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/AcaDbInit.java @@ -2,8 +2,8 @@ package hirs.attestationca; import hirs.appraiser.SupplyChainAppraiser; import hirs.data.persist.policy.SupplyChainPolicy; -import hirs.persist.AppraiserManager; -import hirs.persist.PolicyManager; +import hirs.persist.service.AppraiserService; +import hirs.persist.service.PolicyService; import static hirs.attestationca.AbstractAttestationCertificateAuthority.LOG; @@ -19,18 +19,18 @@ public final class AcaDbInit { * Insert the ACA's default entries into the DB. This class is invoked after successful * install of the HIRS_AttestationCA RPM. * - * @param appraiserManager the AppraiserManager to use to persist appraisers - * @param policyManager the PolicyManager to use to persist policies + * @param appraiserService the AppraiserService to use to persist appraisers + * @param policyService the PolicyService to use to persist policies */ public static synchronized void insertDefaultEntries( - final AppraiserManager appraiserManager, - final PolicyManager policyManager) { + final AppraiserService appraiserService, + final PolicyService policyService) { LOG.info("Ensuring default ACA database entries are present."); // If the SupplyChainAppraiser exists, do not attempt to re-save the supply chain appraiser // or SupplyChainPolicy SupplyChainAppraiser supplyChainAppraiser = (SupplyChainAppraiser) - appraiserManager.getAppraiser(SupplyChainAppraiser.NAME); + appraiserService.getAppraiser(SupplyChainAppraiser.NAME); if (supplyChainAppraiser != null) { LOG.info("Supply chain appraiser is present; not inserting any more entries."); LOG.info("ACA database initialization complete."); @@ -40,15 +40,15 @@ public final class AcaDbInit { // Create the SupplyChainAppraiser LOG.info("Saving supply chain appraiser..."); supplyChainAppraiser = (SupplyChainAppraiser) - appraiserManager.saveAppraiser(new SupplyChainAppraiser()); + appraiserService.saveAppraiser(new SupplyChainAppraiser()); // Create the SupplyChainPolicy LOG.info("Saving default supply chain policy..."); SupplyChainPolicy supplyChainPolicy = new SupplyChainPolicy( SupplyChainPolicy.DEFAULT_POLICY); - policyManager.savePolicy(supplyChainPolicy); - policyManager.setDefaultPolicy(supplyChainAppraiser, supplyChainPolicy); - policyManager.setPolicy(supplyChainAppraiser, supplyChainPolicy); + policyService.savePolicy(supplyChainPolicy); + policyService.setDefaultPolicy(supplyChainAppraiser, supplyChainPolicy); + policyService.setPolicy(supplyChainAppraiser, supplyChainPolicy); LOG.info("ACA database initialization complete."); } diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/InitializationListener.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/InitializationListener.java index 154653ac..fe290bd2 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/InitializationListener.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/InitializationListener.java @@ -1,7 +1,7 @@ package hirs.attestationca; -import hirs.attestationca.servicemanager.DBAppraiserManager; -import hirs.attestationca.servicemanager.DBPolicyManager; +import hirs.attestationca.service.AppraiserServiceImpl; +import hirs.attestationca.service.PolicyServiceImpl; import hirs.utils.HIRSProfiles; import org.springframework.context.annotation.AnnotationConfigApplicationContext; @@ -28,9 +28,8 @@ public class InitializationListener implements ServletContextListener { // .getObject(); EntityManager entityManager = context.getBean(EntityManagerFactory.class) .createEntityManager(); - AcaDbInit.insertDefaultEntries( - new DBAppraiserManager(entityManager), - new DBPolicyManager(entityManager) + AcaDbInit.insertDefaultEntries(new AppraiserServiceImpl(entityManager), + new PolicyServiceImpl(entityManager) ); } diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/service/PolicyServiceImpl.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/service/PolicyServiceImpl.java index 9aa65982..d96b1b99 100644 --- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/service/PolicyServiceImpl.java +++ b/HIRS_AttestationCA/src/main/java/hirs/attestationca/service/PolicyServiceImpl.java @@ -176,6 +176,16 @@ public class PolicyServiceImpl extends DbServiceImpl return ret; } + @Override + public void setPolicy(final Appraiser appraiser, final Policy policy) { + + } + + @Override + public void setDefaultPolicy(final Appraiser appraiser, final Policy policy) { + + } + @Override public FilteredRecordsList getOrderedList( final Class clazz, final String columnToOrder, diff --git a/HIRS_Utils/src/main/java/hirs/persist/service/PolicyService.java b/HIRS_Utils/src/main/java/hirs/persist/service/PolicyService.java index 78c29e05..5df356b5 100644 --- a/HIRS_Utils/src/main/java/hirs/persist/service/PolicyService.java +++ b/HIRS_Utils/src/main/java/hirs/persist/service/PolicyService.java @@ -42,4 +42,33 @@ public interface PolicyService extends OrderedQuery { * @return default policy */ Policy getDefaultPolicy(Appraiser appraiser); + + + + /** + * Sets the Policy for the Appraiser. + * + * @param appraiser appraiser + * @param policy policy + */ + void setPolicy(Appraiser appraiser, Policy policy); + + /** + * Sets the default Policy for an Appraiser. The + * default policy is used by an appraiser when a specific policy has not + * been set for a platform. + *

+ * In this current release a specific policy for a platform cannot yet be + * set, so Appraisers can only call + * {@link #getDefaultPolicy(Appraiser)} to retrieve the Policy + * for a platform. + *

+ * The default policy can be unset by using null for the policy + * parameter. In that case future calls to get the default policy will + * return null. + * + * @param appraiser appraiser + * @param policy default policy + */ + void setDefaultPolicy(Appraiser appraiser, Policy policy); }