Search in sources :

Example 1 with PolicyMap

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

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

the class PolicyWSDLParserExtension method postFinished.

// time to read possible config file and do alternative selection (on client side)
@Override
public void postFinished(final WSDLParserExtensionContext context) {
    // finally register the PolicyMap on the WSDLModel
    EditableWSDLModel wsdlModel = context.getWSDLModel();
    PolicyMap effectiveMap;
    try {
        if (context.isClientSide())
            effectiveMap = context.getPolicyResolver().resolve(new PolicyResolver.ClientContext(policyBuilder.getPolicyMap(), context.getContainer()));
        else
            effectiveMap = context.getPolicyResolver().resolve(new PolicyResolver.ServerContext(policyBuilder.getPolicyMap(), context.getContainer(), null));
        wsdlModel.setPolicyMap(effectiveMap);
    } catch (PolicyException e) {
        LOGGER.logSevereException(e);
        throw LOGGER.logSevereException(new WebServiceException(PolicyMessages.WSP_1007_POLICY_EXCEPTION_WHILE_FINISHING_PARSING_WSDL(), e));
    }
    try {
        PolicyUtil.configureModel(wsdlModel, effectiveMap);
    } catch (PolicyException e) {
        LOGGER.logSevereException(e);
        throw LOGGER.logSevereException(new WebServiceException(PolicyMessages.WSP_1012_FAILED_CONFIGURE_WSDL_MODEL(), e));
    }
    LOGGER.exiting();
}
Also used : PolicyMap(com.sun.xml.ws.policy.PolicyMap) WebServiceException(jakarta.xml.ws.WebServiceException) PolicyException(com.sun.xml.ws.policy.PolicyException) PolicyResolver(com.sun.xml.ws.api.policy.PolicyResolver)

Example 3 with PolicyMap

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

the class AlternativeSelectorTest method testDoSelectionEmpty.

/**
 * Test of doSelection method, of class AlternativeSelector.
 */
public void testDoSelectionEmpty() throws PolicyException {
    final EffectivePolicyModifier modifier = EffectivePolicyModifier.createEffectivePolicyModifier();
    final PolicyMap map = PolicyMap.createPolicyMap(null);
    modifier.connect(map);
    AlternativeSelector.doSelection(modifier);
    assertTrue(map.isEmpty());
}
Also used : EffectivePolicyModifier(com.sun.xml.ws.policy.EffectivePolicyModifier) PolicyMap(com.sun.xml.ws.policy.PolicyMap)

Example 4 with PolicyMap

use of com.sun.xml.ws.policy.PolicyMap 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 5 with PolicyMap

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

Aggregations

PolicyMap (com.sun.xml.ws.policy.PolicyMap)12 EffectivePolicyModifier (com.sun.xml.ws.policy.EffectivePolicyModifier)7 PolicyMapExtender (com.sun.xml.ws.policy.PolicyMapExtender)7 PolicyMapMutator (com.sun.xml.ws.policy.PolicyMapMutator)7 QName (javax.xml.namespace.QName)7 Policy (com.sun.xml.ws.policy.Policy)6 PolicyMapKey (com.sun.xml.ws.policy.PolicyMapKey)6 PolicySubject (com.sun.xml.ws.policy.PolicySubject)6 MetadataReader (com.sun.xml.ws.api.databinding.MetadataReader)1 WSDLPort (com.sun.xml.ws.api.model.wsdl.WSDLPort)1 PolicyResolver (com.sun.xml.ws.api.policy.PolicyResolver)1 SDDocumentSource (com.sun.xml.ws.api.server.SDDocumentSource)1 BindingImpl (com.sun.xml.ws.binding.BindingImpl)1 SOAPBindingImpl (com.sun.xml.ws.binding.SOAPBindingImpl)1 WebServiceFeatureList (com.sun.xml.ws.binding.WebServiceFeatureList)1 AbstractSEIModelImpl (com.sun.xml.ws.model.AbstractSEIModelImpl)1 PolicyException (com.sun.xml.ws.policy.PolicyException)1 WebServiceException (jakarta.xml.ws.WebServiceException)1 WebServiceFeature (jakarta.xml.ws.WebServiceFeature)1 HashSet (java.util.HashSet)1