directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dran...@apache.org
Subject [4/4] directory-kerby git commit: Continued: Remote admin client and admin server
Date Sun, 10 Jan 2016 06:59:59 GMT
Continued: Remote admin client and admin server


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

Branch: refs/heads/kadmin-remote
Commit: 799d8ff129f7bfedff7f0276985103e177631746
Parents: 2a21ba0
Author: Kai Zheng <kai.zheng@intel.com>
Authored: Sun Jan 10 14:59:22 2016 +0800
Committer: Kai Zheng <kai.zheng@intel.com>
Committed: Sun Jan 10 14:59:22 2016 +0800

----------------------------------------------------------------------
 .../kerberos/kerb/admin/server/AdminServer.java | 334 ++++++++++++-------
 .../kerb/admin/server/AdminServerHandler.java   |  73 +---
 .../kerb/admin/server/AdminServerUtil.java      |   2 +-
 .../impl/AbstractInternalAdminServer.java       |  12 +-
 .../server/impl/DefaultAdminServerHandler.java  |  10 +-
 .../impl/DefaultInternalAdminServerImpl.java    |  27 +-
 .../admin/server/impl/InternalAdminServer.java  |   6 +-
 .../kerb/admin/remote/AdminSetting.java         |  14 +-
 .../kerberos/kerb/transport/KdcNetwork.java     |   1 -
 .../kerberos/kerb/server/SimpleKdcServer.java   |   4 +-
 10 files changed, 266 insertions(+), 217 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/799d8ff1/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/AdminServer.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/AdminServer.java
b/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/AdminServer.java
index a1a5c56..2d7fea0 100644
--- a/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/AdminServer.java
+++ b/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/AdminServer.java
@@ -21,125 +21,229 @@ package org.apache.kerby.kerberos.kerb.admin.server;
 
 import org.apache.kerby.KOptions;
 import org.apache.kerby.kerberos.kerb.KrbException;
-import org.apache.kerby.kerberos.kerb.admin.Kadmin;
+import org.apache.kerby.kerberos.kerb.admin.server.impl.DefaultInternalAdminServerImpl;
+import org.apache.kerby.kerberos.kerb.admin.server.impl.InternalAdminServer;
+import org.apache.kerby.kerberos.kerb.identity.backend.BackendConfig;
+import org.apache.kerby.kerberos.kerb.identity.backend.IdentityBackend;
 
 import java.io.File;
-import java.util.List;
 
 /**
- * Server side admin facilities for remote, similar to MIT kadmind service.
- * It uses GSSAPI and XDR to communicate with remote client/kadmin to receive
- * and perform the requested operations. In this server side, it simply leverages
- * LocalKadmin to perform the real work.
- *
- * TO BE IMPLEMENTED.
+ * The implemented Kerberos admin server API.
  */
