@@ -0,0 +1,2435 @@
+package fr.sewatech.tcutils.valves;%0A%0Aimport java.io.IOException;%0A%0Aimport javax.servlet.ServletException;%0A%0Aimport org.apache.catalina.connector.Request;%0Aimport org.apache.catalina.connector.Response;%0Aimport org.apache.catalina.valves.ValveBase;%0A%0A/**%0A * AccessLogValve has a condition feature, based on the presence of an attributeName in request. This valve transform%0A * conditions on HTTP headers into a boolean attributeName.%0A * %3Cp%3E%0A * Conditions are exact value, prefix or suffix%0A * %3Cp%3E%0A * Configuration :%0A * %3CValve className=%22fr.sewatech.tcutils.valves.AccessLogConditionHeaderValve%22%0A *        attributeName=%22sewatech.fr%22 header=%22Host%22 suffix=%22sewatech.fr%22 /%3E%0A * %3Cp%3E%0A * Use in access logs :%0A * %3CValve className=%22org.apache.catalina.valves.AccessLogValve%22%0A * ... conditionIf=%22sewatech.fr%22 ... /%3E%0A *%0A * @author Alexis Hassler%0A */%0A%0Apublic class AccessLogConditionHeaderValve extends ValveBase %7B%0A%0A    private String attributeName = %22%22;%0A    private String header = %22%22;%0A    private String value = %22%22;%0A    private String suffix = %22%22;%0A    private String prefix = %22%22;%0A%0A    @Override%0A    public void invoke(Request request, Response response) throws IOException, ServletException %7B%0A        String headerValue = request.getHeader(this.header);%0A        if (headerValue != null) %7B%0A            if (!value.isEmpty() && headerValue.equals(value)) %7B%0A                request.setAttribute(attributeName, true);%0A            %7D else if (!suffix.isEmpty() && headerValue.endsWith(suffix)%0A                    %7C%7C !prefix.isEmpty() && headerValue.startsWith(prefix)) %7B%0A                request.setAttribute(attributeName, true);%0A            %7D%0A        %7D%0A%0A        this.getNext().invoke(request, response);%0A    %7D%0A%0A    public void setAttributeName(String attributeName) %7B%0A        this.attributeName = attributeName;%0A    %7D%0A%0A    public String getAttributeName() %7B%0A        return attributeName;%0A    %7D%0A%0A    public void setValue(String value) %7B%0A        this.value = value;%0A    %7D%0A%0A    public String getValue() %7B%0A        return value;%0A    %7D%0A%0A    public void setHeader(String header) %7B%0A        this.header = header;%0A    %7D%0A%0A    public String getHeader() %7B%0A        return header;%0A    %7D%0A%0A    public void setSuffix(String suffix) %7B%0A        this.suffix = suffix;%0A    %7D%0A%0A    public String getSuffix() %7B%0A        return suffix;%0A    %7D%0A%0A    public void setPrefix(String prefix) %7B%0A        this.prefix = prefix;%0A    %7D%0A%0A    public String getPrefix() %7B%0A        return prefix;%0A    %7D%0A%7D%0A%0A

Enhance access log condition with a header based valve