Search in sources :

Example 1 with WebServiceEndpoint

use of com.sun.enterprise.deployment.WebServiceEndpoint in project Payara by payara.

the class AuthMessagePolicy method getMessageSecurityBinding.

public static MessageSecurityBindingDescriptor getMessageSecurityBinding(String layer, Map<String, ?> properties) {
    if (properties == null) {
        return null;
    }
    MessageSecurityBindingDescriptor binding = null;
    WebServiceEndpoint e = (WebServiceEndpoint) properties.get("SERVICE_ENDPOINT");
    if (e != null) {
        binding = e.getMessageSecurityBinding();
    } else {
        ServiceReferenceDescriptor s = (ServiceReferenceDescriptor) properties.get("SERVICE_REF");
        if (s != null) {
            WebServicesDelegate delegate = Globals.get(WebServicesDelegate.class);
            if (delegate != null) {
                binding = delegate.getBinding(s, properties);
            }
        }
    }
    if (binding != null) {
        String bindingLayer = binding.getAttributeValue(MessageSecurityBindingDescriptor.AUTH_LAYER);
        if (bindingLayer == null || layer.equals(bindingLayer)) {
            return binding;
        }
    }
    return null;
}
Also used : MessageSecurityBindingDescriptor(com.sun.enterprise.deployment.runtime.common.MessageSecurityBindingDescriptor) WebServiceEndpoint(com.sun.enterprise.deployment.WebServiceEndpoint) ServiceReferenceDescriptor(com.sun.enterprise.deployment.ServiceReferenceDescriptor)

Example 2 with WebServiceEndpoint

use of com.sun.enterprise.deployment.WebServiceEndpoint in project Payara by payara.

the class PipeHelper method getHandlerContext.

@Override
protected HandlerContext getHandlerContext(Map map) {
    String realmName = null;
    WebServiceEndpoint wSE = (WebServiceEndpoint) map.get(PipeConstants.SERVICE_ENDPOINT);
    if (wSE != null) {
        Application app = wSE.getBundleDescriptor().getApplication();
        if (app != null) {
            realmName = app.getRealm();
        }
        if (realmName == null) {
            realmName = wSE.getRealm();
        }
    }
    final String fRealmName = realmName;
    return new HandlerContext() {

        @Override
        public String getRealmName() {
            return fRealmName;
        }
    };
}
Also used : WebServiceEndpoint(com.sun.enterprise.deployment.WebServiceEndpoint) HandlerContext(com.sun.enterprise.security.jmac.config.HandlerContext) Application(com.sun.enterprise.deployment.Application)

Example 3 with WebServiceEndpoint

use of com.sun.enterprise.deployment.WebServiceEndpoint in project Payara by payara.

the class PipeHelper method getAppCtxt.

private static String getAppCtxt(Map map) {
    String rvalue;
    WebServiceEndpoint wse = (WebServiceEndpoint) map.get(PipeConstants.SERVICE_ENDPOINT);
    // endpoint
    if (wse != null) {
        rvalue = getServerName(wse) + " " + getEndpointURI(wse);
    // client reference
    } else {
        ServiceReferenceDescriptor srd = (ServiceReferenceDescriptor) map.get(PipeConstants.SERVICE_REF);
        rvalue = getClientModuleID(srd) + " " + getRefName(srd, map);
    }
    return rvalue;
}
Also used : WebServiceEndpoint(com.sun.enterprise.deployment.WebServiceEndpoint) ServiceReferenceDescriptor(com.sun.enterprise.deployment.ServiceReferenceDescriptor)

Example 4 with WebServiceEndpoint

use of com.sun.enterprise.deployment.WebServiceEndpoint 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)

Example 5 with WebServiceEndpoint

use of com.sun.enterprise.deployment.WebServiceEndpoint in project Payara by payara.

the class WsCompile method doServicePostProcessing.

