You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by shetc <sh...@bellsouth.net> on 2009/09/30 03:33:55 UTC

Accessing a database from a Valve

Hi All,

I have a requirement in which access to a web application will be controlled
by a 'black list' of
IP addresses. That is, access will be refused if the requesting IP address
is contained within
the black list. This list is to be maintained within a relational database
table.

I was thinking of implementing a Valve for this requirement (instead of a
servlet filter). Is it possible
to query a database table from a valve and, if so, what is the usual
approach for doing this?

Thanks very much,

Steve
-- 
View this message in context: http://www.nabble.com/Accessing-a-database-from-a-Valve-tp25673641p25673641.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Accessing a database from a Valve

Posted by Mark Thomas <ma...@apache.org>.
Martin Gainty wrote:
> this should do it
> http://tomcat.apache.org/tomcat-6.0-doc/api/org/apache/catalina/valves/JDBCAccessLogValve.html

No it won't. Not even close.

Mark

> 
> Martin Gainty 
> ______________________________________________ 
> Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
>  
> Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
> Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.
> 
> 
> 
> 
>> Date: Tue, 29 Sep 2009 18:33:55 -0700
>> From: shetc@bellsouth.net
>> To: users@tomcat.apache.org
>> Subject: Accessing a database from a Valve
>>
>>
>> Hi All,
>>
>> I have a requirement in which access to a web application will be controlled
>> by a 'black list' of
>> IP addresses. That is, access will be refused if the requesting IP address
>> is contained within
>> the black list. This list is to be maintained within a relational database
>> table.
>>
>> I was thinking of implementing a Valve for this requirement (instead of a
>> servlet filter). Is it possible
>> to query a database table from a valve and, if so, what is the usual
>> approach for doing this?
>>
>> Thanks very much,
>>
>> Steve
>> -- 
>> View this message in context: http://www.nabble.com/Accessing-a-database-from-a-Valve-tp25673641p25673641.html
>> Sent from the Tomcat - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>  		 	   		  
> _________________________________________________________________
> Insert movie times and more without leaving Hotmail®.
> http://windowslive.com/Tutorial/Hotmail/QuickAdd?ocid=TXT_TAGLM_WL_HM_Tutorial_QuickAdd_062009


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Accessing a database from a Valve

Posted by Martin Gainty <mg...@hotmail.com>.
this should do it
http://tomcat.apache.org/tomcat-6.0-doc/api/org/apache/catalina/valves/JDBCAccessLogValve.html

Martin Gainty 
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.




> Date: Tue, 29 Sep 2009 18:33:55 -0700
> From: shetc@bellsouth.net
> To: users@tomcat.apache.org
> Subject: Accessing a database from a Valve
> 
> 
> Hi All,
> 
> I have a requirement in which access to a web application will be controlled
> by a 'black list' of
> IP addresses. That is, access will be refused if the requesting IP address
> is contained within
> the black list. This list is to be maintained within a relational database
> table.
> 
> I was thinking of implementing a Valve for this requirement (instead of a
> servlet filter). Is it possible
> to query a database table from a valve and, if so, what is the usual
> approach for doing this?
> 
> Thanks very much,
> 
> Steve
> -- 
> View this message in context: http://www.nabble.com/Accessing-a-database-from-a-Valve-tp25673641p25673641.html
> Sent from the Tomcat - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
 		 	   		  
_________________________________________________________________
Insert movie times and more without leaving Hotmail®.
http://windowslive.com/Tutorial/Hotmail/QuickAdd?ocid=TXT_TAGLM_WL_HM_Tutorial_QuickAdd_062009

Re: Accessing a database from a Valve

Posted by shetc <sh...@bellsouth.net>.
Thanks Martin!
-- 
View this message in context: http://www.nabble.com/Accessing-a-database-from-a-Valve-tp25673641p25673745.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Accessing a database from a Valve

Posted by Jason Brittain <ja...@gmail.com>.
Sometimes, maybe infrequently, there's a decent reason to implement a small
amount of code outside of the webapp, in the container space.  There are
cases where either modifying the webapp is off limits, or where it would
simplify things to implement it in container space so that it's just always
running, regardless of which webapps are started, stopped, deployed,
undeployed, or redeployed.  Of course, if Tomcat allowed configuring Filters
everywhere it currently allows configuring Valves (as we previously
discussed), then these could be implemented as Filters -- right now Valves
are the only option for doing this.

--
Jason Brittain


On Wed, Sep 30, 2009 at 10:25 AM, shetc <sh...@bellsouth.net> wrote:

>
> The person paying me :-)
>
> I suggested a filter but he prefers a valve even though it ties that
> functionality to Tomcat.
> --
> View this message in context:
> http://www.nabble.com/Accessing-a-database-from-a-Valve-tp25673641p25685437.html
> Sent from the Tomcat - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

RE: Accessing a database from a Valve

Posted by shetc <sh...@bellsouth.net>.
The person paying me :-)

I suggested a filter but he prefers a valve even though it ties that
functionality to Tomcat.
-- 
View this message in context: http://www.nabble.com/Accessing-a-database-from-a-Valve-tp25673641p25685437.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Accessing a database from a Valve

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: shetc [mailto:shetc@bellsouth.net]
> Subject: Re: Accessing a database from a Valve
> 
> I have been required to try and do this with a Valve.

Just for curiosity's sake, what's the source of that requirement?

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Accessing a database from a Valve

Posted by shetc <sh...@bellsouth.net>.
Thanks for the pointers. That was my original plan but I have been required
to try
and do this with a Valve. The caching is good but I still have to read from
a
database to periodically up the list of IP addresses.
-- 
View this message in context: http://www.nabble.com/Accessing-a-database-from-a-Valve-tp25673641p25684453.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Accessing a database from a Valve

Posted by Mark Thomas <ma...@apache.org>.
shetc wrote:
> Ah, just spotted the JDBCAccessLogValve class. I guess that will clue me in
> :-)

It won't. You want the RemoteAddressValve.

A couple of pointers you can use or ignore as you see fit:
- Use a filter rather than a valve. It is more portable.
- Cache the list of balcklisted IPs if at all possible - you don't want a DB
lookup on every single request.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Accessing a database from a Valve

Posted by shetc <sh...@bellsouth.net>.
Ah, just spotted the JDBCAccessLogValve class. I guess that will clue me in
:-)
-- 
View this message in context: http://www.nabble.com/Accessing-a-database-from-a-Valve-tp25673641p25673723.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org