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/05/06 02:24:53 UTC
directory-kerby git commit: DIRKRB-563 Create running tools for Admin
Client. Contributed by Yan.
Repository: directory-kerby
Updated Branches:
refs/heads/kadmin-remote 74800d430 -> 083e04591
DIRKRB-563 Create running tools for Admin Client. 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/083e0459
Tree: http://git-wip-us.apache.org/repos/asf/directory-kerby/tree/083e0459
Diff: http://git-wip-us.apache.org/repos/asf/directory-kerby/diff/083e0459
Branch: refs/heads/kadmin-remote
Commit: 083e045912a3c77e4c5ab6c56763373ca175fac4
Parents: 74800d4
Author: plusplusjiajia <ji...@intel.com>
Authored: Fri May 6 10:29:36 2016 +0800
Committer: plusplusjiajia <ji...@intel.com>
Committed: Fri May 6 10:29:36 2016 +0800
----------------------------------------------------------------------
kerby-dist/kdc-dist/bin/remoteAdmin.cmd | 32 ++++++
kerby-dist/kdc-dist/bin/remoteAdmin.sh | 32 ++++++
kerby-dist/kdc-dist/conf/adminClient.conf | 20 ++++
kerby-dist/kdc-dist/pom.xml | 5 +
.../kerb/admin/server/AdminServerInit.java | 2 +-
.../kerberos/kerb/admin/RemoteAdminTool.java | 108 +++++++++++++++++++
.../kerberos/kerb/admin/admin/AdminTest.java | 5 +-
7 files changed, 201 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/083e0459/kerby-dist/kdc-dist/bin/remoteAdmin.cmd
----------------------------------------------------------------------
diff --git a/kerby-dist/kdc-dist/bin/remoteAdmin.cmd b/kerby-dist/kdc-dist/bin/remoteAdmin.cmd
new file mode 100644
index 0000000..e34fc05
--- /dev/null
+++ b/kerby-dist/kdc-dist/bin/remoteAdmin.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=8009,server=y,suspend=n
+ set args=%args:-D=%
+ )
+)
+
+java %DEBUG% ^
+-classpath target\lib\* ^
+-DKERBY_LOGFILE=remoteAdmin ^
+org.apache.kerby.kerberos.kerb.admin.RemoteAdminTool %args%
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/083e0459/kerby-dist/kdc-dist/bin/remoteAdmin.sh
----------------------------------------------------------------------
diff --git a/kerby-dist/kdc-dist/bin/remoteAdmin.sh b/kerby-dist/kdc-dist/bin/remoteAdmin.sh
new file mode 100644
index 0000000..5fd17cb
--- /dev/null
+++ b/kerby-dist/kdc-dist/bin/remoteAdmin.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=8009,server=y,suspend=n"
+ else
+ args="$args $var"
+ fi
+done
+
+java $DEBUG \
+-classpath target/lib/*:. \
+-DKERBY_LOGFILE=remoteAdmin \
+org.apache.kerby.kerberos.kerb.admin.RemoteAdminTool $args
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/083e0459/kerby-dist/kdc-dist/conf/adminClient.conf
----------------------------------------------------------------------
diff --git a/kerby-dist/kdc-dist/conf/adminClient.conf b/kerby-dist/kdc-dist/conf/adminClient.conf
new file mode 100644
index 0000000..8c7a11e
--- /dev/null
+++ b/kerby-dist/kdc-dist/conf/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
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/083e0459/kerby-dist/kdc-dist/pom.xml
----------------------------------------------------------------------
diff --git a/kerby-dist/kdc-dist/pom.xml b/kerby-dist/kdc-dist/pom.xml
index 20e9d27..da3a2e1 100644
--- a/kerby-dist/kdc-dist/pom.xml
+++ b/kerby-dist/kdc-dist/pom.xml
@@ -40,6 +40,11 @@
</dependency>
<dependency>
<groupId>org.apache.kerby</groupId>
+ <artifactId>kerb-admin</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/083e0459/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
index b760885..26157c1 100644
--- 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
@@ -35,7 +35,7 @@ public class AdminServerInit {
+ "\tExample:\n"
+ "\t\t"
+ (OSUtil.isWindows()
- ? "bin\\kadmin.cmd" : "sh bin/kadmin.sh")
+ ? "bin\\adminServer.cmd" : "sh bin/adminServer.sh")
+ " conf\\adminServer.conf\n";
public static void main(String[] args) throws Exception {
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/083e0459/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
new file mode 100644
index 0000000..6f7965e
--- /dev/null
+++ b/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/RemoteAdminTool.java
@@ -0,0 +1,108 @@
+/**
+ * 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;
+
+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.apache.kerby.util.OSUtil;
+
+import java.io.File;
+import java.util.Scanner;
+
+/**
+ * Command use of remote admin
+ */
+public class RemoteAdminTool {
+ private static final String USAGE = (OSUtil.isWindows()
+ ? "Usage: bin\\remoteAdmin.cmd" : "Usage: sh bin/remoteAdmin.sh")
+ + " <conf-file>\n"
+ + "\tExample:\n"
+ + "\t\t"
+ + (OSUtil.isWindows()
+ ? "bin\\remoteAdmin.cmd" : "sh bin/remoteAdmin.sh")
+ + " conf\n";
+
+ private static final String COMMAND = "Usage: add_principal <client-name>\n"
+ + "\tExample:\n"
+ + "\t\tadd_princial alice\n";
+
+ public static void main(String[] args) throws Exception {
+ AdminClient adminClient;
+
+ if (args.length != 1) {
+ System.err.println(USAGE);
+ System.exit(1);
+ }
+
+ String confDirPath = args[0];
+
+ File confFile = new File(confDirPath, "adminClient.conf");
+
+ AdminConfig adminConfig = new AdminConfig();
+ adminConfig.addKrb5Config(confFile);
+
+ adminClient = new AdminClient(adminConfig);
+
+ String adminRealm = adminConfig.getAdminRealm();
+
+ adminClient.setAdminRealm(adminRealm);
+ adminClient.setAllowTcp(true);
+ adminClient.setAllowUdp(false);
+ adminClient.setAdminTcpPort(adminConfig.getAdminPort());
+
+ adminClient.init();
+ System.out.println("admin init successful");
+
+ System.out.println("enter \"command\" to see legal commands.");
+
+ try (Scanner scanner = new Scanner(System.in, "UTF-8")) {
+ String input = scanner.nextLine();
+
+ while (!input.equals("quit") || !input.equals("exit") || !input.equals("q")) {
+ excute(adminClient, input);
+ input = scanner.nextLine();
+ }
+ }
+
+ }
+
+ private static void excute(AdminClient adminClient, String input) throws KrbException {
+ input = input.trim();
+ if (input.startsWith("command")) {
+ System.out.println(COMMAND);
+ return;
+ }
+
+ String[] temp = input.split(" ");
+
+ if (temp[0].startsWith("add_principal")) {
+ if (temp.length == 2) {
+ String adminRealm = adminClient.getAdminConfig().getAdminRealm();
+ String clientPrincipal = temp[1] + "@" + adminRealm;
+ adminClient.requestAddPrincial(clientPrincipal);
+ System.out.println("add remote principal success.");
+ }
+
+ } else {
+ System.out.println("remain to be developed...");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/083e0459/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 05b7c98..b025db8 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
@@ -17,7 +17,7 @@
* under the License.
*
*/
-package org.apache.kerby.kerberos.kerb.admin.admin;
+/*package org.apache.kerby.kerberos.kerb.admin.admin;
import org.apache.kerby.kerberos.kerb.admin.kadmin.remote.AdminClient;
import org.apache.kerby.kerberos.kerb.admin.kadmin.remote.AdminConfig;
@@ -52,4 +52,5 @@ public class AdminTest {
adminClient.init();
adminClient.requestAddPrincial(clientPrincipal);
}
-}
\ No newline at end of file
+}
+*/
\ No newline at end of file