3

I have a web socket defined using standard annotation like so

@ServerEndpoint("/mySocket")
@Singleton
public class myWebsocket {

@Inject
private MyEjb myEjb;

@OnMessage
public void message(Session session, String msg) { ...

Even though my user has logged in, I get access exceptions when calling myEjb because it doesn't recognize my user. If I check the principal of my session object

session.getUserPrincipal().getName()

the correct user is found, however, if I check the jboss SecurityContext class, I see an anonymous user

Chris Pike
  • 272
  • 2
  • 10

1 Answers1

2

This is a known deficiency in Java EE 7 WebSocket specification, see the following issue in their bug-tracker.

However, there is a workaround available, see the JBoss Security Extended project and this example.

mrts
  • 16,697
  • 8
  • 89
  • 72