users@glassfish.java.net

Re: EJB, Realms and Remote Clients

From: <glassfish_at_javadesktop.org>
Date: Sun, 03 Jan 2010 12:22:42 PST

Hi,

sorry for hijacking this thread, but it seems answered and I have a similar problem.

In your example, wouldn't you need to add the security.jar to the classpath as well? I tried with various jars, but I can't get it to work.

I already started a different thread. Maybe we can continue the discussion there. It would be great if you could help me with that:
http://forums.java.net/jive/thread.jspa?threadID=71444&tstart=15

>
> But you can still authenticate standalone Java
> applications to Glassfish v3 server with its
> propietary
> "com.sun.appserv.security.ProgrammaticLogin" class
> (provided in "GF_HOME/glassfish/modules/security.jar"
> library). For example:
>
> [code]
> ...
> import com.sun.appserv.security.ProgrammaticLogin;
> ...
> //
> System.setProperty("java.security.auth.login.config",
> "./auth.conf");
> ProgrammaticLogin programmaticLogin = new
> ProgrammaticLogin();
> programmaticLogin.login("Dave", "password");
>
> InitialContext ctx = new InitialContext();
> BusinessInterfaceRemote bean =
> (BusinessInterfaceRemote)
> ctx.lookup("java:global/StDavidEEA/StDavidEJB-ejb/Busi
> nessInterface'");
>
> bean.methodCall1();
> bean.methodCall2();
>
> programmaticLogin.logout();
> ...
> [/code]
>
>
> The ProgrammaticLogin class requires a "JAAS login
> configuration file" in the client application, with a
> "default" login module for user/password
> authentication (independently of the realm name of
> the remote EJB). For example, create a file with the
> name "auth.conf" with the content:
>
> [code]
> default {
>
> om.sun.enterprise.security.auth.login.ClientPasswordLo
> ginModule required debug=false;
> };
> [/code]
>
> And finally, set the
> "java.security.auth.login.config" system property
> with the correct "auth.conf" file path. For example,
> in the application code (as commented before), or in
> the java command line:
>
> [code]
> $ java -Djava.security.auth.login.config=./auth.conf
> -cp
> $GF_HOME/glassfish/modules/gf-client.jar:TheApplicatio
> n.jar TheApplicationMainClassName
> [/code]
>
> Good luck.
[Message sent by forum member 'puce' (fbrunnerreg_at_gmx.ch)]

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