Fernando Padilla wrote:

> On Fri, 2 Mar 2001, Craig R. McClanahan wrote:
>
> > Fernando Padilla wrote:
> > >
> > > Again, I'm trying to bridge the gap between the classloader used by the
> > > server and the classloader used by the web app.  So that I can cast/use an
> > > object from one classloader from the other classloader....
> > >
> > > Ideas?? Help?? Clue?? Rants?? Raves??
> > >
> >
> > In that case, you're not going to be able to do this cast.  The classes placed
> > in $TOMCAT_HOME/server are loaded by a class loader that is not visible to web
> > applications (i.e. it is not a parent class loader to the one used for your
> > web app).
> >
> > If you have additional information from the MyUserPrincipal class that your
> > application needs to see, I suggest that you store them as request attributes
> > or session attributes inside the authenticator.  This will work for anything
> > that is a String or a Java primitive type (wrapped in the corresponding
> > wrapper class such as java.lang.Integer for an "int").
> >
>
> 1) i hear people say, to add jar file to $TOMCAT_HOME/lib, I tried that
> and that did not work, so i added them to $TOMCAT_HOME/server and that did
> work.
>

Yes, that will make your classes available to Catalina's internal class
loader.

>
> 2) request or session attributes inside the authenticator??
>    I'm using MyRealm, the interface to that is just
>    authenticate( String user, String pass ), how can I access the request
>    or session that is being authenticated??
>

You would need to sublcass whichever authenticator class you are using
(such as
org.apache.catalina.authenticator.FormAuthenticator) and override the
authenticate()
method, something like this:

    public boolean authenticate(HttpRequest request,
        HttpResponse response, LoginConfig config) {

        if (!super.authenticate(request, response, config))
            return (false);
        MyPrincipal principal =
          (MyPrincipal) request.getUserPrincipal();
        if (principal == null) {
            // We are asking for the form login page
            return (true);
        } else {
            // Copy the stuff we need into the session
            HttpSession session =
              ((HttpServletRequest) request.getRequest).getSession();
            session.setAttribute("userStatus", principal.getStatus());
            ...
            return (true);
        }

    }

Note that the attributes you save need to be JDK classes like String,
because the
user classes you store in the server directory are not visible to web
apps.

>
> thank you :):):)
>
> fern
>

Craig McClanahan

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to