Multiple choice technology architecture

What method can be used to help programmatically determine the caller’s identity within enterprise bean code?

  1. getIdentity()

  2. getCallerPrincipal()

  3. getCallerIdentity()

  4. getUserId()

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

EJBContext.getCallerPrincipal() is the standard EJB API method to retrieve the caller's identity (as a java.security.Principal object) within enterprise bean code. This works in both session and entity beans. getIdentity(), getCallerIdentity(), and getUserId() are not standard EJBContext methods.