Search in sources :

Example 1 with AssertionSet

use of com.sun.xml.ws.policy.AssertionSet in project metro-jax-ws by eclipse-ee4j.

the class FastInfosetFeatureConfigurator method getFeatures.

/**
 * Process FastInfoset policy assertions.
 *
 * @param key Key to identify the endpoint scope.
 * @param policyMap the policy map.
 * @throws PolicyException If retrieving the policy triggered an exception.
 */
public Collection<WebServiceFeature> getFeatures(final PolicyMapKey key, final PolicyMap policyMap) throws PolicyException {
    final Collection<WebServiceFeature> features = new LinkedList<>();
    if ((key != null) && (policyMap != null)) {
        Policy policy = policyMap.getEndpointEffectivePolicy(key);
        if (null != policy && policy.contains(EncodingConstants.OPTIMIZED_FI_SERIALIZATION_ASSERTION)) {
            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 (EncodingConstants.OPTIMIZED_FI_SERIALIZATION_ASSERTION.equals(assertion.getName())) {
                        String value = assertion.getAttributeValue(enabled);
                        boolean isFastInfosetEnabled = Boolean.valueOf(value.trim());
                        features.add(new FastInfosetFeature(isFastInfosetEnabled));
                    }
                // end-if non optional fast infoset assertion found
                }
            // next assertion
            }
        // next alternative
        }
    // end-if policy contains fast infoset assertion
    }
    return features;
}
Also used : Policy(com.sun.xml.ws.policy.Policy) PolicyAssertion(com.sun.xml.ws.policy.PolicyAssertion) WebServiceFeature(jakarta.xml.ws.WebServiceFeature) AssertionSet(com.sun.xml.ws.policy.AssertionSet) LinkedList(java.util.LinkedList) FastInfosetFeature(com.sun.xml.ws.api.fastinfoset.FastInfosetFeature)

Example 2 with AssertionSet

use of com.sun.xml.ws.policy.AssertionSet in project metro-jax-ws by eclipse-ee4j.

the class PolicyModelTranslator method normalizeRawAssertion.

private List<PolicyAssertion> normalizeRawAssertion(final RawAssertion assertion) throws PolicyException {
    List<PolicyAssertion> parameters;
    if (assertion.parameters.isEmpty()) {
        parameters = null;
    } else {
        parameters = new ArrayList<>(assertion.parameters.size());
        for (ModelNode parameterNode : assertion.parameters) {
            parameters.add(createPolicyAssertionParameter(parameterNode));
        }
    }
    final List<AssertionSet> nestedAlternatives = new LinkedList<>();
    if (assertion.nestedAlternatives != null && !assertion.nestedAlternatives.isEmpty()) {
        final Queue<RawAlternative> nestedAlternativeQueue = new LinkedList<>(assertion.nestedAlternatives);
        RawAlternative rawAlternative;
        while ((rawAlternative = nestedAlternativeQueue.poll()) != null) {
            nestedAlternatives.addAll(normalizeRawAlternative(rawAlternative));
        }
    // if there is only a single result, we can add it direclty to the content base collection
    // more elements in the result indicate that we will have to create combinations
    }
    final List<PolicyAssertion> assertionOptions = new LinkedList<>();
    final boolean nestedAlternativesAvailable = !nestedAlternatives.isEmpty();
    if (nestedAlternativesAvailable) {
        for (AssertionSet nestedAlternative : nestedAlternatives) {
            assertionOptions.add(createPolicyAssertion(assertion.originalNode.getNodeData(), parameters, nestedAlternative));
        }
    } else {
        assertionOptions.add(createPolicyAssertion(assertion.originalNode.getNodeData(), parameters, null));
    }
    return assertionOptions;
}
Also used : PolicyAssertion(com.sun.xml.ws.policy.PolicyAssertion) AssertionSet(com.sun.xml.ws.policy.AssertionSet) LinkedList(java.util.LinkedList)

Example 3 with AssertionSet

use of com.sun.xml.ws.policy.AssertionSet in project metro-jax-ws by eclipse-ee4j.

the class CompactModelGenerator method translate.

@Override
protected ModelNode translate(final ModelNode parentAssertion, final NestedPolicy policy) {
    final ModelNode nestedPolicyRoot = parentAssertion.createChildPolicyNode();
    final AssertionSet set = policy.getAssertionSet();
    translate(nestedPolicyRoot, set);
    return nestedPolicyRoot;
}
Also used : AssertionSet(com.sun.xml.ws.policy.AssertionSet)

