Search in sources :

Example 1 with IncludeProtocols

use of org.apache.cxf.configuration.security.IncludeProtocols in project cxf by apache.

the class JettyHTTPServerEngineBeanDefinitionParser method mapTLSServerParameters.

private void mapTLSServerParameters(Element e, BeanDefinitionBuilder bean) {
    BeanDefinitionBuilder paramsbean = BeanDefinitionBuilder.rootBeanDefinition(TLSServerParametersConfig.TLSServerParametersTypeInternal.class);
    // read the attributes
    NamedNodeMap as = e.getAttributes();
    for (int i = 0; i < as.getLength(); i++) {
        Attr a = (Attr) as.item(i);
        if (a.getNamespaceURI() == null) {
            String aname = a.getLocalName();
            if ("jsseProvider".equals(aname) || "secureSocketProtocol".equals(aname)) {
                paramsbean.addPropertyValue(aname, a.getValue());
            }
        }
    }
    // read the child elements
    Node n = e.getFirstChild();
    while (n != null) {
        if (Node.ELEMENT_NODE != n.getNodeType() || !SECURITY_NS.equals(n.getNamespaceURI())) {
            n = n.getNextSibling();
            continue;
        }
        String ename = n.getLocalName();
        // Schema should require that no more than one each of these exist.
        String ref = ((Element) n).getAttribute("ref");
        if ("keyManagers".equals(ename)) {
            if (ref != null && ref.length() > 0) {
                paramsbean.addPropertyReference("keyManagersRef", ref);
            } else {
                mapElementToJaxbProperty((Element) n, paramsbean, ename, KeyManagersType.class);
            }
        } else if ("trustManagers".equals(ename)) {
            if (ref != null && ref.length() > 0) {
                paramsbean.addPropertyReference("trustManagersRef", ref);
            } else {
                mapElementToJaxbProperty((Element) n, paramsbean, ename, TrustManagersType.class);
            }
        } else if ("cipherSuites".equals(ename)) {
            mapElementToJaxbProperty((Element) n, paramsbean, ename, CipherSuites.class);
        } else if ("cipherSuitesFilter".equals(ename)) {
            mapElementToJaxbProperty((Element) n, paramsbean, ename, FiltersType.class);
        } else if ("excludeProtocols".equals(ename)) {
            mapElementToJaxbProperty((Element) n, paramsbean, ename, ExcludeProtocols.class);
        } else if ("includeProtocols".equals(ename)) {
            mapElementToJaxbProperty((Element) n, paramsbean, ename, IncludeProtocols.class);
        } else if ("secureRandomParameters".equals(ename)) {
            mapElementToJaxbProperty((Element) n, paramsbean, ename, SecureRandomParameters.class);
        } else if ("clientAuthentication".equals(ename)) {
            mapElementToJaxbProperty((Element) n, paramsbean, ename, ClientAuthentication.class);
        } else if ("certConstraints".equals(ename)) {
            mapElementToJaxbProperty((Element) n, paramsbean, ename, CertificateConstraintsType.class);
        } else if ("certAlias".equals(ename)) {
            paramsbean.addPropertyValue(ename, n.getTextContent());
        }
        n = n.getNextSibling();
    }
    BeanDefinitionBuilder jaxbbean = BeanDefinitionBuilder.rootBeanDefinition(TLSServerParametersConfig.class);
    jaxbbean.addConstructorArgValue(paramsbean.getBeanDefinition());
    bean.addPropertyValue("tlsServerParameters", jaxbbean.getBeanDefinition());
}
Also used : BeanDefinitionBuilder(org.springframework.beans.factory.support.BeanDefinitionBuilder) NamedNodeMap(org.w3c.dom.NamedNodeMap) IncludeProtocols(org.apache.cxf.configuration.security.IncludeProtocols) Node(org.w3c.dom.Node) Element(org.w3c.dom.Element) TrustManagersType(org.apache.cxf.configuration.security.TrustManagersType) FiltersType(org.apache.cxf.configuration.security.FiltersType) ClientAuthentication(org.apache.cxf.configuration.security.ClientAuthentication) TLSServerParametersConfig(org.apache.cxf.configuration.jsse.TLSServerParametersConfig) Attr(org.w3c.dom.Attr)

Example 2 with IncludeProtocols

use of org.apache.cxf.configuration.security.IncludeProtocols in project cxf by apache.

the class UndertowHTTPServerEngineBeanDefinitionParser method mapTLSServerParameters.

