Examples of PolicyAssertion


Examples of com.sun.xml.ws.policy.PolicyAssertion

                    final Iterator <AssertionSet> assertions = policy.iterator();
                    while(assertions.hasNext()){
                        final AssertionSet assertionSet = assertions.next();
                        final Iterator<PolicyAssertion> policyAssertion = assertionSet.iterator();
                        while(policyAssertion.hasNext()){
                            final PolicyAssertion assertion = policyAssertion.next();
                            if(assertion.getName().equals(addressingAssertionQName)){
                                final WebServiceFeature feature = AddressingVersion.getFeature(addressingAssertionQName.getNamespaceURI(), true, !assertion.isOptional());
                                if (LOGGER.isLoggable(Level.FINE)) {
                                    LOGGER.fine("Added addressing feature \"" + feature + "\" for element \"" + key + "\"");
                                }
                                features.add(feature);
                            } // end-if non optional wsa assertion found
                        } // next assertion
                    } // next alternative
                } // end-if policy contains wsa assertion
            } //end foreach addr assertion

            // Deal with WS-Addressing 1.0 Metadata assertions
            if (policy != null && policy.contains(W3CAddressingMetadataConstants.WSAM_ADDRESSING_ASSERTION)) {
                for (AssertionSet assertions : policy) {
                    for (PolicyAssertion assertion : assertions) {
                        if (assertion.getName().equals(W3CAddressingMetadataConstants.WSAM_ADDRESSING_ASSERTION)) {
                            NestedPolicy nestedPolicy = assertion.getNestedPolicy();
                            boolean requiresAnonymousResponses = false;
                            boolean requiresNonAnonymousResponses = false;
                            if (nestedPolicy != null) {
                                requiresAnonymousResponses = nestedPolicy.contains(W3CAddressingMetadataConstants.WSAM_ANONYMOUS_NESTED_ASSERTION);
                                requiresNonAnonymousResponses = nestedPolicy.contains(W3CAddressingMetadataConstants.WSAM_NONANONYMOUS_NESTED_ASSERTION);
                            }
                            if(requiresAnonymousResponses && requiresNonAnonymousResponses) {
                                throw new WebServiceException("Only one among AnonymousResponses and NonAnonymousResponses can be nested in an Addressing assertion");
                            }

                            final WebServiceFeature feature;
                            try {
                                if (requiresAnonymousResponses) {
                                    feature = new AddressingFeature(true, !assertion.isOptional(), AddressingFeature.Responses.ANONYMOUS);
                                } else if (requiresNonAnonymousResponses) {
                                    feature = new AddressingFeature(true, !assertion.isOptional(), AddressingFeature.Responses.NON_ANONYMOUS);
                                } else {
                                    feature = new AddressingFeature(true, !assertion.isOptional());
                                }
                            } catch (NoSuchMethodError e) {
                                throw LOGGER.logSevereException(new PolicyException(ModelerMessages.RUNTIME_MODELER_ADDRESSING_RESPONSES_NOSUCHMETHOD(toJar(Which.which(AddressingFeature.class))), e));
                            }
                            if (LOGGER.isLoggable(Level.FINE)) {
View Full Code Here

Examples of com.sun.xml.ws.policy.PolicyAssertion

                Iterator <AssertionSet> assertions = policy.iterator();
                while(assertions.hasNext()){
                    AssertionSet assertionSet = assertions.next();
                    Iterator<PolicyAssertion> policyAssertion = assertionSet.iterator();
                    while(policyAssertion.hasNext()){
                        PolicyAssertion assertion = policyAssertion.next();
                        if(OPTIMIZED_MIME_SERIALIZATION_ASSERTION.equals(assertion.getName())){
                            features.add(new MTOMFeature(true));
                        } // end-if non optional mtom assertion found
                    } // next assertion
                } // next alternative
            } // end-if policy contains mtom assertion
View Full Code Here

Examples of com.sun.xml.ws.policy.PolicyAssertion

                Iterator <AssertionSet> assertions = policy.iterator();
                while(assertions.hasNext()){
                    AssertionSet assertionSet = assertions.next();
                    Iterator<PolicyAssertion> policyAssertion = assertionSet.iterator();
                    while(policyAssertion.hasNext()){
                        PolicyAssertion assertion = policyAssertion.next();
                        if(SELECT_OPTIMAL_ENCODING_ASSERTION.equals(assertion.getName())){
                            String value = assertion.getAttributeValue(enabled);
                            boolean isSelectOptimalEncodingEnabled = value == null || Boolean.valueOf(value.trim());
                            features.add(new SelectOptimalEncodingFeature(isSelectOptimalEncodingEnabled));
                        }
                    }
                }
View Full Code Here

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

        }
        return tokenStore;
    }
    static PolicyAssertion getAddressingPolicy(AssertionInfoMap aim, boolean optional) {
        Collection<AssertionInfo> lst = aim.get(MetadataConstants.USING_ADDRESSING_2004_QNAME);
        PolicyAssertion assertion = null;
        if (null != lst && !lst.isEmpty()) {
            assertion = lst.iterator().next().getAssertion();
        }
        if (assertion == null) {
            lst = aim.get(MetadataConstants.USING_ADDRESSING_2005_QNAME);
            if (null != lst && !lst.isEmpty()) {
                assertion = lst.iterator().next().getAssertion();
            }
        }
        if (assertion == null) {
            lst = aim.get(MetadataConstants.USING_ADDRESSING_2006_QNAME);
            if (null != lst && !lst.isEmpty()) {
                assertion = lst.iterator().next().getAssertion();
            }
        }
        if (assertion == null) {
            return new PrimitiveAssertion(MetadataConstants.USING_ADDRESSING_2006_QNAME,
                                          optional);
        } else if (optional) {
            return new PrimitiveAssertion(assertion.getName(),
                                          optional);           
        }
        return assertion;
    }
View Full Code Here

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

                    //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);
                }
View Full Code Here

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

                    //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);
                    SymmetricBinding binding = new SymmetricBinding(SP12Constants.INSTANCE);
                    binding.setIncludeTimestamp(true);
                    ProtectionToken token = new ProtectionToken(SP12Constants.INSTANCE);
                    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);
                }
