Search in sources :

Example 1 with DomainPolicyResolverProvider

use of org.nhindirect.stagent.policy.impl.provider.DomainPolicyResolverProvider 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 DomainPolicyResolverProvider

use of org.nhindirect.stagent.policy.impl.provider.DomainPolicyResolverProvider in project nhin-d by DirectProject.

the class WSSmtpAgentConfig method buildPolicyResolvers.

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>>();
    CertPolicyGroupDomainReltn[] domainReltns = null;
    try {
        // get all of the policy group to domain relations... 
        // doing this all in one call for efficiency
        domainReltns = cfService.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.getCertPolicyGroup().getCertPolicyGroupReltn() != null) {
                for (CertPolicyGroupReltn policyReltn : domainReltn.getCertPolicyGroup().getCertPolicyGroupReltn()) {
                    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 : CertPolicyGroupReltn(org.nhind.config.CertPolicyGroupReltn) SmtpAgentException(org.nhindirect.gateway.smtp.SmtpAgentException) CertPolicyGroupDomainReltn(org.nhind.config.CertPolicyGroupDomainReltn) HashMap(java.util.HashMap) 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) IOException(java.io.IOException) CertificateException(java.security.cert.CertificateException)

Aggregations

Collection (java.util.Collection)2 HashMap (java.util.HashMap)2 AddressException (javax.mail.internet.AddressException)2 SmtpAgentException (org.nhindirect.gateway.smtp.SmtpAgentException)2 PolicyExpression (org.nhindirect.policy.PolicyExpression)2 PolicyParseException (org.nhindirect.policy.PolicyParseException)2 DomainPolicyResolverProvider (org.nhindirect.stagent.policy.impl.provider.DomainPolicyResolverProvider)2 IOException (java.io.IOException)1 CertificateException (java.security.cert.CertificateException)1 CertPolicyGroupDomainReltn (org.nhind.config.CertPolicyGroupDomainReltn)1 CertPolicyGroupReltn (org.nhind.config.CertPolicyGroupReltn)1 CertPolicyGroupDomainReltn (org.nhindirect.config.model.CertPolicyGroupDomainReltn)1 CertPolicyGroupUse (org.nhindirect.config.model.CertPolicyGroupUse)1