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-180 Better to use string representation of keys in Json backend file. Contributed by Jiajia
Date Fri, 20 Mar 2015 06:56:24 GMT
Repository: directory-kerby
Updated Branches:
  refs/heads/master 7a441d451 -> 8ca2c41f7


DIRKRB-180 Better to use string representation of keys in Json backend file.  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/8ca2c41f
Tree: http://git-wip-us.apache.org/repos/asf/directory-kerby/tree/8ca2c41f
Diff: http://git-wip-us.apache.org/repos/asf/directory-kerby/diff/8ca2c41f

Branch: refs/heads/master
Commit: 8ca2c41f7ecc776b14b53d6dc7e6d543953f3a8c
Parents: 7a441d4
Author: hazel <linchen7@foxmail.com>
Authored: Fri Mar 20 14:56:15 2015 +0800
Committer: hazel <linchen7@foxmail.com>
Committed: Fri Mar 20 14:56:15 2015 +0800

----------------------------------------------------------------------
 .../typeAdapter/EncryptionKeyAdapter.java         | 18 +++---------------
 kdc-backend/pom.xml                               |  8 ++++++++
 2 files changed, 11 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/8ca2c41f/kdc-backend/json-backend/src/main/java/org/apache/kerby/kerberos/kdc/identitybackend/typeAdapter/EncryptionKeyAdapter.java
----------------------------------------------------------------------
diff --git a/kdc-backend/json-backend/src/main/java/org/apache/kerby/kerberos/kdc/identitybackend/typeAdapter/EncryptionKeyAdapter.java
b/kdc-backend/json-backend/src/main/java/org/apache/kerby/kerberos/kdc/identitybackend/typeAdapter/EncryptionKeyAdapter.java
index 96d504d..f1b69c6 100644
--- a/kdc-backend/json-backend/src/main/java/org/apache/kerby/kerberos/kdc/identitybackend/typeAdapter/EncryptionKeyAdapter.java
+++ b/kdc-backend/json-backend/src/main/java/org/apache/kerby/kerberos/kdc/identitybackend/typeAdapter/EncryptionKeyAdapter.java
@@ -22,6 +22,7 @@ package org.apache.kerby.kerberos.kdc.identitybackend.typeAdapter;
 import com.google.gson.*;
 import org.apache.kerby.kerberos.kerb.spec.common.EncryptionKey;
 import org.apache.kerby.kerberos.kerb.spec.common.EncryptionType;
+import org.apache.kerby.util.HexUtil;
 
 import java.lang.reflect.Type;
 
@@ -38,14 +39,7 @@ public class EncryptionKeyAdapter implements JsonSerializer<EncryptionKey>,
         String encryptionTypeString = jsonObject.get("keyType").getAsString();
         EncryptionType encryptionType = EncryptionType.fromName(encryptionTypeString);
         encryptionKey.setKeyType(encryptionType);
-
-        JsonArray jsonArray = jsonObject.get("keyData").getAsJsonArray();
-        byte[] keyData = new byte[jsonArray.size()];
-        for (int i = 0; i < jsonArray.size(); i++) {
-            JsonElement element = jsonArray.get(i);
-            keyData[i] = element.getAsByte();
-        }
-        encryptionKey.setKeyData(keyData);
+        encryptionKey.setKeyData(HexUtil.hex2bytes(jsonObject.get("keyData").getAsString()));
         return encryptionKey;
     }
 
@@ -55,13 +49,7 @@ public class EncryptionKeyAdapter implements JsonSerializer<EncryptionKey>,
         JsonObject jsonObject = new JsonObject();
         jsonObject.addProperty("kvno", encryptionKey.getKvno());
         jsonObject.addProperty("keyType", encryptionKey.getKeyType().getName());
-
-        JsonArray jsonArray = new JsonArray();
-        byte[] keyData = encryptionKey.getKeyData();
-        for (byte aData : keyData) {
-            jsonArray.add(new JsonPrimitive(aData));
-        }
-        jsonObject.add("keyData", jsonArray);
+        jsonObject.addProperty("keyData", HexUtil.bytesToHex(encryptionKey.getKeyData()));
         return jsonObject;
     }
 }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/8ca2c41f/kdc-backend/pom.xml
----------------------------------------------------------------------
diff --git a/kdc-backend/pom.xml b/kdc-backend/pom.xml
index 26560ce..fd1f626 100644
--- a/kdc-backend/pom.xml
+++ b/kdc-backend/pom.xml
@@ -31,4 +31,12 @@
     <module>json-backend</module>
     <module>zookeeper-backend</module>
   </modules>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.kerby</groupId>
+      <artifactId>kerby-util</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+  </dependencies>
 </project>


Mime
View raw message