Java Code Examples for com.sun.xml.internal.ws.policy.PolicyAssertion

The following examples show how to use com.sun.xml.internal.ws.policy.PolicyAssertion. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * Process SelectOptimalEncoding policy assertions.
 *
 * @param key Key that identifies the endpoint scope.
 * @param policyMap The policy map.
 * @throws PolicyException If retrieving the policy triggered an exception.
 */
public Collection<WebServiceFeature> getFeatures(PolicyMapKey key, PolicyMap policyMap) throws PolicyException {
    final Collection<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
    if ((key != null) && (policyMap != null)) {
        Policy policy = policyMap.getEndpointEffectivePolicy(key);
        if (null!=policy && policy.contains(SELECT_OPTIMAL_ENCODING_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(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));
                    }
                }
            }
        }
    }
    return features;
}
 
Example 2
/**
 * Return ManagementAssertion if one can be found in the policy map under
 * the given service and port name.
 *
 * @param <T> The implementation class of the assertion.
 * @param name The fully qualified name of the server or client assertion.
 * @param policyMap The policy map. May be null.
 * @param serviceName The WSDL service name. May not be null.
 * @param portName The WSDL port name. May not be null.
 * @param type The implementation class of the assertion.
 * @return An instance of ManagementAssertion or null.
 * @throws WebServiceException If computing the effective policy of the endpoint scope failed.
 */
protected static <T extends ManagementAssertion> T getAssertion(final QName name,
        final PolicyMap policyMap, QName serviceName, QName portName, Class<T> type)
        throws WebServiceException {
    try {
        PolicyAssertion assertion = null;
        if (policyMap != null) {
            final PolicyMapKey key = PolicyMap.createWsdlEndpointScopeKey(serviceName, portName);
            final Policy policy = policyMap.getEndpointEffectivePolicy(key);
            if (policy != null) {
                final Iterator<AssertionSet> assertionSets = policy.iterator();
                if (assertionSets.hasNext()) {
                    final AssertionSet assertionSet = assertionSets.next();
                    final Iterator<PolicyAssertion> assertions = assertionSet.get(name).iterator();
                    if (assertions.hasNext()) {
                        assertion = assertions.next();
                    }
                }
            }
        }
        return assertion == null ? null : assertion.getImplementation(type);
    } catch (PolicyException ex) {
        throw LOGGER.logSevereException(new WebServiceException(
                ManagementMessages.WSM_1001_FAILED_ASSERTION(name), ex));
    }
}
 
Example 3
/**
 * Checks if the PolicyMap has only single alternative in the scope.
 *
 * @param policyMap
 *      PolicyMap that needs to be validated.
 */
private void validateServerPolicyMap(PolicyMap policyMap) {
    try {
        final ValidationProcessor validationProcessor = ValidationProcessor.getInstance();

        for (Policy policy : policyMap) {

            // TODO:  here is a good place to check if the actual policy has only one alternative...

            for (AssertionSet assertionSet : policy) {
                for (PolicyAssertion assertion : assertionSet) {
                    Fitness validationResult = validationProcessor.validateServerSide(assertion);
                    if (validationResult != Fitness.SUPPORTED) {
                        throw new PolicyException(PolicyMessages.WSP_1015_SERVER_SIDE_ASSERTION_VALIDATION_FAILED(
                                assertion.getName(),
                                validationResult));
                    }
                }
            }
        }
    } catch (PolicyException e) {
        throw new WebServiceException(e);
    }
}
 
Example 4
/**
 * process Mtom policy assertions and if found and is not optional then mtom is enabled on the
 * {@link WSDLBoundPortType}
 *
 * @param key Key that identifies the endpoint scope
 * @param policyMap Must be non-null
 * @throws PolicyException If retrieving the policy triggered an exception
 */
