Package org.apache.neethi

Examples of org.apache.neethi.Policy


                && (s.startsWith(STSUtils.WST_NS_05_02)
                    || s.startsWith(STSUtils.WST_NS_05_12))) {

                SecureConversationToken tok = (SecureConversationToken)ais.iterator()
                    .next().getAssertion();
                Policy pol = tok.getBootstrapPolicy();
                if (s.endsWith("Cancel") || s.endsWith("/Renew")) {
                    //Cancel and Renew just sign with the token
                    Policy p = new Policy();
                    ExactlyOne ea = new ExactlyOne();
                    p.addPolicyComponent(ea);
                    All all = new All();
                    PolicyAssertion ass = SecureConversationTokenInterceptorProvider
                        .getAddressingPolicy(aim, false);
                    all.addPolicyComponent(ass);
                    ea.addPolicyComponent(all);
                    PolicyBuilder pbuilder = message.getExchange().getBus()
                        .getExtension(PolicyBuilder.class);
                    SymmetricBinding binding = new SymmetricBinding(SP12Constants.INSTANCE, pbuilder);
                    binding.setIncludeTimestamp(true);
                    ProtectionToken token = new ProtectionToken(SP12Constants.INSTANCE, pbuilder);
                    token.setToken(new SecureConversationToken(SP12Constants.INSTANCE));
                    binding.setProtectionToken(token);
                    binding.setEntireHeadersAndBodySignatures(true);
                   
                    Binding origBinding = getBinding(aim);
                    binding.setAlgorithmSuite(origBinding.getAlgorithmSuite());
                    all.addPolicyComponent(binding);
                   
                    SignedEncryptedParts parts = new SignedEncryptedParts(true,
                                                                          SP12Constants.INSTANCE);
                    parts.setBody(true);
                    if (addNs != null) {
                        parts.addHeader(new Header("To", addNs));
                        parts.addHeader(new Header("From", addNs));
                        parts.addHeader(new Header("FaultTo", addNs));
                        parts.addHeader(new Header("ReplyTO", addNs));
                        parts.addHeader(new Header("MessageID", addNs));
                        parts.addHeader(new Header("RelatesTo", addNs));
                        parts.addHeader(new Header("Action", addNs));
                    }
                    all.addPolicyComponent(parts);
                    pol = p;
                    message.getInterceptorChain().add(SecureConversationTokenFinderInterceptor.INSTANCE);
                } else {
                    Policy p = new Policy();
                    ExactlyOne ea = new ExactlyOne();
                    p.addPolicyComponent(ea);
                    All all = new All();
                    PolicyAssertion ass = SecureConversationTokenInterceptorProvider
                        .getAddressingPolicy(aim, false);
                    all.addPolicyComponent(ass);
                    ea.addPolicyComponent(all);
                    pol = p.merge(pol);
                }
               
                //setup SCT endpoint and forward to it.
                unmapSecurityProps(message);
                String ns = STSUtils.WST_NS_05_12;
View Full Code Here


                                                      SP12Constants.REQUIRE_EXPLICIT_DERIVED_KEYS) != null) {
                x509Token.setExplicitDerivedKeys(true);
            }


            Policy policy = builder.getPolicy(DOMUtils.getFirstElement(element));
            policy = (Policy)policy.normalize(builder.getPolicyRegistry(), false);

            for (Iterator iterator = policy.getAlternatives(); iterator.hasNext();) {
                processAlternative((List)iterator.next(), x509Token, consts);

                /*
                 * since there should be only one alternative
                 */
 
View Full Code Here

        if (addressingNamespace == null) {
            addressingNamespace = "http://www.w3.org/2005/08/addressing";
        }

        Policy validatePolicy = new Policy();
        ExactlyOne one = new ExactlyOne();
        validatePolicy.addPolicyComponent(one);
        All all = new All();
        PolicyBuilder pbuilder = bus.getExtension(PolicyBuilder.class);
        SymmetricBinding binding = new SymmetricBinding(pbuilder);
        all.addAssertion(binding);
        one.addPolicyComponent(all);
View Full Code Here

        createClient();

        if (addressingNamespace == null) {
            addressingNamespace = "http://www.w3.org/2005/08/addressing";
        }
        Policy cancelPolicy = new Policy();
        ExactlyOne one = new ExactlyOne();
        cancelPolicy.addPolicyComponent(one);
        All all = new All();
        one.addPolicyComponent(all);
        PolicyBuilder pbuilder = bus.getExtension(PolicyBuilder.class);
        SymmetricBinding binding = new SymmetricBinding(pbuilder);
        all.addAssertion(binding);
View Full Code Here

    }
   
    @Test
    public void testElementPolicies() throws WSDLException {
   
        Policy p;
       
        // no extensions      
        p = app.getElementPolicy(services[0]);
        assertTrue(p == null || p.isEmpty());
       
        // extensions not of type Policy or PolicyReference
        p = app.getElementPolicy(services[1]);
        assertTrue(p == null || p.isEmpty());
       
        // one extension of type Policy, without assertion builder
        try {
            p = app.getElementPolicy(services[2]);
            fail("Expected PolicyException not thrown.");
        } catch (PolicyException ex) {
            // expected
        }
       
        // one extension of type Policy
        p = app.getElementPolicy(services[3]);
        assertNotNull(p);
        assertTrue(!p.isEmpty());
        verifyAssertionsOnly(p, 2);
       
        // two extensions of type Policy
        p = app.getElementPolicy(services[4]);
        assertNotNull(p);
        assertTrue(!p.isEmpty());
        verifyAssertionsOnly(p, 3);
       
        EndpointInfo ei = new EndpointInfo();
        assertTrue(app.getElementPolicy(ei) == null);
    }
