FileDocCategorySizeDatePackage
HasHabeasWarrantMark.javaAPI DocApache James 2.3.15219Fri Jan 12 12:56:32 GMT 2007org.apache.james.transport.matchers

HasHabeasWarrantMark

public class HasHabeasWarrantMark extends org.apache.mailet.GenericMatcher
Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. *

Fields Summary
public static final String[]
warrantMark
Constructors Summary
Methods Summary
public java.lang.StringgetMatcherInfo()

        return "Habeas Warrant Mark Matcher (see http://www.habeas.com for details).";
    
public java.util.Collectionmatch(org.apache.mailet.Mail mail)


         
    
        MimeMessage message = mail.getMessage();

        //Loop through all the patterns
        for (int i = 0; i < warrantMark.length; i++) try
        {
            String headerName = warrantMark[i][0];                      //Get the header name
            String requiredValue = warrantMark[i][1];                   //Get the required value
            String headerValue = message.getHeader(headerName, null);   //Get the header value(s)

            // We want an exact match, so only test the first value.
            // If there are multiple values, the header may be
            // (illegally) forged.  I'll leave it as an exercise to
            // others if they want to detect and report potentially
            // forged headers.

            if (!(requiredValue.equals(headerValue))) return null;
        }
        catch (Exception e)
        {
            log(e.toString());
            return null;            //if we get an exception, don't validate the mark
        }

        // If we get here, all headers are present and match.
        return mail.getRecipients();