-public class AdminServer implements Kadmin {
-    //private LocalKadmin localKadmin;
-
-    @Override
-    public String getKadminPrincipal() {
-        return null;
-    }
-
-    @Override
-    public void addPrincipal(String principal) throws KrbException {
-
-    }
-
-    @Override
-    public void addPrincipal(String principal,
-                             KOptions kOptions) throws KrbException {
-
-    }
-
-    @Override
-    public void addPrincipal(String principal,
-                             String password) throws KrbException {
-
-    }
-
-    @Override
-    public void addPrincipal(String principal, String password,
-                             KOptions kOptions) throws KrbException {
-
-    }
-
-    @Override
-    public void exportKeytab(File keytabFile,
-                             String principal) throws KrbException {
-
-    }
-
-    @Override
-    public void exportKeytab(File keytabFile,
-                             List<String> principals) throws KrbException {
-
-    }
-
-    @Override
-    public void exportKeytab(File keytabFile) throws KrbException {
-
-    }
-
-    @Override
-    public void removeKeytabEntriesOf(File keytabFile,
-                                      String principal) throws KrbException {
-
-    }
-
-    @Override
-    public void removeKeytabEntriesOf(File keytabFile, String principal,
-                                      int kvno) throws KrbException {
-
-    }
-
-    @Override
-    public void removeOldKeytabEntriesOf(File keytabFile,
-                                         String principal) throws KrbException {
-
-    }
-
-    @Override
-    public void deletePrincipal(String principal) throws KrbException {
-
-    }
-
-    @Override
-    public void modifyPrincipal(String principal,
-                                KOptions kOptions) throws KrbException {
-
-    }
-
-    @Override
-    public void renamePrincipal(String oldPrincipalName,
-                                String newPrincipalName) throws KrbException {
-
-    }
-
-    @Override
-    public List<String> getPrincipals() throws KrbException {
-        return null;
-    }
-
-    @Override
-    public List<String> getPrincipals(String globString) throws KrbException {
-        return null;
-    }
-
-    @Override
-    public void changePassword(String principal,
-                               String newPassword) throws KrbException {
-
-    }
-
-    @Override
-    public void updateKeys(String principal) throws KrbException {
-
-    }
-
-    @Override
-    public void release() throws KrbException {
-
+public class AdminServer {
+    private final AdminServerConfig adminServerConfig;
+    private final BackendConfig backendConfig;
+    private final AdminServerSetting adminServerSetting;
+    private final KOptions startupOptions;
+
+    private InternalAdminServer innerAdminServer;
+
+    /**
+     * Constructor passing both kdcConfig and backendConfig.
+     * @param kdcConfig The kdc config
+     * @param backendConfig The backend config
+     * @throws KrbException e
+     */
+    public AdminServer(AdminServerConfig kdcConfig,
+                     BackendConfig backendConfig) throws KrbException {
+        this.adminServerConfig = kdcConfig;
+        this.backendConfig = backendConfig;
+        startupOptions = new KOptions();
+        adminServerSetting = new AdminServerSetting(startupOptions, kdcConfig, backendConfig);
+    }
+
+    /**
+     * Constructor given confDir where 'kdc.conf' and 'backend.conf' should be
+     * available.
+     * kdc.conf, that contains kdc server related items.
+     * backend.conf, that contains identity backend related items.
+     *
+     * @param confDir The conf dir
+     * @throws KrbException e
+     */
+    public AdminServer(File confDir) throws KrbException {
+        AdminServerConfig tmpAdminServerConfig = AdminServerUtil.getAdminServerConfig(confDir);
+        if (tmpAdminServerConfig == null) {
+            tmpAdminServerConfig = new AdminServerConfig();
+        }
+        this.adminServerConfig = tmpAdminServerConfig;
+
+        BackendConfig tmpBackendConfig = AdminServerUtil.getBackendConfig(confDir);
+        if (tmpBackendConfig == null) {
+            tmpBackendConfig = new BackendConfig();
+        }
+        tmpBackendConfig.setConfDir(confDir);
+        this.backendConfig = tmpBackendConfig;
+
+        startupOptions = new KOptions();
+        adminServerSetting = new AdminServerSetting(startupOptions,
+            adminServerConfig, backendConfig);
+    }
+
+    /**
+     * Default constructor.
+     */
+    public AdminServer() {
+        adminServerConfig = new AdminServerConfig();
+        backendConfig = new BackendConfig();
+        startupOptions = new KOptions();
+        adminServerSetting = new AdminServerSetting(startupOptions,
+            adminServerConfig, backendConfig);
+    }
+
+    /**
+     * Set KDC realm for ticket request
+     * @param realm The kdc realm
+     */
+    public void setAdminServerRealm(String realm) {
+        startupOptions.add(AdminServerOption.KDC_REALM, realm);
+    }
+
+    /**
+     * Set KDC host.
+     * @param kdcHost The kdc host
+     */
+    public void setAdminServerHost(String kdcHost) {
+        startupOptions.add(AdminServerOption.KDC_HOST, kdcHost);
+    }
+
+    /**
+     * Set KDC port.
+     * @param kdcPort The kdc port
+     */
+    public void setAdminServerPort(int kdcPort) {
+        startupOptions.add(AdminServerOption.KDC_PORT, kdcPort);
+    }
+
+    /**
+     * Set KDC tcp port.
+     * @param kdcTcpPort The kdc tcp port
+     */
+    public void setAdminServerTcpPort(int kdcTcpPort) {
+        startupOptions.add(AdminServerOption.KDC_TCP_PORT, kdcTcpPort);
+    }
+
+    /**
+     * Set to allow UDP or not.
+     * @param allowUdp true if allow udp
+     */
+    public void setAllowUdp(boolean allowUdp) {
+        startupOptions.add(AdminServerOption.ALLOW_UDP, allowUdp);
+    }
+
+    /**
+     * Set to allow TCP or not.
+     * @param allowTcp true if allow tcp
+     */
+    public void setAllowTcp(boolean allowTcp) {
+        startupOptions.add(AdminServerOption.ALLOW_TCP, allowTcp);
+    }
+    /**
+     * Set KDC udp port. Only makes sense when allowUdp is set.
+     * @param kdcUdpPort The kdc udp port
+     */
+    public void setAdminServerUdpPort(int kdcUdpPort) {
+        startupOptions.add(AdminServerOption.KDC_UDP_PORT, kdcUdpPort);
+    }
+
+    /**
+     * Set runtime folder.
+     * @param workDir The work dir
+     */
+    public void setWorkDir(File workDir) {
+        startupOptions.add(AdminServerOption.WORK_DIR, workDir);
+    }
+
+    /**
+     * Allow to debug so have more logs.
+     */
+    public void enableDebug() {
+        startupOptions.add(AdminServerOption.ENABLE_DEBUG);
+    }
+
+    /**
+     * Allow to hook customized kdc implementation.
+     *
+     * @param innerAdminServerImpl The inner kdc implementation
+     */
+    public void setInnerAdminServerImpl(InternalAdminServer innerAdminServerImpl) {
+        startupOptions.add(AdminServerOption.INNER_KDC_IMPL, innerAdminServerImpl);
+    }
+
+    /**
+     * Get KDC setting from startup options and configs.
+     * @return setting
+     */
+    public AdminServerSetting getAdminServerSetting() {
+        return adminServerSetting;
+    }
+
+    /**
+     * Get the KDC config.
+     * @return AdminServerConfig
+     */
+    public AdminServerConfig getAdminServerConfig() {
+        return adminServerConfig;
+    }
+
+    /**
+     * Get backend config.
+     *
+     * @return backend configuration
+     */
+    public BackendConfig getBackendConfig() {
+        return backendConfig;
+    }
+
+    /**
+     * Get identity service.
+     * @return IdentityService
+     */
+    public IdentityBackend getIdentityService() {
+        if (innerAdminServer == null) {
+            throw new RuntimeException("Not init yet");
+        }
+        return innerAdminServer.getIdentityBackend();
+    }
+
+    /**
+     * Initialize.
+     *
+     * @throws org.apache.kerby.kerberos.kerb.KrbException e.
+     */
+    public void init() throws KrbException {
+        if (startupOptions.contains(AdminServerOption.INNER_KDC_IMPL)) {
+            innerAdminServer = (InternalAdminServer) startupOptions.getOptionValue(
+                AdminServerOption.INNER_KDC_IMPL);
+        } else {
+            innerAdminServer =
+                new DefaultInternalAdminServerImpl(adminServerSetting);
+        }
+
+        innerAdminServer.init();
+    }
+
+    /**
+     * Start the KDC server.
+     *
+     * @throws org.apache.kerby.kerberos.kerb.KrbException e.
+     */
+    public void start() throws KrbException {
+        if (innerAdminServer == null) {
+            throw new RuntimeException("Not init yet");
+        }
+        innerAdminServer.start();
+    }
+
+    /**
+     * Stop the KDC server.
+     *
+     * @throws org.apache.kerby.kerberos.kerb.KrbException e.
+     */
+    public void stop() throws KrbException {
+        if (innerAdminServer != null) {
+            innerAdminServer.stop();
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/799d8ff1/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/AdminServerHandler.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/AdminServerHandler.java
b/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/AdminServerHandler.java
index 5b3b6b5..97df6b5 100644
--- a/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/AdminServerHandler.java
+++ b/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/AdminServerHandler.java
@@ -19,26 +19,10 @@
  */
 package org.apache.kerby.kerberos.kerb.admin.server;
 
-import org.apache.kerby.kerberos.kerb.KrbCodec;
-import org.apache.kerby.kerberos.kerb.KrbErrorCode;
 import org.apache.kerby.kerberos.kerb.KrbException;
-import org.apache.kerby.kerberos.kerb.server.KdcContext;
-import org.apache.kerby.kerberos.kerb.server.KdcRecoverableException;
-import org.apache.kerby.kerberos.kerb.server.request.AsRequest;
-import org.apache.kerby.kerberos.kerb.server.request.KdcRequest;
-import org.apache.kerby.kerberos.kerb.server.request.TgsRequest;
-import org.apache.kerby.kerberos.kerb.type.KerberosTime;
-import org.apache.kerby.kerberos.kerb.type.base.KrbError;
-import org.apache.kerby.kerberos.kerb.type.base.KrbMessage;
-import org.apache.kerby.kerberos.kerb.type.base.KrbMessageType;
-import org.apache.kerby.kerberos.kerb.type.base.PrincipalName;
-import org.apache.kerby.kerberos.kerb.type.kdc.AsReq;
-import org.apache.kerby.kerberos.kerb.type.kdc.KdcReq;
-import org.apache.kerby.kerberos.kerb.type.kdc.TgsReq;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.IOException;
 import java.net.InetAddress;
 import java.nio.ByteBuffer;
 
@@ -46,16 +30,16 @@ import java.nio.ByteBuffer;
  * KDC handler to process client requests. Currently only one realm is supported.
  */
 public class AdminServerHandler {
-    private static final Logger LOG = LoggerFactory.getLogger(org.apache.kerby.kerberos.kerb.server.KdcHandler.class);
-    private final KdcContext kdcContext;
+    private static final Logger LOG = LoggerFactory.getLogger(AdminServerHandler.class);
+    private final AdminServerContext adminServerContext;
 
     /**
      * Constructor with kdc context.
      *
-     * @param kdcContext kdc context
+     * @param adminServerContext admin server context
      */
-    public AdminServerHandler(KdcContext kdcContext) {
-        this.kdcContext = kdcContext;
+    public AdminServerHandler(AdminServerContext adminServerContext) {
+        this.adminServerContext = adminServerContext;
     }
 
     /**
@@ -63,12 +47,13 @@ public class AdminServerHandler {
      *
      * @throws KrbException e
      * @param receivedMessage The client request message
-     * @param  isTcp whether the protocol is tcp
      * @param remoteAddress Address from remote side
      * @return The response message
      */
-    public ByteBuffer handleMessage(ByteBuffer receivedMessage, boolean isTcp,
+    public ByteBuffer handleMessage(ByteBuffer receivedMessage,
                                     InetAddress remoteAddress) throws KrbException {
+        return null;
+        /*
         KrbMessage krbRequest;
         KdcRequest kdcRequest = null;
         KrbMessage krbResponse;
@@ -137,46 +122,6 @@ public class AdminServerHandler {
         responseMessage.flip();
 
         return responseMessage;
-    }
-
-    /**
-     * Process the recoverable exception.
-     *
-     * @param e The exception return by kdc
-     * @param kdcRequest kdc request
-     * @return The KrbError
-     */
-    private KrbMessage handleRecoverableException(KdcRecoverableException e,
-                                                  KdcRequest kdcRequest)
-            throws KrbException {
-        LOG.info("KRB error occurred while processing request:"
-                + e.getMessage());
-
-        KrbError error = e.getKrbError();
-        error.setStime(KerberosTime.now());
-        error.setSusec(100);
-        error.setErrorCode(e.getKrbError().getErrorCode());
-        error.setRealm(kdcContext.getKdcRealm());
-        if (kdcRequest != null) {
-            error.setSname(kdcRequest.getKdcReq().getReqBody().getCname());
-        } else {
-            error.setSname(new PrincipalName("NONE"));
-        }
-        error.setEtext(e.getMessage());
-        return error;
-    }
-
-    /**
-     * Get request realm.
-     * @param kdcReq kdc request
-     * @return realm
-     */
-    private String getRequestRealm(KdcReq kdcReq) {
-        String realm = kdcReq.getReqBody().getRealm();
-        if (realm == null && kdcReq.getReqBody().getCname() != null) {
-            realm = kdcReq.getReqBody().getCname().getRealm();
-        }
-
-        return realm;
+        */
     }
 }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/799d8ff1/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/AdminServerUtil.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/AdminServerUtil.java
b/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/AdminServerUtil.java
index 5b6c5e2..cf44fb7 100644
--- a/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/AdminServerUtil.java
+++ b/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/AdminServerUtil.java
@@ -43,7 +43,7 @@ public final class AdminServerUtil {
      * @return kdc configuration
      * @throws KrbException e.
      */
-    public static AdminServerConfig getKdcConfig(File confDir) throws KrbException {
+    public static AdminServerConfig getAdminServerConfig(File confDir) throws KrbException
{
         File kdcConfFile = new File(confDir, "kdc.conf");
         if (kdcConfFile.exists()) {
             AdminServerConfig adminServerConfig = new AdminServerConfig();

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/799d8ff1/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/impl/AbstractInternalAdminServer.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/impl/AbstractInternalAdminServer.java
b/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/impl/AbstractInternalAdminServer.java
index fd42c9c..466b4b4 100644
--- a/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/impl/AbstractInternalAdminServer.java
+++ b/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/impl/AbstractInternalAdminServer.java
@@ -20,6 +20,8 @@
 package org.apache.kerby.kerberos.kerb.admin.server.impl;
 
 import org.apache.kerby.kerberos.kerb.KrbException;
+import org.apache.kerby.kerberos.kerb.admin.server.AdminServerConfig;
+import org.apache.kerby.kerberos.kerb.admin.server.AdminServerSetting;
 import org.apache.kerby.kerberos.kerb.identity.CacheableIdentityService;
 import org.apache.kerby.kerberos.kerb.identity.IdentityService;
 import org.apache.kerby.kerberos.kerb.identity.backend.BackendConfig;
@@ -34,20 +36,20 @@ import org.apache.kerby.kerberos.kerb.server.KdcUtil;
  */
 public class AbstractInternalAdminServer implements InternalAdminServer {
     private boolean started;
-    private final KdcConfig kdcConfig;
+    private final AdminServerConfig kdcConfig;
     private final BackendConfig backendConfig;
-    private final KdcSetting kdcSetting;
+    private final AdminServerSetting kdcSetting;
     private IdentityBackend backend;
     private IdentityService identityService;
 
-    public AbstractInternalAdminServer(KdcSetting kdcSetting) {
+    public AbstractInternalAdminServer(AdminServerSetting kdcSetting) {
         this.kdcSetting = kdcSetting;
-        this.kdcConfig = kdcSetting.getKdcConfig();
+        this.kdcConfig = kdcSetting.getAdminServerConfig();
         this.backendConfig = kdcSetting.getBackendConfig();
     }
 
     @Override
-    public KdcSetting getSetting() {
+    public AdminServerSetting getSetting() {
         return kdcSetting;
     }
 

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/799d8ff1/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/impl/DefaultAdminServerHandler.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/impl/DefaultAdminServerHandler.java
b/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/impl/DefaultAdminServerHandler.java
index 7743c99..bd8ff17 100644
--- a/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/impl/DefaultAdminServerHandler.java
+++ b/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/impl/DefaultAdminServerHandler.java
@@ -19,6 +19,8 @@
  */
 package org.apache.kerby.kerberos.kerb.admin.server.impl;
 
+import org.apache.kerby.kerberos.kerb.admin.server.AdminServerContext;
+import org.apache.kerby.kerberos.kerb.admin.server.AdminServerHandler;
 import org.apache.kerby.kerberos.kerb.server.KdcContext;
 import org.apache.kerby.kerberos.kerb.server.KdcHandler;
 import org.apache.kerby.kerberos.kerb.transport.KrbTcpTransport;
@@ -30,12 +32,12 @@ import java.io.IOException;
 import java.net.InetAddress;
 import java.nio.ByteBuffer;
 
-public class DefaultAdminServerHandler extends KdcHandler implements Runnable {
+public class DefaultAdminServerHandler extends AdminServerHandler implements Runnable {
     private static Logger logger = LoggerFactory.getLogger(DefaultAdminServerHandler.class);
     private final KrbTransport transport;
 
-    public DefaultAdminServerHandler(KdcContext kdcContext, KrbTransport transport) {
-        super(kdcContext);
+    public DefaultAdminServerHandler(AdminServerContext adminServerContext, KrbTransport
transport) {
+        super(adminServerContext);
         this.transport  = transport;
     }
 
@@ -64,7 +66,7 @@ public class DefaultAdminServerHandler extends KdcHandler implements Runnable
{
         boolean isTcp = transport instanceof KrbTcpTransport;
 
         try {
-            ByteBuffer krbResponse = handleMessage(message, isTcp, clientAddress);
+            ByteBuffer krbResponse = handleMessage(message, clientAddress);
             transport.sendMessage(krbResponse);
         } catch (Exception e) {
             transport.release();

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/799d8ff1/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/impl/DefaultInternalAdminServerImpl.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/impl/DefaultInternalAdminServerImpl.java
b/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/impl/DefaultInternalAdminServerImpl.java
index 15d9844..04af0e7 100644
--- a/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/impl/DefaultInternalAdminServerImpl.java
+++ b/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/impl/DefaultInternalAdminServerImpl.java
@@ -19,10 +19,9 @@
  */
 package org.apache.kerby.kerberos.kerb.admin.server.impl;
 
-import org.apache.kerby.kerberos.kerb.server.KdcContext;
-import org.apache.kerby.kerberos.kerb.server.KdcSetting;
-import org.apache.kerby.kerberos.kerb.server.KdcUtil;
-import org.apache.kerby.kerberos.kerb.server.preauth.PreauthHandler;
+import org.apache.kerby.kerberos.kerb.admin.server.AdminServerContext;
+import org.apache.kerby.kerberos.kerb.admin.server.AdminServerSetting;
+import org.apache.kerby.kerberos.kerb.admin.server.AdminServerUtil;
 import org.apache.kerby.kerberos.kerb.transport.KdcNetwork;
 import org.apache.kerby.kerberos.kerb.transport.KrbTransport;
 import org.apache.kerby.kerberos.kerb.transport.TransportPair;
@@ -31,15 +30,15 @@ import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
 /**
- * A default KDC server implementation.
+ * A default admin server implementation.
  */
 public class DefaultInternalAdminServerImpl extends AbstractInternalAdminServer {
     private ExecutorService executor;
-    private KdcContext kdcContext;
+    private AdminServerContext adminContext;
     private KdcNetwork network;
 
-    public DefaultInternalAdminServerImpl(KdcSetting kdcSetting) {
-        super(kdcSetting);
+    public DefaultInternalAdminServerImpl(AdminServerSetting adminSetting) {
+        super(adminSetting);
     }
 
     @Override
@@ -53,23 +52,21 @@ public class DefaultInternalAdminServerImpl extends AbstractInternalAdminServer
         network = new KdcNetwork() {
             @Override
             protected void onNewTransport(KrbTransport transport) {
-                DefaultAdminServerHandler kdcHandler = new DefaultAdminServerHandler(kdcContext,
transport);
+                DefaultAdminServerHandler kdcHandler = 
+                    new DefaultAdminServerHandler(adminContext, transport);
                 executor.execute(kdcHandler);
             }
         };
 
         network.init();
-        TransportPair tpair = KdcUtil.getTransportPair(getSetting());
+        TransportPair tpair = AdminServerUtil.getTransportPair(getSetting());
         network.listen(tpair);
         network.start();
     }
 
     private void prepareHandler() {
-        kdcContext = new KdcContext(getSetting());
-        kdcContext.setIdentityService(getIdentityService());
-        PreauthHandler preauthHandler = new PreauthHandler();
-        preauthHandler.init();
-        kdcContext.setPreauthHandler(preauthHandler);
+        adminContext = new AdminServerContext(getSetting());
+        adminContext.setIdentityService(getIdentityService());
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/799d8ff1/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/impl/InternalAdminServer.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/impl/InternalAdminServer.java
b/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/impl/InternalAdminServer.java
index b01eecd..f370380 100644
--- a/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/impl/InternalAdminServer.java
+++ b/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/impl/InternalAdminServer.java
@@ -20,8 +20,8 @@
 package org.apache.kerby.kerberos.kerb.admin.server.impl;
 
 import org.apache.kerby.kerberos.kerb.KrbException;
+import org.apache.kerby.kerberos.kerb.admin.server.AdminServerSetting;
 import org.apache.kerby.kerberos.kerb.identity.backend.IdentityBackend;
-import org.apache.kerby.kerberos.kerb.server.KdcSetting;
 
 /**
  * An internal KDC server interface.
@@ -47,10 +47,10 @@ public interface InternalAdminServer {
     void stop() throws KrbException;
 
     /**
-     * Get KDC setting.
+     * Get admin server setting.
      * @return setting
      */
-    KdcSetting getSetting();
+    AdminServerSetting getSetting();
 
     /**
      * Get identity backend.

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/799d8ff1/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/remote/AdminSetting.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/remote/AdminSetting.java
b/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/remote/AdminSetting.java
index b02f2cf..19b25c8 100644
--- a/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/remote/AdminSetting.java
+++ b/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/remote/AdminSetting.java
@@ -44,7 +44,7 @@ public class AdminSetting {
     }
 
     public String getKdcRealm() {
-        String kdcRealm = commonOptions.getStringOption(KrbOption.KDC_REALM);
+        String kdcRealm = commonOptions.getStringOption(AdminOption.KDC_REALM);
         if (kdcRealm == null || kdcRealm.isEmpty()) {
             kdcRealm = adminConfig.getKdcRealm();
         }
@@ -52,7 +52,7 @@ public class AdminSetting {
     }
 
     public String getKdcHost() {
-        String kdcHost = commonOptions.getStringOption(KrbOption.KDC_HOST);
+        String kdcHost = commonOptions.getStringOption(AdminOption.KDC_HOST);
         if (kdcHost == null) {
             return adminConfig.getKdcHost();
         }
@@ -92,7 +92,7 @@ public class AdminSetting {
     }
 
     public int getKdcTcpPort() {
-        int tcpPort = commonOptions.getIntegerOption(KrbOption.KDC_TCP_PORT);
+        int tcpPort = commonOptions.getIntegerOption(AdminOption.KDC_TCP_PORT);
         if (tcpPort > 0) {
             return tcpPort;
         }
@@ -101,18 +101,18 @@ public class AdminSetting {
 
     public boolean allowUdp() {
         Boolean allowUdp = commonOptions.getBooleanOption(
-                KrbOption.ALLOW_UDP, adminConfig.allowUdp());
+                AdminOption.ALLOW_UDP, adminConfig.allowUdp());
         return allowUdp;
     }
 
     public boolean allowTcp() {
         Boolean allowTcp = commonOptions.getBooleanOption(
-                KrbOption.ALLOW_TCP, adminConfig.allowTcp());
+                AdminOption.ALLOW_TCP, adminConfig.allowTcp());
         return allowTcp;
     }
 
     public int getKdcUdpPort() {
-        int udpPort = commonOptions.getIntegerOption(KrbOption.KDC_UDP_PORT);
+        int udpPort = commonOptions.getIntegerOption(AdminOption.KDC_UDP_PORT);
         if (udpPort > 0) {
             return udpPort;
         }
@@ -120,7 +120,7 @@ public class AdminSetting {
     }
 
     public int getTimeout() {
-        int timeout = commonOptions.getIntegerOption(KrbOption.CONN_TIMEOUT);
+        int timeout = commonOptions.getIntegerOption(AdminOption.CONN_TIMEOUT);
         if (timeout > 0) {
             return timeout;
         }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/799d8ff1/kerby-kerb/kerb-common/src/main/java/org/apache/kerby/kerberos/kerb/transport/KdcNetwork.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-common/src/main/java/org/apache/kerby/kerberos/kerb/transport/KdcNetwork.java
b/kerby-kerb/kerb-common/src/main/java/org/apache/kerby/kerberos/kerb/transport/KdcNetwork.java
index e3d7570..4b076a5 100644
--- a/kerby-kerb/kerb-common/src/main/java/org/apache/kerby/kerberos/kerb/transport/KdcNetwork.java
+++ b/kerby-kerb/kerb-common/src/main/java/org/apache/kerby/kerberos/kerb/transport/KdcNetwork.java
@@ -118,7 +118,6 @@ public abstract class KdcNetwork {
         }
     }
 
-
     private void checkUdpMessage() throws IOException {
         InetSocketAddress fromAddress = (InetSocketAddress) udpServer.receive(recvBuffer);
         if (fromAddress != null) {

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/799d8ff1/kerby-kerb/kerb-simplekdc/src/main/java/org/apache/kerby/kerberos/kerb/server/SimpleKdcServer.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-simplekdc/src/main/java/org/apache/kerby/kerberos/kerb/server/SimpleKdcServer.java
b/kerby-kerb/kerb-simplekdc/src/main/java/org/apache/kerby/kerberos/kerb/server/SimpleKdcServer.java
index 6f4fd63..69479df 100644
--- a/kerby-kerb/kerb-simplekdc/src/main/java/org/apache/kerby/kerberos/kerb/server/SimpleKdcServer.java
+++ b/kerby-kerb/kerb-simplekdc/src/main/java/org/apache/kerby/kerberos/kerb/server/SimpleKdcServer.java
@@ -20,8 +20,8 @@
 package org.apache.kerby.kerberos.kerb.server;
 
 import org.apache.kerby.kerberos.kerb.KrbException;
-import org.apache.kerby.kerberos.kerb.admin.LocalKadmin;
-import org.apache.kerby.kerberos.kerb.admin.LocalKadminImpl;
+import org.apache.kerby.kerberos.kerb.admin.local.LocalKadmin;
+import org.apache.kerby.kerberos.kerb.admin.local.LocalKadminImpl;
 import org.apache.kerby.kerberos.kerb.client.Krb5Conf;
 import org.apache.kerby.kerberos.kerb.client.KrbClient;
 import org.apache.kerby.kerberos.kerb.client.KrbPkinitClient;


Mime
View raw message