You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Gregor Schneider <rc...@googlemail.com> on 2006/08/07 19:12:22 UTC
How to get hold on org.apache.catalina.Manager?
Hi list,
first, I'm talking about Tomcat 5.0.28, but maybe those questions / pronlems
arise for other version, too.
We do have an application here which is making heavy use of frame, and
frames inside those frame and frames inside.... you know what I mean.
Our developes thought it to be a good idea, and now we can deal with the
pronlems arising.
Whn the session times out, Tomcat leads me to the login-screen - so far, so
good. However, after logging in, Tomcat doesn't know that the RequestedURL
stored in Session is in a framed view, meaning, I see the target without the
framed view.
My first approach was creating a Filter, however, I can not write any Filter
filtering j_security_check since the servlet-specs discourage this (although
Websphere supports it, but that's another story...).
So I thought about a valve...
I wrote a valve which inherits from FormAuthenticator, however, when putting
the Valve-definition itnto server.xml, I get a lot of XML-pasring-messages
(the xml iswrite, it tells me that no Context would be defined). If this
valve inherits from ValveBase, everything is fine.
What I want to do is to overwrite the original requested URL which ist
stored in Session (and where jsecurity_check forwards to), however, to need
to get hold on the Session-object, and therefore I need a Manager-Object,
and I don't see a way to do this.
Here's a snippet of the code:
protected Session getSession(HttpServletRequest aRequest, boolean create)
{
HttpSession hses = aRequest.getSession(create);
if (hses == null)
return (null);
Manager manager = aContext.getManager();
if (manager == null)
return (null);
else {
try {
return (manager.findSession(hses.getId()));
} catch (IOException e) {
return (null);
}
}
}
The variable "aContext" above is a ValveContext, and as you can imagine, I
don't need a ValveContext but org.apache.Catalina.Context... *sic*
No if I inherit my Valve from ValveBase, I don't see any way (I've read the
Catalina-Source 'til my eyes dropped out to no extend...)
Has any of you guys an idea how I can achieve what I want to (namely that
j_security_check does route to my https://myapp/index.html instead of the
saved one within FormAutheticator's Session?
Genereting a FrameBreakout is not an option, since we got tons of pages and
all are *sic* generated...
Hope my mail wasn't to confusing, if so, sorry, but I'm quite confused
myself now....
Greetings from the grounds of distress....
Greg
--
what's puzzlin' you, is the nature of my game
Re: How to get hold on org.apache.catalina.Manager?
Posted by Mark Thomas <ma...@apache.org>.
Gregor Schneider wrote:
> Hi Mark,
>
> I know that this usually belongs to the userlist, however, after a few days
> zero answers - it seems as nobody there has the knoehow to answer those
> questions :(
http://tomcat.apache.org/faq/tomcatuser.html#why
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: How to get hold on org.apache.catalina.Manager?
Posted by Gregor Schneider <rc...@googlemail.com>.
Hi Mark,
I know that this usually belongs to the userlist, however, after a few days
zero answers - it seems as nobody there has the knoehow to answer those
questions :(
Cheers
Greg
--
what's puzzlin' you, is the nature of my game
Re: How to get hold on org.apache.catalina.Manager?
Posted by Mark Thomas <ma...@apache.org>.
Gregor Schneider wrote:
> 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...
This question belongs on the users list. Please redirect your enquiry
to users@tomcat.apache.org
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: How to get hold on org.apache.catalina.Manager?
Posted by Gregor Schneider <rc...@googlemail.com>.
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