1 /****************************************************************
2 * Licensed to the Apache Software Foundation (ASF) under one *
3 * or more contributor license agreements. See the NOTICE file *
4 * distributed with this work for additional information *
5 * regarding copyright ownership. The ASF licenses this file *
6 * to you under the Apache License, Version 2.0 (the *
7 * "License"); you may not use this file except in compliance *
8 * with the License. You may obtain a copy of the License at *
9 * *
10 * http://www.apache.org/licenses/LICENSE-2.0 *
11 * *
12 * Unless required by applicable law or agreed to in writing, *
13 * software distributed under the License is distributed on an *
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
15 * KIND, either express or implied. See the License for the *
16 * specific language governing permissions and limitations *
17 * under the License. *
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 * This abstract class represent a gerneric modifier
34 *
35 */
36 public abstract class GenericModifier implements Modifier, ConfigurationEnabled, LogEnabled {
37
38 private String host;
39
40 protected Logger log;
41
42 /**
43 * @see org.apache.james.jspf.core.SPFChecker#checkSPF(org.apache.james.jspf.core.SPFSession)
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 * @see org.apache.james.jspf.terms.Modifier#enforceSingleInstance()
60 */
61 public boolean enforceSingleInstance() {
62 return true;
63 }
64
65 /**
66 * @see org.apache.james.jspf.terms.ConfigurationEnabled#config(Configuration)
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 * @return Returns the host.
76 */
77 protected synchronized String getHost() {
78 return host;
79 }
80
81
82 /**
83 * @see org.apache.james.jspf.core.LogEnabled#enableLogging(org.apache.james.jspf.core.Logger)
84 */
85 public void enableLogging(Logger logger) {
86 this.log = logger;
87 }
88
89
90 }