For a Servlet to get the Principal
of a web user, he will call HttpServletRequest#getUserPrincipal()
. According to the docs, this method will return null
if the user has not authenticated himself. Makes sense.
If an enterprise java bean (EJB) want to get the Principal of a user, he will make a call to EJBContext#getCallerPrincipal()
. However, according to the docs, this method never returns null.