org.apache.james.jspf.parser
Class RFC4408SPF1Parser

java.lang.Object
  extended by org.apache.james.jspf.parser.RFC4408SPF1Parser
All Implemented Interfaces:
SPFRecordParser

public class RFC4408SPF1Parser
extends java.lang.Object
implements SPFRecordParser

This class is used to parse SPF1-Records from their textual form to an SPF1Record object that is composed by 2 collections: directives and modifiers. The parsing is modular and get informations from Mechanism and Modifiers classes declared in the org/apache/james/jspf/parser/jspf.default.terms file. Each term implementation provide its own REGEX in the REGEX static public field. This parser simply join all the regexp in a single "alternative" pattern and count the number of catch groups (brackets) assigned to each regex fragment. SO it creates a big regex and an array where it store what term is associated to each catch group of the big regex. If the regex matches the input vspf1 record then it start looking for the matched group (not null) and lookup the term that created that part of the regex. With this informations it creates a new instance of the term and, if the term is ConfigurationEnabled it calls the config() method passing to it only the specific subset of the MatchResult (using the MatchResultSubset). TODO doubts about the specification - redirect or exp with no domain-spec are evaluated as an unknown-modifiers according to the current spec (it does not make too much sense) - top-label is defined differently in various specs. We'll have to review the code. - http://data.iana.org/TLD/tlds-alpha-by-domain.txt (we should probably beeter use and alpha sequence being at least 2 chars - Somewhere is defined as "." TLD [ "." ] - Otherwise defined as ( *alphanum ALPHA *alphanum ) / ( 1*alphanum "-" *( * alphanum / "-" ) alphanum )

See Also:
SPF1Record

Constructor Summary
RFC4408SPF1Parser(Logger logger, TermsFactory termsFactory)
          Constructor.
 
Method Summary
 SPF1Record parse(java.lang.String spfRecord)
          This Method parse the given spf record and checks for syntax parse can be called by multiple concurrent threads.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RFC4408SPF1Parser

public RFC4408SPF1Parser(Logger logger,
                         TermsFactory termsFactory)
Constructor. Creates all the values needed to run the parsing

Parameters:
logger - the logger to use
termsFactory - the TermsFactory implementation
Method Detail

parse

public SPF1Record parse(java.lang.String spfRecord)
                 throws PermErrorException,
                        NoneException,
                        NeutralException
Description copied from interface: SPFRecordParser
This Method parse the given spf record and checks for syntax parse can be called by multiple concurrent threads.

Specified by:
parse in interface SPFRecordParser
Parameters:
spfRecord - The String which represent the spf record in dns
Returns:
result The SPF1Record
Throws:
PermErrorException - Get thrown if an syntax error was detected
NoneException - Get thrown if no spf record could be found
NeutralException - Get thrown if an empty spf record was found
See Also:
SPFRecordParser.parse(java.lang.String)


Copyright © 2006-2009 The Apache Software Foundation. All Rights Reserved.