Search in sources :

Example 1 with PolicyException

use of com.sun.xml.ws.policy.PolicyException in project Payara by payara.

the class GFServerPipeCreator method isSecurityEnabled.

// @Override
// public @NotNull
// Tube createSecurityTube(ServerTubelineAssemblyContext ctxt) {
// HashMap props = new HashMap();
// 
// /*TODO V3 enable
// props.put(PipeConstants.POLICY,map);
// props.put(PipeConstants.SEI_MODEL,sei);
// props.put(PipeConstants.WSDL_MODEL,port);
// props.put(PipeConstants.ENDPOINT,owner);
// props.put(PipeConstants.SERVICE_ENDPOINT,endpoint);
// props.put(PipeConstants.NEXT_PIPE,tail);
// props.put(PipeConstants.CONTAINER, owner.getContainer());
// if (isSecurityEnabled(map, port)) {
// endpoint.setSecurePipeline();
// }*/
// 
// return new CommonServerSecurityTube(props, ctxt.getTubelineHead(), isHttpBinding);
// }
/**
 * Checks to see whether WS-Security is enabled or not.
 *
 * @param policyMap policy map for {@link this} assembler
 * @param wsdlPort wsdl:port
 * @return true if Security is enabled, false otherwise
 */
// TODO - this code has been copied from PipelineAssemblerFactoryImpl.java and needs
// to be maintained in both places.  In the future, code needs to be moved somewhere
// where it can be invoked from both places.
public static boolean isSecurityEnabled(PolicyMap policyMap, WSDLPort wsdlPort) {
    if (policyMap == null || wsdlPort == null)
        return false;
    try {
        PolicyMapKey endpointKey = policyMap.createWsdlEndpointScopeKey(wsdlPort.getOwner().getName(), wsdlPort.getName());
        Policy policy = policyMap.getEndpointEffectivePolicy(endpointKey);
        if ((policy != null) && (policy.contains(SECURITY_POLICY_NAMESPACE_URI_SPECVERSION) || policy.contains(SECURITY_POLICY_NAMESPACE_URI_SUBMISSION))) {
            return true;
        }
        for (WSDLBoundOperation wbo : wsdlPort.getBinding().getBindingOperations()) {
            PolicyMapKey operationKey = policyMap.createWsdlOperationScopeKey(wsdlPort.getOwner().getName(), wsdlPort.getName(), wbo.getName());
            policy = policyMap.getOperationEffectivePolicy(operationKey);
            if ((policy != null) && (policy.contains(SECURITY_POLICY_NAMESPACE_URI_SPECVERSION) || policy.contains(SECURITY_POLICY_NAMESPACE_URI_SUBMISSION)))
                return true;
            policy = policyMap.getInputMessageEffectivePolicy(operationKey);
            if ((policy != null) && (policy.contains(SECURITY_POLICY_NAMESPACE_URI_SPECVERSION) || policy.contains(SECURITY_POLICY_NAMESPACE_URI_SUBMISSION)))
                return true;
            policy = policyMap.getOutputMessageEffectivePolicy(operationKey);
            if ((policy != null) && (policy.contains(SECURITY_POLICY_NAMESPACE_URI_SPECVERSION) || policy.contains(SECURITY_POLICY_NAMESPACE_URI_SUBMISSION)))
                return true;
            policy = policyMap.getFaultMessageEffectivePolicy(operationKey);
            if ((policy != null) && (policy.contains(SECURITY_POLICY_NAMESPACE_URI_SPECVERSION) || policy.contains(SECURITY_POLICY_NAMESPACE_URI_SUBMISSION)))
                return true;
        }
    } catch (PolicyException e) {
        return false;
    }
    return false;
}
Also used : Policy(com.sun.xml.ws.policy.Policy) WSDLBoundOperation(com.sun.xml.ws.api.model.wsdl.WSDLBoundOperation) PolicyMapKey(com.sun.xml.ws.policy.PolicyMapKey) PolicyException(com.sun.xml.ws.policy.PolicyException)

Aggregations

WSDLBoundOperation (com.sun.xml.ws.api.model.wsdl.WSDLBoundOperation)1 Policy (com.sun.xml.ws.policy.Policy)1 PolicyException (com.sun.xml.ws.policy.PolicyException)1 PolicyMapKey (com.sun.xml.ws.policy.PolicyMapKey)1