{
EJBContainer ec = (EJBContainer) container;
Principal callerPrincipal = null;
RealmMapping rm = container.getSecurityManager(RealmMapping.class);
SecurityContext sc = SecurityContextAssociation.getSecurityContext();
if(sc == null)
{
SecurityDomain domain =(SecurityDomain)ec.resolveAnnotation(SecurityDomain.class);
String unauth = domain.unauthenticatedPrincipal();
if(unauth != null && unauth.length() > 0)
if(domain.unauthenticatedPrincipal() != null)
callerPrincipal = new SimplePrincipal(unauth);
}
else
{
EJBAuthorizationHelper helper = new EJBAuthorizationHelper(sc);
callerPrincipal = helper.getCallerPrincipal(rm);
}
if(callerPrincipal == null)
{
//try the incoming principal
callerPrincipal = sc.getUtil().getUserPrincipal();
if(rm != null)
callerPrincipal = rm.getPrincipal(callerPrincipal);
}
if(callerPrincipal == null)
{
SecurityDomain domain =(SecurityDomain)ec.resolveAnnotation(SecurityDomain.class);