Search in sources :

Example 36 with WebServiceEndpoint

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

the class PipeHelper method auditInvocation.

public void auditInvocation(Packet request, AuthStatus status) {
    if (auditManager.isAuditOn()) {
        String uri = null;
        if (!isEjbEndpoint && request != null && request.supports(MessageContext.SERVLET_REQUEST)) {
            HttpServletRequest httpServletRequest = (HttpServletRequest) request.get(MessageContext.SERVLET_REQUEST);
            uri = httpServletRequest.getRequestURI();
        }
        String endpointName = null;
        if (map != null) {
            WebServiceEndpoint endpoint = (WebServiceEndpoint) map.get(PipeConstants.SERVICE_ENDPOINT);
            if (endpoint != null) {
                endpointName = endpoint.getEndpointName();
            }
        }
        if (endpointName == null) {
            endpointName = "(no endpoint)";
        }
        if (isEjbEndpoint) {
            auditManager.ejbAsWebServiceInvocation(endpointName, AuthStatus.SUCCESS.equals(status));
        } else {
            auditManager.webServiceInvocation(((uri == null) ? "(no uri)" : uri), endpointName, AuthStatus.SUCCESS.equals(status));
        }
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) WebServiceEndpoint(com.sun.enterprise.deployment.WebServiceEndpoint)

Example 37 with WebServiceEndpoint

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

the class PipeHelper method processSunDeploymentDescriptor.

private boolean processSunDeploymentDescriptor() {
    if (factory == null) {
        return false;
    }
    MessageSecurityBindingDescriptor binding = AuthMessagePolicy.getMessageSecurityBinding(PipeConstants.SOAP_LAYER, map);
    if (binding != null) {
        if (!hasExactMatchAuthProvider()) {
            String jmacProviderRegisID = factory.registerConfigProvider(new GFServerConfigProvider(null, null), layer, appCtxt, "GF AuthConfigProvider bound by Sun Specific Descriptor");
            this.setJmacProviderRegisID(jmacProviderRegisID);
        }
    }
    WebServiceEndpoint e = (WebServiceEndpoint) map.get(PipeConstants.SERVICE_ENDPOINT);
    return (e == null ? false : e.implementedByEjbComponent());
}
Also used : MessageSecurityBindingDescriptor(com.sun.enterprise.deployment.runtime.common.MessageSecurityBindingDescriptor) GFServerConfigProvider(com.sun.enterprise.security.jmac.config.GFServerConfigProvider) WebServiceEndpoint(com.sun.enterprise.deployment.WebServiceEndpoint)

Example 38 with WebServiceEndpoint

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

the class PipeHelper method authorize.

public void authorize(Packet request) throws Exception {
    // SecurityContext constructor should set initiator to
    // unathenticated if Subject is null or empty
    Subject s = (Subject) request.invocationProperties.get(PipeConstants.CLIENT_SUBJECT);
    if (s == null || (s.getPrincipals().isEmpty() && s.getPublicCredentials().isEmpty())) {
        SecurityContext.setUnauthenticatedContext();
    } else {
        SecurityContext sC = new SecurityContext(s);
        SecurityContext.setCurrent(sC);
    }
    if (isEjbEndpoint) {
        if (invManager == null) {
            throw new RuntimeException(localStrings.getLocalString("enterprise.webservice.noEjbInvocationManager", "Cannot validate request : invocation manager null for EJB WebService"));
        }
        ComponentInvocation inv = (ComponentInvocation) invManager.getCurrentInvocation();
        // consumed
        if (ejbDelegate != null) {
            ejbDelegate.setSOAPMessage(request.getMessage(), inv);
        }
        Exception ie;
        Method m = null;
        if (seiModel != null) {
            JavaMethod jm = request.getMessage().getMethod(seiModel);
            m = (jm != null) ? jm.getMethod() : null;
        } else {
            // WebServiceProvider
            WebServiceEndpoint endpoint = (WebServiceEndpoint) map.get(PipeConstants.SERVICE_ENDPOINT);
            EjbDescriptor ejbDescriptor = endpoint.getEjbComponentImpl();
            if (ejbDescriptor != null) {
                final String ejbImplClassName = ejbDescriptor.getEjbImplClassName();
                if (ejbImplClassName != null) {
                    try {
                        m = (Method) AppservAccessController.doPrivileged(new PrivilegedExceptionAction() {

                            @Override
                            public Object run() throws Exception {
                                ClassLoader loader = Thread.currentThread().getContextClassLoader();
                                Class clazz = Class.forName(ejbImplClassName, true, loader);
                                return clazz.getMethod("invoke", new Class[] { Object.class });
                            }
                        });
                    } catch (PrivilegedActionException pae) {
                        throw new RuntimeException(pae.getException());
                    }
                }
            }
        }
        if (m != null) {
            if (ejbDelegate != null) {
                try {
                    if (!ejbDelegate.authorize(inv, m)) {
                        throw new Exception(localStrings.getLocalString("enterprise.webservice.methodNotAuth", "Client not authorized for invocation of {0}", new Object[] { m }));
                    }
                } catch (UnmarshalException e) {
                    String errorMsg = localStrings.getLocalString("enterprise.webservice.errorUnMarshalMethod", "Error unmarshalling method for ejb {0}", new Object[] { ejbName() });
                    ie = new UnmarshalException(errorMsg);
                    ie.initCause(e);
                    throw ie;
                } catch (Exception e) {
                    ie = new Exception(localStrings.getLocalString("enterprise.webservice.methodNotAuth", "Client not authorized for invocation of {0}", new Object[] { m }));
                    ie.initCause(e);
                    throw ie;
                }
            }
        }
    }
}
Also used : ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation) PrivilegedActionException(java.security.PrivilegedActionException) JavaMethod(com.sun.xml.ws.api.model.JavaMethod) Method(java.lang.reflect.Method) PrivilegedExceptionAction(java.security.PrivilegedExceptionAction) Subject(javax.security.auth.Subject) PrivilegedActionException(java.security.PrivilegedActionException) UnmarshalException(javax.xml.bind.UnmarshalException) AuthException(javax.security.auth.message.AuthException) WebServiceException(javax.xml.ws.WebServiceException) EjbDescriptor(com.sun.enterprise.deployment.EjbDescriptor) WebServiceEndpoint(com.sun.enterprise.deployment.WebServiceEndpoint) UnmarshalException(javax.xml.bind.UnmarshalException) ClientSecurityContext(com.sun.enterprise.security.common.ClientSecurityContext) SecurityContext(com.sun.enterprise.security.SecurityContext) JavaMethod(com.sun.xml.ws.api.model.JavaMethod)

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