Search in sources :

Example 51 with ComponentInvocation

use of org.glassfish.api.invocation.ComponentInvocation in project Payara by payara.

the class MessageBeanContainer method createComponentInvocation.

private ComponentInvocation createComponentInvocation() {
    EjbBundleDescriptor ejbBundleDesc = getEjbDescriptor().getEjbBundleDescriptor();
    ComponentInvocation newInv = new ComponentInvocation(getComponentId(), ComponentInvocation.ComponentInvocationType.SERVLET_INVOCATION, this, ejbBundleDesc.getApplication().getAppName(), ejbBundleDesc.getModuleName());
    // newInv.setJNDIEnvironment(getJNDIEnvironment());   ???
    return newInv;
}
Also used : EjbBundleDescriptor(com.sun.enterprise.deployment.EjbBundleDescriptor) ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation)

Example 52 with ComponentInvocation

use of org.glassfish.api.invocation.ComponentInvocation in project Payara by payara.

the class MessageBeanContextImpl method isCallerInRole.

public boolean isCallerInRole(String roleRef) {
    if (roleRef == null)
        throw new IllegalStateException("Argument is null");
    checkAccessToCallerSecurity();
    ComponentInvocation inv = EjbContainerUtilImpl.getInstance().getCurrentInvocation();
    if (inv instanceof EjbInvocation) {
        EjbInvocation ejbInv = (EjbInvocation) inv;
        if (ejbInv.isTimerCallback) {
            throw new IllegalStateException("isCallerInRole not allowed from timer callback");
        }
    } else {
        throw new IllegalStateException("not invoked from within a message-bean context");
    }
    com.sun.enterprise.security.SecurityManager sm = container.getSecurityManager();
    return sm.isCallerInRole(roleRef);
}
Also used : EjbInvocation(com.sun.ejb.EjbInvocation) ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation)

Example 53 with ComponentInvocation

use of org.glassfish.api.invocation.ComponentInvocation 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)

Example 54 with ComponentInvocation

use of org.glassfish.api.invocation.ComponentInvocation in project Payara by payara.

the class JavaEETransactionManagerSimplified method unregisterComponentResource.

public void unregisterComponentResource(TransactionalResource h) {
    if (_logger.isLoggable(Level.FINE)) {
        _logger.log(Level.FINE, "\n\nIn JavaEETransactionManagerSimplified.unregisterComponentResource, h=" + h + " h.xares=" + h.getXAResource());
    }
    Object instance = h.getComponentInstance();
    if (instance == null)
        return;
    h.setComponentInstance(null);
    ComponentInvocation inv = invMgr.getCurrentInvocation();
    List l = getExistingResourceList(instance, inv);
    if (l != null) {
        l.remove(h);
    }
}
Also used : ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation)

Example 55 with ComponentInvocation

use of org.glassfish.api.invocation.ComponentInvocation in project Payara by payara.

the class UserTransactionImpl method begin.

public void begin() throws NotSupportedException, SystemException {
    if (!initialized)
        init();
    if (userTx != null) {
        userTx.begin();
        return;
    }
    ComponentInvocation inv = invocationManager.getCurrentInvocation();
    if (inv != null) {
        checkUserTransactionMethodAccess(inv);
    }
    transactionManager.begin();
    try {
        if (inv != null) {
            TransactionOperationsManager toMgr = (TransactionOperationsManager) inv.getTransactionOperationsManager();
            if (toMgr != null)
                toMgr.doAfterUtxBegin();
            inv.setTransaction(transactionManager.getTransaction());
            transactionManager.enlistComponentResources();
        }
    } catch (RemoteException ex) {
        _logger.log(Level.SEVERE, "enterprise_distributedtx.excep_in_utx_begin", ex);
        SystemException sysEx = new SystemException(ex.getMessage());
        sysEx.initCause(ex);
        throw sysEx;
    }
}
Also used : ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation) TransactionOperationsManager(com.sun.enterprise.transaction.spi.TransactionOperationsManager) RemoteException(java.rmi.RemoteException)

Aggregations

ComponentInvocation (org.glassfish.api.invocation.ComponentInvocation)67 InvocationManager (org.glassfish.api.invocation.InvocationManager)13 JndiNameEnvironment (com.sun.enterprise.deployment.JndiNameEnvironment)8 EjbInvocation (com.sun.ejb.EjbInvocation)7 InvocationException (org.glassfish.api.invocation.InvocationException)7 SecurityContext (com.sun.enterprise.security.SecurityContext)6 WebModule (com.sun.enterprise.web.WebModule)6 PoolingException (com.sun.appserv.connectors.internal.api.PoolingException)5 InjectionException (com.sun.enterprise.container.common.spi.util.InjectionException)5 WebComponentInvocation (com.sun.enterprise.web.WebComponentInvocation)5 BundleDescriptor (com.sun.enterprise.deployment.BundleDescriptor)4 EjbDescriptor (com.sun.enterprise.deployment.EjbDescriptor)4 WebBundleDescriptor (com.sun.enterprise.deployment.WebBundleDescriptor)4 JavaEETransactionManager (com.sun.enterprise.transaction.api.JavaEETransactionManager)4 RemoteException (java.rmi.RemoteException)4 EJBInvocation (org.glassfish.ejb.api.EJBInvocation)4 ArrayList (java.util.ArrayList)3 NamingException (javax.naming.NamingException)3 WeldBootstrap (org.jboss.weld.bootstrap.WeldBootstrap)3 BeanDeploymentArchive (org.jboss.weld.bootstrap.spi.BeanDeploymentArchive)3