Example 4 with AssertionSet

use of com.sun.xml.ws.policy.AssertionSet in project metro-jax-ws by eclipse-ee4j.

the class NormalizedModelGenerator method translate.

@Override
public PolicySourceModel translate(final Policy policy) throws PolicyException {
    LOGGER.entering(policy);
    PolicySourceModel model = null;
    if (policy == null) {
        LOGGER.fine(LocalizationMessages.WSP_0047_POLICY_IS_NULL_RETURNING());
    } else {
        model = this.sourceModelCreator.create(policy);
        final ModelNode rootNode = model.getRootNode();
        final ModelNode exactlyOneNode = rootNode.createChildExactlyOneNode();
        for (AssertionSet set : policy) {
            final ModelNode alternativeNode = exactlyOneNode.createChildAllNode();
            for (PolicyAssertion assertion : set) {
                final AssertionData data = AssertionData.createAssertionData(assertion.getName(), assertion.getValue(), assertion.getAttributes(), assertion.isOptional(), assertion.isIgnorable());
                final ModelNode assertionNode = alternativeNode.createChildAssertionNode(data);
                if (assertion.hasNestedPolicy()) {
                    translate(assertionNode, assertion.getNestedPolicy());
                }
                if (assertion.hasParameters()) {
                    translate(assertionNode, assertion.getParametersIterator());
                }
            }
        }
    }
    LOGGER.exiting(model);
    return model;
}
Also used : PolicyAssertion(com.sun.xml.ws.policy.PolicyAssertion) AssertionSet(com.sun.xml.ws.policy.AssertionSet)

Example 5 with AssertionSet

use of com.sun.xml.ws.policy.AssertionSet in project metro-jax-ws by eclipse-ee4j.

the class AddressingFeatureConfigurator method getFeatures.

public Collection<WebServiceFeature> getFeatures(final PolicyMapKey key, final PolicyMap policyMap) throws PolicyException {
    LOGGER.entering(key, policyMap);
    final Collection<WebServiceFeature> features = new LinkedList<>();
    if ((key != null) && (policyMap != null)) {
        final Policy policy = policyMap.getEndpointEffectivePolicy(key);
        for (QName addressingAssertionQName : ADDRESSING_ASSERTIONS) {
            if ((policy != null) && policy.contains(addressingAssertionQName)) {
                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
        }
        // 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)) {
                            LOGGER.fine("Added addressing feature \"" + feature + "\" for element \"" + key + "\"");
                        }
                        features.add(feature);
                    }
                }
            }
        }
    }
    LOGGER.exiting(features);
    return features;
}
Also used : Policy(com.sun.xml.ws.policy.Policy) NestedPolicy(com.sun.xml.ws.policy.NestedPolicy) PolicyAssertion(com.sun.xml.ws.policy.PolicyAssertion) AddressingFeature(jakarta.xml.ws.soap.AddressingFeature) WebServiceException(jakarta.xml.ws.WebServiceException) QName(javax.xml.namespace.QName) AssertionSet(com.sun.xml.ws.policy.AssertionSet) LinkedList(java.util.LinkedList) PolicyException(com.sun.xml.ws.policy.PolicyException) WebServiceFeature(jakarta.xml.ws.WebServiceFeature) NestedPolicy(com.sun.xml.ws.policy.NestedPolicy)

Aggregations

AssertionSet (com.sun.xml.ws.policy.AssertionSet)13 PolicyAssertion (com.sun.xml.ws.policy.PolicyAssertion)10 Policy (com.sun.xml.ws.policy.Policy)7 LinkedList (java.util.LinkedList)6 WebServiceFeature (jakarta.xml.ws.WebServiceFeature)4 PolicyException (com.sun.xml.ws.policy.PolicyException)3 AssertionData (com.sun.xml.ws.policy.sourcemodel.AssertionData)2 WebServiceException (jakarta.xml.ws.WebServiceException)2 AddressingFeature (jakarta.xml.ws.soap.AddressingFeature)2 QName (javax.xml.namespace.QName)2 SelectOptimalEncodingFeature (com.sun.xml.ws.api.client.SelectOptimalEncodingFeature)1 FastInfosetFeature (com.sun.xml.ws.api.fastinfoset.FastInfosetFeature)1 NestedPolicy (com.sun.xml.ws.policy.NestedPolicy)1 PolicyMapKey (com.sun.xml.ws.policy.PolicyMapKey)1 MTOMFeature (jakarta.xml.ws.soap.MTOMFeature)1 StringReader (java.io.StringReader)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1