Search in sources :

Example 6 with EndpointPolicy

use of org.apache.cxf.ws.policy.EndpointPolicy in project tesb-rt-se by Talend.

the class SingleBusLocatorRegistrar method isSecuredByPolicy.

/**
 * Is the transport secured by a policy
 */
private boolean isSecuredByPolicy(Server server) {
    boolean isSecured = false;
    EndpointInfo ei = server.getEndpoint().getEndpointInfo();
    PolicyEngine pe = bus.getExtension(PolicyEngine.class);
    if (null == pe) {
        LOG.finest("No Policy engine found");
        return isSecured;
    }
    Destination destination = server.getDestination();
    EndpointPolicy ep = pe.getServerEndpointPolicy(ei, destination, null);
    Collection<Assertion> assertions = ep.getChosenAlternative();
    for (Assertion a : assertions) {
        if (a instanceof TransportBinding) {
            TransportBinding tb = (TransportBinding) a;
            TransportToken tt = tb.getTransportToken();
            AbstractToken t = tt.getToken();
            if (t instanceof HttpsToken) {
                isSecured = true;
                break;
            }
        }
    }
    Policy policy = ep.getPolicy();
    List<PolicyComponent> pcList = policy.getPolicyComponents();
    for (PolicyComponent a : pcList) {
        if (a instanceof TransportBinding) {
            TransportBinding tb = (TransportBinding) a;
            TransportToken tt = tb.getTransportToken();
            AbstractToken t = tt.getToken();
            if (t instanceof HttpsToken) {
                isSecured = true;
                break;
            }
        }
    }
    return isSecured;
}
Also used : TransportToken(org.apache.wss4j.policy.model.TransportToken) EndpointPolicy(org.apache.cxf.ws.policy.EndpointPolicy) Policy(org.apache.neethi.Policy) Destination(org.apache.cxf.transport.Destination) PolicyComponent(org.apache.neethi.PolicyComponent) Assertion(org.apache.neethi.Assertion) PolicyEngine(org.apache.cxf.ws.policy.PolicyEngine) EndpointPolicy(org.apache.cxf.ws.policy.EndpointPolicy) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) HttpsToken(org.apache.wss4j.policy.model.HttpsToken) AbstractToken(org.apache.wss4j.policy.model.AbstractToken) TransportBinding(org.apache.wss4j.policy.model.TransportBinding)

Aggregations

EndpointPolicy (org.apache.cxf.ws.policy.EndpointPolicy)6 PolicyEngine (org.apache.cxf.ws.policy.PolicyEngine)6 Bus (org.apache.cxf.Bus)4 HashMap (java.util.HashMap)3 Definition (javax.wsdl.Definition)3 WSDLWriter (javax.wsdl.xml.WSDLWriter)3 Server (org.apache.cxf.endpoint.Server)3 XPathUtils (org.apache.cxf.helpers.XPathUtils)3 JaxWsServerFactoryBean (org.apache.cxf.jaxws.JaxWsServerFactoryBean)3 LocalTransportFactory (org.apache.cxf.transport.local.LocalTransportFactory)3 ServiceWSDLBuilder (org.apache.cxf.wsdl11.ServiceWSDLBuilder)3 Element (org.w3c.dom.Element)3 Endpoint (org.apache.cxf.endpoint.Endpoint)2 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)2 Destination (org.apache.cxf.transport.Destination)2 Assertion (org.apache.neethi.Assertion)2 SoapMessage (org.apache.cxf.binding.soap.SoapMessage)1 SoapBindingInfo (org.apache.cxf.binding.soap.model.SoapBindingInfo)1 Fault (org.apache.cxf.interceptor.Fault)1 Interceptor (org.apache.cxf.interceptor.Interceptor)1