Search in sources :

Example 1 with HandlerInfo

use of com.sun.xml.rpc.spi.tools.HandlerInfo in project Payara by payara.

the class WsCompile method createHandlerInfo.

private HandlerInfo createHandlerInfo(WebServiceHandler handler) {
    HandlerInfo handlerInfo = rpcFactory.createHandlerInfo();
    handlerInfo.setHandlerClassName(handler.getHandlerClass());
    for (Iterator iter = handler.getSoapHeaders().iterator(); iter.hasNext(); ) {
        QName next = (QName) iter.next();
        handlerInfo.addHeaderName(next);
    }
    Map properties = handlerInfo.getProperties();
    for (Iterator iter = handler.getInitParams().iterator(); iter.hasNext(); ) {
        NameValuePairDescriptor next = (NameValuePairDescriptor) iter.next();
        properties.put(next.getName(), next.getValue());
    }
    return handlerInfo;
}
Also used : NameValuePairDescriptor(com.sun.enterprise.deployment.NameValuePairDescriptor) QName(javax.xml.namespace.QName) Iterator(java.util.Iterator) Map(java.util.Map) HandlerInfo(com.sun.xml.rpc.spi.tools.HandlerInfo)

Example 2 with HandlerInfo

use of com.sun.xml.rpc.spi.tools.HandlerInfo in project Payara by payara.

the class WsCompile method setupServiceHandlerChain.

private void setupServiceHandlerChain() {
    Model model = wscompile.getProcessor().getModel();
    Collection endpoints = webService.getEndpoints();
    for (Iterator eIter = endpoints.iterator(); eIter.hasNext(); ) {
        WebServiceEndpoint nextEndpoint = (WebServiceEndpoint) eIter.next();
        if (!nextEndpoint.hasHandlers()) {
            continue;
        }
        Port port = wsUtil.getPortFromModel(model, nextEndpoint.getWsdlPort());
        if (port == null) {
            throw new IllegalStateException("Model port for endpoint " + nextEndpoint.getEndpointName() + " not found");
        }
        List handlerChain = nextEndpoint.getHandlers();
        HandlerChainInfo modelHandlerChain = port.getServerHCI();
        List handlerInfoList = new ArrayList();
        // Insert an container handler as the first element.
        // This is needed to perform method authorization checks.
        HandlerInfo preHandler = rpcFactory.createHandlerInfo();
        String handlerClassName = nextEndpoint.implementedByEjbComponent() ? "org.glassfish.webservices.EjbContainerPreHandler" : "org.glassfish.webservices.ServletPreHandler";
        preHandler.setHandlerClassName(handlerClassName);
        handlerInfoList.add(preHandler);
        // Collect all roles defined on each handler and set them on
        // handler chain. NOTE : There is a bit of a mismatch here between
        // 109 and JAXRPC.  JAXRPC only defines roles at the handler chain
        // level, whereas 109 descriptors put roles at the handler level.
        Collection soapRoles = new HashSet();
        for (Iterator hIter = handlerChain.iterator(); hIter.hasNext(); ) {
            WebServiceHandler nextHandler = (WebServiceHandler) hIter.next();
            HandlerInfo handlerInfo = createHandlerInfo(nextHandler);
            handlerInfoList.add(handlerInfo);
            soapRoles.addAll(nextHandler.getSoapRoles());
        }
        // Insert a container handler as the last element in the chain.
        HandlerInfo postHandler = rpcFactory.createHandlerInfo();
        handlerClassName = nextEndpoint.implementedByEjbComponent() ? "org.glassfish.webservices.EjbContainerPostHandler" : "org.glassfish.webservices.ServletPostHandler";
        postHandler.setHandlerClassName(handlerClassName);
        handlerInfoList.add(postHandler);
        // @@@ should probably use addHandler api instead once
        // == bug is fixed.
        modelHandlerChain.setHandlersList(handlerInfoList);
        for (Iterator roleIter = soapRoles.iterator(); roleIter.hasNext(); ) {
            modelHandlerChain.addRole((String) roleIter.next());
        }
    }
}
Also used : HandlerChainInfo(com.sun.xml.rpc.spi.tools.HandlerChainInfo) Port(com.sun.xml.rpc.spi.model.Port) ArrayList(java.util.ArrayList) WebServiceEndpoint(com.sun.enterprise.deployment.WebServiceEndpoint) Model(com.sun.xml.rpc.spi.model.Model) Iterator(java.util.Iterator) Collection(java.util.Collection) ArrayList(java.util.ArrayList) List(java.util.List) HandlerInfo(com.sun.xml.rpc.spi.tools.HandlerInfo) HashSet(java.util.HashSet) WebServiceHandler(com.sun.enterprise.deployment.WebServiceHandler)

Aggregations

HandlerInfo (com.sun.xml.rpc.spi.tools.HandlerInfo)2 Iterator (java.util.Iterator)2 NameValuePairDescriptor (com.sun.enterprise.deployment.NameValuePairDescriptor)1 WebServiceEndpoint (com.sun.enterprise.deployment.WebServiceEndpoint)1 WebServiceHandler (com.sun.enterprise.deployment.WebServiceHandler)1 Model (com.sun.xml.rpc.spi.model.Model)1 Port (com.sun.xml.rpc.spi.model.Port)1 HandlerChainInfo (com.sun.xml.rpc.spi.tools.HandlerChainInfo)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 QName (javax.xml.namespace.QName)1