Search in sources :

Example 11 with PolicySubject

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

the class AddressingPolicyMapConfigurator method addWsamAddressing.

private void addWsamAddressing(Collection<PolicySubject> subjects, PolicyMap policyMap, SEIModel model, AddressingFeature addressingFeature) throws PolicyException {
    final QName bindingName = model.getBoundPortTypeName();
    final WsdlBindingSubject wsdlSubject = WsdlBindingSubject.createBindingSubject(bindingName);
    final Policy addressingPolicy = createWsamAddressingPolicy(bindingName, addressingFeature);
    final PolicySubject addressingPolicySubject = new PolicySubject(wsdlSubject, addressingPolicy);
    subjects.add(addressingPolicySubject);
    if (LOGGER.isLoggable(Level.FINE)) {
        LOGGER.fine("Added addressing policy with ID \"" + addressingPolicy.getIdOrName() + "\" to binding element \"" + bindingName + "\"");
    }
}
Also used : Policy(com.sun.xml.ws.policy.Policy) PolicySubject(com.sun.xml.ws.policy.PolicySubject) QName(javax.xml.namespace.QName) WsdlBindingSubject(com.sun.xml.ws.policy.subject.WsdlBindingSubject)

Example 12 with PolicySubject

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

the class MtomPolicyMapConfigurator method update.

/**
 * Generates an MTOM policy if MTOM is enabled.
 *
 * <ol>
 * <li>If MTOM is enabled
 * <ol>
 * <li>If MTOM policy does not already exist, generate
 * <li>Otherwise do nothing
 * </ol>
 * <li>Otherwise, do nothing (that implies that we do not remove any MTOM policies if MTOM is disabled)
 * </ol>
 */
public Collection<PolicySubject> update(PolicyMap policyMap, SEIModel model, WSBinding wsBinding) throws PolicyException {
    LOGGER.entering(policyMap, model, wsBinding);
    Collection<PolicySubject> subjects = new ArrayList<>();
    if (policyMap != null) {
        final MTOMFeature mtomFeature = wsBinding.getFeature(MTOMFeature.class);
        if (LOGGER.isLoggable(Level.FINEST)) {
            LOGGER.finest("mtomFeature = " + mtomFeature);
        }
        if ((mtomFeature != null) && mtomFeature.isEnabled()) {
            final QName bindingName = model.getBoundPortTypeName();
            final WsdlBindingSubject wsdlSubject = WsdlBindingSubject.createBindingSubject(bindingName);
            final Policy mtomPolicy = createMtomPolicy(bindingName);
            final PolicySubject mtomPolicySubject = new PolicySubject(wsdlSubject, mtomPolicy);
            subjects.add(mtomPolicySubject);
            if (LOGGER.isLoggable(Level.FINEST)) {
                LOGGER.fine("Added MTOM policy with ID \"" + mtomPolicy.getIdOrName() + "\" to binding element \"" + bindingName + "\"");
            }
        }
    }
    // endif policy map not null
    LOGGER.exiting(subjects);
    return subjects;
}
Also used : Policy(com.sun.xml.ws.policy.Policy) PolicySubject(com.sun.xml.ws.policy.PolicySubject) QName(javax.xml.namespace.QName) MTOMFeature(jakarta.xml.ws.soap.MTOMFeature) ArrayList(java.util.ArrayList) WsdlBindingSubject(com.sun.xml.ws.policy.subject.WsdlBindingSubject)

Example 13 with PolicySubject

use of com.sun.xml.ws.policy.PolicySubject 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)

Example 14 with PolicySubject

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

the class AlternativeSelectorTest method testDoSelectionAlternativesService.

/**
 * Test of doSelection method, of class AlternativeSelector.
 */
public void testDoSelectionAlternativesService() 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.createWsdlServiceScopeKey(new QName("service"));
    extender.putServiceSubject(key, subject);
    final EffectivePolicyModifier modifier = EffectivePolicyModifier.createEffectivePolicyModifier();
    modifier.connect(map);
    AlternativeSelector.doSelection(modifier);
    final Policy result = map.getServiceEffectivePolicy(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 15 with PolicySubject

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

the class AlternativeSelectorTest method testDoSelectionAlternativesEndpoint.

/**
 * Test of doSelection method, of class AlternativeSelector.
 */
public void testDoSelectionAlternativesEndpoint() 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.createWsdlEndpointScopeKey(new QName("service"), new QName("port"));
    extender.putEndpointSubject(key, subject);
    final EffectivePolicyModifier modifier = EffectivePolicyModifier.createEffectivePolicyModifier();
    modifier.connect(map);
    AlternativeSelector.doSelection(modifier);
    final Policy result = map.getEndpointEffectivePolicy(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

PolicySubject (com.sun.xml.ws.policy.PolicySubject)16 Policy (com.sun.xml.ws.policy.Policy)10 QName (javax.xml.namespace.QName)8 PolicyMapExtender (com.sun.xml.ws.policy.PolicyMapExtender)7 EffectivePolicyModifier (com.sun.xml.ws.policy.EffectivePolicyModifier)6 PolicyMap (com.sun.xml.ws.policy.PolicyMap)6 PolicyMapKey (com.sun.xml.ws.policy.PolicyMapKey)6 PolicyMapMutator (com.sun.xml.ws.policy.PolicyMapMutator)6 WsdlBindingSubject (com.sun.xml.ws.policy.subject.WsdlBindingSubject)4 WebServiceException (jakarta.xml.ws.WebServiceException)3 ArrayList (java.util.ArrayList)3 PolicyException (com.sun.xml.ws.policy.PolicyException)2 TypedXmlWriter (com.sun.xml.txw2.TypedXmlWriter)1 AddressingPolicyMapConfigurator (com.sun.xml.ws.addressing.policy.AddressingPolicyMapConfigurator)1 WSBinding (com.sun.xml.ws.api.WSBinding)1 JavaMethod (com.sun.xml.ws.api.model.JavaMethod)1 WSDLBoundFault (com.sun.xml.ws.api.model.wsdl.WSDLBoundFault)1 WSDLBoundOperation (com.sun.xml.ws.api.model.wsdl.WSDLBoundOperation)1 MtomPolicyMapConfigurator (com.sun.xml.ws.encoding.policy.MtomPolicyMapConfigurator)1 PolicyMapConfigurator (com.sun.xml.ws.policy.jaxws.spi.PolicyMapConfigurator)1