Examples of PolicyEngine


Examples of org.apache.cxf.ws.policy.PolicyEngine

    private BindingOperationInfo findOperation(String suffix) {
        BindingInfo bi = client.getEndpoint().getBinding().getBindingInfo();
        for (BindingOperationInfo boi : bi.getOperations()) {
            SoapOperationInfo soi = boi.getExtensor(SoapOperationInfo.class);
            if (soi != null && soi.getAction() != null && soi.getAction().endsWith(suffix)) {
                PolicyEngine pe = bus.getExtension(PolicyEngine.class);
                Conduit conduit = client.getConduit();
                EffectivePolicy effectivePolicy = pe.getEffectiveClientRequestPolicy(client.getEndpoint()
                    .getEndpointInfo(), boi, conduit);
                setPolicyInternal(effectivePolicy.getPolicy());
                return boi;
            }
        }
View Full Code Here

Examples of org.apache.cxf.ws.policy.PolicyEngine

    protected BindingOperationInfo findOperation(String suffix) {
        BindingInfo bi = client.getEndpoint().getBinding().getBindingInfo();
        for (BindingOperationInfo boi : bi.getOperations()) {
            SoapOperationInfo soi = boi.getExtensor(SoapOperationInfo.class);
            if (soi != null && soi.getAction() != null && soi.getAction().endsWith(suffix)) {
                PolicyEngine pe = bus.getExtension(PolicyEngine.class);
                Conduit conduit = client.getConduit();
                EffectivePolicy effectivePolicy = pe.getEffectiveClientRequestPolicy(client.getEndpoint()
                    .getEndpointInfo(), boi, conduit, PhaseInterceptorChain.getCurrentMessage());
                setPolicyInternal(effectivePolicy.getPolicy());
                return boi;
            }
        }
View Full Code Here

Examples of org.apache.cxf.ws.policy.PolicyEngine

        HttpServletResponse response = (HttpServletResponse)inMessage.get(HTTP_RESPONSE);
        return new BackChannelConduit(response);
    }

    private void initConfig() {
        PolicyEngine engine = bus.getExtension(PolicyEngine.class);
        // for a decoupled endpoint there is no service info
        if (null != engine && engine.isEnabled()
            && null != endpointInfo.getService()) {
            server = PolicyUtils.getServer(engine, endpointInfo, this);
        }
        if (null == server) {
            server = endpointInfo.getTraversedExtensor(
View Full Code Here

Examples of org.apache.cxf.ws.policy.PolicyEngine

        endpoints.put(protocol, endpoint);
    }

    void setPolicies(Message message) {
        // use same WS-policies as for application endpoint
        PolicyEngine engine = manager.getBus().getExtension(PolicyEngine.class);
        if (null == engine || !engine.isEnabled()) {
            return;
        }

        for (Endpoint endpoint : endpoints.values()) {
            EndpointInfo ei = endpoint.getEndpointInfo();
            EndpointPolicy epi = null == conduit
                ? engine.getServerEndpointPolicy(applicationEndpoint.getEndpointInfo(), null, message)
                    : engine.getClientEndpointPolicy(applicationEndpoint.getEndpointInfo(), conduit, message);
           
            if (conduit != null) {
                engine.setClientEndpointPolicy(ei, epi);
            } else {
                engine.setServerEndpointPolicy(ei, epi);
            }
            EffectivePolicyImpl effectiveOutbound = new EffectivePolicyImpl();
            effectiveOutbound.initialise(epi, engine, false, false, message);
            EffectivePolicyImpl effectiveInbound = new EffectivePolicyImpl();
            effectiveInbound.initialise(epi, engine, true, false, message);
           
            BindingInfo bi = ei.getBinding();
            Collection<BindingOperationInfo> bois = bi.getOperations();
           
            for (BindingOperationInfo boi : bois) {
                engine.setEffectiveServerRequestPolicy(ei, boi, effectiveInbound);
                engine.setEffectiveServerResponsePolicy(ei, boi, effectiveOutbound);
               
                engine.setEffectiveClientRequestPolicy(ei, boi, effectiveOutbound);
                engine.setEffectiveClientResponsePolicy(ei, boi, effectiveInbound);
            }
        }

        // TODO: FaultPolicy (SequenceFault)
    }
View Full Code Here

Examples of org.apache.cxf.ws.policy.PolicyEngine

        Invoker invoker,
        boolean secConv
    ) {
        Exchange ex = message.getExchange();
        Bus bus = ex.getBus();
        PolicyEngine pe = bus.getExtension(PolicyEngine.class);
        if (null == pe) {
            return;
        }
        Destination destination = ex.getDestination();
        try {
            Endpoint endpoint = message.getExchange().getEndpoint();

            TokenStore store = getTokenStore(message);
            if (secConv) {
                endpoint = STSUtils.createSCEndpoint(bus,
                                                     namespace,
                                                     endpoint.getEndpointInfo().getTransportId(),
                                                     destination.getAddress().getAddress().getValue(),
                                                     message.getVersion().getBindingId(),
                                                     policy);
            } else {
                endpoint = STSUtils.createSTSEndpoint(bus,
                                                      namespace,
                                                      endpoint.getEndpointInfo().getTransportId(),
                                                      destination.getAddress().getAddress().getValue(),
                                                      message.getVersion().getBindingId(),
                                                      policy,
                                                      null);
            }
            endpoint.getEndpointInfo().setProperty(TokenStore.class.getName(), store);
            message.getExchange().put(TokenStore.class.getName(), store);

            EndpointPolicy ep = pe.getServerEndpointPolicy(endpoint.getEndpointInfo(), destination, message);
            List<Interceptor<? extends Message>> interceptors = ep.getInterceptors(message);
            for (Interceptor<? extends Message> i : interceptors) {
                message.getInterceptorChain().add(i);
            }
View Full Code Here

Examples of org.apache.cxf.ws.policy.PolicyEngine

   
    @Test
    public void testChooseMinAlternative() {
        AlternativeSelector selector = new MinimalAlternativeSelector();
       
        PolicyEngine engine = control.createMock(PolicyEngine.class);
        Assertor assertor = control.createMock(Assertor.class);
              
        Policy policy = new Policy();
        ExactlyOne ea = new ExactlyOne();
        All all = new All();
        PolicyAssertion a1 = new TestAssertion();
        all.addAssertion(a1);
        ea.addPolicyComponent(all);
        Collection<PolicyAssertion> maxAlternative =
            CastUtils.cast(all.getPolicyComponents(), PolicyAssertion.class);
        all = new All();
        ea.addPolicyComponent(all);
        Collection<PolicyAssertion> minAlternative =
            CastUtils.cast(all.getPolicyComponents(), PolicyAssertion.class);
        policy.addPolicyComponent(ea)
        EasyMock.expect(engine.supportsAlternative(maxAlternative, assertor)).andReturn(true);
        EasyMock.expect(engine.supportsAlternative(minAlternative, assertor)).andReturn(true);
       
        control.replay();       
        Collection<Assertion> choice =
            selector.selectAlternative(policy, engine, assertor, null);
        assertEquals(0, choice.size());
View Full Code Here

Examples of org.apache.cxf.ws.policy.PolicyEngine

   
    @Test
    public void testChooseMaxAlternative() {
        AlternativeSelector selector = new MaximalAlternativeSelector();
       
        PolicyEngine engine = control.createMock(PolicyEngine.class);
        Assertor assertor = control.createMock(Assertor.class);
              
        Policy policy = new Policy();
        ExactlyOne ea = new ExactlyOne();
        All all = new All();
        PolicyAssertion a1 = new TestAssertion();
        all.addAssertion(a1);
        ea.addPolicyComponent(all);
        Collection<PolicyAssertion> maxAlternative =
            CastUtils.cast(all.getPolicyComponents(), PolicyAssertion.class);
        all = new All();
        ea.addPolicyComponent(all);
        Collection<PolicyAssertion> minAlternative =
            CastUtils.cast(all.getPolicyComponents(), PolicyAssertion.class);
        policy.addPolicyComponent(ea)
        EasyMock.expect(engine.supportsAlternative(maxAlternative, assertor)).andReturn(true);
        EasyMock.expect(engine.supportsAlternative(minAlternative, assertor)).andReturn(true);
       
        control.replay();       
        Collection<Assertion> choice = selector.selectAlternative(policy, engine, assertor, null);
        assertEquals(1, choice.size());
        assertSame(a1, choice.iterator().next());
View Full Code Here

Examples of org.apache.cxf.ws.policy.PolicyEngine

    }
    @Test
    public void testChooseAlternative() {
        AlternativeSelector selector = new FirstAlternativeSelector();
       
        PolicyEngine engine = control.createMock(PolicyEngine.class);
        Assertor assertor = control.createMock(Assertor.class);
              
        Policy policy = new Policy();
        ExactlyOne ea = new ExactlyOne();
        All all = new All();
        PolicyAssertion a1 = new TestAssertion();
        all.addAssertion(a1);
        ea.addPolicyComponent(all);
        Collection<PolicyAssertion> firstAlternative =
            CastUtils.cast(all.getPolicyComponents(), PolicyAssertion.class);
        policy.addPolicyComponent(ea);
       
        EasyMock.expect(engine.supportsAlternative(firstAlternative, assertor)).andReturn(false);
        control.replay();
       
        assertNull(selector.selectAlternative(policy, engine, assertor, null))
        control.verify();
       
        control.reset();       
        EasyMock.expect(engine.supportsAlternative(firstAlternative, assertor)).andReturn(true);
        control.replay();        
        Collection<Assertion> chosen = selector.selectAlternative(policy, engine, assertor, null);
        assertSame(1, chosen.size());
        assertSame(chosen.size(), firstAlternative.size());
        assertSame(chosen.iterator().next(), firstAlternative.iterator().next());
        control.verify();
       
        control.reset();
        All other = new All();
        other.addAssertion(a1);
        ea.addPolicyComponent(other);
        Collection<PolicyAssertion> secondAlternative =
            CastUtils.cast(other.getPolicyComponents(), PolicyAssertion.class);
        EasyMock.expect(engine.supportsAlternative(firstAlternative, assertor)).andReturn(false);
        EasyMock.expect(engine.supportsAlternative(secondAlternative, assertor)).andReturn(true);
        control.replay();       
     
        chosen = selector.selectAlternative(policy, engine, assertor, null);
        assertSame(1, chosen.size());
        assertSame(chosen.size(), secondAlternative.size());
View Full Code Here

Examples of org.apache.cxf.ws.policy.PolicyEngine

        HttpServletResponse response = (HttpServletResponse)inMessage.get(HTTP_RESPONSE);
        return new BackChannelConduit(response);
    }

    private void initConfig() {
        PolicyEngine engine = bus.getExtension(PolicyEngine.class);
        // for a decoupled endpoint there is no service info
        if (null != engine && engine.isEnabled()
            && null != endpointInfo.getService()) {
            server = PolicyUtils.getServer(engine, endpointInfo, this);
        }
        if (null == server && WSDLLibrary.isAvailable()) {
            server = endpointInfo.getTraversedExtensor(
View Full Code Here

Examples of org.apache.cxf.ws.policy.PolicyEngine

    protected BindingOperationInfo findOperation(String suffix) {
        BindingInfo bi = client.getEndpoint().getBinding().getBindingInfo();
        for (BindingOperationInfo boi : bi.getOperations()) {
            SoapOperationInfo soi = boi.getExtensor(SoapOperationInfo.class);
            if (soi != null && soi.getAction() != null && soi.getAction().endsWith(suffix)) {
                PolicyEngine pe = bus.getExtension(PolicyEngine.class);
                Conduit conduit = client.getConduit();
                EffectivePolicy effectivePolicy = pe.getEffectiveClientRequestPolicy(client.getEndpoint()
                    .getEndpointInfo(), boi, conduit);
                setPolicyInternal(effectivePolicy.getPolicy());
                return boi;
            }
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.