Class RFC4408SPF1Parser

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

public class RFC4408SPF1Parser extends 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: