aspose file tools
The moose likes Web Services and the fly likes Rampart at the client side Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Rampart at the client side" Watch "Rampart at the client side" New topic
Author

Rampart at the client side

Arundhathi Menon
Ranch Hand

Joined: Jan 14, 2004
Posts: 113
Hi,

I am using rampart for WS security in my app.

I have placed the rampart.mar including the rampart jars in my WEB-INF/lib folder. For some reason , it doesnt seem to be able to read the file from the classpath. Please let me knwo what needs to be rectified. I do not want to point to a folder outside my app and want to pack in rampart along into my WAR file.



Thank you.

Regards
Menon


SCJP , SCWCD , SCBCD , SCDJWS
Ulf Dittmer
Rancher

Joined: Mar 22, 2005
Posts: 42952
    
  73
I have placed the rampart.mar including the rampart jars in my WEB-INF/lib folder.

*.mar files don't go into WEB-INF/lib - they go into WEB-INF/modules. And since *.mar files don't contain any jar files, all the jar files that come with Rampart need to go into WEB-INF/lib. (For Rampart 1.4 that would be opensaml-1.1.jar, rampart-core-1.4.jar, rampart-policy-1.4.jar, rampart-trust-1.4.jar, wss4j-1.5.4.jar and xmlsec-1.4.1.jar).
Arundhathi Menon
Ranch Hand

Joined: Jan 14, 2004
Posts: 113
Hi Ulf,

Thank you for you quick response.

Will I have to pass this path as well? I am using the following method



where path is null and the axis2xml file is specified.

Since path is null , it looks for it in the classpath. So if I am to place the *.mar file in the WEB-INF/module directory , will it automatically look it up? I mean , is it like a default path?

Ulf Dittmer
Rancher

Joined: Mar 22, 2005
Posts: 42952
    
  73
I'm sorry, I completely missed that you were asking about the client side. The client would of course NOT look automatically in WEB-INF/lib for jar files, so you'd need to add all of those to your classpath in some other way.

I don't know what's required to engage Rampart programmatically - I always engage it declaratively.
Arundhathi Menon
Ranch Hand

Joined: Jan 14, 2004
Posts: 113
Thanks Ulf , for pointing that out.

Is packaging the rampart.mar file directly under src folder considered a good practise?

Am keen on bundling it all up in the app and am trying to figure out the best way to do it.

Or better still , do you think the class path attribute when I build the WAR file can be tweaked to accomodate these files n the classpath?
Ulf Dittmer
Rancher

Joined: Mar 22, 2005
Posts: 42952
    
  73
Now I'm confused. You mentioned "client side", but you keep talking about war files - is that web app a *WS client* or the *WS server*?
Arundhathi Menon
Ranch Hand

Joined: Jan 14, 2004
Posts: 113
I am using Rampart on the client side.

My Web App is a consumer of a Web Service which requires Rampart for client authentication. Hence inorder to fire those web service calls , I need to package Rampart.mar in my WAR file.

I though all files under WEB-INF/lib would be loaded by the classloader and hence be on the classpath.

Seem to be runnning into issues configuring this
Ulf Dittmer
Rancher

Joined: Mar 22, 2005
Posts: 42952
    
  73
I though all files under WEB-INF/lib would be loaded by the classloader and hence be on the classpath.

Yes, but *.mar files are not *.jar files - they are accessed by the Rampart classes, not by the JRE classloader. I would imagine that one of the Rampart classes/methods you're using to set it up takes as a parameter the directory where it should look for *.mar files.
Travis Hein
Ranch Hand

Joined: Jun 06, 2006
Posts: 161
yea, that really bugs me how the only way to initialize rampart is to specify file system path.

if you invoke the axis2 client from inside a servlet, where you have the ability to get a handle of



if not invoked from a servlet, perhaps an initial context listener, to interrogate the servletContext and jam the path into a JNDI, or application variable to be consumed later where you do the webservice client stuff.

Error: Keyboard not attached. Press F1 to continue.
Arundhathi Menon
Ranch Hand

Joined: Jan 14, 2004
Posts: 113
Thanks Travis.
Louis Amstutz
Greenhorn

Joined: Jun 29, 2011
Posts: 1
Resurrecting this thread because I have the same problem. My client will be run from a browser with Java web start, so I can't really put a rampart repo with the rampart.mar on the client's machine. I would really like to have the rampart.mar in the jar file of the application. Does anyone know of a way to do this?
Travis Hein
Ranch Hand

Joined: Jun 06, 2006
Posts: 161
I guess your applet could on boot up do a fetch, such as from URL the rampart and addressing mar files, and then stuff them into a local temporary folder.

for example.
* create a temporary folder on the local machine (e.g. File.createTempFile)
* pull down the mar files from the URL on the server into these machines.
* configure the axis2 context to refer to this temporary folder as the modules folder.

Other than that, I guess it might be possible to instruct axis2 to use a custom URL class loader which would load the modules directly from the URL, but doing that is not clear to me at this time.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Rampart at the client side