private void mapTLSServerParameters(Element e, BeanDefinitionBuilder bean) {
    BeanDefinitionBuilder paramsbean = BeanDefinitionBuilder.rootBeanDefinition(TLSServerParametersConfig.TLSServerParametersTypeInternal.class);
    // read the attributes
    NamedNodeMap as = e.getAttributes();
    for (int i = 0; i < as.getLength(); i++) {
        Attr a = (Attr) as.item(i);
        if (a.getNamespaceURI() == null) {
            String aname = a.getLocalName();
            if ("jsseProvider".equals(aname) || "secureSocketProtocol".equals(aname)) {
                paramsbean.addPropertyValue(aname, a.getValue());
            }
        }
    }
    // read the child elements
    Node n = e.getFirstChild();
    while (n != null) {
        if (Node.ELEMENT_NODE != n.getNodeType() || !SECURITY_NS.equals(n.getNamespaceURI())) {
            n = n.getNextSibling();
            continue;
        }
        String ename = n.getLocalName();
        // Schema should require that no more than one each of these exist.
        String ref = ((Element) n).getAttribute("ref");
        if ("keyManagers".equals(ename)) {
            if (ref != null && ref.length() > 0) {
                paramsbean.addPropertyReference("keyManagersRef", ref);
            } else {
                mapElementToJaxbProperty((Element) n, paramsbean, ename, KeyManagersType.class);
            }
        } else if ("trustManagers".equals(ename)) {
            if (ref != null && ref.length() > 0) {
                paramsbean.addPropertyReference("trustManagersRef", ref);
            } else {
                mapElementToJaxbProperty((Element) n, paramsbean, ename, TrustManagersType.class);
            }
        } else if ("cipherSuites".equals(ename)) {
            mapElementToJaxbProperty((Element) n, paramsbean, ename, CipherSuites.class);
        } else if ("cipherSuitesFilter".equals(ename)) {
            mapElementToJaxbProperty((Element) n, paramsbean, ename, FiltersType.class);
        } else if ("excludeProtocols".equals(ename)) {
            mapElementToJaxbProperty((Element) n, paramsbean, ename, ExcludeProtocols.class);
        } else if ("includeProtocols".equals(ename)) {
            mapElementToJaxbProperty((Element) n, paramsbean, ename, IncludeProtocols.class);
        } else if ("secureRandomParameters".equals(ename)) {
            mapElementToJaxbProperty((Element) n, paramsbean, ename, SecureRandomParameters.class);
        } else if ("clientAuthentication".equals(ename)) {
            mapElementToJaxbProperty((Element) n, paramsbean, ename, ClientAuthentication.class);
        } else if ("certConstraints".equals(ename)) {
            mapElementToJaxbProperty((Element) n, paramsbean, ename, CertificateConstraintsType.class);
        } else if ("certAlias".equals(ename)) {
            paramsbean.addPropertyValue(ename, n.getTextContent());
        }
        n = n.getNextSibling();
    }
    BeanDefinitionBuilder jaxbbean = BeanDefinitionBuilder.rootBeanDefinition(TLSServerParametersConfig.class);
    jaxbbean.addConstructorArgValue(paramsbean.getBeanDefinition());
    bean.addPropertyValue("tlsServerParameters", jaxbbean.getBeanDefinition());
}
Also used : BeanDefinitionBuilder(org.springframework.beans.factory.support.BeanDefinitionBuilder) NamedNodeMap(org.w3c.dom.NamedNodeMap) IncludeProtocols(org.apache.cxf.configuration.security.IncludeProtocols) Node(org.w3c.dom.Node) Element(org.w3c.dom.Element) TrustManagersType(org.apache.cxf.configuration.security.TrustManagersType) FiltersType(org.apache.cxf.configuration.security.FiltersType) ClientAuthentication(org.apache.cxf.configuration.security.ClientAuthentication) TLSServerParametersConfig(org.apache.cxf.configuration.jsse.TLSServerParametersConfig) Attr(org.w3c.dom.Attr)

Aggregations

TLSServerParametersConfig (org.apache.cxf.configuration.jsse.TLSServerParametersConfig)2 ClientAuthentication (org.apache.cxf.configuration.security.ClientAuthentication)2 FiltersType (org.apache.cxf.configuration.security.FiltersType)2 IncludeProtocols (org.apache.cxf.configuration.security.IncludeProtocols)2 TrustManagersType (org.apache.cxf.configuration.security.TrustManagersType)2 BeanDefinitionBuilder (org.springframework.beans.factory.support.BeanDefinitionBuilder)2 Attr (org.w3c.dom.Attr)2 Element (org.w3c.dom.Element)2 NamedNodeMap (org.w3c.dom.NamedNodeMap)2 Node (org.w3c.dom.Node)2