Search in sources :

Example 1 with CertPolicyGroup

use of org.nhind.config.CertPolicyGroup 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());
}
Also used : CertPolicyGroupDomainReltn(org.nhind.config.CertPolicyGroupDomainReltn) CertPolicy(org.nhind.config.CertPolicy) CertPolicyGroup(org.nhind.config.CertPolicyGroup) Domain(org.nhind.config.Domain) Test(org.junit.Test)

Example 2 with CertPolicyGroup

use of org.nhind.config.CertPolicyGroup 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());
}
Also used : CertPolicyGroupDomainReltn(org.nhind.config.CertPolicyGroupDomainReltn) CertPolicy(org.nhind.config.CertPolicy) CertPolicyGroup(org.nhind.config.CertPolicyGroup) Domain(org.nhind.config.Domain) Test(org.junit.Test)

Example 3 with CertPolicyGroup

use of org.nhind.config.CertPolicyGroup in project nhin-d by DirectProject.

the class ClientProxyCertificatePolicyTest method testAddGetRemovePolicyGroup_deletePolicyBeforeDisassociate.

@Test
public void testAddGetRemovePolicyGroup_deletePolicyBeforeDisassociate() 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());
    proxy.deletePolicies(new Long[] { retrievedPolicies[0].getId() });
    retrievedPolicies = proxy.getPolicies();
    assertNull(retrievedPolicies);
    retrievedGroup = proxy.getPolicyGroupById(retrievedGroups[0].getId());
    assertNotNull(retrievedGroup);
    assertNull(retrievedGroup.getCertPolicyGroupReltn());
    proxy.deletePolicyGroups(new Long[] { retrievedGroups[0].getId() });
    retrievedGroups = proxy.getPolicyGroups();
    assertNull(retrievedGroups);
}
Also used : CertPolicy(org.nhind.config.CertPolicy) CertPolicyGroup(org.nhind.config.CertPolicyGroup) Test(org.junit.Test)

Example 4 with CertPolicyGroup

use of org.nhind.config.CertPolicyGroup in project nhin-d by DirectProject.

the class ClientProxyCertificatePolicyTest method testAddGetRemovePolicyGroup.

@Test
public void testAddGetRemovePolicyGroup() 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());
    proxy.removePolicyUseFromGroup(retrievedGroup.getCertPolicyGroupReltn()[0].getId());
    retrievedGroup = proxy.getPolicyGroupById(retrievedGroups[0].getId());
    assertNotNull(retrievedGroup);
    assertNull(retrievedGroup.getCertPolicyGroupReltn());
    proxy.deletePolicies(new Long[] { retrievedPolicies[0].getId() });
    retrievedPolicies = proxy.getPolicies();
    assertNull(retrievedPolicies);
    proxy.deletePolicyGroups(new Long[] { retrievedGroups[0].getId() });
    retrievedGroups = proxy.getPolicyGroups();
    assertNull(retrievedGroups);
}
Also used : CertPolicy(org.nhind.config.CertPolicy) CertPolicyGroup(org.nhind.config.CertPolicyGroup) Test(org.junit.Test)

Example 5 with CertPolicyGroup

use of org.nhind.config.CertPolicyGroup in project nhin-d by DirectProject.

the class ClientProxyCertificatePolicyTest method testAddGetRemovePolicyGroupAndDomain_dissasociateGroupBeforeDeleteDomain.

@Test
public void testAddGetRemovePolicyGroupAndDomain_dissasociateGroupBeforeDeleteDomain() 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);
    // remove policy from single domain
    proxy.disassociatePolicyGroupFromDomain(retrievedDomains[0].getId(), retrievedGroups[0].getId());
    domainGroups = proxy.getPolicyGroupsByDomain(retrievedDomains[0].getId());
    assertNull(domainGroups);
    // should delete domain without error
    proxy.removeDomainById(retrievedDomains[0].getId());
}
Also used : CertPolicyGroupDomainReltn(org.nhind.config.CertPolicyGroupDomainReltn) CertPolicy(org.nhind.config.CertPolicy) CertPolicyGroup(org.nhind.config.CertPolicyGroup) Domain(org.nhind.config.Domain) Test(org.junit.Test)

Aggregations

CertPolicy (org.nhind.config.CertPolicy)6 CertPolicyGroup (org.nhind.config.CertPolicyGroup)6 Test (org.junit.Test)5 Domain (org.nhind.config.Domain)4 CertPolicyGroupDomainReltn (org.nhind.config.CertPolicyGroupDomainReltn)3 Before (org.junit.Before)1