Hi list,

ok, one problems is solved so far, after I plugged my eyes back in I saw how
to get hold of the Container (sometimes it's useful to read the Tomcat-Docs
rather than the Sun-Docs...

Anyways, the Valve is plugged in to server.xml (linux suse 9 btw.) like
this:


<Service debug="9" name="Catalina">
                <Engine debug="9" defaultHost="localhost" name="Catalina">
                     <Host appBase="webapps" debug="9" name="localhost">
                        <Valve className='
org.apache.catalina.valves.AccessLogValve'
                                directory='logs'
                                prefix='dom-access-'
                                suffix='.log'
                                pattern='common'
                                resolveHosts='false'
                          />
                          <Valve className="
org.apache.catalina.authenticator.SingleSignOn" debug="0"/>
                          <Valve className="
com.cr.manuals.catalina.valve.CatalinaLogonValve" debug="0"/>
                         <Logger className="
org.apache.catalina.logger.FileLogger" prefix="localhost_log."
timestamp="true" verbosity="4"/>

[...]

However, I don't get any System.out here (in catalina.out), and my
Logins-Screen doesn't appear at all.

Actually I'm not sure when to call Context.invoke() and
ValveContet.invokeNext() - does anybody of you have a clue why now
j_security_check obviously is not been calle (no forward to login-scren,
neither forward to secured content)?

This is my code:

public class CatalinaLogonValve extends ValveBase {

   public String getInfo() {
       return "LogonValve for Catalina 5.0.x";
   }

   public void invoke(Request aRequest, Response aResponse,
           ValveContext aContext) throws IOException, ServletException {

       if (!(aRequest instanceof HttpServletRequest) ||
            !(aResponse instanceof HttpServletResponse)) {
            aContext.invokeNext(aRequest, aResponse);
            return;
        }

       HttpServletRequest hreq =
           (HttpServletRequest) aRequest.getRequest();
       HttpServletResponse hres =
           (HttpServletResponse) aResponse.getResponse();

       if(hreq.getRequestURI().indexOf("j_security_check")!=-1) {
           // we do have a HTTPServletRequest here, and we're looking for
the TOMCAT-session...
          // **** not showing up **********
           System.out.println("CatalinaLogonValve hit!");
           Session tomcatSession = getSession(hreq, false);
           if (tomcatSession != null) {
               SavedRequest sreq = (SavedRequest)tomcatSession.getNote(
Constants.FORM_REQUEST_NOTE);
               sreq.setRequestURI("https://dekold4711/dom/index.htm";);
               tomcatSession.setNote(Constants.FORM_REQUEST_NOTE, sreq);
               // **** not showing up **********
               System.out.println ("Requested URI:" + sreq.getRequestURI
());
               container.invoke(aRequest, aResponse);
           }else {
               // **** not showing up **********
               System.out.println("TomcatSession is null!");
                aContext.invokeNext(aRequest, aResponse);
           }
       }
   }

   protected Session getSession(HttpServletRequest aRequest, boolean
create) {

       HttpSession hses = aRequest.getSession(create);
       if (hses == null)
           return (null);
       Manager manager = container.getManager();
       if (manager == null)
           return (null);
       else {
           try {
               return (manager.findSession(hses.getId()));
           } catch (IOException e) {
               return (null);
           }
       }

   }
}
--
what's puzzlin' you, is the nature of my game

Reply via email to