com.sun.xml.internal.ws.policy.PolicyMap Java Examples

The following examples show how to use com.sun.xml.internal.ws.policy.PolicyMap. 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
Source File: AddressingPolicyMapConfigurator.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Puts an addressing policy into the PolicyMap if the addressing feature was set.
 */
public Collection<PolicySubject> update(final PolicyMap policyMap, final SEIModel model, final WSBinding wsBinding)
        throws PolicyException {
    LOGGER.entering(policyMap, model, wsBinding);

    Collection<PolicySubject> subjects = new ArrayList<PolicySubject>();
    if (policyMap != null) {
        final AddressingFeature addressingFeature = wsBinding.getFeature(AddressingFeature.class);
        if (LOGGER.isLoggable(Level.FINEST)) {
            LOGGER.finest("addressingFeature = " + addressingFeature);
        }
        if ((addressingFeature != null) && addressingFeature.isEnabled()) {
            //add wsam:Addrressing assertion if not exists.
            addWsamAddressing(subjects, policyMap, model, addressingFeature);
        }
    } // endif policy map not null
    LOGGER.exiting(subjects);
    return subjects;
}
 
Example #2
Source File: SelectOptimalEncodingFeatureConfigurator.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 #3
Source File: DefaultPolicyResolver.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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
Source File: PolicyMapKeyConverter.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public PolicyMapKey getPolicyMapKey(final WsdlBindingSubject subject) {
    LOGGER.entering(subject);

    PolicyMapKey key = null;
    if (subject.isBindingSubject()) {
        key = PolicyMap.createWsdlEndpointScopeKey(this.serviceName, this.portName);
    }
    else if (subject.isBindingOperationSubject()) {
        key = PolicyMap.createWsdlOperationScopeKey(this.serviceName, this.portName, subject.getName());
    }
    else if (subject.isBindingMessageSubject()) {
        if (subject.getMessageType() == WsdlMessageType.FAULT) {
            key = PolicyMap.createWsdlFaultMessageScopeKey(this.serviceName, this.portName,
                    subject.getParent().getName(), subject.getName());
        }
        else {
            key = PolicyMap.createWsdlMessageScopeKey(this.serviceName, this.portName, subject.getParent().getName());
        }
    }

    LOGGER.exiting(key);
    return key;
}
 
Example #5
Source File: AddressingPolicyMapConfigurator.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Puts an addressing policy into the PolicyMap if the addressing feature was set.
 */
public Collection<PolicySubject> update(final PolicyMap policyMap, final SEIModel model, final WSBinding wsBinding)
        throws PolicyException {
    LOGGER.entering(policyMap, model, wsBinding);

    Collection<PolicySubject> subjects = new ArrayList<PolicySubject>();
    if (policyMap != null) {
        final AddressingFeature addressingFeature = wsBinding.getFeature(AddressingFeature.class);
        if (LOGGER.isLoggable(Level.FINEST)) {
            LOGGER.finest("addressingFeature = " + addressingFeature);
        }
        if ((addressingFeature != null) && addressingFeature.isEnabled()) {
            //add wsam:Addrressing assertion if not exists.
            addWsamAddressing(subjects, policyMap, model, addressingFeature);
        }
    } // endif policy map not null
    LOGGER.exiting(subjects);
    return subjects;
}
 
Example #6
Source File: MtomPolicyMapConfigurator.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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<PolicySubject>();
    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;
}
 
Example #7
Source File: AddressingPolicyMapConfigurator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Puts an addressing policy into the PolicyMap if the addressing feature was set.
 */
public Collection<PolicySubject> update(final PolicyMap policyMap, final SEIModel model, final WSBinding wsBinding)
        throws PolicyException {
    LOGGER.entering(policyMap, model, wsBinding);

    Collection<PolicySubject> subjects = new ArrayList<PolicySubject>();
    if (policyMap != null) {
        final AddressingFeature addressingFeature = wsBinding.getFeature(AddressingFeature.class);
        if (LOGGER.isLoggable(Level.FINEST)) {
            LOGGER.finest("addressingFeature = " + addressingFeature);
        }
        if ((addressingFeature != null) && addressingFeature.isEnabled()) {
            //add wsam:Addrressing assertion if not exists.
            addWsamAddressing(subjects, policyMap, model, addressingFeature);
        }
    } // endif policy map not null
    LOGGER.exiting(subjects);
    return subjects;
}
 
