use of org.nhind.config.CertPolicy in project nhin-d by DirectProject.
the class ConfigServiceDNSStore_configCertPolicyTest method testConfigCertPolicy_validPolicy_assertPolicyConfiged.
public void testConfigCertPolicy_validPolicy_assertPolicyConfiged() throws Exception {
System.setProperty(ConfigServiceDNSStore.DNS_CERT_POLICY_NAME_VAR, "ValidPolicy");
try {
final CertPolicy policy = new CertPolicy();
policy.setLexicon(PolicyLexicon.SIMPLE_TEXT_V1);
policy.setPolicyName("ValidPolicy");
policy.setPolicyData(VALID_POLICY.getBytes());
proxy.addPolicy(policy);
final ConfigServiceDNSStore store = new ConfigServiceDNSStore(new URL(ConfigServiceRunner.getConfigServiceURL()));
assertNotNull(store.polExpression);
assertNotNull(store.polFilter);
} finally {
System.setProperty(ConfigServiceDNSStore.DNS_CERT_POLICY_NAME_VAR, "");
}
}
use of org.nhind.config.CertPolicy in project nhin-d by DirectProject.
the class ConfigServiceDNSStore_configCertPolicyTest method testConfigCertPolicy_invalidPolicy_assertNoPolicyConfiged.
public void testConfigCertPolicy_invalidPolicy_assertNoPolicyConfiged() throws Exception {
System.setProperty(ConfigServiceDNSStore.DNS_CERT_POLICY_NAME_VAR, "InvalidPolicy");
try {
final CertPolicy policy = new CertPolicy();
policy.setLexicon(PolicyLexicon.SIMPLE_TEXT_V1);
policy.setPolicyName("InvalidPolicy");
policy.setPolicyData(INVALID_VALID_POLICY.getBytes());
proxy.addPolicy(policy);
final ConfigServiceDNSStore store = new ConfigServiceDNSStore(new URL(ConfigServiceRunner.getConfigServiceURL()));
assertNull(store.polExpression);
assertNull(store.polFilter);
} finally {
System.setProperty(ConfigServiceDNSStore.DNS_CERT_POLICY_NAME_VAR, "");
}
}
use of org.nhind.config.CertPolicy in project nhin-d by DirectProject.
the class ConfigServiceDNSStore_isCertCompliantWithPolicyTest method testisCertCompliantWithPolicy_policyConfigured_nonCompliantCert_assertNonCompliant.
public void testisCertCompliantWithPolicy_policyConfigured_nonCompliantCert_assertNonCompliant() throws Exception {
System.setProperty(ConfigServiceDNSStore.DNS_CERT_POLICY_NAME_VAR, "ValidPolicy");
try {
final CertPolicy policy = new CertPolicy();
policy.setLexicon(PolicyLexicon.SIMPLE_TEXT_V1);
policy.setPolicyName("ValidPolicy");
policy.setPolicyData(KEY_ENC_POLICY.getBytes());
proxy.addPolicy(policy);
final ConfigServiceDNSStore store = new ConfigServiceDNSStore(new URL(ConfigServiceRunner.getConfigServiceURL()));
assertNotNull(store.polExpression);
assertNotNull(store.polFilter);
X509Certificate cert = DNSRecordUtil.loadCertificate("umesh.der");
assertFalse(store.isCertCompliantWithPolicy(cert));
} finally {
System.setProperty(ConfigServiceDNSStore.DNS_CERT_POLICY_NAME_VAR, "");
}
}
use of org.nhind.config.CertPolicy in project nhin-d by DirectProject.
the class ClientProxyCertificatePolicyTest method testAddGetRemovePolicyGroupAndDomain_deleteDomainBeforeDissasociate.
@Test
public void testAddGetRemovePolicyGroupAndDomain_deleteDomainBeforeDissasociate() throws Exception {
CertPolicy addPolicy = new CertPolicy();
addPolicy.setLexicon(PolicyLexicon.XML);
addPolicy.setPolicyName("Test Policy");
addPolicy.setPolicyData(new byte[] { 1, 2, 3 });
proxy.addPolicy(addPolicy);
CertPolicy[] retrievedPolicies = proxy.getPolicies();
assertEquals(1, retrievedPolicies.length);
CertPolicyGroup addGroup = new CertPolicyGroup();
addGroup.setPolicyGroupName("Test Group");
proxy.addPolicyGroup(addGroup);
CertPolicyGroup[] retrievedGroups = proxy.getPolicyGroups();
assertEquals(1, retrievedGroups.length);
proxy.addPolicyUseToGroup(retrievedGroups[0].getId(), retrievedPolicies[0].getId(), CertPolicyUse.TRUST, true, true);
CertPolicyGroup retrievedGroup = proxy.getPolicyGroupById(retrievedGroups[0].getId());
assertNotNull(retrievedGroup);
assertEquals(1, retrievedGroup.getCertPolicyGroupReltn().length);
assertEquals(addPolicy.getPolicyName(), retrievedGroup.getCertPolicyGroupReltn()[0].getCertPolicy().getPolicyName());
Domain domain = new Domain();
domain.setDomainName("Test Domain");
proxy.addDomain(domain);
Domain[] retrievedDomains = proxy.getDomains(new String[] { domain.getDomainName() }, null);
assertEquals(1, retrievedDomains.length);
proxy.associatePolicyGroupToDomain(retrievedDomains[0].getId(), retrievedGroups[0].getId());
CertPolicyGroupDomainReltn[] domainGroups = proxy.getPolicyGroupsByDomain(retrievedDomains[0].getId());
assertEquals(1, domainGroups.length);
// also get all domain/group relts without domain id qualifier
domainGroups = proxy.getPolicyGroupDomainReltns();
assertEquals(1, domainGroups.length);
// should delete domain without error
proxy.removeDomainById(retrievedDomains[0].getId());
}
use of org.nhind.config.CertPolicy in project nhin-d by DirectProject.
the class ClientProxyCertificatePolicyTest method testAddGetRemovePolicyGroupAndDomain_dissasociateGroupFromAllDomains.
@Test
public void testAddGetRemovePolicyGroupAndDomain_dissasociateGroupFromAllDomains() throws Exception {
CertPolicy addPolicy = new CertPolicy();
addPolicy.setLexicon(PolicyLexicon.XML);
addPolicy.setPolicyName("Test Policy");
addPolicy.setPolicyData(new byte[] { 1, 2, 3 });
proxy.addPolicy(addPolicy);
CertPolicy[] retrievedPolicies = proxy.getPolicies();
assertEquals(1, retrievedPolicies.length);
CertPolicyGroup addGroup = new CertPolicyGroup();
addGroup.setPolicyGroupName("Test Group");
proxy.addPolicyGroup(addGroup);
CertPolicyGroup[] retrievedGroups = proxy.getPolicyGroups();
assertEquals(1, retrievedGroups.length);
proxy.addPolicyUseToGroup(retrievedGroups[0].getId(), retrievedPolicies[0].getId(), CertPolicyUse.TRUST, true, true);
CertPolicyGroup retrievedGroup = proxy.getPolicyGroupById(retrievedGroups[0].getId());
assertNotNull(retrievedGroup);
assertEquals(1, retrievedGroup.getCertPolicyGroupReltn().length);
assertEquals(addPolicy.getPolicyName(), retrievedGroup.getCertPolicyGroupReltn()[0].getCertPolicy().getPolicyName());
Domain domain = new Domain();
domain.setDomainName("Test Domain1");
proxy.addDomain(domain);
Domain[] retrievedDomains = proxy.listDomains(null, 100);
assertEquals(1, retrievedDomains.length);
domain = new Domain();
domain.setDomainName("Test Domain2");
proxy.addDomain(domain);
retrievedDomains = proxy.listDomains(null, 100);
assertEquals(2, retrievedDomains.length);
proxy.associatePolicyGroupToDomain(retrievedDomains[0].getId(), retrievedGroups[0].getId());
CertPolicyGroupDomainReltn[] domainGroups = proxy.getPolicyGroupsByDomain(retrievedDomains[0].getId());
assertEquals(1, domainGroups.length);
proxy.associatePolicyGroupToDomain(retrievedDomains[1].getId(), retrievedGroups[0].getId());
domainGroups = proxy.getPolicyGroupsByDomain(retrievedDomains[1].getId());
assertEquals(1, domainGroups.length);
// also get all domain/group relts without domain id qualifier
domainGroups = proxy.getPolicyGroupDomainReltns();
assertEquals(2, domainGroups.length);
// remove policy from all domains domains
proxy.disassociatePolicyGroupFromDomains(retrievedGroups[0].getId());
domainGroups = proxy.getPolicyGroupsByDomain(retrievedDomains[0].getId());
assertNull(domainGroups);
domainGroups = proxy.getPolicyGroupsByDomain(retrievedDomains[0].getId());
assertNull(domainGroups);
// should delete domain without error
proxy.removeDomainById(retrievedDomains[0].getId());
// should delete domain without error
proxy.removeDomainById(retrievedDomains[1].getId());
}
Aggregations