Search in sources :

Example 1 with Implementor

use of com.sun.xml.rpc.spi.runtime.Implementor in project Payara by payara.

the class ImplementorCacheDelegateImpl method createImplementor.

private Implementor createImplementor(RuntimeEndpointInfo targetEndpoint) throws Exception {
    Tie tie = (Tie) targetEndpoint.getTieClass().newInstance();
    Class seiClass = targetEndpoint.getRemoteInterface();
    Class implClass = targetEndpoint.getImplementationClass();
    Remote servant = null;
    if (seiClass.isAssignableFrom(implClass)) {
        // if servlet endpoint impl is a subtype of SEI, use an
        // instance as the servant.
        servant = (Remote) implClass.newInstance();
    } else {
        // Create a dynamic proxy that implements SEI (and optionally
        // ServiceLifecycle) and delegates to an instance of the
        // endpoint impl.
        Object implInstance = implClass.newInstance();
        InvocationHandler handler = new ServletImplInvocationHandler(implInstance);
        boolean implementsLifecycle = ServiceLifecycle.class.isAssignableFrom(implClass);
        Class[] proxyInterfaces = implementsLifecycle ? new Class[] { seiClass, ServiceLifecycle.class } : new Class[] { seiClass };
        servant = (Remote) Proxy.newProxyInstance(implClass.getClassLoader(), proxyInterfaces, handler);
    }
    tie.setTarget(servant);
    Implementor implementor = rpcFactory_.createImplementor(servletContext_, tie);
    implementor.init();
    return implementor;
}
Also used : Tie(com.sun.xml.rpc.spi.runtime.Tie) Implementor(com.sun.xml.rpc.spi.runtime.Implementor) Remote(java.rmi.Remote) InvocationHandler(java.lang.reflect.InvocationHandler)

Example 2 with Implementor

use of com.sun.xml.rpc.spi.runtime.Implementor in project Payara by payara.

the class ImplementorCacheDelegateImpl method getImplementorFor.

public Implementor getImplementorFor(RuntimeEndpointInfo targetEndpoint) {
    Implementor implementor = null;
    try {
        synchronized (targetEndpoint) {
            implementor = (Implementor) implementorCache_.get(targetEndpoint);
            if (implementor == null) {
                implementor = createImplementor(targetEndpoint);
                implementorCache_.put(targetEndpoint, implementor);
            }
        }
        WebServiceContractImpl wscImpl = WebServiceContractImpl.getInstance();
        InvocationManager invManager = wscImpl.getInvocationManager();
        ComponentInvocation inv = invManager.getCurrentInvocation();
        if (inv instanceof EJBInvocation)
            ((EJBInvocation) inv).setWebServiceTie(implementor.getTie());
    } catch (Throwable t) {
        RuntimeException re = new RuntimeException();
        re.initCause(t);
        throw re;
    }
    return implementor;
}
Also used : Implementor(com.sun.xml.rpc.spi.runtime.Implementor) ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation) InvocationManager(org.glassfish.api.invocation.InvocationManager) EJBInvocation(org.glassfish.ejb.api.EJBInvocation)

Example 3 with Implementor

use of com.sun.xml.rpc.spi.runtime.Implementor in project Payara by payara.

the class ServletSystemHandlerDelegate method processRequest.

/**
 * The processRequest method is invoked with an object that implements
 * com.sun.xml.rpc.spi.runtime.SOAPMessageContext.
 * <p>
 * When this method is called by the JAXRPCServletDelegate (on the server side of jaxrpc servlet
 * container invocation processing) it must be called just before the call to
 * implementor.getTie().handle(), and at the time of the request message and the following
 * properties must have been set on the SOAPMessageContext.
 * <p>
 * com.sun.xml.rpc.server.http.MessageContextProperties.IMPLEMENTOR <br>
 * This property must be set to the com.sun.xml.rpc.spi.runtime.Implementor object corresponding to
 * the target endpoint.
 * <p>
 * com.sun.xml.rpc.server.http.MessageContextProperties.HTTP_SERVLET_REQUEST <br>
 * This property must be set to the javax.servlet.http.HttpServletRequest object containing the
 * JAXRPC invocation.
 * <p>
 * com.sun.xml.rpc.server.http.MessageContextProperties.HTTP_SERVLET_RESPONSE <br>
 * This property must be set to the javax.servlet.http.HttpServletResponse object corresponding to
 * the JAXRPC invocation.
 * <p>
 * com.sun.xml.rpc.server.MessageContextProperties.HTTP_SERVLET_CONTEXT <br>
 * This property must be set to the javax.servlet.ServletContext object corresponding to web
 * application in which the JAXRPC servlet is running.
 *
 * @param messageContext the SOAPMessageContext object containing the request message and the
 * properties described above.
 * @return true if processing by the delegate was such that the caller should continue with its
 * normal message processing. Returns false if the processing by the delegate resulted in the
 * messageContext containing a response message that should be returned without the caller proceding
 * to its normal message processing.
 * @throws java.lang.RuntimeException when the processing by the delegate failed, without yielding a
 * response message. In this case, the expectation is that the caller will return a HTTP layer
 * response code reporting that an internal error occured.
 */