Example #8
Source File: PolicyMapKeyConverter.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public PolicyMapKey getPolicyMapKey(final WsdlBindingSubject subject) {
    LOGGER.entering(subject);

    PolicyMapKey key = null;
    if (subject.isBindingSubject()) {
        key = PolicyMap.createWsdlEndpointScopeKey(this.serviceName, this.portName);
    }
    else if (subject.isBindingOperationSubject()) {
        key = PolicyMap.createWsdlOperationScopeKey(this.serviceName, this.portName, subject.getName());
    }
    else if (subject.isBindingMessageSubject()) {
        if (subject.getMessageType() == WsdlMessageType.FAULT) {
            key = PolicyMap.createWsdlFaultMessageScopeKey(this.serviceName, this.portName,
                    subject.getParent().getName(), subject.getName());
        }
        else {
            key = PolicyMap.createWsdlMessageScopeKey(this.serviceName, this.portName, subject.getParent().getName());
        }
    }

    LOGGER.exiting(key);
    return key;
}
 
Example #9
Source File: AddressingPolicyMapConfigurator.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Puts an addressing policy into the PolicyMap if the addressing feature was set.
 */
public Collection<PolicySubject> update(final PolicyMap policyMap, final SEIModel model, final WSBinding wsBinding)
        throws PolicyException {
    LOGGER.entering(policyMap, model, wsBinding);

    Collection<PolicySubject> subjects = new ArrayList<PolicySubject>();
    if (policyMap != null) {
        final AddressingFeature addressingFeature = wsBinding.getFeature(AddressingFeature.class);
        if (LOGGER.isLoggable(Level.FINEST)) {
            LOGGER.finest("addressingFeature = " + addressingFeature);
        }
        if ((addressingFeature != null) && addressingFeature.isEnabled()) {
            //add wsam:Addrressing assertion if not exists.
            addWsamAddressing(subjects, policyMap, model, addressingFeature);
        }
    } // endif policy map not null
    LOGGER.exiting(subjects);
    return subjects;
}
 
Example #10
Source File: PolicyMapKeyConverter.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public PolicyMapKey getPolicyMapKey(final WsdlBindingSubject subject) {
    LOGGER.entering(subject);

    PolicyMapKey key = null;
    if (subject.isBindingSubject()) {
        key = PolicyMap.createWsdlEndpointScopeKey(this.serviceName, this.portName);
    }
    else if (subject.isBindingOperationSubject()) {
        key = PolicyMap.createWsdlOperationScopeKey(this.serviceName, this.portName, subject.getName());
    }
    else if (subject.isBindingMessageSubject()) {
        if (subject.getMessageType() == WsdlMessageType.FAULT) {
            key = PolicyMap.createWsdlFaultMessageScopeKey(this.serviceName, this.portName,
                    subject.getParent().getName(), subject.getName());
        }
        else {
            key = PolicyMap.createWsdlMessageScopeKey(this.serviceName, this.portName, subject.getParent().getName());
        }
    }

    LOGGER.exiting(key);
    return key;
}
 
Example #11
Source File: ManagementAssertion.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 #12
Source File: ManagementAssertion.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 #13
Source File: AddressingPolicyMapConfigurator.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Puts an addressing policy into the PolicyMap if the addressing feature was set.
 */
public Collection<PolicySubject> update(final PolicyMap policyMap, final SEIModel model, final WSBinding wsBinding)
        throws PolicyException {
    LOGGER.entering(policyMap, model, wsBinding);

    Collection<PolicySubject> subjects = new ArrayList<PolicySubject>();
    if (policyMap != null) {
        final AddressingFeature addressingFeature = wsBinding.getFeature(AddressingFeature.class);
        if (LOGGER.isLoggable(Level.FINEST)) {
            LOGGER.finest("addressingFeature = " + addressingFeature);
        }
        if ((addressingFeature != null) && addressingFeature.isEnabled()) {
            //add wsam:Addrressing assertion if not exists.
            addWsamAddressing(subjects, policyMap, model, addressingFeature);
        }
    } // endif policy map not null
    LOGGER.exiting(subjects);
    return subjects;
}
 