public Collection<WebServiceFeature> getFeatures(PolicyMapKey key, PolicyMap policyMap) throws PolicyException {
    final Collection<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
    if ((key != null) && (policyMap != null)) {
        Policy policy = policyMap.getEndpointEffectivePolicy(key);
        if (null!=policy && policy.contains(OPTIMIZED_MIME_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(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
    }
    return features;
}
 
Example 5
/**
 * Process SelectOptimalEncoding policy assertions.
 *
 * @param key Key that identifies the endpoint scope.
 * @param policyMap The policy map.
 * @throws PolicyException If retrieving the policy triggered an exception.
 */
public Collection<WebServiceFeature> getFeatures(PolicyMapKey key, PolicyMap policyMap) throws PolicyException {
    final Collection<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
    if ((key != null) && (policyMap != null)) {
        Policy policy = policyMap.getEndpointEffectivePolicy(key);
        if (null!=policy && policy.contains(SELECT_OPTIMAL_ENCODING_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(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));
                    }
                }
            }
        }
    }
    return features;
}
 
Example 6
/**
 * 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<WebServiceFeature>();
    if ((key != null) && (policyMap != null)) {
        Policy policy = policyMap.getEndpointEffectivePolicy(key);
        if (null!=policy && policy.contains(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(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;
}
 
Example 7
/**
 * 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<WebServiceFeature>();
    if ((key != null) && (policyMap != null)) {
        Policy policy = policyMap.getEndpointEffectivePolicy(key);
        if (null!=policy && policy.contains(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(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;
}
 
Example 8
/**
 * process Mtom policy assertions and if found and is not optional then mtom is enabled on the
 * {@link WSDLBoundPortType}
 *
 * @param key Key that identifies the endpoint scope
 * @param policyMap Must be non-null
 * @throws PolicyException If retrieving the policy triggered an exception
 */
public Collection<WebServiceFeature> getFeatures(PolicyMapKey key, PolicyMap policyMap) throws PolicyException {
    final Collection<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
    if ((key != null) && (policyMap != null)) {
        Policy policy = policyMap.getEndpointEffectivePolicy(key);
        if (null!=policy && policy.contains(OPTIMIZED_MIME_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(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
    }
    return features;
}
 
Example 9
/**
 * Process SelectOptimalEncoding policy assertions.
 *
 * @param key Key that identifies the endpoint scope.
 * @param policyMap The policy map.
 * @throws PolicyException If retrieving the policy triggered an exception.
 */
public Collection<WebServiceFeature> getFeatures(PolicyMapKey key, PolicyMap policyMap) throws PolicyException {
    final Collection<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
    if ((key != null) && (policyMap != null)) {
        Policy policy = policyMap.getEndpointEffectivePolicy(key);
        if (null!=policy && policy.contains(SELECT_OPTIMAL_ENCODING_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(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));
                    }
                }
            }
        }
    }
    return features;
}
 
Example 10
/**
 * Process SelectOptimalEncoding policy assertions.
 *
 * @param key Key that identifies the endpoint scope.
 * @param policyMap The policy map.
 * @throws PolicyException If retrieving the policy triggered an exception.
 */
public Collection<WebServiceFeature> getFeatures(PolicyMapKey key, PolicyMap policyMap) throws PolicyException {
    final Collection<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
    if ((key != null) && (policyMap != null)) {
        Policy policy = policyMap.getEndpointEffectivePolicy(key);
        if (null!=policy && policy.contains(SELECT_OPTIMAL_ENCODING_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(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));
                    }
                }
            }
        }
    }
    return features;
}
 
Example 11
/**
 * Process SelectOptimalEncoding policy assertions.
 *
 * @param key Key that identifies the endpoint scope.
 * @param policyMap The policy map.
 * @throws PolicyException If retrieving the policy triggered an exception.
 */
public Collection<WebServiceFeature> getFeatures(PolicyMapKey key, PolicyMap policyMap) throws PolicyException {
    final Collection<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
    if ((key != null) && (policyMap != null)) {
        Policy policy = policyMap.getEndpointEffectivePolicy(key);
        if (null!=policy && policy.contains(SELECT_OPTIMAL_ENCODING_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(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));
                    }
                }
            }
        }
    }
    return features;
}
 
