Index: EJBContextHelper.java =================================================================== --- EJBContextHelper.java (revision 96635) +++ EJBContextHelper.java (working copy) @@ -64,15 +64,8 @@ Principal callerPrincipal = null; - if(sc == null) + if(sc != null) { - String unauth = domain.unauthenticatedPrincipal(); - if(unauth != null && unauth.length() > 0) - if(domain.unauthenticatedPrincipal() != null) - callerPrincipal = new SimplePrincipal(unauth); - } - else - { AbstractEJBAuthorizationHelper helper; try { @@ -83,23 +76,25 @@ { throw new RuntimeException(e); } - callerPrincipal = helper.getCallerPrincipal(); - } - - if(callerPrincipal == null) - { - //try the incoming principal - callerPrincipal = sc.getUtil().getUserPrincipal(); - if(rm != null) - callerPrincipal = rm.getPrincipal(callerPrincipal); + callerPrincipal = helper.getCallerPrincipal(); + + if(callerPrincipal == null) + { + //try the incoming principal + callerPrincipal = sc.getUtil().getUserPrincipal(); + if(rm != null) + callerPrincipal = rm.getPrincipal(callerPrincipal); + } } if(callerPrincipal == null) { - String unauth = domain.unauthenticatedPrincipal(); - if(unauth != null && unauth.length() > 0) - if(domain.unauthenticatedPrincipal() != null) - callerPrincipal = new SimplePrincipal(unauth); + if(domain != null) + { + String unauth = domain.unauthenticatedPrincipal(); + if(unauth != null && unauth.length() > 0) + callerPrincipal = new SimplePrincipal(unauth); + } } return callerPrincipal; }