Example #14
Source File: DefaultPolicyResolver.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 #15
Source File: MtomFeatureConfigurator.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 #16
Source File: DefaultPolicyResolver.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 #17
Source File: PolicyMapKeyConverter.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public PolicyMapKey getPolicyMapKey(final WsdlBindingSubject subject) {
    LOGGER.entering(subject);

    PolicyMapKey key = null;
    if (subject.isBindingSubject()) {
        key = PolicyMap.createWsdlEndpointScopeKey(this.serviceName, this.portName);
    }
    else if (subject.isBindingOperationSubject()) {
        key = PolicyMap.createWsdlOperationScopeKey(this.serviceName, this.portName, subject.getName());
    }
    else if (subject.isBindingMessageSubject()) {
        if (subject.getMessageType() == WsdlMessageType.FAULT) {
            key = PolicyMap.createWsdlFaultMessageScopeKey(this.serviceName, this.portName,
                    subject.getParent().getName(), subject.getName());
        }
        else {
            key = PolicyMap.createWsdlMessageScopeKey(this.serviceName, this.portName, subject.getParent().getName());
        }
    }

    LOGGER.exiting(key);
    return key;
}
 
Example #18
Source File: AddressingPolicyMapConfigurator.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
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 + "\"");
    }
}
 
Example #19
Source File: PolicyWSDLGeneratorExtension.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@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<PolicySubject>();
            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();
    }
}
 
Example #20
Source File: PolicyUtil.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Iterates through the ports in the WSDL model, for each policy in the policy
 * map that is attached at endpoint scope computes a list of corresponding
 * WebServiceFeatures and sets them on the port.
 *
 * @param model The WSDL model
 * @param policyMap The policy map
 * @throws PolicyException If the list of WebServiceFeatures could not be computed
 */
public static void configureModel(final WSDLModel model, PolicyMap policyMap) throws PolicyException {
    LOGGER.entering(model, policyMap);
    for (WSDLService service : model.getServices().values()) {
        for (WSDLPort port : service.getPorts()) {
            final Collection<WebServiceFeature> features = getPortScopedFeatures(policyMap, service.getName(), port.getName());
            for (WebServiceFeature feature : features) {
                port.addFeature(feature);
                port.getBinding().addFeature(feature);
            }
        }
    }
    LOGGER.exiting();
}
 
Example #21
Source File: PolicyUtil.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Iterates through the ports in the WSDL model, for each policy in the policy
 * map that is attached at endpoint scope computes a list of corresponding
 * WebServiceFeatures and sets them on the port.
 *
 * @param model The WSDL model
 * @param policyMap The policy map
 * @throws PolicyException If the list of WebServiceFeatures could not be computed
 */
public static void configureModel(final WSDLModel model, PolicyMap policyMap) throws PolicyException {
    LOGGER.entering(model, policyMap);
    for (WSDLService service : model.getServices().values()) {
        for (WSDLPort port : service.getPorts()) {
            final Collection<WebServiceFeature> features = getPortScopedFeatures(policyMap, service.getName(), port.getName());
            for (WebServiceFeature feature : features) {
                port.addFeature(feature);
                port.getBinding().addFeature(feature);
            }
        }
    }
    LOGGER.exiting();
}
 
Example #22
Source File: PolicyUtil.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Iterates through the ports in the WSDL model, for each policy in the policy
 * map that is attached at endpoint scope computes a list of corresponding
 * WebServiceFeatures and sets them on the port.
 *
 * @param model The WSDL model
 * @param policyMap The policy map
 * @throws PolicyException If the list of WebServiceFeatures could not be computed
 */
public static void configureModel(final WSDLModel model, PolicyMap policyMap) throws PolicyException {
    LOGGER.entering(model, policyMap);
    for (WSDLService service : model.getServices().values()) {
        for (WSDLPort port : service.getPorts()) {
            final Collection<WebServiceFeature> features = getPortScopedFeatures(policyMap, service.getName(), port.getName());
            for (WebServiceFeature feature : features) {
                port.addFeature(feature);
                port.getBinding().addFeature(feature);
            }
        }
    }
    LOGGER.exiting();
}
 
Example #23
Source File: PortInfo.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public PolicyMap createPolicyMap() {
   PolicyMap map;
   if(portModel != null) {
        map = portModel.getOwner().getParent().getPolicyMap();
   } else {
       map = PolicyResolverFactory.create().resolve(new PolicyResolver.ClientContext(null,owner.getContainer()));
   }
   //still map is null, create a empty map
   if(map == null)
       map = PolicyMap.createPolicyMap(null);
   return map;
}
 
Example #24
Source File: PolicyWSDLGeneratorExtension.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@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<PolicySubject>();
            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();
    }
}
 
