directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From plusplusjia...@apache.org
Subject directory-kerby git commit: DIRKRB-570 Implement Add_Principal (with password) in Remote Kadmin. Contributed by Yan.
Date Tue, 24 May 2016 02:45:01 GMT
Repository: directory-kerby
Updated Branches:
  refs/heads/kadmin-remote 89e538089 -> db2ecc2ed


DIRKRB-570 Implement Add_Principal (with password) in Remote Kadmin. Contributed by Yan.


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

Branch: refs/heads/kadmin-remote
Commit: db2ecc2ed799ad62e347829abb901967e2cdd157
Parents: 89e5380
Author: plusplusjiajia <jiajia.li@intel.com>
Authored: Tue May 24 10:49:45 2016 +0800
Committer: plusplusjiajia <jiajia.li@intel.com>
Committed: Tue May 24 10:49:45 2016 +0800

----------------------------------------------------------------------
 .../admin/server/kadmin/AdminServerHandler.java | 106 +++++++++++++------
 .../kerberos/kerb/admin/RemoteAdminTool.java    |  25 +++--
 .../kerb/admin/kadmin/remote/AdminClient.java   |   7 +-
 .../kerb/admin/kadmin/remote/AdminHandler.java  |  28 ++++-
 .../admin/kadmin/remote/RemoteKadminImpl.java   |   5 +-
 .../remote/request/AddPrincipalRequest.java     |   7 +-
 .../kerb/admin/tool/AddPrincipalRep.java        |   2 +-
 .../kerb/admin/tool/AddPrincipalReq.java        |   2 +-
 .../kerb/admin/tool/AdminMessageCode.java       |   5 +-
 .../kerb/admin/tool/AdminMessageType.java       |   8 +-
 .../kerb/admin/tool/DeletePrincipalRep.java     |   2 +-
 .../kerb/admin/tool/DeletePrincipalReq.java     |   2 +-
 .../kerberos/kerb/admin/tool/KadminCode.java    |   4 +-
 13 files changed, 144 insertions(+), 59 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/db2ecc2e/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/kadmin/AdminServerHandler.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/kadmin/AdminServerHandler.java
b/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/kadmin/AdminServerHandler.java
index 4f81328..951efb6 100644
--- a/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/kadmin/AdminServerHandler.java
+++ b/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/kadmin/AdminServerHandler.java
@@ -21,13 +21,10 @@ package org.apache.kerby.kerberos.kerb.admin.server.kadmin;
 
 import org.apache.kerby.kerberos.kerb.admin.kadmin.local.LocalKadmin;
 import org.apache.kerby.kerberos.kerb.admin.kadmin.local.LocalKadminImpl;
-import org.apache.kerby.kerberos.kerb.admin.tool.AddPrincipalRep;
-import org.apache.kerby.kerberos.kerb.admin.tool.AdminMessageCode;
-import org.apache.kerby.kerberos.kerb.admin.tool.KadminCode;
+import org.apache.kerby.kerberos.kerb.admin.tool.*;
 import org.apache.kerby.kerberos.kerb.KrbException;
-import org.apache.kerby.kerberos.kerb.admin.tool.AdminMessage;
+import org.apache.kerby.xdr.XdrDataType;
 import org.apache.kerby.xdr.XdrFieldInfo;