private void doServicePostProcessing() {
    Model model = wscompile.getProcessor().getModel();
    Collection endpoints = webService.getEndpoints();
    for (Iterator iter = endpoints.iterator(); iter.hasNext(); ) {
        WebServiceEndpoint next = (WebServiceEndpoint) iter.next();
        Service service = wsUtil.getServiceForPort(model, next.getWsdlPort());
        if (service == null) {
            service = (Service) model.getServices().next();
            System.out.println("Warning : Can't find Service for Endpoint '" + next.getEndpointName() + "' Port '" + next.getWsdlPort() + "'");
            System.out.println("Defaulting to " + service.getName());
        }
        QName serviceName = service.getName();
        next.setServiceNamespaceUri(serviceName.getNamespaceURI());
        next.setServiceLocalPart(serviceName.getLocalPart());
        Port port = wsUtil.getPortFromModel(model, next.getWsdlPort());
        if (port == null) {
            String msg = "Can't find model port for endpoint " + next.getEndpointName() + " with wsdl-port " + next.getWsdlPort();
            throw new IllegalStateException(msg);
        }
        // If port has a tie class name property, use it.  Otherwise,
        // use naming convention to derive tie class name.  If there
        // are multiple ports per SEI(binding), then the property then
        // the TIE_CLASS_NAME property will be available.  In that case,
        // a separate tie and stub are generated per port.
        String tieClassName = (String) port.getProperty(ModelProperties.PROPERTY_TIE_CLASS_NAME);
        if (tieClassName == null) {
            tieClassName = next.getServiceEndpointInterface() + "_Tie";
        }
        next.setTieClassName(tieClassName);
        if (next.implementedByWebComponent()) {
            wsUtil.updateServletEndpointRuntime(next);
        } else {
            wsUtil.validateEjbEndpoint(next);
        }
        String endpointAddressUri = next.getEndpointAddressUri();
        if (endpointAddressUri == null) {
            String msg = "Endpoint address uri must be set for endpoint " + next.getEndpointName();
            throw new IllegalStateException(msg);
        } else if (endpointAddressUri.indexOf('*') >= 0) {
            String msg = "Endpoint address uri " + endpointAddressUri + " for endpoint " + next.getEndpointName() + " is invalid. It must not contain the '*' character";
            throw new IllegalStateException(msg);
        } else if (endpointAddressUri.endsWith("/")) {
            String msg = "Endpoint address uri " + endpointAddressUri + " for endpoint " + next.getEndpointName() + " is invalid. It must not end with '/'";
            throw new IllegalStateException(msg);
        }
    }
}
Also used : WebServiceEndpoint(com.sun.enterprise.deployment.WebServiceEndpoint) QName(javax.xml.namespace.QName) Port(com.sun.xml.rpc.spi.model.Port) Model(com.sun.xml.rpc.spi.model.Model) Iterator(java.util.Iterator) Collection(java.util.Collection) Service(com.sun.xml.rpc.spi.model.Service) WebService(com.sun.enterprise.deployment.WebService)

Aggregations

WebServiceEndpoint (com.sun.enterprise.deployment.WebServiceEndpoint)38 ServiceReferenceDescriptor (com.sun.enterprise.deployment.ServiceReferenceDescriptor)7 WebServicesDescriptor (com.sun.enterprise.deployment.WebServicesDescriptor)7 EjbDescriptor (com.sun.enterprise.deployment.EjbDescriptor)6 WebService (com.sun.enterprise.deployment.WebService)6 Iterator (java.util.Iterator)6 Collection (java.util.Collection)5 EjbBundleDescriptor (com.sun.enterprise.deployment.EjbBundleDescriptor)4 WebBundleDescriptor (com.sun.enterprise.deployment.WebBundleDescriptor)4 MessageSecurityBindingDescriptor (com.sun.enterprise.deployment.runtime.common.MessageSecurityBindingDescriptor)4 URL (java.net.URL)4 ArrayList (java.util.ArrayList)4 ServiceRefPortInfo (com.sun.enterprise.deployment.ServiceRefPortInfo)3 HandlerChainContainer (com.sun.enterprise.deployment.types.HandlerChainContainer)3 IOException (java.io.IOException)3 Application (com.sun.enterprise.deployment.Application)2 BundleDescriptor (com.sun.enterprise.deployment.BundleDescriptor)2 WebComponentDescriptor (com.sun.enterprise.deployment.WebComponentDescriptor)2 WebServiceHandler (com.sun.enterprise.deployment.WebServiceHandler)2 SecurityContext (com.sun.enterprise.security.SecurityContext)2