Example 12
/**
 * Checks if the PolicyMap has only single alternative in the scope.
 *
 * @param policyMap
 *      PolicyMap that needs to be validated.
 */
private void validateServerPolicyMap(PolicyMap policyMap) {
    try {
        final ValidationProcessor validationProcessor = ValidationProcessor.getInstance();

        for (Policy policy : policyMap) {

            // TODO:  here is a good place to check if the actual policy has only one alternative...

            for (AssertionSet assertionSet : policy) {
                for (PolicyAssertion assertion : assertionSet) {
                    Fitness validationResult = validationProcessor.validateServerSide(assertion);
                    if (validationResult != Fitness.SUPPORTED) {
                        throw new PolicyException(PolicyMessages.WSP_1015_SERVER_SIDE_ASSERTION_VALIDATION_FAILED(
                                assertion.getName(),
                                validationResult));
                    }
                }
            }
        }
    } catch (PolicyException e) {
        throw new WebServiceException(e);
    }
}
 
Example 13
private ImplementationRecord findImplementation(QName implementationName) {
    final Iterator<PolicyAssertion> parameters = getParametersIterator();
    while (parameters.hasNext()) {
        final PolicyAssertion parameter = parameters.next();
        if (implementationName.equals(parameter.getName())) {
            return getImplementation(parameter);
        }
    }
    return null;
}
 
Example 14
private ImplementationRecord findImplementation(QName implementationName) {
    final Iterator<PolicyAssertion> parameters = getParametersIterator();
    while (parameters.hasNext()) {
        final PolicyAssertion parameter = parameters.next();
        if (implementationName.equals(parameter.getName())) {
            return getImplementation(parameter);
        }
    }
    return null;
}
 
Example 15
/**
 * A list of CommunicationServerImplementation elements that were set as
 * parameters of this assertion.
 *
 * @return A list of CommunicationServerImplementation elements that were set as
 * parameters of this assertion. May be empty.
 */
public Collection<ImplementationRecord> getCommunicationServerImplementations() {
    final Collection<ImplementationRecord> result = new LinkedList<ImplementationRecord>();
    final Iterator<PolicyAssertion> parameters = getParametersIterator();
    while (parameters.hasNext()) {
        final PolicyAssertion parameter = parameters.next();
        if (COMMUNICATION_SERVER_IMPLEMENTATIONS_PARAMETER_QNAME.equals(parameter.getName())) {
            final Iterator<PolicyAssertion> implementations = parameter.getParametersIterator();
            if (!implementations.hasNext()) {
                throw LOGGER.logSevereException(new WebServiceException(
                        ManagementMessages.WSM_1005_EXPECTED_COMMUNICATION_CHILD()));
            }
            while (implementations.hasNext()) {
                final PolicyAssertion implementation = implementations.next();
                if (COMMUNICATION_SERVER_IMPLEMENTATION_PARAMETER_QNAME.equals(implementation.getName())) {
                    result.add(getImplementation(implementation));
                }
                else {
                    throw LOGGER.logSevereException(new WebServiceException(
                            ManagementMessages.WSM_1004_EXPECTED_XML_TAG(
                            COMMUNICATION_SERVER_IMPLEMENTATION_PARAMETER_QNAME, implementation.getName())));
                }
            }
        }
    }
    return result;
}
 
Example 16
private ImplementationRecord findImplementation(QName implementationName) {
    final Iterator<PolicyAssertion> parameters = getParametersIterator();
    while (parameters.hasNext()) {
        final PolicyAssertion parameter = parameters.next();
        if (implementationName.equals(parameter.getName())) {
            return getImplementation(parameter);
        }
    }
    return null;
}
 
