try a generic RegexMatcher (all untested :) )
greets
thomas
in your sitemap add this to components with your pattern:
<map:matchers default="wildcard">
<map:matcher name="regular" src="test.RegexMatcher">
<pattern>^192\.168\.\d+\.\d+</pattern>
</map:matcher>
</map:matchers>
and in your pipeline:
<map:match pattern="{request:remoteAddr}" type="regular">
<!-- matched content, access regex groups with {0} or {1} ... -->
</map:match>
<!-- unmatched content -->
package test;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.cocoon.matching.Matcher;
import org.apache.cocoon.sitemap.PatternException;
public class RegexMatcher extends AbstractLogEnabled implements Matcher,
Configurable, ThreadSafe {
private Pattern regexpattern;
public void configure(Configuration configuration) throws
ConfigurationException {
regexpattern =
Pattern.compile(configuration.getChild("pattern").getValue().trim());
}
public Map match(String pattern, Map objectModel, Parameters
parameters) throws PatternException {
java.util.regex.Matcher m = regexpattern.matcher(pattern);
if (m.matches()) {
HashMap<String, String> h = new HashMap<String, String>();
for (int i = 0, j = m.groupCount(); i <= j; i++)
h.put(String.valueOf(i), m.group(i));
return h;
}
return null;
}
}
Peter Flynn schrieb:
> Peter Flynn wrote:
>> Thomas Markus wrote:
>>> hi,
>>>
>>> look at http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#access
>>>
>>> or use a matcher/selector in your sitemap
>>>
>>> <map:select type="parameter">
>>> <map:parameter name="parameter-selector-test"
>>> value="{request:remoteAddr}" />
>>> <map:when test="127.0.0.1">
>>> <!-- actions for this ip -->
>>> </map:when>
>>> <map:otherwise>
>>> <!-- -->
>>> </map:otherwise>
>>> </map:select>
>>
>> That look like the right approach...except I can't find any
>> documentation at
>> http://cocoon.apache.org/2.2/core-modules/core/2.2/840_1_1.html on
>> the syntax of the test attribute.
>
> I found some under the entry for Parameter Selector but it appears
> that the test will only perform a plain equality. Is there a way to
> perform a substring operation; when testing an IP address for access
> permission I want to allow all xxx.yyy.*.* and prohibit everything else.
>
> ///Peter
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]