Guest User

Untitled

a guest
Jul 20th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. Context ctx = new InitialContext();
  2. String userName = System.getProperty("user.name");
  3. ctx.addToEnvironment(Context.SECURITY_PRINCIPAL, userName);
  4.  
  5. @Resource
  6. EJBContext ctx;
  7.  
  8. // ...
  9.  
  10. String userName = ctx.getCallerPrincipal().getName();
  11.  
  12. java.lang.IllegalStateException: No valid security context for the caller identity
  13. at org.jboss.ejb3.EJBContextImpl.getCallerPrincipal(EJBContextImpl.java:143)
  14.  
  15. <application-policy name="simple">
  16. <authentication>
  17. <login-module code="org.jboss.security.auth.spi.SimpleServerLoginModule" flag="required" />
  18. </authentication>
  19. </application-policy>
Add Comment
Please, Sign In to add comment