Jingmei Li wrote:
> Torgeir:
> 
> Thanks for the suggestion. I ran into some problems when trying your
> solution:
> 
> MySlideRealmPrincipal is my implementation of Principal. I wanted to add
> additional methods to MySlideRealmPrincipal , but how can I access those
> methods from WebdavServlet? java.security.Principal is an interface so that
> it doesn't allow me to cast req.getUserPrincipal() to MySlideRealmPrincipal
> (ClassCastException). I could use Principal.getName() or toString() to
> return my own data but it could cause other problems...

You must just do a

try {
     MyPrincipal p = (MyPrincipal) req.getUserPrincipal();

     p.getWhateverYouNeedFromLoginCode();
} catch (ClassCastException cce) {
     System.err.println("login not configured properly...");
}

If you configure tomcat (or whatever servlet container that you use) 
properly, it will allways use your login code and you can be shure the 
principal are of your type.

We do this in our application, which authenticates to an LDAP server. 
The principal implementation has a method called getDirContext() which 
gives an authenticated connection to the LDAP server.



-- 
-Torgeir


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to