Example 17
private List<AssertionSet> normalizeRawAlternative(final RawAlternative alternative) throws AssertionCreationException, PolicyException {
    final List<PolicyAssertion> normalizedContentBase = new LinkedList<PolicyAssertion>();
    final Collection<List<PolicyAssertion>> normalizedContentOptions = new LinkedList<List<PolicyAssertion>>();
    if (!alternative.nestedAssertions.isEmpty()) {
        final Queue<RawAssertion> nestedAssertionsQueue = new LinkedList<RawAssertion>(alternative.nestedAssertions);
        RawAssertion rawAssertion;
        while((rawAssertion = nestedAssertionsQueue.poll()) != null) {
            final List<PolicyAssertion> normalized = normalizeRawAssertion(rawAssertion);
            // 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
            if (normalized.size() == 1) {
                normalizedContentBase.addAll(normalized);
            } else {
                normalizedContentOptions.add(normalized);
            }
        }
    }

    final List<AssertionSet> options = new LinkedList<AssertionSet>();
    if (normalizedContentOptions.isEmpty()) {
        // we do not have any options to combine => returning this assertion
        options.add(AssertionSet.createAssertionSet(normalizedContentBase));
    } else {
        // we have some options to combine => creating assertion options based on content combinations
        final Collection<Collection<PolicyAssertion>> contentCombinations = PolicyUtils.Collections.combine(normalizedContentBase, normalizedContentOptions, true);
        for (Collection<PolicyAssertion> contentOption : contentCombinations) {
            options.add(AssertionSet.createAssertionSet(contentOption));
        }
    }
    return options;
}
 
Example 18
private PolicyAssertion createPolicyAssertionParameter(final ModelNode parameterNode) throws AssertionCreationException, PolicyException {
    if (parameterNode.getType() != ModelNode.Type.ASSERTION_PARAMETER_NODE) {
        throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0065_INCONSISTENCY_IN_POLICY_SOURCE_MODEL(parameterNode.getType())));
    }

    List<PolicyAssertion> childParameters = null;
    if (parameterNode.hasChildren()) {
        childParameters = new ArrayList<PolicyAssertion>(parameterNode.childrenSize());
        for (ModelNode childParameterNode : parameterNode) {
            childParameters.add(createPolicyAssertionParameter(childParameterNode));
        }
    }

    return createPolicyAssertion(parameterNode.getNodeData(), childParameters, null /* parameters do not have any nested alternatives */);
}
 
Example 19
/**
 * Add the contents of the assertion set as child node to the given model node.
 *
 * @param node The content of this assertion set are added as child nodes to this node.
 *     May not be null.
 * @param assertions The assertions that are to be added to the node. May not be null.
 */
protected void translate(final ModelNode node, final AssertionSet assertions) {
    for (PolicyAssertion assertion : assertions) {
        final AssertionData data = AssertionData.createAssertionData(assertion.getName(), assertion.getValue(), assertion.getAttributes(), assertion.isOptional(), assertion.isIgnorable());
        final ModelNode assertionNode = node.createChildAssertionNode(data);
        if (assertion.hasNestedPolicy()) {
            translate(assertionNode, assertion.getNestedPolicy());
        }
        if (assertion.hasParameters()) {
            translate(assertionNode, assertion.getParametersIterator());
        }
    }
}
 
Example 20
@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;
}
 
Example 21
/**
 * A list of CommunicationServerImplementation elements that were set as
 * parameters of this assertion.
 *
 * @return A list of CommunicationServerImplementation elements that were set as
 * parameters of this assertion. May be empty.
 */
public Collection<ImplementationRecord> getCommunicationServerImplementations() {
    final Collection<ImplementationRecord> result = new LinkedList<ImplementationRecord>();
    final Iterator<PolicyAssertion> parameters = getParametersIterator();
    while (parameters.hasNext()) {
        final PolicyAssertion parameter = parameters.next();
        if (COMMUNICATION_SERVER_IMPLEMENTATIONS_PARAMETER_QNAME.equals(parameter.getName())) {
            final Iterator<PolicyAssertion> implementations = parameter.getParametersIterator();
            if (!implementations.hasNext()) {
                throw LOGGER.logSevereException(new WebServiceException(
                        ManagementMessages.WSM_1005_EXPECTED_COMMUNICATION_CHILD()));
            }
            while (implementations.hasNext()) {
                final PolicyAssertion implementation = implementations.next();
                if (COMMUNICATION_SERVER_IMPLEMENTATION_PARAMETER_QNAME.equals(implementation.getName())) {
                    result.add(getImplementation(implementation));
                }
                else {
                    throw LOGGER.logSevereException(new WebServiceException(
                            ManagementMessages.WSM_1004_EXPECTED_XML_TAG(
                            COMMUNICATION_SERVER_IMPLEMENTATION_PARAMETER_QNAME, implementation.getName())));
                }
            }
        }
    }
    return result;
}
 
