Search in sources :

Example 1 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 2 with Packet

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

the class SOAPAuthParam method putSOAPInPacket.

private boolean putSOAPInPacket(SOAPMessage m, Object p) {
    if (m == null) {
        ((Packet) p).setMessage(null);
    } else {
        Message msg = Messages.create(m);
        ((Packet) p).setMessage(msg);
    }
    return true;
}
Also used : Packet(com.sun.xml.ws.api.message.Packet) Message(com.sun.xml.ws.api.message.Message)

Example 3 with Packet

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

the class ClientSecurityPipe method startSecureConversation.

@Override
public JAXBElement startSecureConversation(Packet packet) throws WSSecureConversationException {
    PacketMessageInfo info = new PacketMapMessageInfo(packet, new Packet());
    JAXBElement token = null;
    try {
        // gets the subject from the packet (puts one there if not found)
        Subject clientSubject = getClientSubject(packet);
        // put MessageInfo in properties map, since MessageInfo
        // is not passed to getAuthContext, key idicates function
        HashMap map = new HashMap();
        map.put(PipeConstants.SECURITY_TOKEN, info);
        helper.getSessionToken(map, info, clientSubject);
        // helper returns token in map of msgInfo, using same key
        Object o = info.getMap().get(PipeConstants.SECURITY_TOKEN);
        if (o != null && o instanceof JAXBElement) {
            token = (JAXBElement) o;
        }
    } catch (Exception e) {
        if (e instanceof WSSecureConversationException) {
            throw (WSSecureConversationException) e;
        } else {
            throw new WSSecureConversationException("Secure Conversation failure: ", e);
        }
    }
    return token;
}
Also used : Packet(com.sun.xml.ws.api.message.Packet) PacketMapMessageInfo(com.sun.enterprise.security.jmac.provider.PacketMapMessageInfo) HashMap(java.util.HashMap) WSSecureConversationException(com.sun.xml.ws.security.secconv.WSSecureConversationException) JAXBElement(javax.xml.bind.JAXBElement) 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 4 with Packet

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

the class ClientSecurityPipe method preDestroy.

@Override
public void preDestroy() {
    // create a dummy request packet
    try {
        Packet request = new Packet();
        PacketMessageInfo info = new PacketMapMessageInfo(request, new Packet());
        Subject subj = getClientSubject(request);
        ClientAuthContext cAC = helper.getClientAuthContext(info, subj);
        if (cAC != null && WSIT_CLIENT_AUTH_CONTEXT.equals(cAC.getClass().getName())) {
            cAC.cleanSubject(info, subj);
        }
    } catch (Exception ex) {
    // ignore exceptions
    }
    helper.disable();
}
Also used : Packet(com.sun.xml.ws.api.message.Packet) PacketMapMessageInfo(com.sun.enterprise.security.jmac.provider.PacketMapMessageInfo) 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 5 with Packet

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

the class ClientSecurityTube method startSecureConversation.

@Override
public JAXBElement startSecureConversation(Packet packet) throws WSSecureConversationException {
    PacketMessageInfo locInfo = new PacketMapMessageInfo(packet, new Packet());
    JAXBElement token = null;
    try {
        // gets the subject from the packet (puts one there if not found)
        Subject locClientSubject = getClientSubject(packet);
        // put MessageInfo in properties map, since MessageInfo
        // is not passed to getAuthContext, key idicates function
        HashMap map = new HashMap();
        map.put(PipeConstants.SECURITY_TOKEN, locInfo);
        helper.getSessionToken(map, locInfo, locClientSubject);
        // helper returns token in map of msgInfo, using same key
        Object o = locInfo.getMap().get(PipeConstants.SECURITY_TOKEN);
        if (o != null && o instanceof JAXBElement) {
            token = (JAXBElement) o;
        }
    } catch (Exception e) {
        if (e instanceof WSSecureConversationException) {
            throw (WSSecureConversationException) e;
        } else {
            throw new WSSecureConversationException("Secure Conversation failure: ", e);
        }
    }
    return token;
}
Also used : Packet(com.sun.xml.ws.api.message.Packet) PacketMapMessageInfo(com.sun.enterprise.security.jmac.provider.PacketMapMessageInfo) HashMap(java.util.HashMap) WSSecureConversationException(com.sun.xml.ws.security.secconv.WSSecureConversationException) JAXBElement(javax.xml.bind.JAXBElement) 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)

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