@Override
public boolean processRequest(SOAPMessageContext messageContext) {
    if (_logger.isLoggable(Level.FINE)) {
        _logger.fine("ws.processRequest");
    }
    final SOAPMessageContext finalMC = messageContext;
    Implementor implementor = (Implementor) messageContext.getProperty(IMPLEMENTOR);
    final Tie tie = implementor.getTie();
    StreamingHandler handler = (StreamingHandler) implementor.getTie();
    SOAPMessage request = finalMC.getMessage();
    final ServerAuthContext sAC = config_.getAuthContext(handler, request);
    boolean status = true;
    try {
        if (sAC != null) {
            status = false;
            // proceed to process message security
            status = WebServiceSecurity.validateRequest(finalMC, sAC);
            if (status) {
                messageContext.setProperty(SERVER_AUTH_CONTEXT, sAC);
            }
        }
    } catch (AuthException ae) {
        _logger.log(Level.SEVERE, LogUtils.ERROR_REQUEST_VALIDATION, ae);
        throw new RuntimeException(ae);
    } finally {
        WebServiceSecurity.auditInvocation(messageContext, endpoint_, status);
    }
    if (status) {
        if (System.getSecurityManager() != null) {
            // on this branch, the endpoint invocation and the
            // processing of the response will be initiated from
            // within the system handler delegate. delegate returns
            // false so that dispatcher will not invoke the endpoint.
            status = false;
            try {
                Subject.doAsPrivileged(SecurityContext.getCurrent().getSubject(), new PrivilegedExceptionAction() {

                    @Override
                    public Object run() throws Exception {
                        tie.handle(finalMC);
                        processResponse(finalMC);
                        return null;
                    }
                }, null);
            } catch (PrivilegedActionException pae) {
                Throwable cause = pae.getCause();
                if (cause instanceof AuthException) {
                    _logger.log(Level.SEVERE, LogUtils.ERROR_RESPONSE_SECURING, cause);
                }
                RuntimeException re = null;
                if (cause instanceof RuntimeException) {
                    re = (RuntimeException) cause;
                } else {
                    re = new RuntimeException(cause);
                }
                throw re;
            }
        }
    }
    return status;
}
Also used : Implementor(com.sun.xml.rpc.spi.runtime.Implementor) PrivilegedActionException(java.security.PrivilegedActionException) StreamingHandler(com.sun.xml.rpc.spi.runtime.StreamingHandler) AuthException(com.sun.enterprise.security.jauth.AuthException) PrivilegedExceptionAction(java.security.PrivilegedExceptionAction) SOAPMessage(javax.xml.soap.SOAPMessage) PrivilegedActionException(java.security.PrivilegedActionException) AuthException(com.sun.enterprise.security.jauth.AuthException) ServerAuthContext(com.sun.enterprise.security.jauth.ServerAuthContext) Tie(com.sun.xml.rpc.spi.runtime.Tie) SOAPMessageContext(com.sun.xml.rpc.spi.runtime.SOAPMessageContext)

Aggregations

Implementor (com.sun.xml.rpc.spi.runtime.Implementor)3 Tie (com.sun.xml.rpc.spi.runtime.Tie)2 AuthException (com.sun.enterprise.security.jauth.AuthException)1 ServerAuthContext (com.sun.enterprise.security.jauth.ServerAuthContext)1 SOAPMessageContext (com.sun.xml.rpc.spi.runtime.SOAPMessageContext)1 StreamingHandler (com.sun.xml.rpc.spi.runtime.StreamingHandler)1 InvocationHandler (java.lang.reflect.InvocationHandler)1 Remote (java.rmi.Remote)1 PrivilegedActionException (java.security.PrivilegedActionException)1 PrivilegedExceptionAction (java.security.PrivilegedExceptionAction)1 SOAPMessage (javax.xml.soap.SOAPMessage)1 ComponentInvocation (org.glassfish.api.invocation.ComponentInvocation)1 InvocationManager (org.glassfish.api.invocation.InvocationManager)1 EJBInvocation (org.glassfish.ejb.api.EJBInvocation)1