-import org.apache.kerby.xdr.type.XdrString;
 import org.apache.kerby.xdr.type.XdrStructType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -66,44 +63,89 @@ public class AdminServerHandler {
         XdrStructType decoded = new AdminMessageCode();
         decoded.decode(receivedMessage);
         XdrFieldInfo[] fieldInfos = decoded.getValue().getXdrFieldInfos();
-        System.out.println("receive message type: " + fieldInfos[0].getValue());
-        System.out.println("receive message paramNum: " + fieldInfos[1].getValue());
-        String receiveMsg = (String) fieldInfos[2].getValue();
-        System.out.println("server handleMessage: " + receiveMsg);
-        String[] principal = receiveMsg.split("@");
-        System.out.println("clientName: " + principal[0]);
-        System.out.println("realm: " + principal[1]);
+        AdminMessageType type = (AdminMessageType) fieldInfos[0].getValue();
 
-        /**Add principal to backend here*/
+        /**Create LocalKadmin here*/
         LocalKadmin localKadmin = new LocalKadminImpl(adminServerContext.getAdminServerSetting());
-        try {
-            localKadmin.addPrincipal(principal[0]);
-        } catch (KrbException e) {
-            String error = "principal already exist!";
-            System.out.println(error);
-            AdminMessage errorMessage = new AddPrincipalRep();
-            XdrString xdrMessage = new XdrString(error);
-            errorMessage.setMessageBuffer(ByteBuffer.wrap(xdrMessage.encode()));
-            ByteBuffer response = KadminCode.encodeMessage(errorMessage);
-            return response;
+        ByteBuffer responseMessage = null;
+
+        switch (type) {
+            case ADD_PRINCIPAL_REQ:
+                System.out.println("message type: add principal req");
+                responseMessage = handleAddPrincipalReq(localKadmin, fieldInfos);
+                break;
+            default:
+                throw new KrbException("AdminMessageType error, can not handle it.");
         }
+        return responseMessage;
+
+    }
+
+    private ByteBuffer handleAddPrincipalReq(LocalKadmin localKadmin, XdrFieldInfo[] fieldInfos)
throws IOException {
+        String principal = (String) fieldInfos[2].getValue();
+        int paramNum = (int) fieldInfos[1].getValue();
+
+        if (paramNum == 1) {
+            /** Add principal with only principal name*/
+            LOG.info("handle nokey principal " + principal);
+            String[] temp = principal.split("@");
+            try {
+                localKadmin.addPrincipal(temp[0]);
+            } catch (KrbException e) {
+                String error = "principal already exist!";
+                LOG.error(error);
+                System.err.println(error);
+                XdrFieldInfo[] xdrFieldInfos = new XdrFieldInfo[3];
+                xdrFieldInfos[0] = new XdrFieldInfo(0, XdrDataType.ENUM, AdminMessageType.ADD_PRINCIPAL_REP);
+                xdrFieldInfos[1] = new XdrFieldInfo(1, XdrDataType.INTEGER, 1);
+                xdrFieldInfos[2] = new XdrFieldInfo(2, XdrDataType.STRING, error);
+                AdminMessageCode value = new AdminMessageCode(xdrFieldInfos);
+                AdminMessage errorMessage = new AddPrincipalRep();
+                errorMessage.setMessageBuffer(ByteBuffer.wrap(value.encode()));
+                ByteBuffer response = KadminCode.encodeMessage(errorMessage);
+                return response;
+            }
+        } else if (paramNum == 2 && fieldInfos[3].getDataType() == XdrDataType.STRING)
{
+            /** Add principal with password*/
+            LOG.info("handle principal with password " + principal);
+            String[] temp = principal.split("@");
+            String password = (String) fieldInfos[3].getValue();
+            try {
+                localKadmin.addPrincipal(temp[0], password);
+            } catch (KrbException e) {
+                String error = "principal already exist.\n"
+                    + "Choose update password instead of add principal";
+                System.err.println(error);
+                LOG.error(error);
 
-        String message = "add principal of " + principal[0];
+                XdrFieldInfo[] xdrFieldInfos = new XdrFieldInfo[3];
+                xdrFieldInfos[0] = new XdrFieldInfo(0, XdrDataType.ENUM, AdminMessageType.ADD_PRINCIPAL_REP);
+                xdrFieldInfos[1] = new XdrFieldInfo(1, XdrDataType.INTEGER, 1);
+                xdrFieldInfos[2] = new XdrFieldInfo(2, XdrDataType.STRING, error);
+                AdminMessageCode value = new AdminMessageCode(xdrFieldInfos);
+                AdminMessage errorMessage = new AddPrincipalRep();
+                errorMessage.setMessageBuffer(ByteBuffer.wrap(value.encode()));
+                ByteBuffer response = KadminCode.encodeMessage(errorMessage);
+                return response;
+            }
+        }
+
+        String message = "add principal of " + principal;
+        LOG.info(message);
         //content to reply remain to construct
         AdminMessage addPrincipalRep = new AddPrincipalRep();
         /** encode admin message:
          *  encode type
-         *  encode paranum
-         *  encode principal name
-         *  (encode koptions)
-         *  (encode passsword)
+         *  encode message
          */
-        XdrString value = new XdrString(message);
+        XdrFieldInfo[] xdrFieldInfos = new XdrFieldInfo[3];
+        xdrFieldInfos[0] = new XdrFieldInfo(0, XdrDataType.ENUM, AdminMessageType.ADD_PRINCIPAL_REP);
+        xdrFieldInfos[1] = new XdrFieldInfo(1, XdrDataType.INTEGER, 1);
+        xdrFieldInfos[2] = new XdrFieldInfo(2, XdrDataType.STRING, message);
+        AdminMessageCode value = new AdminMessageCode(xdrFieldInfos);
         addPrincipalRep.setMessageBuffer(ByteBuffer.wrap(value.encode()));
-        System.out.println("value length:" + addPrincipalRep.getMessageBuffer().capacity());
         ByteBuffer responseMessage = KadminCode.encodeMessage(addPrincipalRep);
-
         return responseMessage;
-
     }
+
 }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/db2ecc2e/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/RemoteAdminTool.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/RemoteAdminTool.java