Example 22
private Fitness validateAssertion(PolicyAssertion assertion, Collection<QName> thisSideAssertions, Collection<QName> otherSideAssertions) {
    QName assertionName = assertion.getName();
    if (thisSideAssertions.contains(assertionName)) {
        return Fitness.SUPPORTED;
    } else if (otherSideAssertions.contains(assertionName)) {
        return Fitness.UNSUPPORTED;
    } else {
        return Fitness.UNKNOWN;
    }
}
 
Example 23
/**
 * A list of CommunicationServerImplementation elements that were set as
 * parameters of this assertion.
 *
 * @return A list of CommunicationServerImplementation elements that were set as
 * parameters of this assertion. May be empty.
 */
public Collection<ImplementationRecord> getCommunicationServerImplementations() {
    final Collection<ImplementationRecord> result = new LinkedList<ImplementationRecord>();
    final Iterator<PolicyAssertion> parameters = getParametersIterator();
    while (parameters.hasNext()) {
        final PolicyAssertion parameter = parameters.next();
        if (COMMUNICATION_SERVER_IMPLEMENTATIONS_PARAMETER_QNAME.equals(parameter.getName())) {
            final Iterator<PolicyAssertion> implementations = parameter.getParametersIterator();
            if (!implementations.hasNext()) {
                throw LOGGER.logSevereException(new WebServiceException(
                        ManagementMessages.WSM_1005_EXPECTED_COMMUNICATION_CHILD()));
            }
            while (implementations.hasNext()) {
                final PolicyAssertion implementation = implementations.next();
                if (COMMUNICATION_SERVER_IMPLEMENTATION_PARAMETER_QNAME.equals(implementation.getName())) {
                    result.add(getImplementation(implementation));
                }
                else {
                    throw LOGGER.logSevereException(new WebServiceException(
                            ManagementMessages.WSM_1004_EXPECTED_XML_TAG(
                            COMMUNICATION_SERVER_IMPLEMENTATION_PARAMETER_QNAME, implementation.getName())));
                }
            }
        }
    }
    return result;
}
 
Example 24
/**
 * Create a policy with an MTOM assertion.
 *
 * @param model The binding element name. Used to generate a (locally) unique ID for the policy.
 * @return The policy.
 */
private Policy createMtomPolicy(final QName bindingName) {
    ArrayList<AssertionSet> assertionSets = new ArrayList<AssertionSet>(1);
    ArrayList<PolicyAssertion> assertions = new ArrayList<PolicyAssertion>(1);
    assertions.add(new MtomAssertion());
    assertionSets.add(AssertionSet.createAssertionSet(assertions));
    return Policy.createPolicy(null, bindingName.getLocalPart() + "_MTOM_Policy", assertionSets);
}
 
Example 25
public Fitness validateServerSide(PolicyAssertion assertion) {
    final QName assertionName = assertion.getName();
    if (ManagedServiceAssertion.MANAGED_SERVICE_QNAME.equals(assertionName)) {
        return Fitness.SUPPORTED;
    }
    else if (ManagedClientAssertion.MANAGED_CLIENT_QNAME.equals(assertionName)) {
        return Fitness.UNSUPPORTED;
    }
    else {
        return Fitness.UNKNOWN;
    }
}
 
