EJB Security Context Problems
cfrostrun Sep 30, 2002 7:26 PMI'm teaching myself the ejb method security implementation, and I'm
running into problems.... Perhaps somebody has the answer.
I don't believe I have something setup correctly: I call this method
from w/in all the methods I want to lock down. It is always throwing
the exception b/c the isCallerInRole is false;
private void security(String methodName)throws LDIException{
LDILogger.info(methodName);
if(requiredRole==null){
LDILogger.warn(methodName);
throw new LDIException("required role is not
set", IExceptionCodes.ROLE_NOT_SET);
}
if(ctx==null){
LDILogger.warn("Context is Null");
}
if(!ctx.isCallerInRole(requiredRole)){
LDILogger.warn(methodName);
throw new LDIException("Access to Enterprise
Resource Denied: EJB Security", IExceptionCodes.EJB_SECURITY);
}
}
If i add this line before the if clause, i get an exception:
LDILogger.info(ctx.getCallerPrincipal().getName());
exception reads:
Embedded Exception
No security context set; nested exception is:
javax.ejb.EJBException: null
Embedded Exception
No security context set
Here's my ejb-jar.xml file:
<ejb-jar>
<enterprise-beans>
<ejb-name>security/UserManager</ejb-name>
com.LiquidDataInc.ejb.security.UserManagerHome
com.LiquidDataInc.ejb.security.UserManager
<ejb-class>com.LiquidDataInc.ejb.security.UserManagerBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Bean</transaction-type>
</enterprise-beans>
<assembly-descriptor>
<security-role>
System Administrators, Full Access
<role-name>SYS_ADMIN</role-name>
</security-role>
<method-permission>
<role-name>SYS_ADMIN</role-name>
<ejb-name>security/UserManager</ejb-name>
<method-intf>Remote</method-intf>
<method-name>load</method-name>
<method-params>
<method-param>long</method-param>
</method-params>
<ejb-name>security/UserManager</ejb-name>
<method-intf>Remote</method-intf>
<method-name>store</method-name>
<method-params>
<method-param></method-param>
</method-params>
<ejb-name>security/UserManager</ejb-name>
<method-intf>Remote</method-intf>
<method-name>getSearchResults</method-name>
<method-params>
<method-param>java.util.HashMap</method-param>
</method-params>
</method-permission>
</assembly-descriptor>
</ejb-jar>
So can somebody help me?
TIA,
Chris