// if ejb call EJBSecurityManager, for servlet call RealmAdapter
if (invType == inv.EJB_INVOCATION) {
SecurityManager sm =
((Container)inv.getContainerContext()).getSecurityManager();
sm.preInvoke(inv);
} else if (invType == inv.SERVLET_INVOCATION){
Realm rlm = ((Context)inv.getContainerContext()).getRealm();
if (rlm instanceof RealmAdapter) {
RealmAdapter rad = (RealmAdapter) rlm;
rad.preSetRunAsIdentity(inv);