mirror of
https://github.com/nsacyber/HIRS.git
synced 2025-01-22 04:18:20 +00:00
Further updates
This commit is contained in:
parent
fcb6170b93
commit
831950313e
@ -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.");
|
||||
}
|
||||
|
@ -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)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -176,6 +176,16 @@ public class PolicyServiceImpl extends DbServiceImpl<Policy>
|
||||
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<Policy> clazz, final String columnToOrder,
|
||||
|
@ -42,4 +42,33 @@ public interface PolicyService extends OrderedQuery<Policy> {
|
||||
* @return default policy
|
||||
*/
|
||||
Policy getDefaultPolicy(Appraiser appraiser);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Sets the <code>Policy</code> for the <code>Appraiser</code>.
|
||||
*
|
||||
* @param appraiser appraiser
|
||||
* @param policy policy
|
||||
*/
|
||||
void setPolicy(Appraiser appraiser, Policy policy);
|
||||
|
||||
/**
|
||||
* Sets the default <code>Policy</code> for an <code>Appraiser</code>. The
|
||||
* default policy is used by an appraiser when a specific policy has not
|
||||
* been set for a platform.
|
||||
* <p>
|
||||
* In this current release a specific policy for a platform cannot yet be
|
||||
* set, so <code>Appraiser</code>s can only call
|
||||
* {@link #getDefaultPolicy(Appraiser)} to retrieve the <code>Policy</code>
|
||||
* for a platform.
|
||||
* <p>
|
||||
* The default policy can be unset by using null for the <code>policy</code>
|
||||
* 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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user