ejb@glassfish.java.net

Re: How to access a secure EJB from stand-alone client

From: Kenneth Saks <Kenneth.Saks_at_Sun.COM>
Date: Thu, 06 Dec 2007 12:41:27 -0500

Eve Pokua wrote:
> Hi,
>
> If it is just testing and you need it quick. Then do something like this:
Hi Eve,

You're right that the mapped name can be used to specify the global JNDI
name that is looked up from the client. In this case, though, the
problem is not finding the appropriate Remote EJB. The problem is that
the Remote EJB has methods that only allow access from specific roles.
That means the client must be authenticated such that its principal
belongs to one of those roles.

If the client code were running in either a Java EE Web Container or
Application Client container, authentication would happen automatically
and the principal would be propagated along with the Remote call. Since
the code is just a plain Java SE stand-alone client, it doesn't have the
standard EE services such as authentication. One of the many reasons
to use an Application Client :-)

We do have a proprietary API for forcing authentication in the client,
which is what Abhijit is using instead.

 --ken

 
>
> Provide a name and mappedNamed for the Bean as below:
>
>
> @Stateful(name="itemdetails", mappedName="IteamdetailsBeanJNDI")
>
> public class IteamdetailsBean implements Iteamdetails{
>
>
> ..................}
>
> This' information is used by the descriptor for access for the client.
>
> In the client:
>
> try{
> InitialContext ctx=new InitialContext();
> Iteamdetails
> iteamdetails=(Iteamdetails)ctx.lookup("IteamdetailsBeanJNDI");
>
>
> .................
>
> iteamdetails is the remote interface.
>
>
> That should work.
>
> eve
>
>
>
>
>
> > From: abhijit.sarcar_at_gmail.com
> > To: Kenneth.Saks_at_Sun.COM
> > CC: ejb_at_glassfish.dev.java.net
> > Date: Thu, 6 Dec 2007 22:44:00 +0530
> > Subject: RE: How to access a secure EJB from stand-alone client
> >
> > Hi,
> >
> > Thanks for the reply. I was using an App client but it needed to be
> built
> > and deployed whenever changed. For faster testing, I resorted to a
> > standalone client.
> >
> > I'm currently trying JAAS login using
> > com.sun.appserv.security.AppservPasswordLoginModule class.
> >
> > Getting the error-
> > "java.util.MissingResourceException: Can't find resource for bundle
> > sun.security.util.Resources, key unable to instantiate LoginModule:"
> >
> > Pls help.
> >
> > Regards,
> > Abhijit
> >
> > -----Original Message-----
> > From: Kenneth.Saks_at_Sun.COM [mailto:Kenneth.Saks_at_Sun.COM]
> > Sent: Thursday, December 06, 2007 8:05 PM
> > To: ejb_at_glassfish.dev.java.net; abhijit.sarcar_at_gmail.com
> > Subject: Re: How to access a secure EJB from stand-alone client
> >
> > Abhijit Sarkar wrote:
> > >
> > > Hi,
> > >
> > > I'm getting the below exception when trying to access a secure EJB
> > > (3.0). I'm using SJSAS 9.1 and EJB 3.0:
> > >
> > Hi Abhijit,
> >
> > This means the caller does not have the appropriate permissions to
> > invoke the method. This is one of the portability problems with
> > stand-alone clients. There is no portable client authentication API in
> > Java EE. Your best bet is to write a Java EE Application Client
> > component. When you run it, the Application Client Container will
> > automatically perform the authentication. See the following entry in
> our
> > EJB FAQ :
> >
> > https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html#AppClientDef
> > >
> > > init:
> > >
> > > deps-jar:
> > >
> > > compile-single:
> > >
> > > run-single:
> > >
> > > javax.naming.NamingException: ejb ref resolution error for remote
> > > business interface <package name>.UserServiceRemote [Root
> exception is
> > > java.rmi.AccessException: CORBA NO_PERMISSION 0 No; nested
> exception is:
> > >
> > > org.omg.CORBA.NO_PERMISSION: ----------BEGIN server-side stack
> > > trace----------
> > >
> > > org.omg.CORBA.NO_PERMISSION: vmcid: 0x0 minor code: 0 completed: No
> > >
> > > at
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: ejb-unsubscribe_at_glassfish.dev.java.net
> > For additional commands, e-mail: ejb-help_at_glassfish.dev.java.net
> >
>
> ------------------------------------------------------------------------
> The next generation of MSN Hotmail has arrived - Windows Live Hotmail
> <http://www.newhotmail.co.uk>