Search in sources :

Example 1 with CertPolicyGroupUse

use of org.nhindirect.config.model.CertPolicyGroupUse in project nhin-d by DirectProject.

the class RESTSmtpAgentConfig method buildPolicyResolvers.

@Override
protected void buildPolicyResolvers() {
    final Map<String, Collection<PolicyExpression>> incomingPrivatePolicies = new HashMap<String, Collection<PolicyExpression>>();
    final Map<String, Collection<PolicyExpression>> outgoingPrivatePolicies = new HashMap<String, Collection<PolicyExpression>>();
    final Map<String, Collection<PolicyExpression>> incomingPublicPolicies = new HashMap<String, Collection<PolicyExpression>>();
    final Map<String, Collection<PolicyExpression>> outgoingPublicPolicies = new HashMap<String, Collection<PolicyExpression>>();
    final Map<String, Collection<PolicyExpression>> trustPolicies = new HashMap<String, Collection<PolicyExpression>>();
    Collection<CertPolicyGroupDomainReltn> domainReltns = null;
    try {
        // get all of the policy group to domain relations... 
        // doing this all in one call for efficiency
        domainReltns = policyService.getPolicyGroupDomainReltns();
    } catch (Exception e) {
        throw new SmtpAgentException(SmtpAgentError.InvalidConfigurationFormat, "WebService error getting certificate policy configuration: " + e.getMessage(), e);
    }
    if (domainReltns != null) {
        for (CertPolicyGroupDomainReltn domainReltn : domainReltns) {
            if (domainReltn.getPolicyGroup().getPolicies() != null) {
                for (CertPolicyGroupUse policyReltn : domainReltn.getPolicyGroup().getPolicies()) {
                    if (policyReltn.getPolicyUse().equals(CertPolicyUse.PRIVATE_RESOLVER)) {
                        if (policyReltn.isIncoming())
                            addPolicyToMap(incomingPrivatePolicies, domainReltn.getDomain().getDomainName(), policyReltn);
                        if (policyReltn.isOutgoing())
                            addPolicyToMap(outgoingPrivatePolicies, domainReltn.getDomain().getDomainName(), policyReltn);
                    } else if (policyReltn.getPolicyUse().equals(CertPolicyUse.PUBLIC_RESOLVER)) {
                        if (policyReltn.isIncoming())
                            addPolicyToMap(incomingPublicPolicies, domainReltn.getDomain().getDomainName(), policyReltn);
                        if (policyReltn.isOutgoing())
                            addPolicyToMap(outgoingPublicPolicies, domainReltn.getDomain().getDomainName(), policyReltn);
                    } else if (policyReltn.getPolicyUse().equals(CertPolicyUse.TRUST)) {
                        addPolicyToMap(trustPolicies, domainReltn.getDomain().getDomainName(), policyReltn);
                    }
                }
            }
        }
    }
    publicPolicyResolverModule = PublicPolicyResolverModule.create(new DomainPolicyResolverProvider(incomingPublicPolicies, outgoingPublicPolicies));
    privatePolicyResolverModule = PrivatePolicyResolverModule.create(new DomainPolicyResolverProvider(incomingPrivatePolicies, outgoingPrivatePolicies));
    trustPolicyResolverModule = TrustPolicyResolverModule.create(new DomainPolicyResolverProvider(trustPolicies));
}
Also used : SmtpAgentException(org.nhindirect.gateway.smtp.SmtpAgentException) CertPolicyGroupDomainReltn(org.nhindirect.config.model.CertPolicyGroupDomainReltn) HashMap(java.util.HashMap) CertPolicyGroupUse(org.nhindirect.config.model.CertPolicyGroupUse) Collection(java.util.Collection) PolicyExpression(org.nhindirect.policy.PolicyExpression) DomainPolicyResolverProvider(org.nhindirect.stagent.policy.impl.provider.DomainPolicyResolverProvider) AddressException(javax.mail.internet.AddressException) SmtpAgentException(org.nhindirect.gateway.smtp.SmtpAgentException) PolicyParseException(org.nhindirect.policy.PolicyParseException)

Example 2 with CertPolicyGroupUse