Example 26
private List<AssertionSet> normalizeRawAlternative(final RawAlternative alternative) throws AssertionCreationException, PolicyException {
    final List<PolicyAssertion> normalizedContentBase = new LinkedList<PolicyAssertion>();
    final Collection<List<PolicyAssertion>> normalizedContentOptions = new LinkedList<List<PolicyAssertion>>();
    if (!alternative.nestedAssertions.isEmpty()) {
        final Queue<RawAssertion> nestedAssertionsQueue = new LinkedList<RawAssertion>(alternative.nestedAssertions);
        RawAssertion rawAssertion;
        while((rawAssertion = nestedAssertionsQueue.poll()) != null) {
            final List<PolicyAssertion> normalized = normalizeRawAssertion(rawAssertion);
            // 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
            if (normalized.size() == 1) {
                normalizedContentBase.addAll(normalized);
            } else {
                normalizedContentOptions.add(normalized);
            }
        }
    }

    final List<AssertionSet> options = new LinkedList<AssertionSet>();
    if (normalizedContentOptions.isEmpty()) {
        // we do not have any options to combine => returning this assertion
        options.add(AssertionSet.createAssertionSet(normalizedContentBase));
    } else {
        // we have some options to combine => creating assertion options based on content combinations
        final Collection<Collection<PolicyAssertion>> contentCombinations = PolicyUtils.Collections.combine(normalizedContentBase, normalizedContentOptions, true);
        for (Collection<PolicyAssertion> contentOption : contentCombinations) {
            options.add(AssertionSet.createAssertionSet(contentOption));
        }
    }
    return options;
}
 
Example 27
/**
 * Create a policy with an MTOM assertion.
 *
 * @param model The binding element name. Used to generate a (locally) unique ID for the policy.
 * @return The policy.
 */
private Policy createMtomPolicy(final QName bindingName) {
    ArrayList<AssertionSet> assertionSets = new ArrayList<AssertionSet>(1);
    ArrayList<PolicyAssertion> assertions = new ArrayList<PolicyAssertion>(1);
    assertions.add(new MtomAssertion());
    assertionSets.add(AssertionSet.createAssertionSet(assertions));
    return Policy.createPolicy(null, bindingName.getLocalPart() + "_MTOM_Policy", assertionSets);
}
 
Example 28
public PolicyAssertion createAssertion(AssertionData data, Collection<PolicyAssertion> assertionParameters,
        AssertionSet nestedAlternative, PolicyAssertionCreator defaultCreator) throws AssertionCreationException {
    final QName name = data.getName();
    if (ManagedServiceAssertion.MANAGED_SERVICE_QNAME.equals(name)) {
        return new ManagedServiceAssertion(data, assertionParameters);
    }
    else if (ManagedClientAssertion.MANAGED_CLIENT_QNAME.equals(name)) {
        return new ManagedClientAssertion(data, assertionParameters);
    }
    else {
        return defaultCreator.createAssertion(data, assertionParameters, nestedAlternative, null);
    }
}
 
Example 29
Source Project: hottub   Source File: PolicyModelTranslator.java    License: GNU General Public License v2.0 5 votes vote down vote up
private PolicyAssertion createPolicyAssertion(final AssertionData data, final Collection<PolicyAssertion> assertionParameters, final AssertionSet nestedAlternative) throws AssertionCreationException {
    final String assertionNamespace = data.getName().getNamespaceURI();
    final PolicyAssertionCreator domainSpecificPAC = assertionCreators.get(assertionNamespace);


    if (domainSpecificPAC == null) {
        return defaultCreator.createAssertion(data, assertionParameters, nestedAlternative, null);
    } else {
        return domainSpecificPAC.createAssertion(data, assertionParameters, nestedAlternative, defaultCreator);
    }
}
 
Example 30
public Fitness validateServerSide(PolicyAssertion assertion) {
    final QName assertionName = assertion.getName();
    if (ManagedServiceAssertion.MANAGED_SERVICE_QNAME.equals(assertionName)) {
        return Fitness.SUPPORTED;
    }
    else if (ManagedClientAssertion.MANAGED_CLIENT_QNAME.equals(assertionName)) {
        return Fitness.UNSUPPORTED;
    }
    else {
        return Fitness.UNKNOWN;
    }
}