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 2018/09/27 05:37:26 UTC
directory-kerby git commit: Separate has-plugins module into
has-client-plugin and has-server-plugin.
Repository: directory-kerby
Updated Branches:
refs/heads/trunk e9aba86ac -> 49c9f511c
Separate has-plugins module into has-client-plugin and has-server-plugin.
Project: http://git-wip-us.apache.org/repos/asf/directory-kerby/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-kerby/commit/49c9f511
Tree: http://git-wip-us.apache.org/repos/asf/directory-kerby/tree/49c9f511
Diff: http://git-wip-us.apache.org/repos/asf/directory-kerby/diff/49c9f511
Branch: refs/heads/trunk
Commit: 49c9f511cd2b96ab7bd3970eb1202d652d7202a7
Parents: e9aba86
Author: plusplusjiajia <ji...@intel.com>
Authored: Thu Sep 27 13:34:27 2018 +0800
Committer: plusplusjiajia <ji...@intel.com>
Committed: Thu Sep 27 13:34:27 2018 +0800
----------------------------------------------------------------------
has-project/has-client-plugin/pom.xml | 33 +++++
.../plugins/client/ldap/LDAPClientPlugin.java | 96 ++++++++++++
.../client/mysql/MySQLHasClientPlugin.java | 67 +++++++++
.../org.apache.kerby.has.client.HasClientPlugin | 17 +++
.../src/main/resources/ldap-client.ini | 3 +
.../client/TestHasClientPluginRegistry.java | 44 ++++++
has-project/has-client/pom.xml | 1 +
.../org/apache/kerby/has/client/HasClient.java | 5 +-
has-project/has-common/pom.xml | 3 +-
has-project/has-plugins/pom.xml | 60 --------
.../plugins/client/ldap/LDAPClientPlugin.java | 96 ------------
.../client/mysql/MySQLHasClientPlugin.java | 67 ---------
.../plugins/server/ldap/LDAPServerPlugin.java | 67 ---------
.../has/plugins/server/ldap/LDAPUtils.java | 87 -----------
.../server/ldap/conf/LDAPServerConf.java | 95 ------------
.../server/mysql/MySQLHasServerPlugin.java | 146 -------------------
.../org.apache.kerby.has.client.HasClientPlugin | 17 ---
.../org.apache.kerby.has.server.HasServerPlugin | 17 ---
.../src/main/resources/ldap-client.ini | 3 -
.../plugins/TestHasClientPluginRegistry.java | 44 ------
.../plugins/TestHasServerPluginRegistry.java | 43 ------
has-project/has-server-plugin/pom.xml | 53 +++++++
.../plugins/server/ldap/LDAPServerPlugin.java | 67 +++++++++
.../has/plugins/server/ldap/LDAPUtils.java | 87 +++++++++++
.../server/ldap/conf/LDAPServerConf.java | 95 ++++++++++++
.../server/mysql/MySQLHasServerPlugin.java | 145 ++++++++++++++++++
.../org.apache.kerby.has.server.HasServerPlugin | 17 +++
.../server/TestHasServerPluginRegistry.java | 43 ++++++
has-project/has-server/pom.xml | 1 +
has-project/pom.xml | 5 +-
kerby-dist/has-dist/pom.xml | 11 +-
kerby-tool/has-tool/pom.xml | 1 +
32 files changed, 786 insertions(+), 750 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/49c9f511/has-project/has-client-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/has-project/has-client-plugin/pom.xml b/has-project/has-client-plugin/pom.xml
new file mode 100644
index 0000000..3634900
--- /dev/null
+++ b/has-project/has-client-plugin/pom.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>has-project</artifactId>
+ <groupId>org.apache.kerby</groupId>
+ <version>2.0.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>has-client-plugin</artifactId>
+ <name>HAS Client Plugin</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.kerby</groupId>
+ <artifactId>has-client</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ini4j</groupId>
+ <artifactId>ini4j</artifactId>
+ <version>${ini4j.version}</version>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/49c9f511/has-project/has-client-plugin/src/main/java/org/apache/kerby/has/plugins/client/ldap/LDAPClientPlugin.java
----------------------------------------------------------------------
diff --git a/has-project/has-client-plugin/src/main/java/org/apache/kerby/has/plugins/client/ldap/LDAPClientPlugin.java b/has-project/has-client-plugin/src/main/java/org/apache/kerby/has/plugins/client/ldap/LDAPClientPlugin.java
new file mode 100755
index 0000000..dffab6e
--- /dev/null
+++ b/has-project/has-client-plugin/src/main/java/org/apache/kerby/has/plugins/client/ldap/LDAPClientPlugin.java
@@ -0,0 +1,96 @@
+/**
+ * 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.plugins.client.ldap;
+
+import org.apache.kerby.has.client.AbstractHasClientPlugin;
+import org.apache.kerby.has.client.HasLoginException;
+import org.apache.kerby.kerberos.kerb.type.base.AuthToken;
+import org.ini4j.Wini;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.util.Date;
+
+public class LDAPClientPlugin extends AbstractHasClientPlugin {
+ public static final Logger LOG = LoggerFactory.getLogger(LDAPClientPlugin.class);
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getLoginType() {
+ return "LDAP";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void doLogin(AuthToken authToken) throws HasLoginException {
+ String user = System.getenv("LDAP_USER");
+ String pwd = System.getenv("LDAP_PWD");
+ if (user == null || pwd == null) {
+ String ldapConfigDir = System.getenv("HAS_CONF_DIR");
+ if (ldapConfigDir == null) {
+ LOG.error("Get LDAP User/Secret failed, "
+ + "you can set them using export system environment(User/Secret),"
+ + "or export HAS_CONF_DIR which has a credential.xml file");
+ } else {
+ try {
+ String confFile = ldapConfigDir + "/ldap-client.ini";
+ Wini ini = new Wini(new File(confFile));
+ user = ini.get("user", "ldap_user");
+ pwd = ini.get("user", "ldap_pwd");
+ } catch (Exception e) {
+ LOG.error("parser ldap ini failed", e);
+ }
+
+ LOG.debug("Get LDAP User/Secret from " + ldapConfigDir
+ + "/ldap-client.ini, user:" + user);
+ }
+ } else {
+ LOG.debug("Get LDAP User/Secret from sys environment, user:" + user);
+ }
+
+ if (user == null) {
+ user = System.getProperty("user.name");
+ }
+
+ if (user == null || pwd == null) {
+ String errMsg = "Get LDAP User/Secret failed, "
+ + "you can set them using export system environment(User/Secret),"
+ + "or export HAS_CONF_DIR which has a credential.xml file";
+ LOG.error(errMsg);
+ throw new HasLoginException(errMsg);
+ }
+
+ authToken.setIssuer("has");
+
+ final Date now = new Date(new Date().getTime() / 1000 * 1000);
+ authToken.setIssueTime(now);
+ // Set expiration in 60 minutes
+ Date exp = new Date(now.getTime() + 1000 * 60 * 60);
+ authToken.setExpirationTime(exp);
+
+ authToken.addAttribute("ldap_user", user);
+ authToken.addAttribute("ldap_pwd", pwd);
+ authToken.addAttribute("passPhrase", pwd);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/49c9f511/has-project/has-client-plugin/src/main/java/org/apache/kerby/has/plugins/client/mysql/MySQLHasClientPlugin.java
----------------------------------------------------------------------
diff --git a/has-project/has-client-plugin/src/main/java/org/apache/kerby/has/plugins/client/mysql/MySQLHasClientPlugin.java b/has-project/has-client-plugin/src/main/java/org/apache/kerby/has/plugins/client/mysql/MySQLHasClientPlugin.java
new file mode 100644
index 0000000..3bbe6f8
--- /dev/null
+++ b/has-project/has-client-plugin/src/main/java/org/apache/kerby/has/plugins/client/mysql/MySQLHasClientPlugin.java
@@ -0,0 +1,67 @@
+/**
+ * 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.plugins.client.mysql;
+
+import org.apache.kerby.has.client.AbstractHasClientPlugin;
+import org.apache.kerby.has.client.HasLoginException;
+import org.apache.kerby.kerberos.kerb.type.base.AuthToken;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Date;
+
+public class MySQLHasClientPlugin extends AbstractHasClientPlugin {
+ private static final Logger LOG = LoggerFactory.getLogger(MySQLHasClientPlugin.class);
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getLoginType() {
+ return "MySQL";
+ }
+
+ @Override
+ protected void doLogin(AuthToken authToken) throws HasLoginException {
+
+ //Get the user info from env
+ String userName = System.getenv("userName");
+ if (userName == null || userName.isEmpty()) {
+ throw new HasLoginException("Please set the userName.");
+ }
+ String password = System.getenv("password");
+ if (password == null || password.isEmpty()) {
+ throw new HasLoginException("Please set the password.");
+ }
+ LOG.debug("Get the user info successfully.");
+
+ authToken.setIssuer("has");
+ authToken.setSubject(userName);
+
+ final Date now = new Date(System.currentTimeMillis() / 1000 * 1000);
+ authToken.setIssueTime(now);
+ // Set expiration in 60 minutes
+ Date exp = new Date(now.getTime() + 1000 * 60 * 60);
+ authToken.setExpirationTime(exp);
+
+ authToken.addAttribute("user", userName);
+ authToken.addAttribute("secret", password);
+
+ authToken.addAttribute("passPhrase", userName + password);
+ }
+}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/49c9f511/has-project/has-client-plugin/src/main/resources/META-INF/services/org.apache.kerby.has.client.HasClientPlugin
----------------------------------------------------------------------
diff --git a/has-project/has-client-plugin/src/main/resources/META-INF/services/org.apache.kerby.has.client.HasClientPlugin b/has-project/has-client-plugin/src/main/resources/META-INF/services/org.apache.kerby.has.client.HasClientPlugin
new file mode 100644
index 0000000..25382fc
--- /dev/null
+++ b/has-project/has-client-plugin/src/main/resources/META-INF/services/org.apache.kerby.has.client.HasClientPlugin
@@ -0,0 +1,17 @@
+# 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.
+
+org.apache.kerby.has.plugins.client.mysql.MySQLHasClientPlugin
+org.apache.kerby.has.plugins.client.ldap.LDAPClientPlugin
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/49c9f511/has-project/has-client-plugin/src/main/resources/ldap-client.ini
----------------------------------------------------------------------
diff --git a/has-project/has-client-plugin/src/main/resources/ldap-client.ini b/has-project/has-client-plugin/src/main/resources/ldap-client.ini
new file mode 100644
index 0000000..888e27a
--- /dev/null
+++ b/has-project/has-client-plugin/src/main/resources/ldap-client.ini
@@ -0,0 +1,3 @@
+[ user ]
+ ldap_user=test
+ ldap_pwd=123456
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/49c9f511/has-project/has-client-plugin/src/test/java/org/apache/kerby/has/plugins/client/TestHasClientPluginRegistry.java
----------------------------------------------------------------------
diff --git a/has-project/has-client-plugin/src/test/java/org/apache/kerby/has/plugins/client/TestHasClientPluginRegistry.java b/has-project/has-client-plugin/src/test/java/org/apache/kerby/has/plugins/client/TestHasClientPluginRegistry.java
new file mode 100644
index 0000000..bbef0a0
--- /dev/null
+++ b/has-project/has-client-plugin/src/test/java/org/apache/kerby/has/plugins/client/TestHasClientPluginRegistry.java
@@ -0,0 +1,44 @@
+/**
+ * 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.plugins.client;
+
+import org.apache.kerby.has.client.HasClientPluginRegistry;
+import org.apache.kerby.has.common.HasException;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.Set;
+
+public class TestHasClientPluginRegistry {
+
+ @Test
+ public void testInit() {
+ Set<String> pluginsNames = HasClientPluginRegistry.registeredPlugins();
+ Assert.assertTrue(pluginsNames.size() > 0);
+ }
+
+ @Test
+ public void testCreatePlugin() throws HasException {
+ Assert.assertTrue(HasClientPluginRegistry.createPlugin("MySQL") != null);
+ Set<String> pluginNames = HasClientPluginRegistry.registeredPlugins();
+ for (String name : pluginNames) {
+ HasClientPluginRegistry.createPlugin(name);
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/49c9f511/has-project/has-client/pom.xml
----------------------------------------------------------------------
diff --git a/has-project/has-client/pom.xml b/has-project/has-client/pom.xml
index c8b3468..2a19734 100644
--- a/has-project/has-client/pom.xml
+++ b/has-project/has-client/pom.xml
@@ -10,6 +10,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>has-client</artifactId>
+ <name>HAS Client</name>
<dependencies>
<dependency>
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/49c9f511/has-project/has-client/src/main/java/org/apache/kerby/has/client/HasClient.java
----------------------------------------------------------------------
diff --git a/has-project/has-client/src/main/java/org/apache/kerby/has/client/HasClient.java b/has-project/has-client/src/main/java/org/apache/kerby/has/client/HasClient.java
index 969c642..c9c5bb6 100755
--- a/has-project/has-client/src/main/java/org/apache/kerby/has/client/HasClient.java
+++ b/has-project/has-client/src/main/java/org/apache/kerby/has/client/HasClient.java
@@ -347,8 +347,9 @@ public class HasClient {
try {
boolean success = json.getBoolean("success");
if (!success) {
- LOG.debug(json.getString("KrbMessage"));
- throw new HasException(json.getString("krbMessage"));
+ String message = json.getString("krbMessage");
+ LOG.debug(message);
+ throw new HasException(message);
}
} catch (JSONException e) {
LOG.debug("Failed to get message. " + e.getMessage());
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/49c9f511/has-project/has-common/pom.xml
----------------------------------------------------------------------
diff --git a/has-project/has-common/pom.xml b/has-project/has-common/pom.xml
index 5cfe239..a9b5d6c 100644
--- a/has-project/has-common/pom.xml
+++ b/has-project/has-common/pom.xml
@@ -10,6 +10,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>has-common</artifactId>
+ <name>HAS Common</name>
<dependencies>
<dependency>
@@ -24,7 +25,7 @@
</dependency>
<dependency>
<groupId>org.apache.kerby</groupId>
- <artifactId>kerb-client-api-all</artifactId>
+ <artifactId>kerb-client</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/49c9f511/has-project/has-plugins/pom.xml
----------------------------------------------------------------------
diff --git a/has-project/has-plugins/pom.xml b/has-project/has-plugins/pom.xml
deleted file mode 100644
index 2b06d17..0000000
--- a/has-project/has-plugins/pom.xml
+++ /dev/null
@@ -1,60 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <parent>
- <artifactId>has-project</artifactId>
- <groupId>org.apache.kerby</groupId>
- <version>2.0.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
-
- <artifactId>has-plugins</artifactId>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.kerby</groupId>
- <artifactId>has-common</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.kerby</groupId>
- <artifactId>has-client</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.kerby</groupId>
- <artifactId>has-server</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>commons-dbutils</groupId>
- <artifactId>commons-dbutils</artifactId>
- <version>${commons-dbutils.version}</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.ini4j</groupId>
- <artifactId>ini4j</artifactId>
- <version>${ini4j.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.directory.api</groupId>
- <artifactId>api-ldap-client-api</artifactId>
- <version>${ldap.api.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.directory.api</groupId>
- <artifactId>api-ldap-codec-standalone</artifactId>
- <version>${ldap.api.version}</version>
- </dependency>
-
-
- </dependencies>
-
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/49c9f511/has-project/has-plugins/src/main/java/org/apache/kerby/has/plugins/client/ldap/LDAPClientPlugin.java
----------------------------------------------------------------------
diff --git a/has-project/has-plugins/src/main/java/org/apache/kerby/has/plugins/client/ldap/LDAPClientPlugin.java b/has-project/has-plugins/src/main/java/org/apache/kerby/has/plugins/client/ldap/LDAPClientPlugin.java
deleted file mode 100755
index dffab6e..0000000
--- a/has-project/has-plugins/src/main/java/org/apache/kerby/has/plugins/client/ldap/LDAPClientPlugin.java
+++ /dev/null
@@ -1,96 +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.has.plugins.client.ldap;
-
-import org.apache.kerby.has.client.AbstractHasClientPlugin;
-import org.apache.kerby.has.client.HasLoginException;
-import org.apache.kerby.kerberos.kerb.type.base.AuthToken;
-import org.ini4j.Wini;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.util.Date;
-
-public class LDAPClientPlugin extends AbstractHasClientPlugin {
- public static final Logger LOG = LoggerFactory.getLogger(LDAPClientPlugin.class);
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getLoginType() {
- return "LDAP";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void doLogin(AuthToken authToken) throws HasLoginException {
- String user = System.getenv("LDAP_USER");
- String pwd = System.getenv("LDAP_PWD");
- if (user == null || pwd == null) {
- String ldapConfigDir = System.getenv("HAS_CONF_DIR");
- if (ldapConfigDir == null) {
- LOG.error("Get LDAP User/Secret failed, "
- + "you can set them using export system environment(User/Secret),"
- + "or export HAS_CONF_DIR which has a credential.xml file");
- } else {
- try {
- String confFile = ldapConfigDir + "/ldap-client.ini";
- Wini ini = new Wini(new File(confFile));
- user = ini.get("user", "ldap_user");
- pwd = ini.get("user", "ldap_pwd");
- } catch (Exception e) {
- LOG.error("parser ldap ini failed", e);
- }
-
- LOG.debug("Get LDAP User/Secret from " + ldapConfigDir
- + "/ldap-client.ini, user:" + user);
- }
- } else {
- LOG.debug("Get LDAP User/Secret from sys environment, user:" + user);
- }
-
- if (user == null) {
- user = System.getProperty("user.name");
- }
-
- if (user == null || pwd == null) {
- String errMsg = "Get LDAP User/Secret failed, "
- + "you can set them using export system environment(User/Secret),"
- + "or export HAS_CONF_DIR which has a credential.xml file";
- LOG.error(errMsg);
- throw new HasLoginException(errMsg);
- }
-
- authToken.setIssuer("has");
-
- final Date now = new Date(new Date().getTime() / 1000 * 1000);
- authToken.setIssueTime(now);
- // Set expiration in 60 minutes
- Date exp = new Date(now.getTime() + 1000 * 60 * 60);
- authToken.setExpirationTime(exp);
-
- authToken.addAttribute("ldap_user", user);
- authToken.addAttribute("ldap_pwd", pwd);
- authToken.addAttribute("passPhrase", pwd);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/49c9f511/has-project/has-plugins/src/main/java/org/apache/kerby/has/plugins/client/mysql/MySQLHasClientPlugin.java
----------------------------------------------------------------------
diff --git a/has-project/has-plugins/src/main/java/org/apache/kerby/has/plugins/client/mysql/MySQLHasClientPlugin.java b/has-project/has-plugins/src/main/java/org/apache/kerby/has/plugins/client/mysql/MySQLHasClientPlugin.java
deleted file mode 100644
index 3bbe6f8..0000000
--- a/has-project/has-plugins/src/main/java/org/apache/kerby/has/plugins/client/mysql/MySQLHasClientPlugin.java
+++ /dev/null
@@ -1,67 +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.has.plugins.client.mysql;
-
-import org.apache.kerby.has.client.AbstractHasClientPlugin;
-import org.apache.kerby.has.client.HasLoginException;
-import org.apache.kerby.kerberos.kerb.type.base.AuthToken;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Date;
-
-public class MySQLHasClientPlugin extends AbstractHasClientPlugin {
- private static final Logger LOG = LoggerFactory.getLogger(MySQLHasClientPlugin.class);
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getLoginType() {
- return "MySQL";
- }
-
- @Override
- protected void doLogin(AuthToken authToken) throws HasLoginException {
-
- //Get the user info from env
- String userName = System.getenv("userName");
- if (userName == null || userName.isEmpty()) {
- throw new HasLoginException("Please set the userName.");
- }
- String password = System.getenv("password");
- if (password == null || password.isEmpty()) {
- throw new HasLoginException("Please set the password.");
- }
- LOG.debug("Get the user info successfully.");
-
- authToken.setIssuer("has");
- authToken.setSubject(userName);
-
- final Date now = new Date(System.currentTimeMillis() / 1000 * 1000);
- authToken.setIssueTime(now);
- // Set expiration in 60 minutes
- Date exp = new Date(now.getTime() + 1000 * 60 * 60);
- authToken.setExpirationTime(exp);
-
- authToken.addAttribute("user", userName);
- authToken.addAttribute("secret", password);
-
- authToken.addAttribute("passPhrase", userName + password);
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/49c9f511/has-project/has-plugins/src/main/java/org/apache/kerby/has/plugins/server/ldap/LDAPServerPlugin.java
----------------------------------------------------------------------
diff --git a/has-project/has-plugins/src/main/java/org/apache/kerby/has/plugins/server/ldap/LDAPServerPlugin.java b/has-project/has-plugins/src/main/java/org/apache/kerby/has/plugins/server/ldap/LDAPServerPlugin.java
deleted file mode 100755
index 1502920..0000000
--- a/has-project/has-plugins/src/main/java/org/apache/kerby/has/plugins/server/ldap/LDAPServerPlugin.java
+++ /dev/null
@@ -1,67 +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.has.plugins.server.ldap;
-
-import org.apache.kerby.has.common.HasException;
-import org.apache.kerby.has.server.AbstractHasServerPlugin;
-import org.apache.kerby.has.server.HasAuthenException;
-import org.apache.kerby.kerberos.kerb.type.base.AuthToken;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-
-public class LDAPServerPlugin extends AbstractHasServerPlugin {
- public static final Logger LOG = LoggerFactory.getLogger(LDAPServerPlugin.class);
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getLoginType() {
- return "LDAP";
- }
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void doAuthenticate(AuthToken userToken, AuthToken authToken) throws HasAuthenException {
-
- String user = (String) userToken.getAttributes().get("ldap_user");
- String pwd = (String) userToken.getAttributes().get("ldap_pwd");
- if (user == null || pwd == null) {
- LOG.error("LDAP: user or pwd is null");
- throw new HasAuthenException("LDAP: user or pwd is null");
- }
-
- try {
- if (LDAPUtils.doUserAuth(user, pwd)) {
- authToken.setIssuer(userToken.getIssuer());
- authToken.setSubject(user);
- authToken.setExpirationTime(userToken.getExpiredTime());
- authToken.addAttribute("passPhrase", pwd);
- } else {
- throw new HasAuthenException("LDAP user auth failed");
- }
- } catch (HasException | IOException e) {
- throw new HasAuthenException("LDAP user auth failed. " + e.getMessage());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/49c9f511/has-project/has-plugins/src/main/java/org/apache/kerby/has/plugins/server/ldap/LDAPUtils.java
----------------------------------------------------------------------
diff --git a/has-project/has-plugins/src/main/java/org/apache/kerby/has/plugins/server/ldap/LDAPUtils.java b/has-project/has-plugins/src/main/java/org/apache/kerby/has/plugins/server/ldap/LDAPUtils.java
deleted file mode 100644
index 9a703eb..0000000
--- a/has-project/has-plugins/src/main/java/org/apache/kerby/has/plugins/server/ldap/LDAPUtils.java
+++ /dev/null
@@ -1,87 +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.has.plugins.server.ldap;
-
-import org.apache.directory.api.ldap.model.entry.Entry;
-import org.apache.directory.api.ldap.model.exception.LdapException;
-import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException;
-import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException;
-import org.apache.directory.api.ldap.model.name.Dn;
-import org.apache.directory.api.ldap.model.name.Rdn;
-import org.apache.directory.api.ldap.model.password.PasswordUtil;
-import org.apache.directory.ldap.client.api.LdapNetworkConnection;
-import org.apache.kerby.has.common.HasException;
-import org.apache.kerby.has.plugins.server.ldap.conf.LDAPServerConf;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-
-public class LDAPUtils {
- public static final Logger LOG = LoggerFactory.getLogger(LDAPUtils.class);
-
- private static String ldapServerConfDir = "/etc/has/";
- private static LDAPServerConf ldapServerConf = null;
- static {
- try {
- ldapServerConf = new LDAPServerConf(ldapServerConfDir);
- } catch (Exception e) {
- LOG.error("load conf failed,", e);
- }
- }
-
- public static boolean doUserAuth(String user, String pwd) throws HasException, IOException {
- LdapNetworkConnection connection = new LdapNetworkConnection(
- ldapServerConf.getHost(), Integer.parseInt(ldapServerConf.getPort()));
- try {
- connection.bind(ldapServerConf.getBindDN(), ldapServerConf.getBindPwd());
- } catch (LdapException e) {
- connection.close();
- throw new HasException("Failed to bind. " + e.getMessage());
- }
- Dn dn;
- try {
- dn = new Dn(new Rdn(ldapServerConf.getUserNameAttr(), user),
- new Dn(ldapServerConf.getBaseDN()));
- } catch (LdapInvalidDnException e) {
- connection.close();
- throw new HasException(e.getMessage());
- }
- Entry entry;
- try {
- entry = connection.lookup(dn);
- } catch (LdapException e) {
- throw new HasException(e.getMessage());
- } finally {
- connection.close();
- }
-
- if (entry == null) {
- throw new HasException("Please check your user name: " + user);
- }
- try {
- if (PasswordUtil.compareCredentials(pwd.getBytes(), entry.get("userpassword").getBytes())) {
- return true;
- } else {
- throw new HasException("Wrong user password.");
- }
- } catch (LdapInvalidAttributeValueException e) {
- throw new HasException(e.getMessage());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/49c9f511/has-project/has-plugins/src/main/java/org/apache/kerby/has/plugins/server/ldap/conf/LDAPServerConf.java
----------------------------------------------------------------------
diff --git a/has-project/has-plugins/src/main/java/org/apache/kerby/has/plugins/server/ldap/conf/LDAPServerConf.java b/has-project/has-plugins/src/main/java/org/apache/kerby/has/plugins/server/ldap/conf/LDAPServerConf.java
deleted file mode 100644
index fbea036..0000000
--- a/has-project/has-plugins/src/main/java/org/apache/kerby/has/plugins/server/ldap/conf/LDAPServerConf.java
+++ /dev/null
@@ -1,95 +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.has.plugins.server.ldap.conf;
-
-import org.ini4j.Wini;
-
-import java.io.File;
-
-public class LDAPServerConf {
-
- private String userNameAttr = "sn";
- private String baseDN = null;
- private String bindDN = null;
- private String bindPwd = null;
- private String host;
- private String port;
-
- public LDAPServerConf(String confDir) throws Exception {
- if (confDir == null) {
- throw new RuntimeException("ldap server conf dir is null");
- }
-
- String confFile = confDir + "/ldap-server.ini";
- Wini ini = new Wini(new File(confFile));
- host = ini.get("ldap", "host");
- port = ini.get("ldap", "port");
- userNameAttr = ini.get("users", "user_name_attr");
- baseDN = ini.get("ldap", "base_dn");
- bindDN = ini.get("ldap", "bind_dn");
- bindPwd = ini.get("ldap", "bind_password");
- }
-
- public String getHost() {
- return host;
- }
-
- public void setHost(String host) {
- this.host = host;
- }
-
- public String getPort() {
- return port;
- }
-
- public void setPort(String port) {
- this.port = port;
- }
-
- public String getUserNameAttr() {
- return userNameAttr;
- }
-
- public void setUserNameAttr(String userNameAttr) {
- this.userNameAttr = userNameAttr;
- }
-
- public String getBaseDN() {
- return baseDN;
- }
-
- public void setBaseDN(String baseDN) {
- this.baseDN = baseDN;
- }
-
- public String getBindDN() {
- return bindDN;
- }
-
- public void setBindDN(String bindDN) {
- this.bindDN = bindDN;
- }
-
- public String getBindPwd() {
- return bindPwd;
- }
-
- public void setBindPwd(String bindPwd) {
- this.bindPwd = bindPwd;
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/49c9f511/has-project/has-plugins/src/main/java/org/apache/kerby/has/plugins/server/mysql/MySQLHasServerPlugin.java
----------------------------------------------------------------------
diff --git a/has-project/has-plugins/src/main/java/org/apache/kerby/has/plugins/server/mysql/MySQLHasServerPlugin.java b/has-project/has-plugins/src/main/java/org/apache/kerby/has/plugins/server/mysql/MySQLHasServerPlugin.java
deleted file mode 100644
index 85e2308..0000000
--- a/has-project/has-plugins/src/main/java/org/apache/kerby/has/plugins/server/mysql/MySQLHasServerPlugin.java
+++ /dev/null
@@ -1,146 +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.has.plugins.server.mysql;
-
-import org.apache.commons.dbutils.DbUtils;
-import org.apache.kerby.has.server.AbstractHasServerPlugin;
-import org.apache.kerby.has.server.HasAuthenException;
-import org.apache.kerby.kerberos.kerb.type.base.AuthToken;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.sql.ResultSet;
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.sql.DriverManager;
-import java.sql.PreparedStatement;
-import java.util.Date;
-
-public class MySQLHasServerPlugin extends AbstractHasServerPlugin {
- private static final Logger LOG = LoggerFactory.getLogger(MySQLHasServerPlugin.class);
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getLoginType() {
- return "MySQL";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void doAuthenticate(AuthToken userToken, AuthToken authToken)
- throws HasAuthenException {
-
- // Check if the token is expired
- Date expiredTime = userToken.getExpiredTime();
- Date now = new Date();
- if (now.after(expiredTime)) {
- LOG.error("Authentication failed: token is expired.");
- throw new HasAuthenException("Authentication failed: token is expired.");
- }
-
- String user = (String) userToken.getAttributes().get("user");
- String secret = (String) userToken.getAttributes().get("secret");
-
- String mysqlUrl = System.getenv("mysqlUrl");
- if (mysqlUrl == null || mysqlUrl.isEmpty()) {
- throw new HasAuthenException("Please set the mysqlUrl.");
- }
- mysqlUrl = mysqlUrl.replace("jdbc:mysql:", "jdbc:mysql:thin:");
- String mysqlUser = System.getenv("mysqlUser");
- if (mysqlUser == null || mysqlUser.isEmpty()) {
- throw new HasAuthenException("Please set the mysqlUser.");
- }
- String mysqlPasswd = System.getenv("mysqlPasswd");
- if (mysqlPasswd == null || mysqlPasswd.isEmpty()) {
- throw new HasAuthenException("Please set the mysqlPasswd.");
- }
- Connection connection = startConnection(mysqlUrl, mysqlUser, mysqlPasswd);
-
- ResultSet res = null;
- try {
- String stm = "SELECT COUNT(*) FROM `has_user` WHERE user_name = ? AND pass_word = ?";
- try (PreparedStatement preStm = connection.prepareStatement(stm)) {
- preStm.setString(1, user);
- preStm.setString(2, secret);
- res = preStm.executeQuery();
-
- }
- if (res.next() && res.getInt(1) > 0) {
- LOG.debug("UserName: {}", user);
- } else {
- String sql = "SELECT COUNT(*) FROM `has_user` WHERE user_name = ?";
- try (PreparedStatement preStm = connection.prepareStatement(sql)) {
- preStm.setString(1, user);
- res = preStm.executeQuery();
- preStm.close();
- if (res.next() && res.getInt(1) > 0) {
- throw new HasAuthenException("Authentication failed. "
- + "Incorrect password.");
- } else if (!res.next()) {
- throw new HasAuthenException("Authentication failed. "
- + "Incorrect userName.");
- } else {
- throw new HasAuthenException("Authentication failed. "
- + "Please check your userName and password.");
- }
- }
- }
- } catch (SQLException e) {
- LOG.error("Failed.");
- LOG.error("Error code: " + e.getErrorCode());
- LOG.error("Error message: " + e.getMessage());
- throw new HasAuthenException("Authentication failed." + e.getMessage());
- } finally {
- DbUtils.closeQuietly(res);
- DbUtils.closeQuietly(connection);
- }
-
- authToken.setIssuer(userToken.getIssuer());
- authToken.setSubject(user);
- authToken.setExpirationTime(userToken.getExpiredTime());
-
- authToken.addAttribute("userName", user);
- authToken.addAttribute("passPhrase", user + secret);
- }
-
- /**
- * Start the MySQL connection.
- */
- private Connection startConnection(String url, String user,
- String password) throws HasAuthenException {
- Connection connection;
- try {
- Class.forName("org.drizzle.jdbc.DrizzleDriver");
- connection = DriverManager.getConnection(url, user, password);
- if (!connection.isClosed()) {
- LOG.info("Succeeded in connecting to MySQL.");
- }
- } catch (ClassNotFoundException e) {
- throw new HasAuthenException("JDBC Driver Class not found. ", e);
- } catch (SQLException e) {
- throw new HasAuthenException("Failed to connecting to MySQL."
- + "Please check MySQL URL, username and password. ", e);
- }
-
- return connection;
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/49c9f511/has-project/has-plugins/src/main/resources/META-INF/services/org.apache.kerby.has.client.HasClientPlugin
----------------------------------------------------------------------
diff --git a/has-project/has-plugins/src/main/resources/META-INF/services/org.apache.kerby.has.client.HasClientPlugin b/has-project/has-plugins/src/main/resources/META-INF/services/org.apache.kerby.has.client.HasClientPlugin
deleted file mode 100644
index 25382fc..0000000
--- a/has-project/has-plugins/src/main/resources/META-INF/services/org.apache.kerby.has.client.HasClientPlugin
+++ /dev/null
@@ -1,17 +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.
-
-org.apache.kerby.has.plugins.client.mysql.MySQLHasClientPlugin
-org.apache.kerby.has.plugins.client.ldap.LDAPClientPlugin
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/49c9f511/has-project/has-plugins/src/main/resources/META-INF/services/org.apache.kerby.has.server.HasServerPlugin
----------------------------------------------------------------------
diff --git a/has-project/has-plugins/src/main/resources/META-INF/services/org.apache.kerby.has.server.HasServerPlugin b/has-project/has-plugins/src/main/resources/META-INF/services/org.apache.kerby.has.server.HasServerPlugin
deleted file mode 100644
index a7757ba..0000000
--- a/has-project/has-plugins/src/main/resources/META-INF/services/org.apache.kerby.has.server.HasServerPlugin
+++ /dev/null
@@ -1,17 +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.
-
-org.apache.kerby.has.plugins.server.mysql.MySQLHasServerPlugin
-org.apache.kerby.has.plugins.server.ldap.LDAPServerPlugin
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/49c9f511/has-project/has-plugins/src/main/resources/ldap-client.ini
----------------------------------------------------------------------
diff --git a/has-project/has-plugins/src/main/resources/ldap-client.ini b/has-project/has-plugins/src/main/resources/ldap-client.ini
deleted file mode 100644
index 888e27a..0000000
--- a/has-project/has-plugins/src/main/resources/ldap-client.ini
+++ /dev/null
@@ -1,3 +0,0 @@
-[ user ]
- ldap_user=test
- ldap_pwd=123456
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/49c9f511/has-project/has-plugins/src/test/java/org/apache/kerby/has/plugins/TestHasClientPluginRegistry.java
----------------------------------------------------------------------
diff --git a/has-project/has-plugins/src/test/java/org/apache/kerby/has/plugins/TestHasClientPluginRegistry.java b/has-project/has-plugins/src/test/java/org/apache/kerby/has/plugins/TestHasClientPluginRegistry.java
deleted file mode 100644
index 55f0f70..0000000
--- a/has-project/has-plugins/src/test/java/org/apache/kerby/has/plugins/TestHasClientPluginRegistry.java
+++ /dev/null
@@ -1,44 +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.has.plugins;
-
-import org.apache.kerby.has.client.HasClientPluginRegistry;
-import org.apache.kerby.has.common.HasException;
-import org.junit.Assert;
-import org.junit.Test;
-
-import java.util.Set;
-
-public class TestHasClientPluginRegistry {
-
- @Test
- public void testInit() {
- Set<String> pluginsNames = HasClientPluginRegistry.registeredPlugins();
- Assert.assertTrue(pluginsNames.size() > 0);
- }
-
- @Test
- public void testCreatePlugin() throws HasException {
- Assert.assertTrue(HasClientPluginRegistry.createPlugin("MySQL") != null);
- Set<String> pluginNames = HasClientPluginRegistry.registeredPlugins();
- for (String name : pluginNames) {
- HasClientPluginRegistry.createPlugin(name);
- }
- }
-}
-
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/49c9f511/has-project/has-plugins/src/test/java/org/apache/kerby/has/plugins/TestHasServerPluginRegistry.java
----------------------------------------------------------------------
diff --git a/has-project/has-plugins/src/test/java/org/apache/kerby/has/plugins/TestHasServerPluginRegistry.java b/has-project/has-plugins/src/test/java/org/apache/kerby/has/plugins/TestHasServerPluginRegistry.java
deleted file mode 100644
index d727b12..0000000
--- a/has-project/has-plugins/src/test/java/org/apache/kerby/has/plugins/TestHasServerPluginRegistry.java
+++ /dev/null
@@ -1,43 +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.has.plugins;
-
-import org.apache.kerby.has.common.HasException;
-import org.apache.kerby.has.server.HasServerPluginRegistry;
-import org.junit.Assert;
-import org.junit.Test;
-
-import java.util.Set;
-
-public class TestHasServerPluginRegistry {
-
- @Test
- public void testInit() {
- Set<String> pluginsNames = HasServerPluginRegistry.registeredPlugins();
- Assert.assertTrue(pluginsNames.size() > 0);
- }
-
- @Test
- public void testCreatePlugin() throws HasException {
- Assert.assertTrue(HasServerPluginRegistry.createPlugin("MySQL") != null);
- Set<String> pluginNames = HasServerPluginRegistry.registeredPlugins();
- for (String name : pluginNames) {
- HasServerPluginRegistry.createPlugin(name);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/49c9f511/has-project/has-server-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/has-project/has-server-plugin/pom.xml b/has-project/has-server-plugin/pom.xml
new file mode 100644
index 0000000..e35b5fa
--- /dev/null
+++ b/has-project/has-server-plugin/pom.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>has-project</artifactId>
+ <groupId>org.apache.kerby</groupId>
+ <version>2.0.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>has-server-plugin</artifactId>
+ <name>HAS Server Plugin</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.kerby</groupId>
+ <artifactId>has-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.kerby</groupId>
+ <artifactId>has-server</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-dbutils</groupId>
+ <artifactId>commons-dbutils</artifactId>
+ <version>${commons-dbutils.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ini4j</groupId>
+ <artifactId>ini4j</artifactId>
+ <version>${ini4j.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.directory.api</groupId>
+ <artifactId>api-ldap-client-api</artifactId>
+ <version>${ldap.api.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.directory.api</groupId>
+ <artifactId>api-ldap-codec-standalone</artifactId>
+ <version>${ldap.api.version}</version>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/49c9f511/has-project/has-server-plugin/src/main/java/org/apache/kerby/has/plugins/server/ldap/LDAPServerPlugin.java
----------------------------------------------------------------------
diff --git a/has-project/has-server-plugin/src/main/java/org/apache/kerby/has/plugins/server/ldap/LDAPServerPlugin.java b/has-project/has-server-plugin/src/main/java/org/apache/kerby/has/plugins/server/ldap/LDAPServerPlugin.java
new file mode 100755
index 0000000..1502920
--- /dev/null
+++ b/has-project/has-server-plugin/src/main/java/org/apache/kerby/has/plugins/server/ldap/LDAPServerPlugin.java
@@ -0,0 +1,67 @@
+/**
+ * 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.plugins.server.ldap;
+
+import org.apache.kerby.has.common.HasException;
+import org.apache.kerby.has.server.AbstractHasServerPlugin;
+import org.apache.kerby.has.server.HasAuthenException;
+import org.apache.kerby.kerberos.kerb.type.base.AuthToken;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+
+public class LDAPServerPlugin extends AbstractHasServerPlugin {
+ public static final Logger LOG = LoggerFactory.getLogger(LDAPServerPlugin.class);
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getLoginType() {
+ return "LDAP";
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void doAuthenticate(AuthToken userToken, AuthToken authToken) throws HasAuthenException {
+
+ String user = (String) userToken.getAttributes().get("ldap_user");
+ String pwd = (String) userToken.getAttributes().get("ldap_pwd");
+ if (user == null || pwd == null) {
+ LOG.error("LDAP: user or pwd is null");
+ throw new HasAuthenException("LDAP: user or pwd is null");
+ }
+
+ try {
+ if (LDAPUtils.doUserAuth(user, pwd)) {
+ authToken.setIssuer(userToken.getIssuer());
+ authToken.setSubject(user);
+ authToken.setExpirationTime(userToken.getExpiredTime());
+ authToken.addAttribute("passPhrase", pwd);
+ } else {
+ throw new HasAuthenException("LDAP user auth failed");
+ }
+ } catch (HasException | IOException e) {
+ throw new HasAuthenException("LDAP user auth failed. " + e.getMessage());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/49c9f511/has-project/has-server-plugin/src/main/java/org/apache/kerby/has/plugins/server/ldap/LDAPUtils.java
----------------------------------------------------------------------
diff --git a/has-project/has-server-plugin/src/main/java/org/apache/kerby/has/plugins/server/ldap/LDAPUtils.java b/has-project/has-server-plugin/src/main/java/org/apache/kerby/has/plugins/server/ldap/LDAPUtils.java
new file mode 100644
index 0000000..9a703eb
--- /dev/null
+++ b/has-project/has-server-plugin/src/main/java/org/apache/kerby/has/plugins/server/ldap/LDAPUtils.java
@@ -0,0 +1,87 @@
+/**
+ * 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.plugins.server.ldap;
+
+import org.apache.directory.api.ldap.model.entry.Entry;
+import org.apache.directory.api.ldap.model.exception.LdapException;
+import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException;
+import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException;
+import org.apache.directory.api.ldap.model.name.Dn;
+import org.apache.directory.api.ldap.model.name.Rdn;
+import org.apache.directory.api.ldap.model.password.PasswordUtil;
+import org.apache.directory.ldap.client.api.LdapNetworkConnection;
+import org.apache.kerby.has.common.HasException;
+import org.apache.kerby.has.plugins.server.ldap.conf.LDAPServerConf;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+
+public class LDAPUtils {
+ public static final Logger LOG = LoggerFactory.getLogger(LDAPUtils.class);
+
+ private static String ldapServerConfDir = "/etc/has/";
+ private static LDAPServerConf ldapServerConf = null;
+ static {
+ try {
+ ldapServerConf = new LDAPServerConf(ldapServerConfDir);
+ } catch (Exception e) {
+ LOG.error("load conf failed,", e);
+ }
+ }
+
+ public static boolean doUserAuth(String user, String pwd) throws HasException, IOException {
+ LdapNetworkConnection connection = new LdapNetworkConnection(
+ ldapServerConf.getHost(), Integer.parseInt(ldapServerConf.getPort()));
+ try {
+ connection.bind(ldapServerConf.getBindDN(), ldapServerConf.getBindPwd());
+ } catch (LdapException e) {
+ connection.close();
+ throw new HasException("Failed to bind. " + e.getMessage());
+ }
+ Dn dn;
+ try {
+ dn = new Dn(new Rdn(ldapServerConf.getUserNameAttr(), user),
+ new Dn(ldapServerConf.getBaseDN()));
+ } catch (LdapInvalidDnException e) {
+ connection.close();
+ throw new HasException(e.getMessage());
+ }
+ Entry entry;
+ try {
+ entry = connection.lookup(dn);
+ } catch (LdapException e) {
+ throw new HasException(e.getMessage());
+ } finally {
+ connection.close();
+ }
+
+ if (entry == null) {
+ throw new HasException("Please check your user name: " + user);
+ }
+ try {
+ if (PasswordUtil.compareCredentials(pwd.getBytes(), entry.get("userpassword").getBytes())) {
+ return true;
+ } else {
+ throw new HasException("Wrong user password.");
+ }
+ } catch (LdapInvalidAttributeValueException e) {
+ throw new HasException(e.getMessage());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/49c9f511/has-project/has-server-plugin/src/main/java/org/apache/kerby/has/plugins/server/ldap/conf/LDAPServerConf.java
----------------------------------------------------------------------
diff --git a/has-project/has-server-plugin/src/main/java/org/apache/kerby/has/plugins/server/ldap/conf/LDAPServerConf.java b/has-project/has-server-plugin/src/main/java/org/apache/kerby/has/plugins/server/ldap/conf/LDAPServerConf.java
new file mode 100644
index 0000000..fbea036
--- /dev/null
+++ b/has-project/has-server-plugin/src/main/java/org/apache/kerby/has/plugins/server/ldap/conf/LDAPServerConf.java
@@ -0,0 +1,95 @@
+/**
+ * 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.plugins.server.ldap.conf;
+
+import org.ini4j.Wini;
+
+import java.io.File;
+
+public class LDAPServerConf {
+
+ private String userNameAttr = "sn";
+ private String baseDN = null;
+ private String bindDN = null;
+ private String bindPwd = null;
+ private String host;
+ private String port;
+
+ public LDAPServerConf(String confDir) throws Exception {
+ if (confDir == null) {
+ throw new RuntimeException("ldap server conf dir is null");
+ }
+
+ String confFile = confDir + "/ldap-server.ini";
+ Wini ini = new Wini(new File(confFile));
+ host = ini.get("ldap", "host");
+ port = ini.get("ldap", "port");
+ userNameAttr = ini.get("users", "user_name_attr");
+ baseDN = ini.get("ldap", "base_dn");
+ bindDN = ini.get("ldap", "bind_dn");
+ bindPwd = ini.get("ldap", "bind_password");
+ }
+
+ public String getHost() {
+ return host;
+ }
+
+ public void setHost(String host) {
+ this.host = host;
+ }
+
+ public String getPort() {
+ return port;
+ }
+
+ public void setPort(String port) {
+ this.port = port;
+ }
+
+ public String getUserNameAttr() {
+ return userNameAttr;
+ }
+
+ public void setUserNameAttr(String userNameAttr) {
+ this.userNameAttr = userNameAttr;
+ }
+
+ public String getBaseDN() {
+ return baseDN;
+ }
+
+ public void setBaseDN(String baseDN) {
+ this.baseDN = baseDN;
+ }
+
+ public String getBindDN() {
+ return bindDN;
+ }
+
+ public void setBindDN(String bindDN) {
+ this.bindDN = bindDN;
+ }
+
+ public String getBindPwd() {
+ return bindPwd;
+ }
+
+ public void setBindPwd(String bindPwd) {
+ this.bindPwd = bindPwd;
+ }
+}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/49c9f511/has-project/has-server-plugin/src/main/java/org/apache/kerby/has/plugins/server/mysql/MySQLHasServerPlugin.java
----------------------------------------------------------------------
diff --git a/has-project/has-server-plugin/src/main/java/org/apache/kerby/has/plugins/server/mysql/MySQLHasServerPlugin.java b/has-project/has-server-plugin/src/main/java/org/apache/kerby/has/plugins/server/mysql/MySQLHasServerPlugin.java
new file mode 100644
index 0000000..1aba04d
--- /dev/null
+++ b/has-project/has-server-plugin/src/main/java/org/apache/kerby/has/plugins/server/mysql/MySQLHasServerPlugin.java
@@ -0,0 +1,145 @@
+/**
+ * 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.plugins.server.mysql;
+
+import org.apache.commons.dbutils.DbUtils;
+import org.apache.kerby.has.server.AbstractHasServerPlugin;
+import org.apache.kerby.has.server.HasAuthenException;
+import org.apache.kerby.kerberos.kerb.type.base.AuthToken;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.sql.ResultSet;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.util.Date;
+
+public class MySQLHasServerPlugin extends AbstractHasServerPlugin {
+ private static final Logger LOG = LoggerFactory.getLogger(MySQLHasServerPlugin.class);
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getLoginType() {
+ return "MySQL";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void doAuthenticate(AuthToken userToken, AuthToken authToken)
+ throws HasAuthenException {
+
+ // Check if the token is expired
+ Date expiredTime = userToken.getExpiredTime();
+ Date now = new Date();
+ if (now.after(expiredTime)) {
+ LOG.error("Authentication failed: token is expired.");
+ throw new HasAuthenException("Authentication failed: token is expired.");
+ }
+
+ String user = (String) userToken.getAttributes().get("user");
+ String secret = (String) userToken.getAttributes().get("secret");
+
+ String mysqlUrl = System.getenv("mysqlUrl");
+ if (mysqlUrl == null || mysqlUrl.isEmpty()) {
+ throw new HasAuthenException("Please set the mysqlUrl.");
+ }
+ mysqlUrl = mysqlUrl.replace("jdbc:mysql:", "jdbc:mysql:thin:");
+ String mysqlUser = System.getenv("mysqlUser");
+ if (mysqlUser == null || mysqlUser.isEmpty()) {
+ throw new HasAuthenException("Please set the mysqlUser.");
+ }
+ String mysqlPasswd = System.getenv("mysqlPasswd");
+ if (mysqlPasswd == null || mysqlPasswd.isEmpty()) {
+ throw new HasAuthenException("Please set the mysqlPasswd.");
+ }
+ Connection connection = startConnection(mysqlUrl, mysqlUser, mysqlPasswd);
+
+ ResultSet res = null;
+ PreparedStatement preStm = null;
+ try {
+ String stm = "SELECT COUNT(*) FROM `has_user` WHERE user_name = ? AND pass_word = ?";
+ preStm = connection.prepareStatement(stm);
+ preStm.setString(1, user);
+ preStm.setString(2, secret);
+ res = preStm.executeQuery();
+
+ if (res.next() && res.getInt(1) > 0) {
+ LOG.debug("UserName: {}", user);
+ } else {
+ String sql = "SELECT COUNT(*) FROM `has_user` WHERE user_name = ?";
+ preStm = connection.prepareStatement(sql);
+ preStm.setString(1, user);
+ res = preStm.executeQuery();
+ if (res.next() && res.getInt(1) > 0) {
+ throw new HasAuthenException("Authentication failed. "
+ + "Incorrect password.");
+ } else if (!res.next()) {
+ throw new HasAuthenException("Authentication failed. "
+ + "Incorrect userName: " + user);
+ } else {
+ throw new HasAuthenException("Authentication failed. "
+ + "Please check your userName and password.");
+ }
+ }
+ } catch (SQLException e) {
+ LOG.error("Failed.");
+ LOG.error("Error code: " + e.getErrorCode());
+ LOG.error("Error message: " + e.getMessage());
+ throw new HasAuthenException("Authentication failed." + e.getMessage());
+ } finally {
+ DbUtils.closeQuietly(preStm);
+ DbUtils.closeQuietly(res);
+ DbUtils.closeQuietly(connection);
+ }
+
+ authToken.setIssuer(userToken.getIssuer());
+ authToken.setSubject(user);
+ authToken.setExpirationTime(userToken.getExpiredTime());
+
+ authToken.addAttribute("userName", user);
+ authToken.addAttribute("passPhrase", user + secret);
+ }
+
+ /**
+ * Start the MySQL connection.
+ */
+ private Connection startConnection(String url, String user,
+ String password) throws HasAuthenException {
+ Connection connection;
+ try {
+ Class.forName("org.drizzle.jdbc.DrizzleDriver");
+ connection = DriverManager.getConnection(url, user, password);
+ if (!connection.isClosed()) {
+ LOG.info("Succeeded in connecting to MySQL.");
+ }
+ } catch (ClassNotFoundException e) {
+ throw new HasAuthenException("JDBC Driver Class not found. ", e);
+ } catch (SQLException e) {
+ throw new HasAuthenException("Failed to connecting to MySQL."
+ + "Please check MySQL URL, username and password. ", e);
+ }
+
+ return connection;
+ }
+}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/49c9f511/has-project/has-server-plugin/src/main/resources/META-INF/services/org.apache.kerby.has.server.HasServerPlugin
----------------------------------------------------------------------
diff --git a/has-project/has-server-plugin/src/main/resources/META-INF/services/org.apache.kerby.has.server.HasServerPlugin b/has-project/has-server-plugin/src/main/resources/META-INF/services/org.apache.kerby.has.server.HasServerPlugin
new file mode 100644
index 0000000..a7757ba
--- /dev/null
+++ b/has-project/has-server-plugin/src/main/resources/META-INF/services/org.apache.kerby.has.server.HasServerPlugin
@@ -0,0 +1,17 @@
+# 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.
+
+org.apache.kerby.has.plugins.server.mysql.MySQLHasServerPlugin
+org.apache.kerby.has.plugins.server.ldap.LDAPServerPlugin
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/49c9f511/has-project/has-server-plugin/src/test/java/org/apache/kerby/has/plugins/server/TestHasServerPluginRegistry.java
----------------------------------------------------------------------
diff --git a/has-project/has-server-plugin/src/test/java/org/apache/kerby/has/plugins/server/TestHasServerPluginRegistry.java b/has-project/has-server-plugin/src/test/java/org/apache/kerby/has/plugins/server/TestHasServerPluginRegistry.java
new file mode 100644
index 0000000..3d2d7fe
--- /dev/null
+++ b/has-project/has-server-plugin/src/test/java/org/apache/kerby/has/plugins/server/TestHasServerPluginRegistry.java
@@ -0,0 +1,43 @@
+/**
+ * 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.plugins.server;
+
+import org.apache.kerby.has.common.HasException;
+import org.apache.kerby.has.server.HasServerPluginRegistry;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.Set;
+
+public class TestHasServerPluginRegistry {
+
+ @Test
+ public void testInit() {
+ Set<String> pluginsNames = HasServerPluginRegistry.registeredPlugins();
+ Assert.assertTrue(pluginsNames.size() > 0);
+ }
+
+ @Test
+ public void testCreatePlugin() throws HasException {
+ Assert.assertTrue(HasServerPluginRegistry.createPlugin("MySQL") != null);
+ Set<String> pluginNames = HasServerPluginRegistry.registeredPlugins();
+ for (String name : pluginNames) {
+ HasServerPluginRegistry.createPlugin(name);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/49c9f511/has-project/has-server/pom.xml
----------------------------------------------------------------------
diff --git a/has-project/has-server/pom.xml b/has-project/has-server/pom.xml
index f772bd4..11b1b5d 100644
--- a/has-project/has-server/pom.xml
+++ b/has-project/has-server/pom.xml
@@ -11,6 +11,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>has-server</artifactId>
+ <name>HAS Server</name>
<dependencies>
<dependency>
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/49c9f511/has-project/pom.xml
----------------------------------------------------------------------
diff --git a/has-project/pom.xml b/has-project/pom.xml
index 411767f..ec4b2a9 100644
--- a/has-project/pom.xml
+++ b/has-project/pom.xml
@@ -11,14 +11,15 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>has-project</artifactId>
- <name>HAS project</name>
+ <name>HAS Project</name>
<packaging>pom</packaging>
<modules>
<module>has-common</module>
<module>has-server</module>
<module>has-client</module>
- <module>has-plugins</module>
+ <module>has-client-plugin</module>
+ <module>has-server-plugin</module>
</modules>
</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/49c9f511/kerby-dist/has-dist/pom.xml
----------------------------------------------------------------------
diff --git a/kerby-dist/has-dist/pom.xml b/kerby-dist/has-dist/pom.xml
index f51b31d..b400960 100644
--- a/kerby-dist/has-dist/pom.xml
+++ b/kerby-dist/has-dist/pom.xml
@@ -10,8 +10,8 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>has-dist</artifactId>
- <description>HAS dist</description>
- <name>HAS dist</name>
+ <name>HAS Dist</name>
+ <packaging>pom</packaging>
<dependencies>
<dependency>
@@ -21,7 +21,12 @@
</dependency>
<dependency>
<groupId>org.apache.kerby</groupId>
- <artifactId>has-plugins</artifactId>
+ <artifactId>has-client-plugin</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.kerby</groupId>
+ <artifactId>has-server-plugin</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/49c9f511/kerby-tool/has-tool/pom.xml
----------------------------------------------------------------------
diff --git a/kerby-tool/has-tool/pom.xml b/kerby-tool/has-tool/pom.xml
index 0dc5ca4..5c5b6ba 100644
--- a/kerby-tool/has-tool/pom.xml
+++ b/kerby-tool/has-tool/pom.xml
@@ -10,6 +10,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>has-tool</artifactId>
+ <name>HAS Tool</name>
<dependencies>
<dependency>