cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Niclas Hedhman <nic...@localbar.com>
Subject ClientAddressChooser
Date Wed, 05 Jul 2000 07:32:47 GMT

My first try to put together a Chooser, and I selected to do one for
ClientAddress validation.

There is one thing that comes into view though.
IMO, this should not be aware of Http being the transport. But there is
no parameter or method in Request that gives me this, so I have taken
the liberty (awaiting something else) to define that "client-address"
parameter is known by the Request object, and that it returns a String
with the hostname followed by the ipnumber, separated by a slash. eg.
envision.asiaconnect.com.my/202.190.60.242
If the slash is not present, it assumes it to be an IP number is the
first character is a digit, otherwise a host name.

Hostnames are matched to the domain/host names in the allow and deny
sections, by check-and-remove-left sequence, and IP number is by
check-and-remove-right. It means that if you give;
<host>202.190.60</host>, all hosts from 202.190.60.1 to 202.190.60.254
is matched true.


In the Sitemap;

definition
   <map:chooser type="clientaddress"
src="class:///org.apache.cocoon.choosers.ClientAddressChooser">
     <param name="order" value="allow,deny" />
     <param name="all" value="false" />
     <allow>
       <host>com</host>
       <host>se</host>
       <host>com.my</host>
     </allow>
     <deny>
       <host>asiaconnect.com.my</host>
     </deny>
   </map:chooser>

and usage
<map:choose type="clientaddress" >
  <map:when test="allow()" >
    ...
  </map:when>
</map:choose>


I hope I have attacked this in the proper way, and awaiting some
comments.

There is a test part at the bottom for the Chooser, which is not
prudently written...

Niclas

Mime
View raw message