Methods Summary |
---|
public java.lang.Object | getBusinessObject(java.lang.Class businessInterface)
return ((EJBContainer)container).getBusinessObject(baseContext, businessInterface);
|
public java.security.Identity | getCallerIdentity()
throw new IllegalStateException("deprecated");
|
public java.security.Principal | getCallerPrincipal()
Principal principal = SecurityAssociation.getCallerPrincipal();
if (getRm() != null)
{
principal = getRm().getPrincipal(principal);
}
// This method never returns null.
if (principal == null)
throw new java.lang.IllegalStateException("No valid security context for the caller identity");
return principal;
|
public Container | getContainer()
return container;
|
public javax.ejb.EJBHome | getEJBHome()
throw new EJBException("EJB 3.0 does not have a home type.");
|
public javax.ejb.EJBLocalHome | getEJBLocalHome()
throw new EJBException("EJB 3.0 does not have a home type.");
|
public javax.ejb.EJBLocalObject | getEJBLocalObject()
try
{
Object id = baseContext.getId();
EJBLocalObject proxy = (EJBLocalObject)((SessionContainer)container).createLocalProxy(id);
return proxy;
}
catch (Exception e)
{
throw new IllegalStateException(e);
}
|
public javax.ejb.EJBObject | getEJBObject()
try
{
Object id = baseContext.getId();
EJBObject proxy = (EJBObject)((SessionContainer)container).createRemoteProxy(id);
return proxy;
}
catch (Exception e)
{
throw new IllegalStateException(e);
}
|
public java.util.Properties | getEnvironment()
throw new EJBException("Deprecated");
|
public java.lang.Class | getInvokedBusinessInterface()
return ((SessionContainer)container).getInvokedBusinessInterface();
|
public javax.xml.rpc.handler.MessageContext | getMessageContext()
// disallowed for stateful session beans (EJB3 FR 4.4.1 p 81)
if(baseContext instanceof StatelessBeanContext)
{
MessageContext ctx = ((StatelessBeanContext) baseContext).getMessageContextJAXRPC();
if(ctx == null)
throw new IllegalStateException("No message context found");
return ctx;
}
throw new UnsupportedOperationException("Only stateless beans can have a message context");
|
protected org.jboss.security.RealmMapping | getRm()
return rm;
|
public boolean | getRollbackOnly()
// EJB1.1 11.6.1: Must throw IllegalStateException if BMT
TransactionManagementType type = TxUtil.getTransactionManagementType(((Advisor) getContainer()));
if (type != TransactionManagementType.CONTAINER)
throw new IllegalStateException("Container " + getContainer().getEjbName() + ": it is illegal to call getRollbackOnly from BMT: " + type);
try
{
TransactionManager tm = TxUtil.getTransactionManager();
// The getRollbackOnly and setRollBackOnly method of the SessionContext interface should be used
// only in the session bean methods that execute in the context of a transaction.
if (tm.getTransaction() == null)
throw new IllegalStateException("getRollbackOnly() not allowed without a transaction.");
// EJBTHREE-805, consider an asynchronous rollback due to timeout
int status = tm.getStatus();
return status == Status.STATUS_MARKED_ROLLBACK
|| status == Status.STATUS_ROLLING_BACK
|| status == Status.STATUS_ROLLEDBACK;
}
catch (SystemException e)
{
log.warn("failed to get tx manager status; ignoring", e);
return true;
}
|
public javax.ejb.TimerService | getTimerService()
return getContainer().getTimerService();
|
public javax.transaction.UserTransaction | getUserTransaction()
TransactionManagementType type = TxUtil.getTransactionManagementType(((Advisor) getContainer()));
if (type != TransactionManagementType.BEAN) throw new IllegalStateException("Container " + getContainer().getEjbName() + ": it is illegal to inject UserTransaction into a CMT bean");
return new UserTransactionImpl();
|
public boolean | isCallerInRole(java.security.Identity role)
throw new IllegalStateException("deprecated");
|
public boolean | isCallerInRole(java.lang.String roleName)
// TODO revert to aspects.security.SecurityContext impl when JBoss AOP 1.1 is out.
Principal principal = getCallerPrincipal();
// Check the caller of this beans run-as identity
// todo use priveleged stuff in ejb class
RunAsIdentity runAsIdentity = SecurityActions.peekRunAsIdentity(1);
if (principal == null && runAsIdentity == null)
return false;
if (getRm() == null)
{
String msg = "isCallerInRole() called with no security context. "
+ "Check that a security-domain has been set for the application.";
throw new IllegalStateException(msg);
}
// Ensure that you go through the security role references that may be configured
EJBContainer ejbc = (EJBContainer)container;
if(ejbc.getXml() != null)
{
Collection<SecurityRoleRef> securityRoleRefs = ejbc.getXml().getSecurityRoleRefs();
for(SecurityRoleRef roleRef: securityRoleRefs)
{
String refName = roleRef.getRoleName();
if(roleName.equals(refName))
roleName = roleRef.getRoleLink();
}
}
HashSet set = new HashSet();
set.add(new SimplePrincipal(roleName));
if (runAsIdentity == null)
return getRm().doesUserHaveRole(principal, set);
else
return runAsIdentity.doesUserHaveRole(set);
|
public java.lang.Object | lookup(java.lang.String name)
String newName;
if (name.startsWith("/"))
{
newName = "env" + name;
}
else
{
newName = "env/" + name;
}
try
{
return getContainer().getEnc().lookup(newName);
}
catch (NamingException ignored)
{
try
{
return getContainer().getInitialContext().lookup(name);
}
catch (NamingException ignored2)
{
}
}
return null;
|
public void | readExternal(java.io.ObjectInput in)
container = Ejb3Registry.getContainer(in.readUTF());
InitialContext ctx = container.getInitialContext();
try
{
setupSecurityDomain(container, ctx);
}
catch (NamingException e)
{
throw new RuntimeException(e);
}
|
public void | setBaseContext(BaseContext baseContext)
this.baseContext = baseContext;
|
public void | setContainer(Container container)
this.container = container;
try
{
InitialContext ctx = container.getInitialContext();
setupSecurityDomain(container, ctx);
}
catch (NamingException e)
{
throw new RuntimeException(e);
}
|
public void | setRollbackOnly()
// EJB1.1 11.6.1: Must throw IllegalStateException if BMT
TransactionManagementType type = TxUtil.getTransactionManagementType(((Advisor) getContainer()));
if (type != TransactionManagementType.CONTAINER) throw new IllegalStateException("Container " + getContainer().getEjbName() + ": it is illegal to call setRollbackOnly from BMT: " + type);
try
{
TransactionManager tm = TxUtil.getTransactionManager();
// The getRollbackOnly and setRollBackOnly method of the SessionContext interface should be used
// only in the session bean methods that execute in the context of a transaction.
if (tm.getTransaction() == null)
throw new IllegalStateException("setRollbackOnly() not allowed without a transaction.");
tm.setRollbackOnly();
}
catch (SystemException e)
{
log.warn("failed to set rollback only; ignoring", e);
}
|
private void | setupSecurityDomain(Container container, javax.naming.InitialContext ctx)
SecurityDomain securityAnnotation = (SecurityDomain) ((Advisor) container).resolveAnnotation(SecurityDomain.class);
if (securityAnnotation == null) return;
Object domain = SecurityDomainManager.getSecurityManager(securityAnnotation.value(), ctx);
rm = (RealmMapping) domain;
|
public void | writeExternal(java.io.ObjectOutput out)
out.writeUTF(container.getObjectName().getCanonicalName());
|