b/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/RemoteAdminTool.java
index 9faf8fd..defbd92 100644
--- a/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/RemoteAdminTool.java
+++ b/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/RemoteAdminTool.java
@@ -40,9 +40,12 @@ public class RemoteAdminTool {
         ? "bin\\remoteAdmin.cmd" : "sh bin/remoteAdmin.sh")
         + " conf\n";
 
-    private static final String COMMAND = "Usage: add_principal <client-name>\n"
+    private static final String COMMAND = "Usage: add_principal [options] <principal-name>\n"
+        + "\toptions are:\n"
+        + "\t\t[-randkey|-nokey]\n"
+        + "\t\t[-pw password]"
         + "\tExample:\n"
-        + "\t\tadd_princial alice\n";
+        + "\t\tadd_principal -pw mypassword alice\n";
 
     public static void main(String[] args) throws Exception {
         AdminClient adminClient;
@@ -91,13 +94,21 @@ public class RemoteAdminTool {
             return;
         }
 
-        String[] temp = input.split(" ");
+        String[] temp = input.split("\\s+");
 
         if (temp[0].startsWith("add_principal")) {
-            if (temp.length == 2) {
-                String adminRealm = adminClient.getAdminConfig().getAdminRealm();
-                String clientPrincipal = temp[1] + "@" + adminRealm;
-                adminClient.requestAddPrincial(clientPrincipal);
+            String adminRealm = adminClient.getAdminConfig().getAdminRealm();
+            String clientPrincipal = temp[temp.length - 1] + "@" + adminRealm;
+            if (!temp[1].startsWith("-")) {
+                adminClient.requestAddPrincipal(clientPrincipal);
+            } else if (temp[1].startsWith("-nokey")) {
+                adminClient.requestAddPrincipal(clientPrincipal);
+            } else if (temp[1].startsWith("-pw")) {
+                String password = temp[2];
+                adminClient.requestAddPrincipal(clientPrincipal, password);
+            } else {
+                System.out.println("add_principal command format error.\n"
+                + "Please input command for further reference.");
             }
 
         } else {

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/db2ecc2e/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/kadmin/remote/AdminClient.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/kadmin/remote/AdminClient.java
b/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/kadmin/remote/AdminClient.java
index ab94349..5860eaf 100644
--- a/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/kadmin/remote/AdminClient.java
+++ b/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/kadmin/remote/AdminClient.java
@@ -165,8 +165,13 @@ public class AdminClient {
         return adminConfig;
     }
 
-    public void requestAddPrincial(String principal) throws KrbException {
+    public void requestAddPrincipal(String principal) throws KrbException {
         Kadmin remote = new RemoteKadminImpl(innerClient);
         remote.addPrincipal(principal);
     }
+
+    public void requestAddPrincipal(String principal, String password) throws KrbException
{
+        Kadmin remote = new RemoteKadminImpl(innerClient);
+        remote.addPrincipal(principal, password);
+    }
 }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/db2ecc2e/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/kadmin/remote/AdminHandler.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/kadmin/remote/AdminHandler.java
b/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/kadmin/remote/AdminHandler.java
index 9238110..fe220b4 100644
--- a/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/kadmin/remote/AdminHandler.java
+++ b/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/kadmin/remote/AdminHandler.java
@@ -21,9 +21,12 @@ package org.apache.kerby.kerberos.kerb.admin.kadmin.remote;
 
 import org.apache.kerby.kerberos.kerb.KrbException;
 import org.apache.kerby.kerberos.kerb.admin.kadmin.remote.request.AdminRequest;
+import org.apache.kerby.kerberos.kerb.admin.tool.AdminMessageCode;
+import org.apache.kerby.kerberos.kerb.admin.tool.AdminMessageType;
 import org.apache.kerby.kerberos.kerb.admin.tool.AdminReq;
 import org.apache.kerby.kerberos.kerb.admin.tool.KadminCode;
-import org.apache.kerby.xdr.type.XdrString;
+import org.apache.kerby.xdr.XdrFieldInfo;
+import org.apache.kerby.xdr.type.XdrStructType;
 
 import java.io.IOException;
 import java.nio.ByteBuffer;
@@ -69,13 +72,28 @@ public abstract class AdminHandler {
     public void onResponseMessage(AdminRequest adminRequest,
                                   ByteBuffer responseMessage) throws KrbException {
 
+
+        XdrStructType decoded = new AdminMessageCode();
         try {
-            XdrString decoded = new XdrString();
             decoded.decode(responseMessage);
-            String reply = decoded.getValue();
-            System.out.println(reply);
         } catch (IOException e) {
-            throw new KrbException("Kadmin decoding message failed", e);
+            throw new KrbException("On response message failed.", e);
+        }
+        XdrFieldInfo[] fieldInfos = decoded.getValue().getXdrFieldInfos();
+        AdminMessageType type = (AdminMessageType) fieldInfos[0].getValue();
+
+        switch (type) {
+            case ADD_PRINCIPAL_REP:
+                if (adminRequest.getAdminReq().getAdminMessageType()
+                    == AdminMessageType.ADD_PRINCIPAL_REQ) {
+                    System.out.println((String) fieldInfos[2].getValue());
+                } else {
+                    throw new KrbException("Response message type error: need "
+                    + AdminMessageType.ADD_PRINCIPAL_REP);
+                }
+                break;
+            default:
+                throw new KrbException("Response message type error: " + type);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/db2ecc2e/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/kadmin/remote/RemoteKadminImpl.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/kadmin/remote/RemoteKadminImpl.java
b/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/kadmin/remote/RemoteKadminImpl.java
index e74567b..c069a39 100644
--- a/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/kadmin/remote/RemoteKadminImpl.java
+++ b/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/kadmin/remote/RemoteKadminImpl.java
@@ -100,7 +100,10 @@ public class RemoteKadminImpl implements Kadmin {
     @Override
     public void addPrincipal(String principal,
                              String password) throws KrbException {
-
+        AdminRequest addPrincipalRequest = new AddPrincipalRequest(principal, password);
+        addPrincipalRequest.setTransport(transport);
+        AdminHandler adminHandler = new DefaultAdminHandler();
+        adminHandler.handleRequest(addPrincipalRequest);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/db2ecc2e/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/kadmin/remote/request/AddPrincipalRequest.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/kadmin/remote/request/AddPrincipalRequest.java
b/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/kadmin/remote/request/AddPrincipalRequest.java
index cc2a447..f8a23e0 100644
--- a/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/kadmin/remote/request/AddPrincipalRequest.java
+++ b/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/kadmin/remote/request/AddPrincipalRequest.java
@@ -47,6 +47,11 @@ public class AddPrincipalRequest extends AdminRequest {
         this.kOptions = kOptions;
     }
 
+    public AddPrincipalRequest(String principal, String password) {
+        super(principal);
+        this.password = password;
+    }
+
     public AddPrincipalRequest(String princial, KOptions kOptions, String password) {
         super(princial);
         this.kOptions = kOptions;
@@ -68,7 +73,7 @@ public class AddPrincipalRequest extends AdminRequest {
          */
         int paramNum = getParamNum();
         XdrFieldInfo[] xdrFieldInfos = new XdrFieldInfo[paramNum + 2];
-        xdrFieldInfos[0] = new XdrFieldInfo(0, XdrDataType.ENUM, AdminMessageType.AD_REQ);
+        xdrFieldInfos[0] = new XdrFieldInfo(0, XdrDataType.ENUM, AdminMessageType.ADD_PRINCIPAL_REQ);
         xdrFieldInfos[1] = new XdrFieldInfo(1, XdrDataType.INTEGER, paramNum);
         xdrFieldInfos[2] = new XdrFieldInfo(2, XdrDataType.STRING, getPrincipal());
         if (paramNum == 2 && kOptions != null) {

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/db2ecc2e/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/tool/AddPrincipalRep.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/tool/AddPrincipalRep.java
b/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/tool/AddPrincipalRep.java
index 7ba92b8..3025845 100644
--- a/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/tool/AddPrincipalRep.java
+++ b/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/tool/AddPrincipalRep.java
@@ -25,6 +25,6 @@ package org.apache.kerby.kerberos.kerb.admin.tool;
  */
 public class AddPrincipalRep extends AdminRep {
     public AddPrincipalRep() {
-        super(AdminMessageType.AD_REP);
+        super(AdminMessageType.ADD_PRINCIPAL_REP);
     }
 }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/db2ecc2e/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/tool/AddPrincipalReq.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/tool/AddPrincipalReq.java
b/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/tool/AddPrincipalReq.java
index 5e8780e..0b58157 100644
--- a/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/tool/AddPrincipalReq.java
+++ b/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/tool/AddPrincipalReq.java
@@ -25,6 +25,6 @@ package org.apache.kerby.kerberos.kerb.admin.tool;
  */
 public class AddPrincipalReq extends AdminReq {
     public AddPrincipalReq() {
-      super(AdminMessageType.AD_REQ);
+      super(AdminMessageType.ADD_PRINCIPAL_REQ);
     }
 }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/db2ecc2e/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/tool/AdminMessageCode.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/tool/AdminMessageCode.java
b/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/tool/AdminMessageCode.java
index 98c0482..eb83e94 100644
--- a/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/tool/AdminMessageCode.java
+++ b/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/tool/AdminMessageCode.java
@@ -75,11 +75,12 @@ public class AdminMessageCode extends XdrStructType {
 
     @Override
     protected AbstractXdrType[] getAllFields() {
-        AbstractXdrType[] fields = new AbstractXdrType[3];
+        AbstractXdrType[] fields = new AbstractXdrType[5];
         fields[0] = new AdminMessageEnum();
         fields[1] = new XdrInteger();
         fields[2] = new XdrString();
-        //fields3,4
+        fields[3] = new XdrString(); //suppose it is string
+        fields[4] = null; // kOptions is not supported.
         return fields;
     }
 

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/db2ecc2e/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/tool/AdminMessageType.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/tool/AdminMessageType.java
b/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/tool/AdminMessageType.java
index 5c24157..52cbc6e 100644
--- a/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/tool/AdminMessageType.java
+++ b/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/tool/AdminMessageType.java
@@ -32,10 +32,10 @@ import org.apache.kerby.xdr.EnumType;
 
 public enum AdminMessageType implements EnumType {
     NONE(-1),
-    AD_REQ(0),
-    AD_REP(1),
-    DE_REQ(2),
-    DE_REP(3);
+    ADD_PRINCIPAL_REQ(0),
+    ADD_PRINCIPAL_REP(1),
+    DELETE_PRINCIPAL_REQ(2),
+    DELETE_PRINCIPAL_REP(3);
 
     private int value;
 

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/db2ecc2e/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/tool/DeletePrincipalRep.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/tool/DeletePrincipalRep.java
b/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/tool/DeletePrincipalRep.java
index 134247a..7568e9a 100644
--- a/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/tool/DeletePrincipalRep.java
+++ b/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/tool/DeletePrincipalRep.java
@@ -25,6 +25,6 @@ package org.apache.kerby.kerberos.kerb.admin.tool;
  */
 public class DeletePrincipalRep extends AdminRep {
     public DeletePrincipalRep() {
-        super(AdminMessageType.DE_REP);
+        super(AdminMessageType.DELETE_PRINCIPAL_REP);
     }
 }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/db2ecc2e/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/tool/DeletePrincipalReq.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/tool/DeletePrincipalReq.java
b/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/tool/DeletePrincipalReq.java
index 32f535c..4ebb5a2 100644
--- a/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/tool/DeletePrincipalReq.java
+++ b/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/tool/DeletePrincipalReq.java
@@ -25,6 +25,6 @@ package org.apache.kerby.kerberos.kerb.admin.tool;
  */
 public class DeletePrincipalReq extends AdminReq {
     public DeletePrincipalReq() {
-        super(AdminMessageType.DE_REQ);
+        super(AdminMessageType.DELETE_PRINCIPAL_REQ);
     }
 }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/db2ecc2e/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/tool/KadminCode.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/tool/KadminCode.java
b/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/tool/KadminCode.java
index d063f70..674136e 100644
--- a/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/tool/KadminCode.java
+++ b/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/tool/KadminCode.java
@@ -46,10 +46,10 @@ public class KadminCode {
         AdminMessage adminMessage = null;
         byte[] bytes = new byte[buffer.remaining()];
         buffer.get(bytes);
-        if (adminMessageType == AdminMessageType.AD_REQ) {
+        if (adminMessageType == AdminMessageType.ADD_PRINCIPAL_REQ) {
             adminMessage = new AddPrincipalReq();
             System.out.println("check if decoding right: " + new String(ByteBuffer.wrap(bytes).array()));
-        } else if (adminMessageType == AdminMessageType.AD_REP) {
+        } else if (adminMessageType == AdminMessageType.ADD_PRINCIPAL_REP) {
             adminMessage = new AddPrincipalRep();
             System.out.println("check if decoding right2: " + new String(ByteBuffer.wrap(bytes).array()));
         } else {


Mime
View raw message