View Full Code Here

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

        policies = buildTestPolicies();
    }
   
    @Test
    public void testNoNeedToAssertWithEmptyPolicy() {
        PolicyAssertion a = new NestedPrimitiveAssertion(
                                new QName("abc"), false, null, false,
                                null);
        AssertionInfoMap aim = new AssertionInfoMap(
                                Collections.singletonList(a));
        assertTrue("No need to assert", a.isAsserted(aim));
        a = new NestedPrimitiveAssertion(new QName("abc"),
                                         false,
                                         null,
                                         false,
                                         null);
        assertTrue("No need to assert", a.isAsserted(aim));
    }
View Full Code Here

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

    }
   
   
    @Test
    public void testNoNeedToAssertWithNonEmptyPolicy() {
        PolicyAssertion a = new NestedPrimitiveAssertion(
                                new QName("abc"), false, null, false,
                                null);
        AssertionInfoMap aim = new AssertionInfoMap(
                                Collections.singletonList(a));
        assertTrue("No need to assert", a.isAsserted(aim));
        Policy p = new Policy();
        p.addAssertion(new PrimitiveAssertion(new QName("abc"), false));
        a = new NestedPrimitiveAssertion(new QName("abc"),
                                         false,
                                         p,
                                         false,
                                         null);
        assertFalse("Primitive Assertions need to be asserted",
                    a.isAsserted(aim));
       
        p = new Policy();
        p.addAssertion(new NestedPrimitiveAssertion(new QName("abc"),
                                         false,
                                         null,
                                         false,
                                         null));
        a = new NestedPrimitiveAssertion(new QName("abc"),
                                         false,
                                         p,
                                         false,
                                         null);
        assertTrue("No need to assert", a.isAsserted(aim));
    }
View Full Code Here

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

    }
   
   
    @Test
    public void testAsserted() {
        PolicyAssertion a1 =
            new CustomPrimitiveAssertion(new QName("abc"), 1);
        PolicyAssertion a2 =
            new CustomPrimitiveAssertion(new QName("abc"), 2);
        Policy nested = new Policy();
        All all = new All();
        all.addAssertion(a2);
        nested.addPolicyComponent(all);
       
        NestedPrimitiveAssertion na = new NestedPrimitiveAssertion(new QName("nested"),
                                         false,
                                         nested,
                                         true,
                                         null);
        List<PolicyAssertion> ais =
            new ArrayList<PolicyAssertion>();
       
        ais.add(a1);
        ais.add(a2);
        ais.add(na);
               
        AssertionInfoMap aim = new AssertionInfoMap(ais);
       
        assertFalse("Assertion has been asserted even though nether na nor a2 have been",
                    na.isAsserted(aim));
       
        assertAssertion(aim, new QName("nested"), true, true);
        assertFalse("Assertion has been asserted even though a2 has not been",
                    na.isAsserted(aim));
       
        // assert a1 only
        assertAssertion(aim, new QName("abc"), true, false);
        assertFalse("Assertion has been asserted even though a2 has not been",
                    na.isAsserted(aim));
        // assert a2 tpp
        assertAssertion(aim, new QName("abc"), true, true);
        assertTrue("Assertion has not been asserted even though both na nad a2 have been",
                    na.isAsserted(aim));
       
        PolicyAssertion a3 = new CustomPrimitiveAssertion(new QName("abc"), 3);
        all.addAssertion(a3);
        aim.getAssertionInfo(new QName("abc")).add(new AssertionInfo(a3));
       
        assertFalse("Assertion has been asserted even though a3 has not been",
                    na.isAsserted(aim));
View Full Code Here

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

    }
   
      
    @Test
    public void testEqual() {
        PolicyAssertion other = new PrimitiveAssertion(new QName("abc"));
        for (int i = 0; i < policies.length; i++) {
            PolicyAssertion a =
                (PolicyAssertion)policies[i].getFirstPolicyComponent();
            assertTrue("Assertion " + i + " should equal itself.", a.equal(a));
            assertTrue("Assertion " + i + " should not equal other.", !a.equal(other));
            for (int j = i + 1; j < policies.length; j++) {
                Assertion b = (Assertion)policies[j].getFirstPolicyComponent();
                if (j == 1) {
                    assertTrue("Assertion " + i + " should equal " + j + ".", a.equal(b));
                } else {
                    assertTrue("Assertion " + i + " unexpectedly equals assertion " + j + ".", !a.equal(b));
                }
            }
        }
    }
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.