001 /****************************************************************
002 * Licensed to the Apache Software Foundation (ASF) under one *
003 * or more contributor license agreements. See the NOTICE file *
004 * distributed with this work for additional information *
005 * regarding copyright ownership. The ASF licenses this file *
006 * to you under the Apache License, Version 2.0 (the *
007 * "License"); you may not use this file except in compliance *
008 * with the License. You may obtain a copy of the License at *
009 * *
010 * http://www.apache.org/licenses/LICENSE-2.0 *
011 * *
012 * Unless required by applicable law or agreed to in writing, *
013 * software distributed under the License is distributed on an *
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
015 * KIND, either express or implied. See the License for the *
016 * specific language governing permissions and limitations *
017 * under the License. *
018 ****************************************************************/
019
020
021 package org.apache.james.jspf.terms;
022
023 import org.apache.james.jspf.core.DNSLookupContinuation;
024 import org.apache.james.jspf.core.SPFSession;
025 import org.apache.james.jspf.core.SPFTermsRegexps;
026 import org.apache.james.jspf.core.exceptions.PermErrorException;
027
028 /**
029 * This Class represent an Unknown Modifier
030 *
031 */
032 public class UnknownModifier implements Modifier, ConfigurationEnabled {
033
034 /**
035 * ABNF: name = ALPHA *( ALPHA / DIGIT / "-" / "_" / "." ) ABNF:
036 * unknown-modifier = name "=" macro-string
037 */
038 public static final String REGEX = "(" + SPFTermsRegexps.ALPHA_PATTERN + "{1}"
039 + "[A-Za-z0-9\\-\\_\\.]*" + ")" + "\\=("
040 + SPFTermsRegexps.MACRO_STRING_REGEX + ")";
041
042 /**
043 * @see org.apache.james.jspf.core.SPFChecker#checkSPF(org.apache.james.jspf.core.SPFSession)
044 */
045 public DNSLookupContinuation checkSPF(SPFSession spfData) throws PermErrorException {
046 return null;
047 }
048
049 /**
050 * @see org.apache.james.jspf.terms.Modifier#enforceSingleInstance()
051 */
052 public boolean enforceSingleInstance() {
053 return false;
054 }
055
056 /**
057 * @see org.apache.james.jspf.terms.ConfigurationEnabled#config(org.apache.james.jspf.terms.Configuration)
058 */
059 public synchronized void config(Configuration params) throws PermErrorException {
060 if (params.groupCount() >= 2 && params.group(1) != null) {
061 String name = params.group(1).toLowerCase();
062 if ("exp".equals(name) || "redirect".equals(name)) {
063 throw new PermErrorException("exp and redirect are not valid names for unknown modifier: this probably means an invalid syntax for exp or redirect fallback to the unkown modifier.");
064 }
065 }
066 }
067
068 }