The "linking" can be done in several ways.
You can link this information in an external map via:
@Override
public boolean canHandshake(BayeuxServer server, ServerSession session, ServerMessage message)
{
...
Map<String, Object> authentication = ...;
map.put((String)authentication.get("userName"), session);
...
}
where the map
can be a java.util.ConcurrentHashMap<String, ServerSession>
field in the security policy itself, or in another object such as a user service.
For simpler use cases, the userName
can be linked directly to the session in this way:
session.setAttribute("userName", authentication.get("userName"));
Or you can use both techniques.
This is the updated link for the authentication how-to, and you can find the latest comprehensive CometD documentation at http://docs.cometd.org.