Example #25
Source File: PolicyUtil.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Iterates through the ports in the WSDL model, for each policy in the policy
 * map that is attached at endpoint scope computes a list of corresponding
 * WebServiceFeatures and sets them on the port.
 *
 * @param model The WSDL model
 * @param policyMap The policy map
 * @throws PolicyException If the list of WebServiceFeatures could not be computed
 */
public static void configureModel(final WSDLModel model, PolicyMap policyMap) throws PolicyException {
    LOGGER.entering(model, policyMap);
    for (WSDLService service : model.getServices().values()) {
        for (WSDLPort port : service.getPorts()) {
            final Collection<WebServiceFeature> features = getPortScopedFeatures(policyMap, service.getName(), port.getName());
            for (WebServiceFeature feature : features) {
                port.addFeature(feature);
                port.getBinding().addFeature(feature);
            }
        }
    }
    LOGGER.exiting();
}
 
Example #26
Source File: PolicyWSDLGeneratorExtension.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private static boolean isCorrectType(final PolicyMap map, final PolicySubject subject, final ScopeType type) {
    switch (type) {
        case OPERATION:
            return !(map.isInputMessageSubject(subject) || map.isOutputMessageSubject(subject) || map.isFaultMessageSubject(subject));
        case INPUT_MESSAGE:
            return map.isInputMessageSubject(subject);
        case OUTPUT_MESSAGE:
            return map.isOutputMessageSubject(subject);
        case FAULT_MESSAGE:
            return map.isFaultMessageSubject(subject);
        default:
            return true;
    }
}
 
Example #27
Source File: PolicyUtil.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Iterates through the ports in the WSDL model, for each policy in the policy
 * map that is attached at endpoint scope computes a list of corresponding
 * WebServiceFeatures and sets them on the port.
 *
 * @param model The WSDL model
 * @param policyMap The policy map
 * @throws PolicyException If the list of WebServiceFeatures could not be computed
 */
public static void configureModel(final WSDLModel model, PolicyMap policyMap) throws PolicyException {
    LOGGER.entering(model, policyMap);
    for (WSDLService service : model.getServices().values()) {
        for (WSDLPort port : service.getPorts()) {
            final Collection<WebServiceFeature> features = getPortScopedFeatures(policyMap, service.getName(), port.getName());
            for (WebServiceFeature feature : features) {
                port.addFeature(feature);
                port.getBinding().addFeature(feature);
            }
        }
    }
    LOGGER.exiting();
}
 
Example #28
Source File: PortInfo.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public PolicyMap createPolicyMap() {
   PolicyMap map;
   if(portModel != null) {
        map = portModel.getOwner().getParent().getPolicyMap();
   } else {
       map = PolicyResolverFactory.create().resolve(new PolicyResolver.ClientContext(null,owner.getContainer()));
   }
   //still map is null, create a empty map
   if(map == null)
       map = PolicyMap.createPolicyMap(null);
   return map;
}
 
Example #29
Source File: PortInfo.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public PolicyMap createPolicyMap() {
   PolicyMap map;
   if(portModel != null) {
        map = portModel.getOwner().getParent().getPolicyMap();
   } else {
       map = PolicyResolverFactory.create().resolve(new PolicyResolver.ClientContext(null,owner.getContainer()));
   }
   //still map is null, create a empty map
   if(map == null)
       map = PolicyMap.createPolicyMap(null);
   return map;
}
 
Example #30
Source File: ManagedClientAssertion.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return ManagedClient assertion if there is one associated with the client.
 *
 * @param portInfo The client PortInfo.
 * @return The policy assertion if found. Null otherwise.
 * @throws WebServiceException If computing the effective policy of the port failed.
 */
public static ManagedClientAssertion getAssertion(WSPortInfo portInfo) throws WebServiceException {
    if (portInfo == null)
            return null;

    LOGGER.entering(portInfo);
    // getPolicyMap is deprecated because it is only supposed to be used by Metro code
    // and not by other clients.
    @SuppressWarnings("deprecation")
    final PolicyMap policyMap = portInfo.getPolicyMap();
    final ManagedClientAssertion assertion = ManagementAssertion.getAssertion(MANAGED_CLIENT_QNAME,
            policyMap, portInfo.getServiceName(), portInfo.getPortName(), ManagedClientAssertion.class);
    LOGGER.exiting(assertion);
    return assertion;
}