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;
}
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);
}
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;
}
}
}
}
}
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);
}
}
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;
}
}
Aggregations