1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.apache.james.jspf.terms;
22
23 import org.apache.james.jspf.core.DNSLookupContinuation;
24 import org.apache.james.jspf.core.LogEnabled;
25 import org.apache.james.jspf.core.Logger;
26 import org.apache.james.jspf.core.SPFSession;
27 import org.apache.james.jspf.core.exceptions.NeutralException;
28 import org.apache.james.jspf.core.exceptions.NoneException;
29 import org.apache.james.jspf.core.exceptions.PermErrorException;
30 import org.apache.james.jspf.core.exceptions.TempErrorException;
31
32
33
34
35
36 public abstract class GenericModifier implements Modifier, ConfigurationEnabled, LogEnabled {
37
38 private String host;
39
40 protected Logger log;
41
42
43
44
45 public DNSLookupContinuation checkSPF(SPFSession spfData) throws PermErrorException,
46 TempErrorException, NeutralException, NoneException {
47 log.debug("Processing modifier: " + this);
48 DNSLookupContinuation res = checkSPFLogged(spfData);
49 log.debug("Processed modifier: " + this + " resulted in "
50 + res == null ? spfData.getCurrentResult() : " dns continuation...");
51 return res;
52 }
53
54 protected abstract DNSLookupContinuation checkSPFLogged(SPFSession spfData) throws PermErrorException,
55 TempErrorException, NeutralException, NoneException;
56
57
58
59
60
61 public boolean enforceSingleInstance() {
62 return true;
63 }
64
65
66
67
68 public synchronized void config(Configuration params) throws PermErrorException {
69 if (params.groupCount() > 0) {
70 this.host = params.group(1);
71 }
72 }
73
74
75
76
77 protected synchronized String getHost() {
78 return host;
79 }
80
81
82
83
84
85 public void enableLogging(Logger logger) {
86 this.log = logger;
87 }
88
89
90 }