directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ha...@apache.org
Subject directory-kerby git commit: DIRKRB-241 Move parseSetValue function from ToolUtil class to KOptions class. Contributed by Jiajia
Date Fri, 24 Apr 2015 15:32:40 GMT
Repository: directory-kerby
Updated Branches:
  refs/heads/master 854f924db -> 9d78fd57a


DIRKRB-241 Move parseSetValue function from ToolUtil class to KOptions class. Contributed
by Jiajia


Project: http://git-wip-us.apache.org/repos/asf/directory-kerby/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-kerby/commit/9d78fd57
Tree: http://git-wip-us.apache.org/repos/asf/directory-kerby/tree/9d78fd57
Diff: http://git-wip-us.apache.org/repos/asf/directory-kerby/diff/9d78fd57

Branch: refs/heads/master
Commit: 9d78fd57a08f7690b6fa418faa02b25e6e94f852
Parents: 854f924
Author: Lin <linchen7@foxmail.com>
Authored: Fri Apr 24 23:32:18 2015 +0800
Committer: Lin <linchen7@foxmail.com>
Committed: Fri Apr 24 23:32:18 2015 +0800

----------------------------------------------------------------------
 .../apache/kerby/kerberos/tool/ToolUtil.java    | 45 +-------------------
 .../apache/kerby/kerberos/tool/kinit/Kinit.java |  2 +-
 .../apache/kerby/kerberos/tool/klist/Klist.java |  5 +--
 .../main/java/org/apache/kerby/KOptions.java    | 39 +++++++++++++++++
 4 files changed, 43 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9d78fd57/kerby-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/ToolUtil.java
----------------------------------------------------------------------
diff --git a/kerby-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/ToolUtil.java
b/kerby-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/ToolUtil.java
index 45d9c65..c9b5c6e 100644
--- a/kerby-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/ToolUtil.java
+++ b/kerby-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/ToolUtil.java
@@ -20,11 +20,8 @@
 package org.apache.kerby.kerberos.tool;
 
 import org.apache.kerby.KOption;
-import org.apache.kerby.KOptionType;
-import org.apache.kerby.kerberos.kerb.client.KrbOption;
 import org.apache.kerby.KOptions;
