Search in sources :

Example 11 with Packet

use of com.sun.xml.ws.api.message.Packet in project Payara by payara.

the class MonitoringPipe method process.

public Packet process(Packet request) {
    // if it is a JBI request then skip the monitoring logic. This is done
    // as HTTPServletRequest/Response is not available when the invocation
    // is from JavaEE service engine.
    String delegateClassName = request.webServiceContextDelegate.getClass().getName();
    if (delegateClassName.equals("com.sun.enterprise.jbi.serviceengine." + "bridge.transport.NMRServerConnection")) {
        return next.process(request);
    }
    // No monitoring available for restful services
    if ("http://www.w3.org/2004/08/wsdl/http".equals(endpoint.getProtocolBinding())) {
        return next.process(request);
    }
    SOAPMessageContext ctxt = new SOAPMessageContextImpl(request);
    HttpServletRequest httpRequest = (HttpServletRequest) request.get(javax.xml.ws.handler.MessageContext.SERVLET_REQUEST);
    HttpServletResponse httpResponse = (HttpServletResponse) request.get(javax.xml.ws.handler.MessageContext.SERVLET_RESPONSE);
    String messageId = null;
    JAXWSEndpointImpl endpt1;
    if (endpoint.implementedByWebComponent()) {
        endpt1 = (JAXWSEndpointImpl) wsEngine.getEndpoint(httpRequest.getServletPath());
    } else {
        endpt1 = (JAXWSEndpointImpl) wsEngine.getEndpoint(httpRequest.getRequestURI());
    }
    messageId = wsEngine.preProcessRequest(endpt1);
    if (messageId != null) {
        ctxt.put(EndpointImpl.MESSAGE_ID, messageId);
        ThreadLocalInfo config = new ThreadLocalInfo(messageId, httpRequest);
        wsEngine.getThreadLocal().set(config);
    }
    try {
        endpt1.processRequest(ctxt);
    } catch (Exception e) {
    // temporary - need to send back SOAP fault message
    }
    Packet pipeResponse = next.process(request);
    // Make the response packet available in the MessageContext
    ((SOAPMessageContextImpl) ctxt).setPacket(pipeResponse);
    try {
        if (endpt1 != null) {
            endpt1.processResponse(ctxt);
        }
    } catch (Exception e) {
    // temporary - need to send back SOAP fault message
    }
    if (messageId != null) {
        HttpResponseInfoImpl info = new HttpResponseInfoImpl(httpResponse);
        wsEngine.postProcessResponse(messageId, info);
    }
    return pipeResponse;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) Packet(com.sun.xml.ws.api.message.Packet) HttpServletResponse(javax.servlet.http.HttpServletResponse)

Example 12 with Packet

use of com.sun.xml.ws.api.message.Packet in project Payara by payara.

the class ClientSecurityPipe method processSecureRequest.

private Packet processSecureRequest(PacketMessageInfo info, ClientAuthContext cAC, Subject clientSubject) throws WebServiceException {
    // send the request
    Packet response = next.process(info.getRequestPacket());
    // check for response
    Message m = response.getMessage();
    if (m != null) {
        if (cAC != null) {
            AuthStatus status;
            info.setResponsePacket(response);
            try {
                status = cAC.validateResponse(info, clientSubject, null);
            } catch (Exception e) {
                throw new WebServiceException(localStrings.getLocalString("enterprise.webservice.cantValidateResponse", "Cannot validate response for {0}", new Object[] { helper.getModelName() }), e);
            }
            if (status == AuthStatus.SEND_CONTINUE) {
                response = processSecureRequest(info, cAC, clientSubject);
            } else {
                response = info.getResponsePacket();
            }
        }
    }
    return response;
}
Also used : Packet(com.sun.xml.ws.api.message.Packet) Message(com.sun.xml.ws.api.message.Message) WebServiceException(javax.xml.ws.WebServiceException) AuthStatus(javax.security.auth.message.AuthStatus) WSSecureConversationException(com.sun.xml.ws.security.secconv.WSSecureConversationException) WebServiceException(javax.xml.ws.WebServiceException)

Example 13 with Packet

use of com.sun.xml.ws.api.message.Packet in project Payara by payara.

the class ClientSecurityPipe method process.

