You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pl...@apache.org on 2018/08/15 07:13:47 UTC

directory-kerby git commit: Remove the org.json dependency.

Repository: directory-kerby
Updated Branches:
  refs/heads/trunk 7ec96950d -> f44144cff


Remove the org.json dependency.


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

Branch: refs/heads/trunk
Commit: f44144cff85df8c9af61a6a53b41ea5786c16a3d
Parents: 7ec9695
Author: plusplusjiajia <ji...@intel.com>
Authored: Wed Aug 15 15:10:51 2018 +0800
Committer: plusplusjiajia <ji...@intel.com>
Committed: Wed Aug 15 15:10:51 2018 +0800

----------------------------------------------------------------------
 kerby-tool/has-tool/pom.xml                     |  5 ---
 .../remote/cmd/GetPrincipalRemoteCommand.java   | 47 ++++++++++++++------
 2 files changed, 33 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/f44144cf/kerby-tool/has-tool/pom.xml
----------------------------------------------------------------------
diff --git a/kerby-tool/has-tool/pom.xml b/kerby-tool/has-tool/pom.xml
index 0844dd4..0dc5ca4 100644
--- a/kerby-tool/has-tool/pom.xml
+++ b/kerby-tool/has-tool/pom.xml
@@ -42,11 +42,6 @@
             <artifactId>jsch</artifactId>
             <version>${jsch.version}</version>
         </dependency>
-        <dependency>
-            <groupId>org.json</groupId>
-            <artifactId>json</artifactId>
-            <version>LATEST</version>
-        </dependency>
     </dependencies>
 
 </project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/f44144cf/kerby-tool/has-tool/src/main/java/org/apache/kerby/kerberos/tool/admin/remote/cmd/GetPrincipalRemoteCommand.java
----------------------------------------------------------------------
diff --git a/kerby-tool/has-tool/src/main/java/org/apache/kerby/kerberos/tool/admin/remote/cmd/GetPrincipalRemoteCommand.java b/kerby-tool/has-tool/src/main/java/org/apache/kerby/kerberos/tool/admin/remote/cmd/GetPrincipalRemoteCommand.java
index ce32237..1b062e2 100644
--- a/kerby-tool/has-tool/src/main/java/org/apache/kerby/kerberos/tool/admin/remote/cmd/GetPrincipalRemoteCommand.java
+++ b/kerby-tool/has-tool/src/main/java/org/apache/kerby/kerberos/tool/admin/remote/cmd/GetPrincipalRemoteCommand.java
@@ -19,9 +19,10 @@
  */
 package org.apache.kerby.kerberos.tool.admin.remote.cmd;
 
-import org.json.JSONObject;
 import org.apache.kerby.kerberos.kerb.KrbException;
 import org.apache.kerby.has.client.HasAuthAdminClient;
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
 
 /**
  * Remote get principal cmd
@@ -55,20 +56,38 @@ public class GetPrincipalRemoteCommand extends AdminRemoteCmd {
             return;
         } else {
             System.out.println("Principal is listed:");
-            JSONObject principle = new JSONObject(principalData);
-            System.out.println(
-                    "Principal: " + principle.getString("Name") + "\n"
-                            + "Expiration date: " + principle.getString("Expiration date") + "\n"
-                            + "Created time: "
-                            + principle.getString("Created time") + "\n"
-                            + "KDC flags: " + String.valueOf(principle.getInt("KDC flags")) + "\n"
-                            + "Key version: " + String.valueOf(principle.getInt("Key version")) + "\n"
-                            + "Number of keys: " + String.valueOf(principle.getInt("Number of keys"))
-            );
+            JSONObject principle;
+            try {
+                principle = new JSONObject(principalData);
+            } catch (JSONException e) {
+                throw new KrbException(e.getMessage());
+            }
+            try {
+                System.out.println(
+                        "Principal: " + principle.getString("Name") + "\n"
+                                + "Expiration date: " + principle.getString("Expiration date") + "\n"
+                                + "Created time: "
+                                + principle.getString("Created time") + "\n"
+                                + "KDC flags: " + String.valueOf(principle.getInt("KDC flags")) + "\n"
+                                + "Key version: " + String.valueOf(principle.getInt("Key version")) + "\n"
+                                + "Number of keys: " + String.valueOf(principle.getInt("Number of keys"))
+                );
+            } catch (JSONException e) {
+                throw new KrbException(e.getMessage());
+            }
 
-            JSONObject keySet = principle.getJSONObject("Keys");
-            for (int keyCount = 0; keyCount < principle.getInt("Number of keys"); keyCount++) {
-                System.out.println("key: " + keySet.getString(String.valueOf(keyCount)));
+            JSONObject keySet;
+            try {
+                keySet = principle.getJSONObject("Keys");
+            } catch (JSONException e) {
+                throw new KrbException(e.getMessage());
+            }
+            try {
+                for (int keyCount = 0; keyCount < principle.getInt("Number of keys"); keyCount++) {
+                    System.out.println("key: " + keySet.getString(String.valueOf(keyCount)));
+                }
+            } catch (JSONException e) {
+                throw new KrbException(e.getMessage());
             }
         }
     }