Search in sources :

Example 1 with PolicyMapExtender

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

the class PolicyMapBuilder method getNewPolicyMap.

/**
 * Iterates all the registered PolicyBuilders and lets them populate
 * their changes into PolicyMap. Registers mutators from collection given as a parameter
 * with the newly created map.
 */
private PolicyMap getNewPolicyMap(final PolicyMapMutator... externalMutators) throws PolicyException {
    final HashSet<PolicyMapMutator> mutators = new HashSet<>();
    final PolicyMapExtender myExtender = PolicyMapExtender.createPolicyMapExtender();
    mutators.add(myExtender);
    if (null != externalMutators) {
        mutators.addAll(Arrays.asList(externalMutators));
    }
    final PolicyMap policyMap = PolicyMap.createPolicyMap(mutators);
    for (BuilderHandler builder : policyBuilders) {
        builder.populate(myExtender);
    }
    return policyMap;
}
Also used : PolicyMap(com.sun.xml.ws.policy.PolicyMap) PolicyMapMutator(com.sun.xml.ws.policy.PolicyMapMutator) PolicyMapExtender(com.sun.xml.ws.policy.PolicyMapExtender) HashSet(java.util.HashSet)

Example 2 with PolicyMapExtender

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

the class PolicyWSDLGeneratorExtension method start.

@Override
public void start(final WSDLGenExtnContext context) {
    LOGGER.entering();
    try {
        this.seiModel = context.getModel();
        final PolicyMapConfigurator[] policyMapConfigurators = loadConfigurators();
        final PolicyMapExtender[] extenders = new PolicyMapExtender[policyMapConfigurators.length];
        for (int i = 0; i < policyMapConfigurators.length; i++) {
            extenders[i] = PolicyMapExtender.createPolicyMapExtender();
        }
        // Read policy config file
        policyMap = PolicyResolverFactory.create().resolve(new PolicyResolver.ServerContext(policyMap, context.getContainer(), context.getEndpointClass(), false, extenders));
        if (policyMap == null) {
            LOGGER.fine(PolicyMessages.WSP_1019_CREATE_EMPTY_POLICY_MAP());
            policyMap = PolicyMap.createPolicyMap(Arrays.asList(extenders));
        }
        final WSBinding binding = context.getBinding();
        try {
            final Collection<PolicySubject> policySubjects = new LinkedList<>();
            for (int i = 0; i < policyMapConfigurators.length; i++) {
                policySubjects.addAll(policyMapConfigurators[i].update(policyMap, seiModel, binding));
                extenders[i].disconnect();
            }
            PolicyMapUtil.insertPolicies(policyMap, policySubjects, this.seiModel.getServiceQName(), this.seiModel.getPortName());
        } catch (PolicyException e) {
            throw LOGGER.logSevereException(new WebServiceException(PolicyMessages.WSP_1017_MAP_UPDATE_FAILED(), e));
        }
        final TypedXmlWriter root = context.getRoot();
        root._namespace(NamespaceVersion.v1_2.toString(), NamespaceVersion.v1_2.getDefaultNamespacePrefix());
        root._namespace(NamespaceVersion.v1_5.toString(), NamespaceVersion.v1_5.getDefaultNamespacePrefix());
        root._namespace(PolicyConstants.WSU_NAMESPACE_URI, PolicyConstants.WSU_NAMESPACE_PREFIX);
    } finally {
        LOGGER.exiting();
    }
}
Also used : WSBinding(com.sun.xml.ws.api.WSBinding) PolicySubject(com.sun.xml.ws.policy.PolicySubject) WebServiceException(jakarta.xml.ws.WebServiceException) TypedXmlWriter(com.sun.xml.txw2.TypedXmlWriter) PolicyMapExtender(com.sun.xml.ws.policy.PolicyMapExtender) LinkedList(java.util.LinkedList) PolicyException(com.sun.xml.ws.policy.PolicyException) PolicyMapConfigurator(com.sun.xml.ws.policy.jaxws.spi.PolicyMapConfigurator) MtomPolicyMapConfigurator(com.sun.xml.ws.encoding.policy.MtomPolicyMapConfigurator) AddressingPolicyMapConfigurator(com.sun.xml.ws.addressing.policy.AddressingPolicyMapConfigurator)

Example 3 with PolicyMapExtender

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

the class AlternativeSelectorTest method testDoSelectionAlternativesFault.

public void testDoSelectionAlternativesFault() throws PolicyException {
    final PolicyMapExtender extender = PolicyMapExtender.createPolicyMapExtender();
    final PolicyMap map = PolicyMap.createPolicyMap(Arrays.asList(new PolicyMapMutator[] { extender }));
    final PolicySubject subject = new PolicySubject("dummy", this.multipleAlternativesPolicy);
    final PolicyMapKey key = PolicyMap.createWsdlFaultMessageScopeKey(new QName("service"), new QName("port"), new QName("operation"), new QName("fault"));
    extender.putFaultMessageSubject(key, subject);
    final EffectivePolicyModifier modifier = EffectivePolicyModifier.createEffectivePolicyModifier();
    modifier.connect(map);
    AlternativeSelector.doSelection(modifier);
    final Policy result = map.getFaultMessageEffectivePolicy(key);
    if (result.contains(this.assertion1Name)) {
        assertFalse(result.contains(this.assertion2Name));
    } else if (result.contains(this.assertion2Name)) {
        assertFalse(result.contains(this.assertion1Name));
    } else {
        fail("Expected exactly one assertion in the resulting policy.");
    }
}
Also used : Policy(com.sun.xml.ws.policy.Policy) PolicySubject(com.sun.xml.ws.policy.PolicySubject) EffectivePolicyModifier(com.sun.xml.ws.policy.EffectivePolicyModifier) PolicyMap(com.sun.xml.ws.policy.PolicyMap) PolicyMapKey(com.sun.xml.ws.policy.PolicyMapKey) QName(javax.xml.namespace.QName) PolicyMapMutator(com.sun.xml.ws.policy.PolicyMapMutator) PolicyMapExtender(com.sun.xml.ws.policy.PolicyMapExtender)

