You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jose Miguel Guzman <jm...@entelchile.net> on 2002/11/20 04:03:01 UTC

Session Tracking based on the Client's IP

Hi Guys

I need to track sessions based on the Client's IP, instead of using Cookies
or URL re-writing.. (My clients don't support Cookies, and I cannot re-write
the URL). I know this sounds useless, but believe me... this is what I
need.... ;-)

I found that in the Catalina internal API there is a Manager class
(org.apache.catalina.Manager) that provides some methods to manipulate the
Sessions base:

    Manager.findSession(java.lang.String id)
    Manager.add(Session session)
    etc..

The problem is that I couldn't find a way get a reference for the Manager,
from the servlet...
I was trying to do something like:

    Context context = request.getContext();         <== No such method
available
    Manager manager = context.getManager();
    String id = request.getRemoteAddr().toString();
    Session sesion = manager.findSession(id);
    if (sesion == null) {
        sesion = manager.createSession();
        sesion.setId(id);
    }

but the getContext() method is not available from the
javax.servlet.http.HttpServletRequest interface.. (It's only accesible from
the internal org.apache.catalina.connector.RequestBase class).

Is there a way to access some Manager class implementation (ManagerBase,
StatandardManager) within the servlet?
Do someone have some idea for facing this problem?

Basically, I require to use the client IP address, as the only ID in the
Session base.
I would appreciate any help, from more experienced users...

Thanks, very much...

Jose Miguel Guzman
Santiago, Chile.

PS: Sorry for my English..


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Session Tracking based on the Client's IP

Posted by Jose Miguel Guzman Cassanello <jm...@entelchile.net>.
Thanks Norbert

In my environment, all client are well-know stations in a well-know network.
There isn't any NAT or FW, and the clients are not going to spoof their IPs
addresses.

Basically, I need to have a Session Status Table in memory, with some very
basic status info for each client, indexed by the client IP address.
This info should be shared among all the servlets in the application
(context).

Is there some way to customize the Session Tracking API, for using other
indexes (as the Client IP) instead JSESSIONs?

Thanks
Jose Miguel Guzman





----- Original Message -----
From: "Norbert Kuhnert" <no...@cafesoft.com>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Wednesday, November 20, 2002 1:51 PM
Subject: Re: Session Tracking based on the Client's IP


>
> Jose,
>
> Unfortunately, this approach would be somewhat unreliable, depending
> on the sites accessing Tomcat. Most corporate networks are protected
> by a firewall and many of the do "Dynamic Network Address Translation".
> Dynamic NAT is used to hide the real IP address of clients connected
> from the internal corporate network.
>
> So, all traffic passing out of the firewall to your site will appear
> to come from the same IP address.
>
> If your needs are to support know customers that don't have dynamic
> NAT, then a session management scheme based on IP address should
> be possible.
>
> I know that's probably not helpful, but maybe it will save you the
> time of working on a scheme that won't suit your requirements.
>
> Best regards,
>
> Norb
>
>
>
> Jose Miguel Guzman wrote:
> >
> > Hi Guys
> >
> > I need to track sessions based on the Client's IP, instead of using
Cookies
> > or URL re-writing.. (My clients don't support Cookies, and I cannot
re-write
> > the URL). I know this sounds useless, but believe me... this is what I
> > need.... ;-)
> >
> > I found that in the Catalina internal API there is a Manager class
> > (org.apache.catalina.Manager) that provides some methods to manipulate
the
> > Sessions base:
> >
> >     Manager.findSession(java.lang.String id)
> >     Manager.add(Session session)
> >     etc..
> >
> > The problem is that I couldn't find a way get a reference for the
Manager,
> > from the servlet...
> > I was trying to do something like:
> >
> >     Context context = request.getContext();         <== No such method
> > available
> >     Manager manager = context.getManager();
> >     String id = request.getRemoteAddr().toString();
> >     Session sesion = manager.findSession(id);
> >     if (sesion == null) {
> >         sesion = manager.createSession();
> >         sesion.setId(id);
> >     }
> >
> > but the getContext() method is not available from the
> > javax.servlet.http.HttpServletRequest interface.. (It's only accesible
from
> > the internal org.apache.catalina.connector.RequestBase class).
> >
> > Is there a way to access some Manager class implementation (ManagerBase,
> > StatandardManager) within the servlet?
> > Do someone have some idea for facing this problem?
> >
> > Basically, I require to use the client IP address, as the only ID in the
> > Session base.
> > I would appreciate any help, from more experienced users...
> >
> > Thanks, very much...
> >
> > Jose Miguel Guzman
> > Santiago, Chile.
> >
> > PS: Sorry for my English..
> >
> > --
> > To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> > For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Session Tracking based on the Client's IP

Posted by Norbert Kuhnert <no...@cafesoft.com>.
Jose,

Unfortunately, this approach would be somewhat unreliable, depending
on the sites accessing Tomcat. Most corporate networks are protected
by a firewall and many of the do "Dynamic Network Address Translation".
Dynamic NAT is used to hide the real IP address of clients connected
from the internal corporate network.

So, all traffic passing out of the firewall to your site will appear 
to come from the same IP address. 

If your needs are to support know customers that don't have dynamic
NAT, then a session management scheme based on IP address should
be possible.

I know that's probably not helpful, but maybe it will save you the
time of working on a scheme that won't suit your requirements.

Best regards,

Norb



Jose Miguel Guzman wrote:
> 
> Hi Guys
> 
> I need to track sessions based on the Client's IP, instead of using Cookies
> or URL re-writing.. (My clients don't support Cookies, and I cannot re-write
> the URL). I know this sounds useless, but believe me... this is what I
> need.... ;-)
> 
> I found that in the Catalina internal API there is a Manager class
> (org.apache.catalina.Manager) that provides some methods to manipulate the
> Sessions base:
> 
>     Manager.findSession(java.lang.String id)
>     Manager.add(Session session)
>     etc..
> 
> The problem is that I couldn't find a way get a reference for the Manager,
> from the servlet...
> I was trying to do something like:
> 
>     Context context = request.getContext();         <== No such method
> available
>     Manager manager = context.getManager();
>     String id = request.getRemoteAddr().toString();
>     Session sesion = manager.findSession(id);
>     if (sesion == null) {
>         sesion = manager.createSession();
>         sesion.setId(id);
>     }
> 
> but the getContext() method is not available from the
> javax.servlet.http.HttpServletRequest interface.. (It's only accesible from
> the internal org.apache.catalina.connector.RequestBase class).
> 
> Is there a way to access some Manager class implementation (ManagerBase,
> StatandardManager) within the servlet?
> Do someone have some idea for facing this problem?
> 
> Basically, I require to use the client IP address, as the only ID in the
> Session base.
> I would appreciate any help, from more experienced users...
> 
> Thanks, very much...
> 
> Jose Miguel Guzman
> Santiago, Chile.
> 
> PS: Sorry for my English..
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>