Return-Path: X-Original-To: apmail-directory-commits-archive@www.apache.org Delivered-To: apmail-directory-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A8D30174C6 for ; Fri, 13 Mar 2015 03:55:18 +0000 (UTC) Received: (qmail 72535 invoked by uid 500); 13 Mar 2015 03:55:18 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 72481 invoked by uid 500); 13 Mar 2015 03:55:18 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 72461 invoked by uid 99); 13 Mar 2015 03:55:18 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Mar 2015 03:55:18 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 3DC41E111A; Fri, 13 Mar 2015 03:55:18 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: hazel@apache.org To: commits@directory.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: directory-kerberos git commit: Read config from file Date: Fri, 13 Mar 2015 03:55:18 +0000 (UTC) Repository: directory-kerberos Updated Branches: refs/heads/kdc-with-configfile [created] d9a233f22 Read config from file Project: http://git-wip-us.apache.org/repos/asf/directory-kerberos/repo Commit: http://git-wip-us.apache.org/repos/asf/directory-kerberos/commit/d9a233f2 Tree: http://git-wip-us.apache.org/repos/asf/directory-kerberos/tree/d9a233f2 Diff: http://git-wip-us.apache.org/repos/asf/directory-kerberos/diff/d9a233f2 Branch: refs/heads/kdc-with-configfile Commit: d9a233f22c39feabb991131108b6d2754d71a066 Parents: 0b649f5 Author: chenlin1 Authored: Fri Mar 13 11:55:11 2015 +0800 Committer: chenlin1 Committed: Fri Mar 13 11:55:11 2015 +0800 ---------------------------------------------------------------------- kerby-kdc/kerby-kdc-dist/bin/kerbykdc.sh | 16 ++++++ .../kerberos/kdc/server/KerbyKdcServer.java | 52 +++++++++++++++----- 2 files changed, 57 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/d9a233f2/kerby-kdc/kerby-kdc-dist/bin/kerbykdc.sh ---------------------------------------------------------------------- diff --git a/kerby-kdc/kerby-kdc-dist/bin/kerbykdc.sh b/kerby-kdc/kerby-kdc-dist/bin/kerbykdc.sh index 07d6214..fc1bf05 100644 --- a/kerby-kdc/kerby-kdc-dist/bin/kerbykdc.sh +++ b/kerby-kdc/kerby-kdc-dist/bin/kerbykdc.sh @@ -1,4 +1,20 @@ #!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. confdir=/etc/kerby/kdc.conf workingdir=/usr/kerby/kdc/ java -jar ../kerby-kdc/kerby-kdc-1.0-SNAPSHOT-jar-with-dependencies.jar -start ${confdir} ${workingdir} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/d9a233f2/kerby-kdc/src/main/java/org/apache/kerby/kerberos/kdc/server/KerbyKdcServer.java ---------------------------------------------------------------------- diff --git a/kerby-kdc/src/main/java/org/apache/kerby/kerberos/kdc/server/KerbyKdcServer.java b/kerby-kdc/src/main/java/org/apache/kerby/kerberos/kdc/server/KerbyKdcServer.java index f9a85bb..ab33d0f 100644 --- a/kerby-kdc/src/main/java/org/apache/kerby/kerberos/kdc/server/KerbyKdcServer.java +++ b/kerby-kdc/src/main/java/org/apache/kerby/kerberos/kdc/server/KerbyKdcServer.java @@ -19,11 +19,16 @@ */ package org.apache.kerby.kerberos.kdc.server; +import org.apache.kerby.config.Conf; import org.apache.kerby.config.Config; import org.apache.kerby.kerberos.kdc.identitybackend.LdapIdentityBackend; import org.apache.kerby.kerberos.kerb.identity.IdentityService; +import org.apache.kerby.kerberos.kerb.server.KdcConfig; import org.apache.kerby.kerberos.kerb.server.KdcServer; +import java.io.File; +import java.io.IOException; + /** * The mentioned Kerby KDC server implementation */ @@ -38,7 +43,33 @@ public class KerbyKdcServer extends KdcServer { initIdentityService(); } - private static KdcServer server; + public void init(String confDir, String workDir) throws IOException { + init(); + initConfig(confDir); + initWorkDir(workDir); + } + + /** + * init config from configuration file + */ + private void initConfig(String confDirString) throws IOException { + super.initConfig(); + kdcConfig = new KdcConfig(); + Conf conf = kdcConfig.getConf(); + + File confDir = new File(confDirString); + File[] files = confDir.listFiles(); + for (File file : files) { + conf.addIniConfig(file); + } + + } + + private void initWorkDir(String workDir) { + initWorkDir(); + } + + private static KerbyKdcServer server; private static final String USAGE = "Usage: " + KerbyKdcServer.class.getSimpleName() + " -start conf-dir working-dir|-stop"; public static void main(String[] args) { @@ -53,18 +84,17 @@ public class KerbyKdcServer extends KdcServer { return; } String confDir = args[1]; - String workingDir = args[2]; + String workDir = args[2]; - //FIXME host and config should be loaded from configuration. - String serverHost = "localhost"; - short serverPort = 8015; - - server = new KdcServer(); - server.setKdcHost(serverHost); - server.setKdcTcpPort(serverPort); - server.init(); + server = new KerbyKdcServer(); + try { + server.init(confDir, workDir); + } catch (IOException e) { + System.err.println("Something wrong with configuration directory or work directory"); + return; + } server.start(); - System.out.println("KDC Server(" + KerbyKdcServer.class.getSimpleName() + ") started."); + System.out.println(KerbyKdcServer.class.getSimpleName() + " started."); } else if (args[0].equals("-stop")) { //server.stop();//FIXME can't get the server instance here System.out.println("KDC Server stoped.");