Example 4 with PolicyMapExtender

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

the class AlternativeSelectorTest method testDoSelectionAlternativesOperation.

/**
 * Test of doSelection method, of class AlternativeSelector.
 */
public void testDoSelectionAlternativesOperation() throws PolicyException {
    final PolicyMapExtender extender = PolicyMapExtender.createPolicyMapExtender();
    final PolicyMap map = PolicyMap.createPolicyMap(Arrays.asList(new PolicyMapMutator[] { extender }));
    final PolicySubject subject = new PolicySubject("dummy", this.multipleAlternativesPolicy);
    final PolicyMapKey key = PolicyMap.createWsdlOperationScopeKey(new QName("service"), new QName("port"), new QName("operation"));
    extender.putOperationSubject(key, subject);
    final EffectivePolicyModifier modifier = EffectivePolicyModifier.createEffectivePolicyModifier();
    modifier.connect(map);
    AlternativeSelector.doSelection(modifier);
    final Policy result = map.getOperationEffectivePolicy(key);
    if (result.contains(this.assertion1Name)) {
        assertFalse(result.contains(this.assertion2Name));
    } else if (result.contains(this.assertion2Name)) {
        assertFalse(result.contains(this.assertion1Name));
    } else {
        fail("Expected exactly one assertion in the resulting policy.");
    }
}
Also used : Policy(com.sun.xml.ws.policy.Policy) PolicySubject(com.sun.xml.ws.policy.PolicySubject) EffectivePolicyModifier(com.sun.xml.ws.policy.EffectivePolicyModifier) PolicyMap(com.sun.xml.ws.policy.PolicyMap) PolicyMapKey(com.sun.xml.ws.policy.PolicyMapKey) QName(javax.xml.namespace.QName) PolicyMapMutator(com.sun.xml.ws.policy.PolicyMapMutator) PolicyMapExtender(com.sun.xml.ws.policy.PolicyMapExtender)

Example 5 with PolicyMapExtender

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

the class AlternativeSelectorTest method testDoSelectionAlternativesInput.

/**
 * Test of doSelection method, of class AlternativeSelector.
 */
public void testDoSelectionAlternativesInput() throws PolicyException {
    final PolicyMapExtender extender = PolicyMapExtender.createPolicyMapExtender();
    final PolicyMap map = PolicyMap.createPolicyMap(Arrays.asList(new PolicyMapMutator[] { extender }));
    final PolicySubject subject = new PolicySubject("dummy", this.multipleAlternativesPolicy);
    final PolicyMapKey key = PolicyMap.createWsdlMessageScopeKey(new QName("service"), new QName("port"), new QName("operation"));
    extender.putInputMessageSubject(key, subject);
    final EffectivePolicyModifier modifier = EffectivePolicyModifier.createEffectivePolicyModifier();
    modifier.connect(map);
    AlternativeSelector.doSelection(modifier);
    final Policy result = map.getInputMessageEffectivePolicy(key);
    if (result.contains(this.assertion1Name)) {
        assertFalse(result.contains(this.assertion2Name));
    } else if (result.contains(this.assertion2Name)) {
        assertFalse(result.contains(this.assertion1Name));
    } else {
        fail("Expected exactly one assertion in the resulting policy.");
    }
}
Also used : Policy(com.sun.xml.ws.policy.Policy) PolicySubject(com.sun.xml.ws.policy.PolicySubject) EffectivePolicyModifier(com.sun.xml.ws.policy.EffectivePolicyModifier) PolicyMap(com.sun.xml.ws.policy.PolicyMap) PolicyMapKey(com.sun.xml.ws.policy.PolicyMapKey) QName(javax.xml.namespace.QName) PolicyMapMutator(com.sun.xml.ws.policy.PolicyMapMutator) PolicyMapExtender(com.sun.xml.ws.policy.PolicyMapExtender)

Aggregations

PolicyMapExtender (com.sun.xml.ws.policy.PolicyMapExtender)8 PolicyMap (com.sun.xml.ws.policy.PolicyMap)7 PolicyMapMutator (com.sun.xml.ws.policy.PolicyMapMutator)7 PolicySubject (com.sun.xml.ws.policy.PolicySubject)7 EffectivePolicyModifier (com.sun.xml.ws.policy.EffectivePolicyModifier)6 Policy (com.sun.xml.ws.policy.Policy)6 PolicyMapKey (com.sun.xml.ws.policy.PolicyMapKey)6 QName (javax.xml.namespace.QName)6 TypedXmlWriter (com.sun.xml.txw2.TypedXmlWriter)1 AddressingPolicyMapConfigurator (com.sun.xml.ws.addressing.policy.AddressingPolicyMapConfigurator)1 WSBinding (com.sun.xml.ws.api.WSBinding)1 MtomPolicyMapConfigurator (com.sun.xml.ws.encoding.policy.MtomPolicyMapConfigurator)1 PolicyException (com.sun.xml.ws.policy.PolicyException)1 PolicyMapConfigurator (com.sun.xml.ws.policy.jaxws.spi.PolicyMapConfigurator)1 WebServiceException (jakarta.xml.ws.WebServiceException)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1