-
-import java.io.File;
+import org.apache.kerby.kerberos.kerb.client.KrbOption;
 
 /**
  * Tool utilities.
@@ -32,46 +29,6 @@ import java.io.File;
 public class ToolUtil {
 
     /**
-     * Parse string value according to kopt type.
-     * @param kopt
-     * @param strValue
-     * @return true when successful, false otherwise
-     */
-    public static boolean parseSetValue(KOption kopt, String strValue) {
-        KOptionType kt = kopt.getType();
-        if (kt == KOptionType.NOV) {
-            return true; // no need of a value
-        }
-        if (strValue == null || strValue.isEmpty()) {
-            return false;
-        }
-
-        if (kt == KOptionType.FILE) {
-            // May check file sanity
-            kopt.setValue(new File(strValue));
-        } else if (kt == KOptionType.DIR) {
-            File dir = new File(strValue);
-            if (! dir.exists()) {
-                throw new IllegalArgumentException("Invalid dir:" + strValue);
-            }
-            kopt.setValue(dir);
-        } else if (kt == KOptionType.INT) {
-            try {
-                Integer num = Integer.valueOf(strValue);
-                kopt.setValue(num);
-            } catch (NumberFormatException nfe) {
-                throw new IllegalArgumentException("Invalid integer:" + strValue);
-            }
-        } else if (kt == KOptionType.STR) {
-            kopt.setValue(strValue);
-        } else {
-            throw new IllegalArgumentException("Not recognised option:" + strValue);
-        }
-
-        return true;
-    }
-
-    /**
      * Convert tool (like kinit) options to KrbOptions.
      * @param krbOptions
      * @return krb options

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9d78fd57/kerby-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/kinit/Kinit.java
----------------------------------------------------------------------
diff --git a/kerby-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/kinit/Kinit.java
b/kerby-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/kinit/Kinit.java
index 6c47ee9..cdb5997 100644
--- a/kerby-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/kinit/Kinit.java
+++ b/kerby-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/kinit/Kinit.java
@@ -176,7 +176,7 @@ public class Kinit {
                     param = args[i++];
                 }
                 if (param != null) {
-                    ToolUtil.parseSetValue(kto, param);
+                    KOptions.parseSetValue(kto, param);
                 } else {
                     error = "Option " + opt + " require a parameter";
                 }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9d78fd57/kerby-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/klist/Klist.java
----------------------------------------------------------------------
diff --git a/kerby-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/klist/Klist.java
b/kerby-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/klist/Klist.java
index fae97fd..88e8700 100644
--- a/kerby-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/klist/Klist.java
+++ b/kerby-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/klist/Klist.java
@@ -20,10 +20,9 @@
 package org.apache.kerby.kerberos.tool.klist;
 
 import org.apache.kerby.KOptionType;
+import org.apache.kerby.KOptions;
 import org.apache.kerby.kerberos.kerb.ccache.Credential;
 import org.apache.kerby.kerberos.kerb.ccache.CredentialCache;
-import org.apache.kerby.KOptions;
-import org.apache.kerby.kerberos.tool.ToolUtil;
 
 import java.io.FileInputStream;
 import java.io.IOException;
@@ -141,7 +140,7 @@ public class Klist {
                     value = args[i++];
                 }
                 if (value != null) {
-                    ToolUtil.parseSetValue(klopt, value);
+                    KOptions.parseSetValue(klopt, value);
                 } else {
                     error = "Option" + klopt + "requires a following value";
                 }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/9d78fd57/lib/kerby-util/src/main/java/org/apache/kerby/KOptions.java
----------------------------------------------------------------------
diff --git a/lib/kerby-util/src/main/java/org/apache/kerby/KOptions.java b/lib/kerby-util/src/main/java/org/apache/kerby/KOptions.java
index 5e2780d..b31cb7b 100644
--- a/lib/kerby-util/src/main/java/org/apache/kerby/KOptions.java
+++ b/lib/kerby-util/src/main/java/org/apache/kerby/KOptions.java
@@ -33,6 +33,45 @@ public class KOptions {
     private final Map<KOption, KOption> options =
             new HashMap<KOption, KOption>();
 
+    /**
+     * Parse string value according to kopt type.
+     * @param kopt
+     * @param strValue
+     * @return true when successful, false otherwise
+     */
+    public static boolean parseSetValue(KOption kopt, String strValue) {
+        KOptionType kt = kopt.getType();
+        if (kt == KOptionType.NOV) {
+            return true; // no need of a value
+        }
+        if (strValue == null || strValue.isEmpty()) {
+            return false;
+        }
+
+        if (kt == KOptionType.FILE) {
+            // May check file sanity
+            kopt.setValue(new File(strValue));
+        } else if (kt == KOptionType.DIR) {
+            File dir = new File(strValue);
+            if (! dir.exists()) {
+                throw new IllegalArgumentException("Invalid dir:" + strValue);
+            }
+            kopt.setValue(dir);
+        } else if (kt == KOptionType.INT) {
+            try {
+                Integer num = Integer.valueOf(strValue);
+                kopt.setValue(num);
+            } catch (NumberFormatException nfe) {
+                throw new IllegalArgumentException("Invalid integer:" + strValue);
+            }
+        } else if (kt == KOptionType.STR) {
+            kopt.setValue(strValue);
+        } else {
+            throw new IllegalArgumentException("Not recognised option:" + strValue);
+        }
+        return true;
+    }
+
     public void add(KOption option) {
         if (option != null) {
             options.put(option, option);


Mime
View raw message