aspose file tools*
The moose likes Security and the fly likes Accessing a J2EE Security enabled Application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Engineering » Security
Bookmark "Accessing a J2EE Security enabled Application" Watch "Accessing a J2EE Security enabled Application" New topic
Author

Accessing a J2EE Security enabled Application

akhil karthik
Greenhorn

Joined: Jul 06, 2009
Posts: 13
I am trying to connect to a j2EE security enabled system using Programmatic login using the userId and Password but the subject object returned from lc.getSubject() is just Subject: . it is not even null though. My login is successful, but for subject object it is returning Subject: and when i go to next line i.e. WSSubject.setRunAsSubject() it is throwing me a null pointer exception.

Why is this happening. I am using JDK1.3 and is it because the JAAS is not compatible with JDK1.3 version. If it is so, how should i be able to establish a connection to j2EE secured application.

Any help is appreciated . Thanks in advance!

LoginContext lc = new LoginContext("WSLogin", new WSCallbackHandlerImpl(username, "realm", password));
lc.login();
log.info("Login done successfully " );
log.info("about to get subject");
Subject sub = lc.getSubject();
System.out.println("subject is:sub" );
WSSubject.setRunAsSubject(sub);

Here is the message is am receiving when i try to establish a connection:

[7/6/09 12:32:22:334 EDT] 0000002e SystemOut O Login done successfully
[7/6/09 12:32:22:334 EDT] 0000002e SystemOut O about to get subject
[7/6/09 12:32:22:334 EDT] 0000002e SystemOut O subject is:Subject:
[7/6/09 12:32:22:350 EDT] 0000002e ExceptionUtil E CNTR0020E: EJB threw an unexpected (non-declared) exception during invocation of method. Exception data: java.lang.NullPointerException
at com.ibm.ws.security.auth.distContextManagerImpl.isWSSubject(distContextManagerImpl.java:605)
at com.ibm.ws.security.auth.distContextManagerImpl.addWSSubjectToCache(distContextManagerImpl.java:2450)
at com.ibm.websphere.security.auth.WSSubject$3.run(WSSubject.java:448)
at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java(Compiled Code))
at com.ibm.websphere.security.auth.WSSubject.setRunAsSubject(WSSubject.java:444)
.....................
Rajit Patel
Greenhorn

Joined: Aug 01, 2008
Posts: 9
Hi I am getting same Problem...

I am surprised !!! There is no reply from any rancher...

There are must be intelligent ranchers available on this forum..

Please reply soon...
akhil karthik
Greenhorn

Joined: Jul 06, 2009
Posts: 13
Assuming that you are testing in RAD and that you are connecting to an EJB instance :
Is you application server enabled for global security ?

If your app server is not enabled with Global security , you see null subject. So either you have to enable Global Security on local env or you should be using WebService instance of the service(if available)..

AkhilKathik.
Rajit Patel
Greenhorn

Joined: Aug 01, 2008
Posts: 9
Thanks Akhil...

YOu are correct...i am working with RAD7.5 and WAS 6.1... I am new with WAS...

So could you please tell me how to enable Global security ?
akhil karthik
Greenhorn

Joined: Jul 06, 2009
Posts: 13
It has to be set from Server's adminstrative console after you configure your server.
Also, This link will be useful to know basics of j2ee Security ..
http://www.redbooks.ibm.com/redbooks/SG246846/wwhelp/wwhimpl/java/html/wwhelp.htm

AkhilKarthik
Rajit Patel
Greenhorn

Joined: Aug 01, 2008
Posts: 9
Thanks...
If you can give the steps to enable the Global security then it would be great help.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Accessing a J2EE Security enabled Application