Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How do I get the the subject/ principals in the EJB?

0 views
Skip to first unread message

Harish Murthy

unread,
Jan 8, 2002, 5:16:26 PM1/8/02
to
Hi,

Im using weblogic server 6.1.
Now, at the Client side , I get the subject in the login()
Code -> Environment env = new Environment();
env.setProviderUrl(url);
env.setSecurityPrincipal(username); // username --> joeuser
env.setSecurityCredentials(password);
Authenticate.authenticate(env, subject);

In the commit() of the login module , I add *another* principal
Code ->
userPrincipal = new SamplePrincipal("scott"); //username--> "scott"
subject.getPrincipals().add(userPrincipal);

#1 How do i get the Subject in the EJB , as when I try
Subject.getSubject(java.security.AccessController.getContext() ??
I always get the SecurityException("Method not found") in my runs.
I looked thru the Subject bundled with Weblogic,and it alwaysit throws
a
NullPointerException or a SecurityException..

#2 When I call getCallerPrincipal() , I always get the
Principal set as part of the env.setSecurityPrincipal(username); ..
Now, how do I get the other principals( "scott") linked with the
caller of the EJB method ??( I guess once I get the Subject , thru #1
, getPrincipals()
would return me the list of the Principals?)


Any info will be highly appreciated
Thanks
Harish

Richard Wallace

unread,
Jan 11, 2002, 10:33:39 AM1/11/02
to

Hi Harish,

Can you elaborate more on what you are trying to do here? Also can provide a
stacktrace of the exceptions you are getting.

I believe that only the principal will be returned and it depends on what the
subject holds as to whether the other principals will be returned.

Regards,

Richard Wallace
Senior Developer Relations Engineer
BEA Support.

Harish Murthy

unread,
Jan 11, 2002, 7:29:51 PM1/11/02
to
Hi Richard,

In the JAAS specifications , it allows you to add new Principals
to the subject in the LoginModule.
What I am trying to do here , is to add Principals
and retrieve the Principals from the subject in the EJB , by means of
call to
Subject.getSubject(java.security.AccessController.getContext()) in the
EJB Method.
Once the Subject is retrieved , I want to get all the Principals that
were part
of the Caller's subject.

The stack trace on Subject.getSubject(java.security.AccessController.getContext())
in the bean is pasted below.

RemoteException: EJB Exception: ; nested exception is:
java.lang.SecurityException: Method Not Supported

Start server side stack trace:
java.rmi.RemoteException: EJB Exception: ; nested exception is:
java.lang.SecurityException: Method Not Supported
java.lang.SecurityException: Method Not Supported
at javax.security.auth.Subject.getSubject(Subject.java:281)
at examples.ejb.basic.statelessSession.TraderBean.buy(TraderBean.java:11
6)
at examples.ejb.basic.statelessSession.TraderBean_3p5ifg_EOImpl.buy(Trad
erBean_3p5ifg_EOImpl.java:79)
at examples.ejb.basic.statelessSession.TraderBean_3p5ifg_EOImpl_WLSkel.i
nvoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:298)
at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerR
ef.java:93)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.jav
a:267)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest
.java:22)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
End server side stack trace
; nested exception is:
java.lang.SecurityException: Method Not Supported

Start server side stack trace:
java.lang.SecurityException: Method Not Supported
at javax.security.auth.Subject.getSubject(Subject.java:281)
at examples.ejb.basic.statelessSession.TraderBean.buy(TraderBean.java:11
6)
at examples.ejb.basic.statelessSession.TraderBean_3p5ifg_EOImpl.buy(Trad
erBean_3p5ifg_EOImpl.java:79)
at examples.ejb.basic.statelessSession.TraderBean_3p5ifg_EOImpl_WLSkel.i
nvoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:298)
at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerR
ef.java:93)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.jav
a:267)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest
.java:22)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
End server side stack trace


Regards,
- Harish


"Richard Wallace" <Re...@ToNewsgroup.Only> wrote in message news:<3c3f05d3$1...@newsgroups.bea.com>...

0 new messages