use of org.glassfish.api.invocation.ComponentInvocation in project Payara by payara.
the class ContextSetupProviderImpl method createComponentInvocation.
private ComponentInvocation createComponentInvocation(ComponentInvocation currInv) {
ComponentInvocation newInv = currInv.clone();
newInv.setResourceTableKey(null);
newInv.instance = currInv.getInstance();
if (!naming) {
newInv.setJNDIEnvironment(null);
}
return newInv;
}
use of org.glassfish.api.invocation.ComponentInvocation in project Payara by payara.
the class ContextSetupProviderImpl method saveContext.
@Override
public ContextHandle saveContext(ContextService contextService, Map<String, String> contextObjectProperties) {
// Capture the current thread context
ClassLoader contextClassloader = null;
SecurityContext currentSecurityContext = null;
ComponentInvocation savedInvocation = null;
if (classloading) {
contextClassloader = Utility.getClassLoader();
}
if (security) {
currentSecurityContext = SecurityContext.getCurrent();
}
ComponentInvocation currentInvocation = invocationManager.getCurrentInvocation();
if (currentInvocation != null) {
savedInvocation = createComponentInvocation(currentInvocation);
}
boolean useTransactionOfExecutionThread = transactionManager == null && useTransactionOfExecutionThread(contextObjectProperties);
// TODO - support workarea propagation
return new InvocationContext(savedInvocation, contextClassloader, currentSecurityContext, useTransactionOfExecutionThread);
}
use of org.glassfish.api.invocation.ComponentInvocation in project Payara by payara.
the class EjbNamingReferenceManagerImpl method getEJBContextObject.
public Object getEJBContextObject(String contextType) {
ComponentInvocation currentInv = invMgr.getCurrentInvocation();
if (currentInv == null) {
throw new IllegalStateException("no current invocation");
} else if (currentInv.getInvocationType() != ComponentInvocation.ComponentInvocationType.EJB_INVOCATION) {
throw new IllegalStateException("Illegal invocation type for EJB Context : " + currentInv.getInvocationType());
}
EjbInvocation ejbInv = (EjbInvocation) currentInv;
Object returnObject = ejbInv.context;
if (contextType.equals("javax.ejb.TimerService")) {
if (EJBTimerService.getEJBTimerService() == null) {
throw new IllegalStateException("EJB Timer Service not " + "available");
}
returnObject = new EJBTimerServiceWrapper(EJBTimerService.getEJBTimerService(), (EJBContextImpl) ejbInv.context);
}
return returnObject;
}
use of org.glassfish.api.invocation.ComponentInvocation in project Payara by payara.
the class SecurityMechanismSelector method selectSecurityContext.
/**
* Select the security context to be used by the CSIV2 layer based on whether the current component
* is an application client or a web/EJB component.
*/
public SecurityContext selectSecurityContext(IOR ior) throws InvalidIdentityTokenException, InvalidMechanismException, SecurityMechanismException {
SecurityContext context = null;
ConnectionContext cc = new ConnectionContext();
// print CSIv2 mechanism definition in IOR
if (traceIORs()) {
_logger.info("\nCSIv2 Mechanism List:" + getSecurityMechanismString(ctc, ior));
}
getSSLPort(ior, cc);
setClientConnectionContext(cc);
CompoundSecMech mechanism = cc.getMechanism();
if (mechanism == null) {
return null;
}
boolean sslUsed = cc.getSSLUsed();
boolean clientAuthOccurred = cc.getSSLClientAuthenticationOccurred();
// Standalone client
if (isNotServerOrACC()) {
context = getSecurityContextForAppClient(null, sslUsed, clientAuthOccurred, mechanism);
return context;
}
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "SSL used:" + sslUsed + " SSL Mutual auth:" + clientAuthOccurred);
}
ComponentInvocation ci = null;
/*
* // BEGIN IASRI# 4646060 ci = invMgr.getCurrentInvocation(); if (ci == null) { // END IASRI#
* 4646060 return null; } Object obj = ci.getContainerContext();
*/
if (isACC()) {
context = getSecurityContextForAppClient(ci, sslUsed, clientAuthOccurred, mechanism);
} else {
context = getSecurityContextForWebOrEJB(ci, sslUsed, clientAuthOccurred, mechanism);
}
return context;
}
use of org.glassfish.api.invocation.ComponentInvocation in project Payara by payara.
the class EJBSecurityManager method isCallerInRole.
/**
* This method returns a boolean value indicating whether or not the
* caller is in the specified role.
*
* @param role role name in the form of java.lang.String
* @return A boolean true/false depending on whether or not the caller
* has the specified role.
*/
public boolean isCallerInRole(String role) {
/* In case of Run As - Should check isCallerInRole with
* respect to the old security context.
*/
boolean ret = false;
if (_logger.isLoggable(Level.FINE)) {
_logger.entering("EJBSecurityManager", "isCallerInRole", role);
}
EJBRoleRefPermission ejbrr = new EJBRoleRefPermission(ejbName, role);
SecurityContext sc;
if (runAs != null) {
ComponentInvocation ci = invMgr.getCurrentInvocation();
sc = (SecurityContext) ci.getOldSecurityContext();
} else {
sc = SecurityContext.getCurrent();
}
Set principalSet = (sc != null) ? sc.getPrincipalSet() : null;
ProtectionDomain prdm = getCachedProtectionDomain(principalSet, true);
String oldContextId = null;
try {
// set the policy context in the TLS.
oldContextId = setPolicyContext(this.contextId);
ret = policy.implies(prdm, ejbrr);
} catch (SecurityException se) {
_logger.log(Level.SEVERE, "jacc_is_caller_in_role_exception", se);
ret = false;
} catch (Throwable t) {
_logger.log(Level.SEVERE, "jacc_is_caller_in_role_exception", t);
ret = false;
} finally {
try {
resetPolicyContext(oldContextId, this.contextId);
} catch (Throwable ex) {
_logger.log(Level.SEVERE, "jacc_policy_context_exception", ex);
ret = false;
}
}
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("JACC: isCallerInRole Result: " + ret + " EJBRoleRefPermission (Name) = " + ejbrr.getName() + " (Action) = " + ejbrr.getActions() + " (Codesource) = " + prdm.getCodeSource());
}
return ret;
}
Aggregations