View Full Code Here

    }
   
    @Test
    public void testEffectiveServicePolicies() throws WSDLException {
       
        Policy p;
        Policy ep;
       
        // no extensions       
        ep = app.getEffectivePolicy(services[0]);
        assertTrue(ep == null || ep.isEmpty());
        p = app.getElementPolicy(services[0]);
        assertTrue(p == null || p.isEmpty());
       
        // extensions not of type Policy or PolicyReference
        ep = app.getEffectivePolicy(services[1]);
        assertTrue(ep == null || ep.isEmpty());
       
        // one extension of type Policy, without assertion builder
        try {
            ep = app.getEffectivePolicy(services[2]);
            fail("Expected PolicyException not thrown.");
        } catch (PolicyException ex) {
            // expected
        }
       
        // one extension of type Policy
        ep = app.getEffectivePolicy(services[3]);
        assertNotNull(ep);
        assertTrue(!ep.isEmpty());
        verifyAssertionsOnly(ep, 2);
        p = app.getElementPolicy(services[3]);
        assertTrue(PolicyComparator.compare(p, ep));
       
        // two extensions of type Policy
        ep = app.getEffectivePolicy(services[4]);
        assertNotNull(ep);
        assertTrue(!ep.isEmpty());
        verifyAssertionsOnly(ep, 3);
        p = app.getElementPolicy(services[4]);
        assertTrue(PolicyComparator.compare(p, ep));
    }
View Full Code Here

        assertTrue(PolicyComparator.compare(p, ep));
    }

    @Test
    public void testEffectiveEndpointPolicies() {
        Policy ep;
        Policy p;
       
        // port has no extensions
        // porttype has no extensions
        // binding has no extensions
        ep = app.getEffectivePolicy(endpoints[0]);
View Full Code Here

        verifyAssertionsOnly(ep, 2);      
    }
   
    @Test
    public void testEffectiveBindingOperationPolicies() {
        Policy ep;
       
        // operation has no extensions
        // binding operation has no extensions
        ep = app.getEffectivePolicy(getBindingOperationInfo(endpoints[0]));
        assertTrue(ep == null || ep.isEmpty());
       
        // operation has no extensions
        // binding operation has one extension of type Policy
        ep = app.getEffectivePolicy(getBindingOperationInfo(endpoints[9]));
        assertNotNull(ep);
        assertTrue(!ep.isEmpty());
        verifyAssertionsOnly(ep, 1);
       
        // operation has one extension of type Policy
        // binding operation has no extensions
        ep = app.getEffectivePolicy(getBindingOperationInfo(endpoints[10]));
        assertNotNull(ep);
        assertTrue(!ep.isEmpty());
        verifyAssertionsOnly(ep, 2);
       
        // operation has one extension of type Policy
        // binding operation one extension of type Policy
        ep = app.getEffectivePolicy(getBindingOperationInfo(endpoints[11]));
        assertNotNull(ep);
        assertTrue(!ep.isEmpty());
        verifyAssertionsOnly(ep, 3);
    }
View Full Code Here

        verifyAssertionsOnly(ep, 3);
    }
   
    @Test
    public void testEffectiveMessagePolicies() {
        Policy ep;
       
        // binding operation message has no extensions
        // operation message has no extensions
        // message has no extensions
        ep = app.getEffectivePolicy(getBindingMessageInfo(endpoints[0], true));
        assertTrue(ep == null || ep.isEmpty());
       
        // binding operation message has one extension of type Policy
        // operation message has no extensions
        // message has no extensions
        ep = app.getEffectivePolicy(getBindingMessageInfo(endpoints[12], true));
        assertTrue(!ep.isEmpty());
        verifyAssertionsOnly(ep, 1);
       
        // binding operation message has no extensions
        // operation message has one extension of type Policy
        // message has no extensions 
        ep = app.getEffectivePolicy(getBindingMessageInfo(endpoints[13], true));
        assertTrue(!ep.isEmpty());
        verifyAssertionsOnly(ep, 1);
       
        // binding operation message has no extensions
        // operation message has no extensions
        // message has one extension of type Policy
        ep = app.getEffectivePolicy(getBindingMessageInfo(endpoints[14], true));
        assertTrue(!ep.isEmpty());
        verifyAssertionsOnly(ep, 1);
       
        // binding operation message has one extension of type Policy
        // operation message has one extension of type Policy
        // message has one extension of type Policy
        ep = app.getEffectivePolicy(getBindingMessageInfo(endpoints[15], true));
        assertTrue(!ep.isEmpty());
        verifyAssertionsOnly(ep, 3);     
    }
View Full Code Here

    }
   
    @Test
    public void testResolveLocal() {
       
        Policy ep;
       
        // service has one extension of type PolicyReference, reference can be resolved locally
        ep = app.getElementPolicy(services[16]);
        assertNotNull(ep);
        verifyAssertionsOnly(ep, 2);
View Full Code Here

TOP

Related Classes of org.apache.neethi.Policy

Copyright © 2018 www.massapicom. 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.