You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by no...@apache.org on 2006/05/24 15:19:43 UTC

svn commit: r409155 - /james/jspf/trunk/src/main/java/org/apache/james/jspf/SPFQuery.java

Author: norman
Date: Wed May 24 06:19:43 2006
New Revision: 409155

URL: http://svn.apache.org/viewvc?rev=409155&view=rev
Log:
Add new class for commandline usage. See JSPF-13

Added:
    james/jspf/trunk/src/main/java/org/apache/james/jspf/SPFQuery.java

Added: james/jspf/trunk/src/main/java/org/apache/james/jspf/SPFQuery.java
URL: http://svn.apache.org/viewvc/james/jspf/trunk/src/main/java/org/apache/james/jspf/SPFQuery.java?rev=409155&view=auto
==============================================================================
--- james/jspf/trunk/src/main/java/org/apache/james/jspf/SPFQuery.java (added)
+++ james/jspf/trunk/src/main/java/org/apache/james/jspf/SPFQuery.java Wed May 24 06:19:43 2006
@@ -0,0 +1,81 @@
+/***********************************************************************
+ * Copyright (c) 2006 The Apache Software Foundation.                  *
+ * All rights reserved.                                                *
+ * ------------------------------------------------------------------- *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you *
+ * may not use this file except in compliance with the License. You    *
+ * may obtain a copy of the License at:                                *
+ *                                                                     *
+ *     http://www.apache.org/licenses/LICENSE-2.0                      *
+ *                                                                     *
+ * Unless required by applicable law or agreed to in writing, software *
+ * distributed under the License is distributed on an "AS IS" BASIS,   *
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or     *
+ * implied.  See the License for the specific language governing       *
+ * permissions and limitations under the License.                      *
+ ***********************************************************************/
+
+package org.apache.james.jspf;
+
+/**
+ * This class is used for commandline usage of JSPF
+ * 
+ * @author Norman Maurer <nm...@byteaction.de>
+ * @author Stefano Bagnara <ap...@bago.org>
+ */
+public class SPFQuery {
+
+    /**
+     * @param args
+     *            The commandline arguments to parse
+     */
+    public static void main(String[] args) {
+        String ip = null;
+        String sender = null;
+        String helo = null;
+
+        // Parse the command line arguments
+        if (args.length < 3) {
+            usage();
+        } else {
+            for (int i = 0; i < args.length; i++) {
+                String[] arguments = args[i].split("=");
+                if (arguments.length == 2) {
+                    if (arguments[0].equals("-ip")) {
+                        ip = arguments[1];
+                    } else if (arguments[0].equals("-sender")) {
+                        sender = arguments[1];
+                    } else if (arguments[0].equals("-helo")) {
+                        helo = arguments[1];
+                    } else {
+                        usage();
+                    }
+                } else {
+                    usage();
+                }
+
+            }
+
+            // check if all needed values was set
+            if (ip != null && sender != null && helo != null) {
+                SPF spf = new SPF();
+                SPFResult result = spf.checkSPF(ip, sender, helo);
+                System.out.println(result.getResult());
+                System.out.println(result.getHeader());
+                System.exit(0);
+            } else {
+                usage();
+            }
+        }
+    }
+
+    /**
+     * Print out the usage
+     */
+    private static void usage() {
+        System.out
+                .println("Usage: SPFQuery -ip=192.168.100.1 -sender=postmaster@foo.bar -helo=foo.bar");
+        System.exit(0);
+    }
+
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org