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 2017/11/28 03:04:05 UTC
[04/15] directory-kerby git commit: Change the Maven groupId in HAS
folder to org.apache.kerby.
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/a8b1c28f/has/has-server/src/test/java/org/apache/kerby/has/server/json/TestJsonConfApi.java
----------------------------------------------------------------------
diff --git a/has/has-server/src/test/java/org/apache/kerby/has/server/json/TestJsonConfApi.java b/has/has-server/src/test/java/org/apache/kerby/has/server/json/TestJsonConfApi.java
new file mode 100644
index 0000000..f880e78
--- /dev/null
+++ b/has/has-server/src/test/java/org/apache/kerby/has/server/json/TestJsonConfApi.java
@@ -0,0 +1,83 @@
+/**
+ * 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.has.server.json;
+
+import com.sun.jersey.api.client.WebResource;
+import com.sun.jersey.core.util.MultivaluedMapImpl;
+import org.apache.kerby.has.server.TestRestApiBase;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runners.MethodSorters;
+
+import java.io.File;
+import java.io.IOException;
+import javax.ws.rs.core.MultivaluedMap;
+
+import static org.junit.Assert.assertEquals;
+
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestJsonConfApi extends TestRestApiBase {
+
+ @Test
+ public void testSetPlugin() {
+ WebResource webResource = getWebResource("conf/setplugin");
+ MultivaluedMap<String, String> params = new MultivaluedMapImpl();
+ params.add("plugin", "RAM");
+ String response = webResource.queryParams(params).put(String.class);
+ assertEquals("HAS plugin set successfully.\n", response);
+ }
+
+ @Test
+ public void testConfigKdcBackend() {
+ WebResource webResource = getWebResource("conf/configkdcbackend");
+ MultivaluedMap<String, String> params = new MultivaluedMapImpl();
+ params.add("backendType", "json");
+ String backend = null;
+ try {
+ backend = new File(testDir, "json-backend").getCanonicalPath();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ params.add("dir", backend);
+ String response = webResource.queryParams(params).put(String.class);
+ assertEquals("Json backend set successfully.\n", response);
+ }
+
+ @Test
+ public void testConfigXJsonKdc() {
+ WebResource webResource = getWebResource("conf/configkdc");
+ MultivaluedMap<String, String> params = new MultivaluedMapImpl();
+ params.add("realm", "HADOOP.COM");
+ params.add("host", "localhost");
+ params.add("port", "8866");
+ String response = webResource.queryParams(params).put(String.class);
+ assertEquals("HAS server KDC set successfully.\n", response);
+ }
+
+ @Test
+ public void testGetKrb5Conf() {
+ getKrb5Conf();
+ }
+
+ @Test
+ public void testGetHasConf() {
+ getHasConf();
+ }
+}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/a8b1c28f/has/has-server/src/test/java/org/apache/kerby/has/server/json/TestJsonHadminApi.java
----------------------------------------------------------------------
diff --git a/has/has-server/src/test/java/org/apache/kerby/has/server/json/TestJsonHadminApi.java b/has/has-server/src/test/java/org/apache/kerby/has/server/json/TestJsonHadminApi.java
new file mode 100644
index 0000000..cbf86a7
--- /dev/null
+++ b/has/has-server/src/test/java/org/apache/kerby/has/server/json/TestJsonHadminApi.java
@@ -0,0 +1,80 @@
+/**
+ * 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.has.server.json;
+
+import com.sun.jersey.api.client.ClientResponse;
+import com.sun.jersey.api.client.WebResource;
+import com.sun.jersey.core.util.MultivaluedMapImpl;
+import org.apache.kerby.has.server.TestRestApiBase;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runners.MethodSorters;
+
+import javax.ws.rs.core.MultivaluedMap;
+
+import static org.junit.Assert.assertEquals;
+
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestJsonHadminApi extends TestRestApiBase {
+
+ @Test
+ public void testCreatePrincipals() {
+ createPrincipals();
+ }
+
+ @Test
+ public void testExportKeytabs() {
+ exportKeytabs();
+ }
+
+ @Test
+ public void testExportKeytab() {
+ exportKeytab();
+ }
+
+ @Test
+ public void testAddPrincipal() {
+ addPrincipal();
+ }
+
+ @Test
+ public void testGetPrincipals() {
+ getPrincipals();
+ }
+
+ @Test
+ public void testRenamePrincipal() {
+ renamePrincipal();
+ }
+
+ @Test
+ public void testXDeletePrincipal() {
+ deletePrincipal();
+ }
+
+ @Test
+ public void testSetConf() {
+ WebResource webResource = getWebResource("admin/setconf");
+ MultivaluedMap<String, String> params = new MultivaluedMapImpl();
+ params.add("isEnable", "true");
+ ClientResponse response = webResource.queryParams(params).put(ClientResponse.class);
+ assertEquals(200, response.getStatus());
+ }
+}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/a8b1c28f/has/has-server/src/test/java/org/apache/kerby/has/server/json/TestJsonHasApi.java
----------------------------------------------------------------------
diff --git a/has/has-server/src/test/java/org/apache/kerby/has/server/json/TestJsonHasApi.java b/has/has-server/src/test/java/org/apache/kerby/has/server/json/TestJsonHasApi.java
new file mode 100644
index 0000000..56fffd9
--- /dev/null
+++ b/has/has-server/src/test/java/org/apache/kerby/has/server/json/TestJsonHasApi.java
@@ -0,0 +1,54 @@
+/**
+ * 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.has.server.json;
+
+import com.sun.jersey.api.client.WebResource;
+import org.apache.hadoop.fs.FileUtil;
+import org.apache.kerby.has.server.TestRestApiBase;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runners.MethodSorters;
+
+import java.io.File;
+
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestJsonHasApi extends TestRestApiBase {
+
+ @Test
+ public void hostRoles() {
+ WebResource webResource = getWebResource("hostroles");
+ String response = webResource.get(String.class);
+ System.out.println(response);
+ }
+
+ @Test
+ public void testKdcStart() {
+ kdcStart();
+ File backendDir = new File(testDir, "json-backend");
+ if (backendDir.exists()) {
+ FileUtil.fullyDelete(backendDir);
+ }
+ }
+
+ @Test
+ public void testKdcInit() {
+ kdcInit();
+ }
+}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/a8b1c28f/has/has-server/src/test/java/org/apache/kerby/has/server/mysql/TestMySQLConfApi.java
----------------------------------------------------------------------
diff --git a/has/has-server/src/test/java/org/apache/kerby/has/server/mysql/TestMySQLConfApi.java b/has/has-server/src/test/java/org/apache/kerby/has/server/mysql/TestMySQLConfApi.java
new file mode 100644
index 0000000..b5fe29c
--- /dev/null
+++ b/has/has-server/src/test/java/org/apache/kerby/has/server/mysql/TestMySQLConfApi.java
@@ -0,0 +1,70 @@
+/**
+ * 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.has.server.mysql;
+
+import com.sun.jersey.api.client.WebResource;
+import com.sun.jersey.core.util.MultivaluedMapImpl;
+import org.apache.kerby.has.server.TestRestApiBase;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runners.MethodSorters;
+
+import javax.ws.rs.core.MultivaluedMap;
+import java.io.IOException;
+
+import static org.junit.Assert.assertEquals;
+
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestMySQLConfApi extends TestRestApiBase {
+
+ @Test
+ public void testConfigKdcBackend() throws IOException {
+ WebResource webResource = getWebResource("conf/configkdcbackend");
+ MultivaluedMap<String, String> params = new MultivaluedMapImpl();
+ params.add("backendType", "mysql");
+ params.add("driver", "org.h2.Driver");
+ params.add("url", "jdbc:h2:" + testDir.getCanonicalPath() + "/mysql-backend/mysqlbackend;MODE=MySQL");
+ params.add("user", "root");
+ params.add("password", "123456");
+ String response = webResource.queryParams(params).put(String.class);
+ assertEquals("MySQL backend set successfully.\n", response);
+ }
+
+ @Test
+ public void testConfigMySQLKdc() {
+ WebResource webResource = getWebResource("conf/configkdc");
+ MultivaluedMap<String, String> params = new MultivaluedMapImpl();
+ params.add("realm", "HADOOP.COM");
+ params.add("host", "localhost");
+ params.add("port", "8899");
+ String response = webResource.queryParams(params).put(String.class);
+ assertEquals("HAS server KDC set successfully.\n", response);
+ }
+
+ @Test
+ public void testGetKrb5Conf() {
+ getKrb5Conf();
+ }
+
+ @Test
+ public void testGetHasConf() {
+ getHasConf();
+ }
+}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/a8b1c28f/has/has-server/src/test/java/org/apache/kerby/has/server/mysql/TestMySQLHadminApi.java
----------------------------------------------------------------------
diff --git a/has/has-server/src/test/java/org/apache/kerby/has/server/mysql/TestMySQLHadminApi.java b/has/has-server/src/test/java/org/apache/kerby/has/server/mysql/TestMySQLHadminApi.java
new file mode 100644
index 0000000..ba31f06
--- /dev/null
+++ b/has/has-server/src/test/java/org/apache/kerby/has/server/mysql/TestMySQLHadminApi.java
@@ -0,0 +1,64 @@
+/**
+ * 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.has.server.mysql;
+
+import org.apache.kerby.has.server.TestRestApiBase;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runners.MethodSorters;
+
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestMySQLHadminApi extends TestRestApiBase {
+
+ @Test
+ public void testCreatePrincipals() {
+ createPrincipals();
+ }
+
+ @Test
+ public void testExportKeytabs() {
+ exportKeytabs();
+ }
+
+ @Test
+ public void testExportKeytab() {
+ exportKeytab();
+ }
+
+ @Test
+ public void testAddPrincipal() {
+ addPrincipal();
+ }
+
+ @Test
+ public void testGetPrincipals() {
+ getPrincipals();
+ }
+
+ @Test
+ public void testRenamePrincipal() {
+ renamePrincipal();
+ }
+
+ @Test
+ public void testXDeletePrincipal() {
+ deletePrincipal();
+ }
+}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/a8b1c28f/has/has-server/src/test/java/org/apache/kerby/has/server/mysql/TestMySQLHasApi.java
----------------------------------------------------------------------
diff --git a/has/has-server/src/test/java/org/apache/kerby/has/server/mysql/TestMySQLHasApi.java b/has/has-server/src/test/java/org/apache/kerby/has/server/mysql/TestMySQLHasApi.java
new file mode 100644
index 0000000..fbe01ab
--- /dev/null
+++ b/has/has-server/src/test/java/org/apache/kerby/has/server/mysql/TestMySQLHasApi.java
@@ -0,0 +1,46 @@
+/**
+ * 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.has.server.mysql;
+
+import org.apache.hadoop.fs.FileUtil;
+import org.apache.kerby.has.server.TestRestApiBase;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runners.MethodSorters;
+
+import java.io.File;
+
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestMySQLHasApi extends TestRestApiBase {
+
+ @Test
+ public void testKdcStart() {
+ kdcStart();
+ File backendDir = new File(testDir, "mysql-backend");
+ if (backendDir.exists()) {
+ FileUtil.fullyDelete(backendDir);
+ }
+ }
+
+ @Test
+ public void testKdcInit() {
+ kdcInit();
+ }
+}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/a8b1c28f/has/has-tool/has-client-tool/pom.xml
----------------------------------------------------------------------
diff --git a/has/has-tool/has-client-tool/pom.xml b/has/has-tool/has-client-tool/pom.xml
index 7ded9e1..adb6852 100644
--- a/has/has-tool/has-client-tool/pom.xml
+++ b/has/has-tool/has-client-tool/pom.xml
@@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>has-tool</artifactId>
- <groupId>org.apache.hadoop</groupId>
+ <groupId>org.apache.kerby</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -13,7 +13,7 @@
<dependencies>
<dependency>
- <groupId>org.apache.hadoop</groupId>
+ <groupId>org.apache.kerby</groupId>
<artifactId>has-client</artifactId>
<version>${project.version}</version>
</dependency>
@@ -23,7 +23,7 @@
<version>${kerby.version}</version>
</dependency>
<dependency>
- <groupId>org.apache.hadoop</groupId>
+ <groupId>org.apache.kerby</groupId>
<artifactId>has-plugins</artifactId>
<version>${project.version}</version>
</dependency>
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/a8b1c28f/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hadmin/remote/HadminRemoteTool.java
----------------------------------------------------------------------
diff --git a/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hadmin/remote/HadminRemoteTool.java b/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hadmin/remote/HadminRemoteTool.java
deleted file mode 100644
index 8756420..0000000
--- a/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hadmin/remote/HadminRemoteTool.java
+++ /dev/null
@@ -1,164 +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.hadoop.has.tool.client.hadmin.remote;
-
-import org.apache.hadoop.has.client.HasAdminClient;
-import org.apache.hadoop.has.client.HasAuthAdminClient;
-import org.apache.hadoop.has.common.HasConfig;
-import org.apache.hadoop.has.common.HasException;
-import org.apache.hadoop.has.common.util.HasUtil;
-import org.apache.hadoop.has.tool.client.hadmin.remote.cmd.HadminRemoteCmd;
-import org.apache.hadoop.has.tool.client.hadmin.remote.cmd.HasRemoteAddPrincipalCmd;
-import org.apache.hadoop.has.tool.client.hadmin.remote.cmd.HasRemoteCreatePrincipalsCmd;
-import org.apache.hadoop.has.tool.client.hadmin.remote.cmd.HasRemoteDeletePrincipalCmd;
-import org.apache.hadoop.has.tool.client.hadmin.remote.cmd.HasRemoteDisableConfCmd;
-import org.apache.hadoop.has.tool.client.hadmin.remote.cmd.HasRemoteEnableConfCmd;
-import org.apache.hadoop.has.tool.client.hadmin.remote.cmd.HasRemoteExportKeytabsCmd;
-import org.apache.hadoop.has.tool.client.hadmin.remote.cmd.HasRemoteGetHostRolesCmd;
-import org.apache.hadoop.has.tool.client.hadmin.remote.cmd.HasRemoteGetPrincipalsCmd;
-import org.apache.hadoop.has.tool.client.hadmin.remote.cmd.HasRemoteRenamePrincipalCmd;
-import org.apache.kerby.util.OSUtil;
-
-import java.io.File;
-import java.util.Scanner;
-
-public class HadminRemoteTool {
-
- private static final String PROMPT = HadminRemoteTool.class.getSimpleName() + ".remote";
- private static final String USAGE = (OSUtil.isWindows()
- ? "Usage: bin\\hadmin-remote.cmd" : "Usage: sh bin/hadmin-remote.sh")
- + " <conf-file>\n"
- + "\tExample:\n"
- + "\t\t"
- + (OSUtil.isWindows()
- ? "bin\\hadmin-remote.cmd" : "sh bin/hadmin-remote.sh")
- + " conf\n";
-
- private static final String LEGAL_COMMANDS = "Available commands are: "
- + "\n"
- + "add_principal, addprinc\n"
- + " Add principal\n"
- + "delete_principal, delprinc\n"
- + " Delete principal\n"
- + "rename_principal, renprinc\n"
- + " Rename principal\n"
- + "list_principals, listprincs\n"
- + " List principals\n"
- + "get_hostroles, hostroles\n"
- + " Get hostRoles\n"
- + "export_keytabs, expkeytabs\n"
- + " Export keytabs\n"
- + "create_principals, creprincs\n"
- + " Create principals\n"
- + "enable_configure, enable\n"
- + " Enable configure\n"
- + "disable_configure, disable\n"
- + " Disable configure\n";
-
- public static void main(String[] args) {
- HasAdminClient hadmin;
- HasAuthAdminClient authHasAdminClient = null;
-
- if (args.length < 1) {
- System.err.println(USAGE);
- System.exit(1);
- }
-
- String confDirPath = args[0];
- File confFile = new File(confDirPath, "hadmin.conf");
- HasConfig hasConfig;
- try {
- hasConfig = HasUtil.getHasConfig(confFile);
- } catch (HasException e) {
- System.err.println(e.getMessage());
- return;
- }
-
- hadmin = new HasAdminClient(hasConfig);
-
- if (hasConfig.getFilterAuthType().equals("kerberos")) {
- authHasAdminClient = new HasAuthAdminClient(hasConfig);
- }
-
- System.out.println("enter \"cmd\" to see legal commands.");
- System.out.print(PROMPT + ": ");
-
- try (Scanner scanner = new Scanner(System.in, "UTF-8")) {
- String input = scanner.nextLine();
-
- while (!(input.equals("quit") || input.equals("exit") || input.equals("q"))) {
- try {
- execute(hadmin, authHasAdminClient, input);
- } catch (HasException e) {
- System.err.println(e.getMessage());
- }
- System.out.print(PROMPT + ": ");
- input = scanner.nextLine();
- }
- }
- }
-
- private static void execute(HasAdminClient hadmin, HasAuthAdminClient hasAuthAdminClient,
- String input) throws HasException {
- input = input.trim();
- if (input.startsWith("cmd")) {
- System.out.println(LEGAL_COMMANDS);
- return;
- }
- HadminRemoteCmd executor;
-
- String[] items = input.split("\\s+");
- String cmd = items[0];
-
- if (cmd.equals("add_principal")
- || cmd.equals("addprinc")) {
- executor = new HasRemoteAddPrincipalCmd(hadmin, hasAuthAdminClient);
- } else if (cmd.equals("delete_principal")
- || cmd.equals("delprinc")) {
- executor = new HasRemoteDeletePrincipalCmd(hadmin, hasAuthAdminClient);
- } else if (cmd.equals("rename_principal")
- || cmd.equals("renprinc")) {
- executor = new HasRemoteRenamePrincipalCmd(hadmin, hasAuthAdminClient);
- } else if (cmd.equals("list_principals")
- || cmd.equals("listprincs")) {
- executor = new HasRemoteGetPrincipalsCmd(hadmin, hasAuthAdminClient);
- } else if (cmd.equals("get_hostroles")
- || cmd.equals("hostroles")) {
- executor = new HasRemoteGetHostRolesCmd(hadmin, hasAuthAdminClient);
- } else if (cmd.equals("create_principals")
- || cmd.equals("creprincs")) {
- executor = new HasRemoteCreatePrincipalsCmd(hadmin, hasAuthAdminClient);
- } else if (cmd.equals("export_keytabs")
- || cmd.equals("expkeytabs")) {
- executor = new HasRemoteExportKeytabsCmd(hadmin, hasAuthAdminClient);
- } else if (cmd.equals("enable_configure")
- || cmd.equals("enable")) {
- executor = new HasRemoteEnableConfCmd(hadmin, hasAuthAdminClient);
- } else if (cmd.equals("disable_configure")
- || cmd.equals("disable")) {
- executor = new HasRemoteDisableConfCmd(hadmin, hasAuthAdminClient);
- } else {
- System.out.println(LEGAL_COMMANDS);
- return;
- }
- executor.execute(items);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/a8b1c28f/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hadmin/remote/cmd/HadminRemoteCmd.java
----------------------------------------------------------------------
diff --git a/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hadmin/remote/cmd/HadminRemoteCmd.java b/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hadmin/remote/cmd/HadminRemoteCmd.java
deleted file mode 100644
index 81f6d98..0000000
--- a/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hadmin/remote/cmd/HadminRemoteCmd.java
+++ /dev/null
@@ -1,49 +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.hadoop.has.tool.client.hadmin.remote.cmd;
-
-import org.apache.hadoop.has.client.HasAdminClient;
-import org.apache.hadoop.has.client.HasAuthAdminClient;
-import org.apache.hadoop.has.common.HasException;
-
-public abstract class HadminRemoteCmd {
-
- private HasAdminClient hadmin;
- private HasAuthAdminClient authHadmin;
-
- public HadminRemoteCmd(HasAdminClient hadmin, HasAuthAdminClient authHadminClient) {
- this.hadmin = hadmin;
- this.authHadmin = authHadminClient;
- }
-
- protected HasAdminClient getHadmin() {
- return hadmin;
- }
-
- protected HasAuthAdminClient getAuthHadmin() {
- return authHadmin;
- }
-
- /**
- * Execute the hadmin cmd.
- * @param input Input cmd to execute
- */
- public abstract void execute(String[] input) throws HasException;
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/a8b1c28f/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hadmin/remote/cmd/HasRemoteAddPrincipalCmd.java
----------------------------------------------------------------------
diff --git a/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hadmin/remote/cmd/HasRemoteAddPrincipalCmd.java b/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hadmin/remote/cmd/HasRemoteAddPrincipalCmd.java
deleted file mode 100644
index 39a24d0..0000000
--- a/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hadmin/remote/cmd/HasRemoteAddPrincipalCmd.java
+++ /dev/null
@@ -1,70 +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.hadoop.has.tool.client.hadmin.remote.cmd;
-
-import org.apache.hadoop.has.client.HasAdminClient;
-import org.apache.hadoop.has.client.HasAuthAdminClient;
-import org.apache.hadoop.has.common.HasException;
-
-/**
- * Remote add principal cmd
- */
-public class HasRemoteAddPrincipalCmd extends HadminRemoteCmd {
-
- public static final String USAGE = "Usage: add_principal [options] <principal-name>\n"
- + "\toptions are:\n"
- + "\t\t[-randkey]\n"
- + "\t\t[-pw password]"
- + "\tExample:\n"
- + "\t\tadd_principal -pw mypassword alice\n";
-
- public HasRemoteAddPrincipalCmd(HasAdminClient hadmin, HasAuthAdminClient authHadmin) {
- super(hadmin, authHadmin);
- }
-
- @Override
- public void execute(String[] items) throws HasException {
- if (items.length < 2) {
- System.err.println(USAGE);
- return;
- }
-
- String clientPrincipal = items[items.length - 1];
-
- HasAdminClient hasAdminClient;
- if (getAuthHadmin() != null) {
- hasAdminClient = getAuthHadmin();
- } else {
- hasAdminClient = getHadmin();
- }
-
- if (!items[1].startsWith("-")) {
- hasAdminClient.addPrincipal(clientPrincipal);
- } else if (items[1].startsWith("-randkey")) {
- hasAdminClient.addPrincipal(clientPrincipal);
- } else if (items[1].startsWith("-pw")) {
- String password = items[2];
- hasAdminClient.addPrincipal(clientPrincipal, password);
- } else {
- System.err.println("add_principal cmd format error.");
- System.err.println(USAGE);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/a8b1c28f/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hadmin/remote/cmd/HasRemoteCreatePrincipalsCmd.java
----------------------------------------------------------------------
diff --git a/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hadmin/remote/cmd/HasRemoteCreatePrincipalsCmd.java b/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hadmin/remote/cmd/HasRemoteCreatePrincipalsCmd.java
deleted file mode 100644
index aa79e23..0000000
--- a/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hadmin/remote/cmd/HasRemoteCreatePrincipalsCmd.java
+++ /dev/null
@@ -1,82 +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.hadoop.has.tool.client.hadmin.remote.cmd;
-
-import org.apache.hadoop.has.client.HasAdminClient;
-import org.apache.hadoop.has.client.HasAuthAdminClient;
-import org.apache.hadoop.has.common.HasException;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-
-public class HasRemoteCreatePrincipalsCmd extends HadminRemoteCmd {
- private static final String USAGE = "\nUsage: create_principals [hostRoles-file]\n"
- + "\t'hostRoles-file' is a file with a hostRoles json string like:\n"
- + "\t\t{HOSTS: [ {\"name\":\"host1\",\"hostRoles\":\"HDFS\"}, "
- + "{\"name\":\"host2\",\"hostRoles\":\"HDFS,HBASE\"} ] }\n"
- + "\tExample:\n"
- + "\t\tcreate_principals hostroles.txt\n";
-
- public HasRemoteCreatePrincipalsCmd(HasAdminClient hadmin, HasAuthAdminClient authHadmin) {
- super(hadmin, authHadmin);
- }
-
- @Override
- public void execute(String[] items) throws HasException {
- //String param = items[0];
- if (items.length != 2) {
- System.err.println(USAGE);
- return;
- }
-
- File hostRoles = new File(items[1]);
- if (!hostRoles.exists()) {
- System.err.println("HostRoles file is not exists.");
- return;
- }
-
- HasAdminClient hasAdminClient;
- if (getAuthHadmin() != null) {
- hasAdminClient = getAuthHadmin();
- } else {
- hasAdminClient = getHadmin();
- }
-
- BufferedReader reader;
- try {
- reader = new BufferedReader(new FileReader(hostRoles));
- } catch (FileNotFoundException e) {
- throw new HasException("File not exist", e);
- }
- StringBuilder sb = new StringBuilder();
- String tempString;
- try {
- while ((tempString = reader.readLine()) != null) {
- sb.append(tempString);
- }
- } catch (IOException e) {
- throw new HasException("Errors occurred when read line. ", e);
- }
- hasAdminClient.requestCreatePrincipals(sb.toString());
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/a8b1c28f/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hadmin/remote/cmd/HasRemoteDeletePrincipalCmd.java
----------------------------------------------------------------------
diff --git a/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hadmin/remote/cmd/HasRemoteDeletePrincipalCmd.java b/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hadmin/remote/cmd/HasRemoteDeletePrincipalCmd.java
deleted file mode 100644
index 260ff2c..0000000
--- a/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hadmin/remote/cmd/HasRemoteDeletePrincipalCmd.java
+++ /dev/null
@@ -1,89 +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.hadoop.has.tool.client.hadmin.remote.cmd;
-
-import org.apache.hadoop.has.client.HasAdminClient;
-import org.apache.hadoop.has.client.HasAuthAdminClient;
-import org.apache.hadoop.has.common.HasException;
-
-import java.io.Console;
-import java.util.Scanner;
-
-/**
- * Remote delete principal cmd
- */
-public class HasRemoteDeletePrincipalCmd extends HadminRemoteCmd {
-
- public static final String USAGE = "Usage: delete_principal <principal-name>\n"
- + "\tExample:\n"
- + "\t\tdelete_principal alice\n";
-
- public HasRemoteDeletePrincipalCmd(HasAdminClient hadmin, HasAuthAdminClient authHadmin) {
- super(hadmin, authHadmin);
- }
-
- @Override
- public void execute(String[] items) throws HasException {
- if (items.length < 2) {
- System.err.println(USAGE);
- return;
- }
-
- HasAdminClient hasAdminClient;
- if (getAuthHadmin() != null) {
- hasAdminClient = getAuthHadmin();
- } else {
- hasAdminClient = getHadmin();
- }
-
- String principal = items[items.length - 1];
- String reply;
- Console console = System.console();
- String prompt = "Are you sure to delete the principal? (yes/no, YES/NO, y/n, Y/N) ";
- if (console == null) {
- System.out.println("Couldn't get Console instance, "
- + "maybe you're running this from within an IDE. "
- + "Use scanner to read password.");
- Scanner scanner = new Scanner(System.in, "UTF-8");
- reply = getReply(scanner, prompt);
- } else {
- reply = getReply(console, prompt);
- }
- if (reply.equals("yes") || reply.equals("YES") || reply.equals("y") || reply.equals("Y")) {
- hasAdminClient.deletePrincipal(principal);
- } else if (reply.equals("no") || reply.equals("NO") || reply.equals("n") || reply.equals("N")) {
- System.out.println("Principal \"" + principal + "\" not deleted.");
- } else {
- System.err.println("Unknown request, fail to delete the principal.");
- System.err.println(USAGE);
- }
- }
-
- private String getReply(Scanner scanner, String prompt) {
- System.out.println(prompt);
- return scanner.nextLine().trim();
- }
-
- private String getReply(Console console, String prompt) {
- console.printf(prompt);
- String line = console.readLine();
- return line;
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/a8b1c28f/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hadmin/remote/cmd/HasRemoteDisableConfCmd.java
----------------------------------------------------------------------
diff --git a/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hadmin/remote/cmd/HasRemoteDisableConfCmd.java b/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hadmin/remote/cmd/HasRemoteDisableConfCmd.java
deleted file mode 100644
index 30027b3..0000000
--- a/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hadmin/remote/cmd/HasRemoteDisableConfCmd.java
+++ /dev/null
@@ -1,49 +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.hadoop.has.tool.client.hadmin.remote.cmd;
-
-import org.apache.hadoop.has.client.HasAdminClient;
-import org.apache.hadoop.has.client.HasAuthAdminClient;
-import org.apache.hadoop.has.common.HasException;
-
-/**
- * Remote add principal cmd
- */
-public class HasRemoteDisableConfCmd extends HadminRemoteCmd {
-
- public static final String USAGE = "Usage: disable_configure\n"
- + "\tExample:\n"
- + "\t\tdisable\n";
-
- public HasRemoteDisableConfCmd(HasAdminClient hadmin, HasAuthAdminClient authHadmin) {
- super(hadmin, authHadmin);
- }
-
- @Override
- public void execute(String[] items) throws HasException {
- HasAdminClient hasAdminClient;
- if (getAuthHadmin() != null) {
- hasAdminClient = getAuthHadmin();
- } else {
- hasAdminClient = getHadmin();
- }
- hasAdminClient.setEnableOfConf("false");
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/a8b1c28f/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hadmin/remote/cmd/HasRemoteEnableConfCmd.java
----------------------------------------------------------------------
diff --git a/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hadmin/remote/cmd/HasRemoteEnableConfCmd.java b/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hadmin/remote/cmd/HasRemoteEnableConfCmd.java
deleted file mode 100644
index 852d487..0000000
--- a/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hadmin/remote/cmd/HasRemoteEnableConfCmd.java
+++ /dev/null
@@ -1,49 +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.hadoop.has.tool.client.hadmin.remote.cmd;
-
-import org.apache.hadoop.has.client.HasAdminClient;
-import org.apache.hadoop.has.client.HasAuthAdminClient;
-import org.apache.hadoop.has.common.HasException;
-
-/**
- * Remote add principal cmd
- */
-public class HasRemoteEnableConfCmd extends HadminRemoteCmd {
-
- public static final String USAGE = "Usage: enable_configure\n"
- + "\tExample:\n"
- + "\t\tenable\n";
-
- public HasRemoteEnableConfCmd(HasAdminClient hadmin, HasAuthAdminClient authHadmin) {
- super(hadmin, authHadmin);
- }
-
- @Override
- public void execute(String[] items) throws HasException {
- HasAdminClient hasAdminClient;
- if (getAuthHadmin() != null) {
- hasAdminClient = getAuthHadmin();
- } else {
- hasAdminClient = getHadmin();
- }
- hasAdminClient.setEnableOfConf("true");
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/a8b1c28f/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hadmin/remote/cmd/HasRemoteExportKeytabsCmd.java
----------------------------------------------------------------------
diff --git a/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hadmin/remote/cmd/HasRemoteExportKeytabsCmd.java b/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hadmin/remote/cmd/HasRemoteExportKeytabsCmd.java
deleted file mode 100644
index ead3b28..0000000
--- a/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hadmin/remote/cmd/HasRemoteExportKeytabsCmd.java
+++ /dev/null
@@ -1,58 +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.hadoop.has.tool.client.hadmin.remote.cmd;
-
-import org.apache.hadoop.has.client.HasAdminClient;
-import org.apache.hadoop.has.client.HasAuthAdminClient;
-import org.apache.hadoop.has.common.HasException;
-
-public class HasRemoteExportKeytabsCmd extends HadminRemoteCmd {
- private static final String USAGE = "\nUsage: export_keytabs <host> [role]\n"
- + "\tExample:\n"
- + "\t\texport_keytabs host1 HDFS\n";
-
- public HasRemoteExportKeytabsCmd(HasAdminClient hadmin, HasAuthAdminClient authHadmin) {
- super(hadmin, authHadmin);
- }
-
- @Override
- public void execute(String[] items) throws HasException {
- //TODO add save path option
- //String param = items[0];
- if (items.length < 2) {
- System.err.println(USAGE);
- return;
- }
-
- HasAdminClient hasAdminClient;
- if (getAuthHadmin() != null) {
- hasAdminClient = getAuthHadmin();
- } else {
- hasAdminClient = getHadmin();
- }
-
- String host = items[1];
- String role = "";
- if (items.length >= 3) {
- role = items[2];
- }
- hasAdminClient.getKeytabByHostAndRole(host, role);
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/a8b1c28f/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hadmin/remote/cmd/HasRemoteGetHostRolesCmd.java
----------------------------------------------------------------------
diff --git a/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hadmin/remote/cmd/HasRemoteGetHostRolesCmd.java b/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hadmin/remote/cmd/HasRemoteGetHostRolesCmd.java
deleted file mode 100644
index 70b9ea7..0000000
--- a/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hadmin/remote/cmd/HasRemoteGetHostRolesCmd.java
+++ /dev/null
@@ -1,68 +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.hadoop.has.tool.client.hadmin.remote.cmd;
-
-import org.apache.hadoop.has.client.HasAdminClient;
-import org.apache.hadoop.has.client.HasAuthAdminClient;
-import org.apache.hadoop.has.common.HasException;
-import org.codehaus.jettison.json.JSONArray;
-import org.codehaus.jettison.json.JSONException;
-import org.codehaus.jettison.json.JSONObject;
-
-public class HasRemoteGetHostRolesCmd extends HadminRemoteCmd {
- private static final String USAGE = "Usage: get_hostroles\n"
- + "\tExample:\n"
- + "\t\tget_hostroles\n";
-
- public HasRemoteGetHostRolesCmd(HasAdminClient hadmin, HasAuthAdminClient authHadmin) {
- super(hadmin, authHadmin);
- }
-
- @Override
- public void execute(String[] input) throws HasException {
- HasAdminClient hasAdminClient = getHadmin();
- String result = hasAdminClient.getHostRoles();
-
- if (result != null) {
- try {
- JSONArray hostRoles = new JSONArray(result);
- for (int i = 0; i < hostRoles.length(); i++) {
- JSONObject hostRole = hostRoles.getJSONObject(i);
- System.out.print("\tHostRole: " + hostRole.getString("HostRole")
- + ", PrincipalNames: ");
- JSONArray principalNames = hostRole.getJSONArray("PrincipalNames");
- for (int j = 0; j < principalNames.length(); j++) {
- System.out.print(principalNames.getString(j));
- if (j == principalNames.length() - 1) {
- System.out.println();
- } else {
- System.out.print(", ");
- }
- }
- }
- } catch (JSONException e) {
- throw new HasException("Errors occurred when getting the host roles.", e);
- }
- } else {
- throw new HasException("Could not get hostRoles.");
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/a8b1c28f/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hadmin/remote/cmd/HasRemoteGetPrincipalsCmd.java
----------------------------------------------------------------------
diff --git a/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hadmin/remote/cmd/HasRemoteGetPrincipalsCmd.java b/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hadmin/remote/cmd/HasRemoteGetPrincipalsCmd.java
deleted file mode 100644
index 05d6970..0000000
--- a/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hadmin/remote/cmd/HasRemoteGetPrincipalsCmd.java
+++ /dev/null
@@ -1,76 +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.hadoop.has.tool.client.hadmin.remote.cmd;
-
-import org.apache.hadoop.has.client.HasAdminClient;
-import org.apache.hadoop.has.client.HasAuthAdminClient;
-import org.apache.hadoop.has.common.HasException;
-
-import java.util.List;
-
-public class HasRemoteGetPrincipalsCmd extends HadminRemoteCmd {
- private static final String USAGE = "Usage: list_principals [expression]\n"
- + "\t'expression' is a shell-style glob expression that can contain the wild-card characters ?, *, and []."
- + "\tExample:\n"
- + "\t\tlist_principals [expression]\n";
-
- public HasRemoteGetPrincipalsCmd(HasAdminClient hadmin, HasAuthAdminClient authHadmin) {
- super(hadmin, authHadmin);
- }
-
- @Override
- public void execute(String[] items) throws HasException {
- if (items.length > 2) {
- System.err.println(USAGE);
- return;
- }
-
- HasAdminClient hasAdminClient;
- if (getAuthHadmin() != null) {
- hasAdminClient = getAuthHadmin();
- } else {
- hasAdminClient = getHadmin();
- }
-
- List<String> principalLists = null;
-
- if (items.length == 1) {
- try {
- principalLists = hasAdminClient.getPrincipals();
- } catch (Exception e) {
- System.err.println("Errors occurred when getting the principals. " + e.getMessage());
- }
- } else {
- //have expression
- String exp = items[1];
- principalLists = hasAdminClient.getPrincipals(exp);
- }
-
- if (principalLists.size() == 0 || principalLists.size() == 1 && principalLists.get(0).isEmpty()) {
- return;
- } else {
- System.out.println("Principals are listed:");
- for (int i = 0; i < principalLists.size(); i++) {
- System.out.println(principalLists.get(i));
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/a8b1c28f/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hadmin/remote/cmd/HasRemoteRenamePrincipalCmd.java
----------------------------------------------------------------------
diff --git a/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hadmin/remote/cmd/HasRemoteRenamePrincipalCmd.java b/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hadmin/remote/cmd/HasRemoteRenamePrincipalCmd.java
deleted file mode 100644
index f900f3a..0000000
--- a/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hadmin/remote/cmd/HasRemoteRenamePrincipalCmd.java
+++ /dev/null
@@ -1,91 +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.hadoop.has.tool.client.hadmin.remote.cmd;
-
-import org.apache.hadoop.has.client.HasAdminClient;
-import org.apache.hadoop.has.client.HasAuthAdminClient;
-import org.apache.hadoop.has.common.HasException;
-
-import java.io.Console;
-import java.util.Scanner;
-
-/**
- * Remote rename principal cmd
- */
-public class HasRemoteRenamePrincipalCmd extends HadminRemoteCmd {
- public static final String USAGE = "Usage: rename_principal <old_principal_name>"
- + " <new_principal_name>\n"
- + "\tExample:\n"
- + "\t\trename_principal alice bob\n";
-
- public HasRemoteRenamePrincipalCmd(HasAdminClient hadmin, HasAuthAdminClient authHadmin) {
- super(hadmin, authHadmin);
- }
-
- @Override
- public void execute(String[] items) throws HasException {
- if (items.length < 3) {
- System.err.println(USAGE);
- return;
- }
-
- HasAdminClient hasAdminClient;
- if (getAuthHadmin() != null) {
- hasAdminClient = getAuthHadmin();
- } else {
- hasAdminClient = getHadmin();
- }
-
- String oldPrincipalName = items[items.length - 2];
- String newPrincipalName = items[items.length - 1];
-
- String reply;
- Console console = System.console();
- String prompt = "Are you sure to rename the principal? (yes/no, YES/NO, y/n, Y/N) ";
- if (console == null) {
- System.out.println("Couldn't get Console instance, "
- + "maybe you're running this from within an IDE. "
- + "Use scanner to read password.");
- Scanner scanner = new Scanner(System.in, "UTF-8");
- reply = getReply(scanner, prompt);
- } else {
- reply = getReply(console, prompt);
- }
- if (reply.equals("yes") || reply.equals("YES") || reply.equals("y") || reply.equals("Y")) {
- hasAdminClient.renamePrincipal(oldPrincipalName, newPrincipalName);
- } else if (reply.equals("no") || reply.equals("NO") || reply.equals("n") || reply.equals("N")) {
- System.out.println("Principal \"" + oldPrincipalName + "\" not renamed.");
- } else {
- System.err.println("Unknown request, fail to rename the principal.");
- System.err.println(USAGE);
- }
- }
-
- private String getReply(Scanner scanner, String prompt) {
- System.out.println(prompt);
- return scanner.nextLine().trim();
- }
-
- private String getReply(Console console, String prompt) {
- console.printf(prompt);
- String line = console.readLine();
- return line;
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/a8b1c28f/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hclient/HasClientLoginTool.java
----------------------------------------------------------------------
diff --git a/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hclient/HasClientLoginTool.java b/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hclient/HasClientLoginTool.java
deleted file mode 100644
index 906b6fb..0000000
--- a/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/hclient/HasClientLoginTool.java
+++ /dev/null
@@ -1,269 +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.hadoop.has.tool.client.hclient;
-
-import org.apache.hadoop.has.client.HasAdminClient;
-import org.apache.hadoop.has.client.HasAuthAdminClient;
-import org.apache.hadoop.has.client.HasClient;
-import org.apache.hadoop.has.common.HasConfig;
-import org.apache.hadoop.has.common.HasException;
-import org.apache.hadoop.has.common.util.HasJaasLoginUtil;
-import org.apache.hadoop.has.common.util.HasUtil;
-import org.apache.kerby.kerberos.kerb.KrbException;
-import org.apache.kerby.kerberos.kerb.server.KdcConfig;
-import org.apache.kerby.kerberos.kerb.server.KdcUtil;
-import org.apache.kerby.kerberos.kerb.type.ticket.TgtTicket;
-import org.apache.kerby.util.OSUtil;
-
-import javax.security.auth.Subject;
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
-public class HasClientLoginTool {
- private static List<String> principalList = new ArrayList<String>();
- private static List<File> keytabList = new ArrayList<File>();
-
- private static final String KEYTAB_USAGE = (OSUtil.isWindows()
- ? "Usage: bin\\k=login-test.cmd" : "Usage: sh bin/login-test.sh")
- + " [add|run|delete] [conf_dir] [work_dir] [number]\n"
- + "\n";
-
- private static final String TGT_USAGE = (OSUtil.isWindows()
- ? "Usage: bin\\k=login-test.cmd" : "Usage: sh bin/login-test.sh")
- + " tgt [conf_dir]\n"
- + "\n";
-
- private static void printKeytabUsage(String error) {
- System.err.println(error + "\n");
- System.err.println(KEYTAB_USAGE);
- System.exit(-1);
- }
-
- private static void printTgtUsage(String error) {
- System.err.println(error + "\n");
- System.err.println(TGT_USAGE);
- System.exit(-1);
- }
-
- public static class Task implements Runnable {
- private int index;
-
- Task(int index) {
- this.index = index;
- }
-
- @Override
- public void run() {
- Subject subject = null;
- try {
- subject = HasJaasLoginUtil.loginUsingKeytab(principalList.get(index),
- keytabList.get(index));
- } catch (IOException e) {
- System.err.println("Fail to login using keytab. " + e);
- }
- System.out.println("Login succeeded for user: "
- + subject.getPrincipals().iterator().next());
- }
- }
-
- public static void main(String[] args) {
-
- String cmd = args[0];
- File confDir;
- File workDir;
-
- if (cmd.equals("tgt")) {
- if (args.length != 2) {
- printTgtUsage("Need 2 args.");
- return;
- }
-
- confDir = new File(args[1]);
- if (!confDir.exists()) {
- printTgtUsage("Need the valid conf dir.");
- return;
- }
- File confFile = new File(confDir, "hadmin.conf");
- HasConfig hasConfig;
- try {
- hasConfig = HasUtil.getHasConfig(confFile);
- } catch (HasException e) {
- System.err.println(e.getMessage());
- return;
- }
- if (hasConfig == null) {
- System.err.println("hadmin.conf not exist in " + confDir.getAbsolutePath());
- return;
- }
- String host = hasConfig.getHttpsHost();
- String port = hasConfig.getHttpsPort();
-
- HasClient hasClient = new HasClient();
- TgtTicket tgtTicket;
- try {
- tgtTicket = hasClient.requestTgt();
- } catch (HasException e) {
- System.err.println("Errors occurred when getting TGT. " + e.getMessage());
- return;
- }
-
- System.out.println("Get the tgt ticket successfully!");
- System.out.println("The client principal of tgt ticket: " + tgtTicket.getClientPrincipal());
-
- Subject subject = null;
- try {
- subject = HasJaasLoginUtil.loginUserFromTgtTicket(
- "https://" + host + ":" + port + "/has/v1?auth_type=RAM");
- } catch (IOException e) {
- System.err.println("Errors occurred when login user with TGT. " + e.getMessage());
- return;
- }
-
- System.out.println("Principal: " + subject.getPrincipals().iterator().next());
- } else {
- if (args.length != 4) {
- printKeytabUsage("Need 4 args.");
- return;
- }
-
- confDir = new File(args[1]);
- workDir = new File(args[2]);
-
- if (!confDir.exists()) {
- printKeytabUsage("Need the valid conf dir.");
- return;
- }
- if (!workDir.exists()) {
- printKeytabUsage("Need the valid work dir.");
- return;
- }
-
- int taskNum = Integer.parseInt(args[3]);
-
- System.out.println("The task num is: " + taskNum);
-
- if (taskNum <= 0) {
- printKeytabUsage("The task num must be greater than zero");
- System.exit(-1);
- }
-
- HasAdminClient hasAdminClient;
- HasAuthAdminClient authHasAdminClient = null;
- File confFile = new File(confDir, "hadmin.conf");
- HasConfig hasConfig = null;
- try {
- hasConfig = HasUtil.getHasConfig(confFile);
- } catch (HasException e) {
- System.err.println(e.getMessage());
- return;
- }
-
- if (hasConfig == null) {
- System.err.println("hadmin.conf not exist in " + confDir.getAbsolutePath());
- return;
- }
-
- if (hasConfig.getFilterAuthType().equals("kerberos")) {
- authHasAdminClient = new HasAuthAdminClient(hasConfig);
- }
- if (authHasAdminClient != null) {
- hasAdminClient = authHasAdminClient;
- } else {
- hasAdminClient = new HasAdminClient(hasConfig);
- }
- String realm = null;
- try {
- KdcConfig kdcConfig = KdcUtil.getKdcConfig(confDir);
- realm = kdcConfig.getKdcRealm();
- } catch (KrbException e) {
- printKeytabUsage(e.getMessage());
- }
-
- if (cmd.equals("add")) {
- for (int i = 0; i < taskNum; i++) {
- String principal = "test" + i + "@" + realm;
- try {
- hasAdminClient.addPrincipal(principal);
- } catch (HasException e) {
- System.err.println("Errors occurred when adding principal. "
- + e.getMessage());
- return;
- }
- File keytabFile = new File(workDir, i + ".keytab");
- try {
- hasAdminClient.exportKeytab(keytabFile, principal);
- } catch (HasException e) {
- System.err.println("Errors occurred when exporting the keytabs. "
- + e.getMessage());
- return;
- }
- System.out.println("Add principals and keytabs successfully.");
- }
- } else if (cmd.equals("run")) {
- ExecutorService exec;
- for (int i = 0; i < taskNum; i++) {
- String principal = "test" + i + "@" + realm;
- principalList.add(i, principal);
- File file = new File(workDir, i + ".keytab");
- keytabList.add(i, file);
- }
- System.out.println("Start the login test.");
- Long startTime = System.currentTimeMillis();
- exec = Executors.newFixedThreadPool(5);
- for (int i = 0; i < taskNum; ++i) {
- exec.submit(new Task(i));
- }
- exec.shutdown();
- try {
- exec.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
- } catch (InterruptedException e) {
- System.err.println(e.getMessage());
- return;
- }
- Long endTime = System.currentTimeMillis();
- System.out.println("Finish the login test.");
- System.out.println("Cost time: " + (endTime - startTime) + "ms");
- } else if (cmd.equals("delete")) {
- for (int i = 0; i < taskNum; i++) {
- String principal = "test" + i + "@" + realm;
- try {
- hasAdminClient.deletePrincipal(principal);
- } catch (HasException e) {
- System.err.println("Errors occurred when deleting the principal. "
- + e.getMessage());
- continue;
- }
- File file = new File(workDir, i + ".keytab");
- if (!file.delete()) {
- System.err.println("Failed to delete " + i + ".keytab.");
- }
- }
- System.out.println("Delete principals and keytabs successfully.");
- } else {
- printKeytabUsage("Need the cmd with add, run or delete.");
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/a8b1c28f/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/kdcinit/HasInitTool.java
----------------------------------------------------------------------
diff --git a/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/kdcinit/HasInitTool.java b/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/kdcinit/HasInitTool.java
deleted file mode 100644
index 1f46305..0000000
--- a/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/kdcinit/HasInitTool.java
+++ /dev/null
@@ -1,132 +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.hadoop.has.tool.client.kdcinit;
-
-import org.apache.hadoop.has.client.HasAdminClient;
-import org.apache.hadoop.has.common.HasConfig;
-import org.apache.hadoop.has.common.HasException;
-import org.apache.hadoop.has.common.util.HasUtil;
-import org.apache.hadoop.has.tool.client.kdcinit.cmd.*;
-import org.apache.kerby.kerberos.kerb.KrbException;
-import org.apache.kerby.util.OSUtil;
-
-import java.io.File;
-import java.util.Scanner;
-
-public class HasInitTool {
- private static final String PROMPT = HasInitTool.class.getSimpleName();
- private static final String USAGE = (OSUtil.isWindows()
- ? "Usage: bin\\hadmin.cmd" : "Usage: sh bin/kdcinit.sh")
- + " <conf-file>\n"
- + "\tExample:\n"
- + "\t\t"
- + (OSUtil.isWindows()
- ? "bin\\kdcinit.cmd" : "sh bin/kdcinit.sh")
- + " conf\n";
-
- private static final String LEGAL_COMMANDS = "Available commands are: "
- + "\n"
- + "get_krb5conf, getkrb5\n"
- + " Get krb5.conf\n"
- + "get_hasConf, gethas\n"
- + " Get has-client.conf\n"
- + "set_plugin, setplugin\n"
- + " Set plugin\n"
- + "config_kdcBackend, confbackend\n"
- + " Config kdc backend\n"
- + "config_kdc, confkdc\n"
- + " Config kdc\n"
- + "start_kdc, start\n"
- + " Start kdc\n"
- + "init_kdc, init\n"
- + " Init kdc\n";
-
- public static void main(String[] args) {
- if (args.length < 1) {
- System.err.println(USAGE);
- System.exit(1);
- }
- String confDirPath = args[0];
- File confFile = new File(confDirPath, "hadmin.conf");
- HasConfig hasConfig;
- try {
- hasConfig = HasUtil.getHasConfig(confFile);
- } catch (HasException e) {
- System.err.println(e.getMessage());
- return;
- }
-
- System.out.println(LEGAL_COMMANDS);
- System.out.println("enter \"<cmd> [?][-help]\" to get cmd help.");
- Scanner scanner = new Scanner(System.in, "UTF-8");
- System.out.print(PROMPT + ": ");
- String input = scanner.nextLine();
-
- HasAdminClient hadmin = new HasAdminClient(hasConfig, new File(confDirPath));
- while (!(input.equals("quit") || input.equals("exit") || input.equals("q"))) {
- try {
- execute(hadmin, input);
- } catch (KrbException e) {
- System.err.println(e.getMessage());
- }
- System.out.print(PROMPT + ": ");
- input = scanner.nextLine();
- }
- }
-
- private static void execute(HasAdminClient hadmin, String input) throws KrbException {
- input = input.trim();
- if (input.startsWith("cmd")) {
- System.out.println(LEGAL_COMMANDS);
- return;
- }
- String[] items = input.split("\\s+");
- String cmd = items[0];
-
- KdcInitCmd executor;
- if (cmd.equals("get_krb5conf")
- || cmd.equals("getkrb5")) {
- executor = new HasGetKrb5confCmd(hadmin);
- } else if (cmd.equals("get_hasConf")
- || cmd.equals("gethas")) {
- executor = new HasGetHasconfCmd(hadmin);
- } else if (cmd.equals("set_plugin")
- || cmd.equals("setplugin")) {
- executor = new HasSetPluginCmd(hadmin);
- } else if (cmd.equals("config_kdcBackend")
- || cmd.equals("confbackend")) {
- executor = new HasConfKdcBackendCmd(hadmin);
- } else if (cmd.equals("config_kdc")
- || cmd.equals("confkdc")) {
- executor = new HasConfKdcCmd(hadmin);
- } else if (cmd.equals("start_kdc")
- || cmd.equals("start")) {
- executor = new HasStartKdcCmd(hadmin);
- } else if (cmd.equals("init_kdc")
- || cmd.equals("init")) {
- executor = new HasInitKdcCmd(hadmin);
- } else {
- System.out.println(LEGAL_COMMANDS);
- return;
- }
- executor.execute(items);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/a8b1c28f/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/kdcinit/cmd/HasConfKdcBackendCmd.java
----------------------------------------------------------------------
diff --git a/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/kdcinit/cmd/HasConfKdcBackendCmd.java b/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/kdcinit/cmd/HasConfKdcBackendCmd.java
deleted file mode 100644
index 002e936..0000000
--- a/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/kdcinit/cmd/HasConfKdcBackendCmd.java
+++ /dev/null
@@ -1,66 +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.hadoop.has.tool.client.kdcinit.cmd;
-
-import org.apache.hadoop.has.client.HasAdminClient;
-import org.apache.kerby.kerberos.kerb.KrbException;
-
-/**
- * Remote config kdc cmd
- */
-public class HasConfKdcBackendCmd extends KdcInitCmd {
-
- public static final String USAGE = "Usage: config_kdcBackend <backendType> [dir] [url] [user]"
- + " [password]\n"
- + "\tSupported backendType : json,mysql\n"
- + "\tExample:\n"
- + "\t\tconfig_kdcBackend json /tmp/has/jsonbackend \n"
- + "\t\tconfig_kdcBackend mysql jdbc:mysql://127.0.0.1:3306/mysqlbackend root passwd\n";
-
- public HasConfKdcBackendCmd(HasAdminClient hadmin) {
- super(hadmin);
- }
-
- @Override
- public void execute(String[] items) throws KrbException {
- if (items.length >= 2) {
- if (items[1].startsWith("?") || items[1].startsWith("-help")) {
- System.out.println(USAGE);
- return;
- }
- }
- if (items.length < 3) {
- System.err.println(USAGE);
- return;
- }
-
- HasAdminClient hasAdminClient = getHadmin();
- if (items.length >= 3 && items[1].equals("json")) {
- hasAdminClient.configKdcBackend(items[1], items[2],
- null, null, null);
- } else if (items.length >= 5 && items[1].equals("mysql")) {
- hasAdminClient.configKdcBackend(items[1], null,
- items[2], items[3], items[4]);
- } else {
- System.err.println(USAGE);
- return;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/a8b1c28f/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/kdcinit/cmd/HasConfKdcCmd.java
----------------------------------------------------------------------
diff --git a/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/kdcinit/cmd/HasConfKdcCmd.java b/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/kdcinit/cmd/HasConfKdcCmd.java
deleted file mode 100644
index fdd3e92..0000000
--- a/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/kdcinit/cmd/HasConfKdcCmd.java
+++ /dev/null
@@ -1,54 +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.hadoop.has.tool.client.kdcinit.cmd;
-
-import org.apache.hadoop.has.client.HasAdminClient;
-import org.apache.kerby.kerberos.kerb.KrbException;
-
-/**
- * Remote config kdc cmd
- */
-public class HasConfKdcCmd extends KdcInitCmd {
-
- public static final String USAGE = "Usage: config_kdc <host> <port> <realm>\n"
- + "\tExample:\n"
- + "\t\tconfig_kdc localhost 88 HADOOP.COM\n";
-
- public HasConfKdcCmd(HasAdminClient hadmin) {
- super(hadmin);
- }
-
- @Override
- public void execute(String[] items) throws KrbException {
- if (items.length >= 2) {
- if (items[1].startsWith("?") || items[1].startsWith("-help")) {
- System.out.println(USAGE);
- return;
- }
- }
- if (items.length < 4) {
- System.err.println(USAGE);
- return;
- }
-
- HasAdminClient hasAdminClient = getHadmin();
- hasAdminClient.configKdc(items[2], items[3], items[1]);
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/a8b1c28f/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/kdcinit/cmd/HasGetHasconfCmd.java
----------------------------------------------------------------------
diff --git a/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/kdcinit/cmd/HasGetHasconfCmd.java b/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/kdcinit/cmd/HasGetHasconfCmd.java
deleted file mode 100644
index 3011cb4..0000000
--- a/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/kdcinit/cmd/HasGetHasconfCmd.java
+++ /dev/null
@@ -1,77 +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.hadoop.has.tool.client.kdcinit.cmd;
-
-import org.apache.hadoop.has.client.HasAdminClient;
-import org.apache.kerby.kerberos.kerb.KrbException;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.PrintStream;
-
-/**
- * Remote get has-client.conf cmd
- */
-public class HasGetHasconfCmd extends KdcInitCmd {
-
- public static final String USAGE = "Usage: get_hasConf [-p] [path]\n"
- + "\tExample:\n"
- + "\t\tget_hasConf\n";
-
- public HasGetHasconfCmd(HasAdminClient hadmin) {
- super(hadmin);
- }
-
- @Override
- public void execute(String[] items) throws KrbException {
- if (items.length >= 2) {
- if (items[1].startsWith("?") || items[1].startsWith("-help")) {
- System.out.println(USAGE);
- return;
- }
- }
- File path = getHadmin().getConfDir();
- if (items.length >= 3 && items[1].startsWith("-p")) {
- path = new File(items[2]);
- if (!path.exists()) {
- if (!path.mkdirs()) {
- System.err.println("Cannot create file : " + items[2]);
- return;
- }
- }
- }
- File hasConf = new File(path, "has-client.conf");
-
- HasAdminClient hasAdminClient = getHadmin();
- String content = hasAdminClient.getHasconf();
- if (content == null) {
- System.err.println("Failed to get has.conf.");
- return;
- }
- try {
- PrintStream ps = new PrintStream(new FileOutputStream(hasConf));
- ps.println(content);
- System.out.println("has-client.conf has saved in : " + hasConf.getAbsolutePath());
- } catch (FileNotFoundException e) {
- System.err.println(e.getMessage());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/a8b1c28f/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/kdcinit/cmd/HasGetKrb5confCmd.java
----------------------------------------------------------------------
diff --git a/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/kdcinit/cmd/HasGetKrb5confCmd.java b/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/kdcinit/cmd/HasGetKrb5confCmd.java
deleted file mode 100644
index 4b39ac8..0000000
--- a/has/has-tool/has-client-tool/src/main/java/org/apache/hadoop/has/tool/client/kdcinit/cmd/HasGetKrb5confCmd.java
+++ /dev/null
@@ -1,77 +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.hadoop.has.tool.client.kdcinit.cmd;
-
-import org.apache.hadoop.has.client.HasAdminClient;
-import org.apache.kerby.kerberos.kerb.KrbException;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.PrintStream;
-
-/**
- * Remote get krb5.conf cmd
- */
-public class HasGetKrb5confCmd extends KdcInitCmd {
-
- public static final String USAGE = "Usage: get_krb5conf [-p] [path]\n"
- + "\tExample:\n"
- + "\t\tget_krb5conf -p /tmp/has\n";
-
- public HasGetKrb5confCmd(HasAdminClient hadmin) {
- super(hadmin);
- }
-
- @Override
- public void execute(String[] items) throws KrbException {
- if (items.length >= 2) {
- if (items[1].startsWith("?") || items[1].startsWith("-help")) {
- System.out.println(USAGE);
- return;
- }
- }
- File path = getHadmin().getConfDir();
- if (items.length >= 3 && items[1].startsWith("-p")) {
- path = new File(items[2]);
- if (!path.exists()) {
- if (!path.mkdirs()) {
- System.err.println("Cannot create file : " + items[2]);
- return;
- }
- }
- }
- File krb5Conf = new File(path, "krb5.conf");
-
- HasAdminClient hasAdminClient = getHadmin();
- String content = hasAdminClient.getKrb5conf();
- if (content == null) {
- System.err.println("Failed to get krb5.conf.");
- return;
- }
- try {
- PrintStream ps = new PrintStream(new FileOutputStream(krb5Conf));
- ps.println(content);
- System.out.println("krb5.conf has saved in : " + krb5Conf.getAbsolutePath());
- } catch (FileNotFoundException e) {
- System.err.println(e.getMessage());
- }
- }
-}