users@glassfish.java.net

Glassfish security - user session linked with database

From: <glassfish_at_javadesktop.org>
Date: Tue, 21 Sep 2010 16:43:04 PDT

Ok, I've trying to figure this out by myself, but I can't do it, and can't find the proper keywords to find an answer on google.

Users have profile and their data is stored in a table with id, login, password, email, adresse, description. My declarative security works, all my user protected page needs the user to be authenticated to see its content. I can also display the users login with request.getUserPrincial().getName() in a jsp. The get request.isUserInRole() doesn't work and always display false. Wich is kinda weird.

So, i'd like that when my user is logged in, it displays its own user information queried from my mysql databse. I could do this with getUserPrincipal().getName() use some SQL query in my jsp and find the table of the corresponding login and then print the description, email...etc. But using this technique just seems dirty and not Java like.

Im sure there is some way to link the current secured session with an persistent object. I was thinking a stateful session bean that uses JPA to get the data... I just cant find the proper pattern or model to follow to build this. All this java theory can get complicated and would like to get clues where to align myself to do this. Google has failed helping me. I thought using programmatic login, but I cant find a good java ee 6 tutorial.

Thanks, sorry if this sound messed up. But it is in my head.
[Message sent by forum member 'guiomie']

http://forums.java.net/jive/thread.jspa?messageID=483287