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 2016/04/29 08:51:52 UTC
directory-kerby git commit: DIRKRB-558 Create running tools for
AdminServer. Contributed by Yan.
Repository: directory-kerby
Updated Branches:
refs/heads/kadmin-remote c1e324d73 -> 74800d430
DIRKRB-558 Create running tools for AdminServer. 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/74800d43
Tree: http://git-wip-us.apache.org/repos/asf/directory-kerby/tree/74800d43
Diff: http://git-wip-us.apache.org/repos/asf/directory-kerby/diff/74800d43
Branch: refs/heads/kadmin-remote
Commit: 74800d430d74d5ce683451de403263d0e126c782
Parents: c1e324d
Author: plusplusjiajia <ji...@intel.com>
Authored: Fri Apr 29 14:56:49 2016 +0800
Committer: plusplusjiajia <ji...@intel.com>
Committed: Fri Apr 29 14:56:49 2016 +0800
----------------------------------------------------------------------
kerby-dist/kdc-dist/bin/adminServer.cmd | 32 ++++++++
kerby-dist/kdc-dist/bin/adminServer.sh | 32 ++++++++
kerby-dist/kdc-dist/conf/adminServer.conf | 20 +++++
kerby-dist/kdc-dist/pom.xml | 5 ++
.../kerb/admin/server/AdminServerInit.java | 82 ++++++++++++++++++++
.../src/main/resources/adminServer.conf | 20 +++++
.../kerb/admin/admin/AdminServerTest.java | 40 ----------
.../admin/kadmin/remote/RemoteKadminImpl.java | 5 +-
.../kerberos/kerb/admin/admin/AdminTest.java | 36 ++++++---
.../src/test/resources/adminClient.conf | 20 +++++
10 files changed, 238 insertions(+), 54 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/74800d43/kerby-dist/kdc-dist/bin/adminServer.cmd
----------------------------------------------------------------------
diff --git a/kerby-dist/kdc-dist/bin/adminServer.cmd b/kerby-dist/kdc-dist/bin/adminServer.cmd
new file mode 100644
index 0000000..9e5afaa
--- /dev/null
+++ b/kerby-dist/kdc-dist/bin/adminServer.cmd
@@ -0,0 +1,32 @@
+@echo off
+@rem Licensed to the Apache Software Foundation (ASF) under one
+@rem or more contributor license agreements. See the NOTICE file
+@rem distributed with this work for additional information
+@rem regarding copyright ownership. The ASF licenses this file
+@rem to you under the Apache License, Version 2.0 (the
+@rem "License"); you may not use this file except in compliance
+@rem with the License. You may obtain a copy of the License at
+@rem
+@rem http://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing,
+@rem software distributed under the License is distributed on an
+@rem "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+@rem KIND, either express or implied. See the License for the
+@rem specific language governing permissions and limitations
+@rem under the License.
+@rem
+
+set DEBUG=
+set args=%*
+for %%a in (%*) do (
+ if -D == %%a (
+ set DEBUG=-Xdebug -Xrunjdwp:transport=dt_socket,address=8008,server=y,suspend=n
+ set args=%args:-D=%
+ )
+)
+
+java %DEBUG% ^
+-classpath target\lib\* ^
+-DKERBY_LOGFILE=adminServer ^
+org.apache.kerby.kerberos.kerb.admin.server.AdminServerInit %args%
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/74800d43/kerby-dist/kdc-dist/bin/adminServer.sh
----------------------------------------------------------------------
diff --git a/kerby-dist/kdc-dist/bin/adminServer.sh b/kerby-dist/kdc-dist/bin/adminServer.sh
new file mode 100644
index 0000000..01e55a0
--- /dev/null
+++ b/kerby-dist/kdc-dist/bin/adminServer.sh
@@ -0,0 +1,32 @@
+#!/usr/bin/env 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.
+
+DEBUG=
+args=
+for var in $*; do
+ if [ X"$var" = X"-D" ]; then
+ DEBUG="-Xdebug -Xrunjdwp:transport=dt_socket,address=8008,server=y,suspend=n"
+ else
+ args="$args $var"
+ fi
+done
+
+java $DEBUG \
+-classpath target/lib/*:. \
+-DKERBY_LOGFILE=adminServer \
+org.apache.kerby.kerberos.kerb.admin.server.AdminServerInit $args
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/74800d43/kerby-dist/kdc-dist/conf/adminServer.conf
----------------------------------------------------------------------
diff --git a/kerby-dist/kdc-dist/conf/adminServer.conf b/kerby-dist/kdc-dist/conf/adminServer.conf
new file mode 100644
index 0000000..8c7a11e
--- /dev/null
+++ b/kerby-dist/kdc-dist/conf/adminServer.conf
@@ -0,0 +1,20 @@
+#
+# 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.
+#
+[libdefaults]
+default_realm = TEST.COM
+admin_port = 65417
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/74800d43/kerby-dist/kdc-dist/pom.xml
----------------------------------------------------------------------
diff --git a/kerby-dist/kdc-dist/pom.xml b/kerby-dist/kdc-dist/pom.xml
index 71c5f25..20e9d27 100644
--- a/kerby-dist/kdc-dist/pom.xml
+++ b/kerby-dist/kdc-dist/pom.xml
@@ -35,6 +35,11 @@
</dependency>
<dependency>
<groupId>org.apache.kerby</groupId>
+ <artifactId>kerb-admin-server</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.kerby</groupId>
<artifactId>kerby-asn1</artifactId>
<version>${project.version}</version>
</dependency>
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/74800d43/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/AdminServerInit.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/AdminServerInit.java b/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/AdminServerInit.java
new file mode 100644
index 0000000..b760885
--- /dev/null
+++ b/kerby-kerb/kerb-admin-server/src/main/java/org/apache/kerby/kerberos/kerb/admin/server/AdminServerInit.java
@@ -0,0 +1,82 @@
+/**
+ * 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.
+ *
+ */
+package org.apache.kerby.kerberos.kerb.admin.server;
+
+
+import org.apache.kerby.kerberos.kerb.KrbException;
+import org.apache.kerby.kerberos.kerb.admin.server.kadmin.AdminServer;
+import org.apache.kerby.kerberos.kerb.admin.server.kadmin.AdminServerConfig;
+import org.apache.kerby.kerberos.kerb.identity.backend.BackendConfig;
+import org.apache.kerby.util.OSUtil;
+
+import java.io.File;
+
+public class AdminServerInit {
+ private static final String USAGE = (OSUtil.isWindows()
+ ? "Usage: bin\\adminServer.cmd" : "Usage: sh bin/adminServer.sh")
+ + " <conf-file>\n"
+ + "\tExample:\n"
+ + "\t\t"
+ + (OSUtil.isWindows()
+ ? "bin\\kadmin.cmd" : "sh bin/kadmin.sh")
+ + " conf\\adminServer.conf\n";
+
+ public static void main(String[] args) throws Exception {
+
+ if (args.length != 1) {
+ System.err.println(USAGE);
+ System.exit(1);
+ }
+
+ String confDirPath = args[0];
+ File serverConfFile = new File(confDirPath);
+
+ if (!serverConfFile.exists()) {
+ System.err.println("Invalid or not exist conf");
+ System.exit(2);
+ }
+
+ /**
+ * Below two lines cannot be used in jar.
+ * Because url is not hierarchical
+ */
+ //URL serverConfFileUrl = AdminServerInit.class.getResource("/adminServer.conf");
+ //File serverConfFile = new File(serverConfFileUrl.toURI());
+ AdminServerConfig adminServerConfig = new AdminServerConfig();
+ adminServerConfig.addKrb5Config(serverConfFile);
+
+ BackendConfig backendConfig = new BackendConfig();
+
+ AdminServer adminServer = new AdminServer(adminServerConfig, backendConfig);
+ adminServer.setAdminHost(adminServerConfig.getAdminHost());
+ adminServer.setAllowTcp(true);
+ adminServer.setAllowUdp(false);
+ adminServer.setAdminServerPort(adminServerConfig.getAdminPort());
+
+ try {
+ adminServer.init();
+ } catch (KrbException e) {
+ System.err.println("Errors occurred when start admin server: " + e.getMessage());
+ System.exit(3);
+ }
+ adminServer.start();
+ System.out.println("Admin server started!");
+ }
+}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/74800d43/kerby-kerb/kerb-admin-server/src/main/resources/adminServer.conf
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-admin-server/src/main/resources/adminServer.conf b/kerby-kerb/kerb-admin-server/src/main/resources/adminServer.conf
new file mode 100644
index 0000000..8c7a11e
--- /dev/null
+++ b/kerby-kerb/kerb-admin-server/src/main/resources/adminServer.conf
@@ -0,0 +1,20 @@
+#
+# 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.
+#
+[libdefaults]
+default_realm = TEST.COM
+admin_port = 65417
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/74800d43/kerby-kerb/kerb-admin-server/src/test/java/org/apache/kerby/kerberos/kerb/admin/admin/AdminServerTest.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-admin-server/src/test/java/org/apache/kerby/kerberos/kerb/admin/admin/AdminServerTest.java b/kerby-kerb/kerb-admin-server/src/test/java/org/apache/kerby/kerberos/kerb/admin/admin/AdminServerTest.java
deleted file mode 100644
index 654327e..0000000
--- a/kerby-kerb/kerb-admin-server/src/test/java/org/apache/kerby/kerberos/kerb/admin/admin/AdminServerTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * 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.
- *
- */
-package org.apache.kerby.kerberos.kerb.admin.admin;
-
-
-import org.apache.kerby.kerberos.kerb.KrbException;
-import org.apache.kerby.kerberos.kerb.admin.server.kadmin.AdminServer;
-
-public class AdminServerTest {
- public static void main(String[] args) throws KrbException {
- String serverHost = "localhost";
- AdminServer adminServer;
-
- adminServer = new AdminServer();
- adminServer.setAdminHost(serverHost);
- adminServer.setAllowUdp(false);
- adminServer.setAllowTcp(true);
- adminServer.setAdminTcpPort(65417);
- /*adminServer.init();
- adminServer.start();
- System.out.println("Server started!");*/
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/74800d43/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 dc8e1f8..ad8022e 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
@@ -71,8 +71,9 @@ public class RemoteKadminImpl implements Kadmin {
@Override
- public String getKadminPrincipal() {
- return null;
+ public String getKadminPrincipal() { //think again. can be this easy?
+ String name = innerClient.getSetting().getAdminConfig().getAdminHost();
+ return name;
}
@Override
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/74800d43/kerby-kerb/kerb-admin/src/test/java/org/apache/kerby/kerberos/kerb/admin/admin/AdminTest.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-admin/src/test/java/org/apache/kerby/kerberos/kerb/admin/admin/AdminTest.java b/kerby-kerb/kerb-admin/src/test/java/org/apache/kerby/kerberos/kerb/admin/admin/AdminTest.java
index 56a061d..05b7c98 100644
--- a/kerby-kerb/kerb-admin/src/test/java/org/apache/kerby/kerberos/kerb/admin/admin/AdminTest.java
+++ b/kerby-kerb/kerb-admin/src/test/java/org/apache/kerby/kerberos/kerb/admin/admin/AdminTest.java
@@ -19,25 +19,37 @@
*/
package org.apache.kerby.kerberos.kerb.admin.admin;
-import org.apache.kerby.kerberos.kerb.KrbException;
import org.apache.kerby.kerberos.kerb.admin.kadmin.remote.AdminClient;
+import org.apache.kerby.kerberos.kerb.admin.kadmin.remote.AdminConfig;
import org.junit.Test;
+import java.io.File;
+import java.net.URL;
+
public class AdminTest {
- private final String kdcRealm = "TEST.COM";
- //private final String clientPrincipalName = "alice";
- //private final String clientPrincipal =
- //clientPrincipalName + "@" + kdcRealm;
+ private final String clientPrincipalName = "alice";
private AdminClient adminClient;
@Test
- public void testAdminClient() throws KrbException {
- adminClient = new AdminClient();
- adminClient.setAdminRealm(kdcRealm);
+ public void testAdminClient() throws Exception {
+
+ URL confFileUrl = AdminTest.class.getResource("/adminClient.conf");
+ File confFile = new File(confFileUrl.toURI());
+
+ AdminConfig adminConfig = new AdminConfig();
+ adminConfig.addKrb5Config(confFile);
+
+ adminClient = new AdminClient(adminConfig);
+
+ String adminRealm = adminConfig.getAdminRealm();
+ String clientPrincipal = clientPrincipalName + "@" + adminRealm;
+
+ adminClient.setAdminRealm(adminRealm);
adminClient.setAllowTcp(true);
adminClient.setAllowUdp(false);
- adminClient.setAdminTcpPort(65417);
- /*adminClient.init();
- adminClient.requestAddPrincial(clientPrincipal);*/
+ adminClient.setAdminTcpPort(adminConfig.getAdminPort());
+
+ adminClient.init();
+ adminClient.requestAddPrincial(clientPrincipal);
}
-}
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/74800d43/kerby-kerb/kerb-admin/src/test/resources/adminClient.conf
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-admin/src/test/resources/adminClient.conf b/kerby-kerb/kerb-admin/src/test/resources/adminClient.conf
new file mode 100644
index 0000000..8c7a11e
--- /dev/null
+++ b/kerby-kerb/kerb-admin/src/test/resources/adminClient.conf
@@ -0,0 +1,20 @@
+#
+# 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.
+#
+[libdefaults]
+default_realm = TEST.COM
+admin_port = 65417
\ No newline at end of file