users@glassfish.java.net

(Security Multi-user Client Problem) Bad remote CallerPrincipal when

From: <forums_at_java.net>
Date: Sun, 24 Mar 2013 08:29:01 -0500 (CDT)

Hi, I have a very annoying issue with my secured Glassfish 3.1.2. When I
connect 2 (or more) users from my EJB client, I am having always the last
connected user when I do this in my EJB:
sessionContext.getCallerPrincipal().getName(); Could you please give me a
help on this issue? Here is my client: public static void main(String[] args)
{ new Thread(new Runnable() { @Override public void run() {
connectUser("userA", "pwdB"); } }).start(); new Thread(new Runnable() {
@Override public void run() { connectUser("userB", "pwdB"); } }).start(); }
public static void connectUser(String userName, String password) { try {
ProgrammaticLogin login = new ProgrammaticLogin(); login.login(userName,
password.toCharArray()); Context context = new InitialContext();
ServiceRemote myService = (ServiceRemote) context.lookup("MyService"); String
remoteCaller = myService.getUserName(); System.out.println("Local is (" +
userName + "), Remote is (" + remoteCaller + ")"); } catch (Exception e) {
e.printStackTrace(); } } Here is my EJB: @Stateless(mappedName = "MyService",
name="MyServiceBean") public class MyServiceBean implements MyServiceRemote{
@Resource private SessionContext sessionContext; public MyServiceBean () {
super(); } @Override public String getUserName() { return
sessionContext.getCallerPrincipal().getName(); } }

--
[Message sent by forum member 'sam.ad']
View Post: http://forums.java.net/node/895893