use of org.nhindirect.config.model.CertPolicyGroupUse in project nhin-d by DirectProject.

the class EntityModelConversion method toEntityCertPolicyGroup.

public static org.nhindirect.config.store.CertPolicyGroup toEntityCertPolicyGroup(CertPolicyGroup group) {
    if (group == null)
        return null;
    final org.nhindirect.config.store.CertPolicyGroup retVal = new org.nhindirect.config.store.CertPolicyGroup();
    final Collection<org.nhindirect.config.store.CertPolicyGroupReltn> reltns = new ArrayList<org.nhindirect.config.store.CertPolicyGroupReltn>();
    if (group.getPolicies() != null) {
        for (CertPolicyGroupUse use : group.getPolicies()) {
            org.nhindirect.config.store.CertPolicyGroupReltn reltn = new org.nhindirect.config.store.CertPolicyGroupReltn();
            reltn.setCertPolicy(toEntityCertPolicy(use.getPolicy()));
            reltn.setCertPolicyGroup(retVal);
            reltn.setIncoming(use.isIncoming());
            reltn.setOutgoing(use.isOutgoing());
            if (use.getPolicyUse() != null)
                reltn.setPolicyUse(org.nhindirect.config.store.CertPolicyUse.valueOf(use.getPolicyUse().toString()));
            reltns.add(reltn);
        }
    }
    retVal.setPolicyGroupName(group.getPolicyGroupName());
    retVal.setCreateTime(group.getCreateTime());
    retVal.setCertPolicyGroupReltn(reltns);
    return retVal;
}
Also used : CertPolicyGroupUse(org.nhindirect.config.model.CertPolicyGroupUse) ArrayList(java.util.ArrayList) CertPolicyGroup(org.nhindirect.config.model.CertPolicyGroup)

Example 3 with CertPolicyGroupUse

use of org.nhindirect.config.model.CertPolicyGroupUse in project nhin-d by DirectProject.

the class EntityModelConversion method toModelCertPolicyGroup.

public static CertPolicyGroup toModelCertPolicyGroup(org.nhindirect.config.store.CertPolicyGroup group) {
    if (group == null)
        return null;
    final CertPolicyGroup retVal = new CertPolicyGroup();
    final Collection<CertPolicyGroupUse> uses = new ArrayList<CertPolicyGroupUse>();
    if (group.getCertPolicyGroupReltn() != null) {
        for (org.nhindirect.config.store.CertPolicyGroupReltn reltn : group.getCertPolicyGroupReltn()) {
            final CertPolicyGroupUse use = new CertPolicyGroupUse();
            use.setPolicy(toModelCertPolicy(reltn.getCertPolicy()));
            if (reltn.getPolicyUse() != null)
                use.setPolicyUse(CertPolicyUse.valueOf(reltn.getPolicyUse().toString()));
            use.setIncoming(reltn.isIncoming());
            use.setOutgoing(reltn.isOutgoing());
            uses.add(use);
        }
    }
    retVal.setPolicyGroupName(group.getPolicyGroupName());
    retVal.setCreateTime(group.getCreateTime());
    retVal.setPolicies(uses);
    return retVal;
}
Also used : CertPolicyGroupUse(org.nhindirect.config.model.CertPolicyGroupUse) ArrayList(java.util.ArrayList) CertPolicyGroup(org.nhindirect.config.model.CertPolicyGroup)

Aggregations

CertPolicyGroupUse (org.nhindirect.config.model.CertPolicyGroupUse)3 ArrayList (java.util.ArrayList)2 CertPolicyGroup (org.nhindirect.config.model.CertPolicyGroup)2 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 AddressException (javax.mail.internet.AddressException)1 CertPolicyGroupDomainReltn (org.nhindirect.config.model.CertPolicyGroupDomainReltn)1 SmtpAgentException (org.nhindirect.gateway.smtp.SmtpAgentException)1 PolicyExpression (org.nhindirect.policy.PolicyExpression)1 PolicyParseException (org.nhindirect.policy.PolicyParseException)1 DomainPolicyResolverProvider (org.nhindirect.stagent.policy.impl.provider.DomainPolicyResolverProvider)1