Guide to Profiling IP Addresses

Jetspeed has a built in mechanism to serve custom content to a specific IP address. This feature uses the Profiler to negociate pages based on the requesting clients IP address.

1. The Rule

The rule is identified by the key ip-address. There is one criterion called ip resolved using the IP Criterion Resolver. This class implements the resolve method of the Rule Criterion Resolver in order to obtain the IP address from the request.

    public String resolve(RequestContext context, RuleCriterion criterion)
    {
        // look for override
        String value = super.resolve(context, criterion);
        if (value != null) { return value.toLowerCase(); }

        // Note IP addresses can vary depending on the client
        // Konqueror 3.4.2 returns IPv6 e.g. 0:0:0:0:0:0:0:1
        // Firefox 1.0.7 returns IPv4 e.g. 127.0.0.1
        // This is the value used to resolve pages in the _ip directory
        // TODO create an option to convert all IPv4 addresses to IPv6
        return context.getRequest().getRemoteAddr();
    }
                        

2. The Page Locator

Users with this profile rule set to the page locator are served pages from the _ip directory of the psml site tree. Example, if a request is made for http://www.apache.org/jetspeed/portal/default-page.psml from 81.29.65.234 then the rule will match /WEB-INF/pages/_ip/81.29.65.234/default-page.psml before falling back to /WEB-INF/pages/default-page.psml

3. Example Use Cases

You have a location in Tokyo serving content specific to that location. Your kiosk is configured with a fixed IP address. The annonymous user (guest by default) uses this profile rule. Anyone using the portal from that kiosk would be served content from the _ip directory.

It could also be used to profile robots. Or keep out unwanted visitors. And can be the basis for profiling IP ranges or IP prefixes, networks and subnetworks, and geographic locations.