views:

61

answers:

1

Hi,

So I have a Tomcat server within a Java web application, authentication is done using Tomcat's usernames and passwords specified in the tomcat-users.xml file, and form based authentication (posting to *j_security_check*). I have now also registered a remote object (using Java RMI) that I want to access from outside of the web context, from an eclipse plugin.

My intention is to obtain the remote object which has a method

public AnotherRemoteClsWithRestrictedMethods login(user, pass);

and then the implementation uses the web application's security framework to verify the user and password combination. If valid, would then return another object with restricted methods.

How would I go about obtaining / querying the web application's security details?

Note: I do not have an HttpRequest object, should I call another URL to verfiy the user? Any other ways?

Thanks in advance.

A: 

j_security_check is a HTTP based authentication. You'll really need to fire a HTTP request. You can use java.net.URLConnection for this, or the more convenienced Apache Commons HttpClient.

BalusC
Yeah I figured that's one way but ideally I don't want to have to fire an HTTP request, is there no static method like SecurityContext.verifyUser(user, pass)?
Ed
Not in Servlet API, no. You'll need to parse the `tomcat-users.xml` yourself and grab/test the credentials. Better is to store them in a database and let Tomcat use a `DatasourceRealm` (or `JDBCRealm`) instead. This way you can more easy access the credentials from other sources.
BalusC