@Override
public Packet process(Packet request) {
    /*
	 * XXX should there be code like the following?
	 if(isHttpBinding) {
	     return next.process(request);
	 }
        */
    PacketMessageInfo info = new PacketMapMessageInfo(request, new Packet());
    info.getMap().put(javax.xml.ws.Endpoint.WSDL_SERVICE, helper.getProperty(PipeConstants.WSDL_SERVICE));
    AuthStatus status = AuthStatus.SEND_SUCCESS;
    Subject clientSubject = getClientSubject(request);
    ClientAuthContext cAC = null;
    try {
        cAC = helper.getClientAuthContext(info, clientSubject);
        if (cAC != null) {
            // proceed to process message sescurity
            status = cAC.secureRequest(info, clientSubject);
        }
    } catch (Exception e) {
        _logger.log(Level.SEVERE, LogUtils.ERROR_REQUEST_SECURING, e);
        throw new WebServiceException(localStrings.getLocalString("enterprise.webservice.cantSecureRequst", "Cannot secure request for {0}", new Object[] { helper.getModelName() }), e);
    }
    Packet response;
    if (status == AuthStatus.FAILURE) {
        if (_logger.isLoggable(Level.FINE)) {
            _logger.log(Level.FINE, "ws.status_secure_request", status);
        }
        response = info.getResponsePacket();
    } else {
        response = processSecureRequest(info, cAC, clientSubject);
    }
    // may return a security fault even if the MEP was one-way
    return response;
}
Also used : Packet(com.sun.xml.ws.api.message.Packet) PacketMapMessageInfo(com.sun.enterprise.security.jmac.provider.PacketMapMessageInfo) WebServiceException(javax.xml.ws.WebServiceException) AuthStatus(javax.security.auth.message.AuthStatus) Subject(javax.security.auth.Subject) WSSecureConversationException(com.sun.xml.ws.security.secconv.WSSecureConversationException) WebServiceException(javax.xml.ws.WebServiceException) PacketMessageInfo(com.sun.enterprise.security.jmac.provider.PacketMessageInfo)

Example 14 with Packet

use of com.sun.xml.ws.api.message.Packet in project Payara by payara.

the class ClientSecurityTube method processRequest.

@Override
public NextAction processRequest(Packet request) {
    try {
        /*
             * XXX should there be code like the following?
            if(isHttpBinding) {
            return next.process(request);
            }
             */
        info = new PacketMapMessageInfo(request, new Packet());
        AuthStatus status = AuthStatus.SEND_SUCCESS;
        info.getMap().put(javax.xml.ws.Endpoint.WSDL_SERVICE, helper.getProperty(PipeConstants.WSDL_SERVICE));
        Subject locClientSubject = getClientSubject(request);
        cAC = helper.getClientAuthContext(info, locClientSubject);
        if (cAC != null) {
            // proceed to process message sescurity
            status = cAC.secureRequest(info, locClientSubject);
        }
        if (status == AuthStatus.FAILURE) {
            if (_logger.isLoggable(Level.FINE)) {
                _logger.log(Level.FINE, "ws.status_secure_request", status);
            }
            throw new WebServiceException(localStrings.getLocalString("enterprise.webservice.cantSecureRequst", "Cannot secure request for {0}", new Object[] { helper.getModelName() }), new Exception("An Error occured while Securing the Request"));
        } else {
            return doInvoke(super.next, info.getRequestPacket());
        }
    } catch (Exception e) {
        _logger.log(Level.SEVERE, LogUtils.ERROR_REQUEST_SECURING, e);
        throw new WebServiceException(localStrings.getLocalString("enterprise.webservice.cantSecureRequst", "Cannot secure request for {0}", new Object[] { helper.getModelName() }), e);
    }
}
Also used : Packet(com.sun.xml.ws.api.message.Packet) PacketMapMessageInfo(com.sun.enterprise.security.jmac.provider.PacketMapMessageInfo) WebServiceException(javax.xml.ws.WebServiceException) AuthStatus(javax.security.auth.message.AuthStatus) Subject(javax.security.auth.Subject) WSSecureConversationException(com.sun.xml.ws.security.secconv.WSSecureConversationException) WebServiceException(javax.xml.ws.WebServiceException)

Aggregations

Packet (com.sun.xml.ws.api.message.Packet)14 WebServiceException (javax.xml.ws.WebServiceException)11 PacketMapMessageInfo (com.sun.enterprise.security.jmac.provider.PacketMapMessageInfo)9 Subject (javax.security.auth.Subject)9 PacketMessageInfo (com.sun.enterprise.security.jmac.provider.PacketMessageInfo)8 WSSecureConversationException (com.sun.xml.ws.security.secconv.WSSecureConversationException)7 AuthStatus (javax.security.auth.message.AuthStatus)5 Message (com.sun.xml.ws.api.message.Message)3 PrivilegedActionException (java.security.PrivilegedActionException)3 AuthException (javax.security.auth.message.AuthException)3 PrivilegedExceptionAction (java.security.PrivilegedExceptionAction)2 HashMap (java.util.HashMap)2 JAXBElement (javax.xml.bind.JAXBElement)2 WSDLBoundOperation (com.sun.xml.ws.api.model.wsdl.WSDLBoundOperation)1 WSDLPort (com.sun.xml.ws.api.model.wsdl.WSDLPort)1 NextAction (com.sun.xml.ws.api.pipe.NextAction)1 Tube (com.sun.xml.ws.api.pipe.Tube)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 QName (javax.xml.namespace.QName)1