Search in sources :

Example 1 with WSDLBoundOperation

use of com.sun.xml.ws.api.model.wsdl.WSDLBoundOperation 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)

Example 2 with WSDLBoundOperation

use of com.sun.xml.ws.api.model.wsdl.WSDLBoundOperation in project Payara by payara.

the class WebServicesDelegateImpl method getAuthContextID.

public String getAuthContextID(MessageInfo messageInfo) {
    // make this more efficient by operating on packet
    String rvalue = null;
    if (messageInfo instanceof PacketMessageInfo) {
        PacketMessageInfo pmi = (PacketMessageInfo) messageInfo;
        Packet p = (Packet) pmi.getRequestPacket();
        if (p != null) {
            Message m = p.getMessage();
            if (m != null) {
                WSDLPort port = (WSDLPort) messageInfo.getMap().get("WSDL_MODEL");
                if (port != null) {
                    WSDLBoundOperation w = m.getOperation(port);
                    if (w != null) {
                        QName n = w.getName();
                        if (n != null) {
                            rvalue = n.getLocalPart();
                        }
                    }
                }
            }
        }
        return rvalue;
    } else {
        // make this more efficient by operating on packet
        return getOpName((SOAPMessage) messageInfo.getRequestMessage());
    }
}
Also used : Packet(com.sun.xml.ws.api.message.Packet) Message(com.sun.xml.ws.api.message.Message) SOAPMessage(javax.xml.soap.SOAPMessage) WSDLBoundOperation(com.sun.xml.ws.api.model.wsdl.WSDLBoundOperation) QName(javax.xml.namespace.QName) PacketMessageInfo(com.sun.enterprise.security.jmac.provider.PacketMessageInfo) WSDLPort(com.sun.xml.ws.api.model.wsdl.WSDLPort)

Aggregations

WSDLBoundOperation (com.sun.xml.ws.api.model.wsdl.WSDLBoundOperation)2 PacketMessageInfo (com.sun.enterprise.security.jmac.provider.PacketMessageInfo)1 Message (com.sun.xml.ws.api.message.Message)1 Packet (com.sun.xml.ws.api.message.Packet)1 WSDLPort (com.sun.xml.ws.api.model.wsdl.WSDLPort)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 QName (javax.xml.namespace.QName)1 SOAPMessage (javax.xml.soap.SOAPMessage)1