directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From plusplusjia...@apache.org
Subject directory-kerby git commit: DIRKRB-680 Add new authentication mechanism API
Date Tue, 26 Dec 2017 02:37:36 GMT
Repository: directory-kerby
Updated Branches:
  refs/heads/trunk 59a310120 -> bcf3ba10f


DIRKRB-680 Add new authentication mechanism API


Project: http://git-wip-us.apache.org/repos/asf/directory-kerby/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-kerby/commit/bcf3ba10
Tree: http://git-wip-us.apache.org/repos/asf/directory-kerby/tree/bcf3ba10
Diff: http://git-wip-us.apache.org/repos/asf/directory-kerby/diff/bcf3ba10

Branch: refs/heads/trunk
Commit: bcf3ba10ffc3bb4c7639dc2ef8017545c40143f3
Parents: 59a3101
Author: plusplusjiajia <jiajia.li@intel.com>
Authored: Tue Dec 26 10:33:59 2017 +0800
Committer: plusplusjiajia <jiajia.li@intel.com>
Committed: Tue Dec 26 10:33:59 2017 +0800

----------------------------------------------------------------------
 has-project/has-client/pom.xml                  | 32 ++++++++++++++
 .../has/client/AbstractHasClientPlugin.java     | 44 +++++++++++++++++++
 .../kerby/has/client/HasClientPlugin.java       | 42 ++++++++++++++++++
 .../kerby/has/client/HasLoginException.java     | 37 ++++++++++++++++
 .../has/server/AbstractHasServerPlugin.java     | 45 ++++++++++++++++++++
 .../kerby/has/server/HasAuthenException.java    | 37 ++++++++++++++++
 .../kerby/has/server/HasServerPlugin.java       | 39 +++++++++++++++++
 has-project/pom.xml                             |  1 +
 8 files changed, 277 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/bcf3ba10/has-project/has-client/pom.xml
----------------------------------------------------------------------
diff --git a/has-project/has-client/pom.xml b/has-project/has-client/pom.xml
new file mode 100644
index 0000000..9be9333
--- /dev/null
+++ b/has-project/has-client/pom.xml
@@ -0,0 +1,32 @@
+<?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>1.1.1-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>has-client</artifactId>
+
+    <dependencies>
+    <dependency>
+      <groupId>org.apache.kerby</groupId>
+      <artifactId>kerb-core</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+      <version>${slf4j.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.kerby</groupId>
+      <artifactId>has-common</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+  </dependencies>
+
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/bcf3ba10/has-project/has-client/src/main/java/org/apache/kerby/has/client/AbstractHasClientPlugin.java
----------------------------------------------------------------------
diff --git a/has-project/has-client/src/main/java/org/apache/kerby/has/client/AbstractHasClientPlugin.java
b/has-project/has-client/src/main/java/org/apache/kerby/has/client/AbstractHasClientPlugin.java
new file mode 100644
index 0000000..f60a6d0
--- /dev/null
+++ b/has-project/has-client/src/main/java/org/apache/kerby/has/client/AbstractHasClientPlugin.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.client;
+
+import org.apache.kerby.has.common.HasConfig;
+import org.apache.kerby.kerberos.kerb.KrbRuntime;
+import org.apache.kerby.kerberos.kerb.type.base.AuthToken;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class AbstractHasClientPlugin implements HasClientPlugin {
+    public static final Logger LOG = LoggerFactory.getLogger(AbstractHasClientPlugin.class);
+
+    protected abstract void doLogin(AuthToken token) throws HasLoginException;
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public AuthToken login(HasConfig conf) throws HasLoginException {
+
+        AuthToken authToken = KrbRuntime.getTokenProvider("JWT").createTokenFactory().createToken();
+
+        doLogin(authToken);
+
+        return authToken;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/bcf3ba10/has-project/has-client/src/main/java/org/apache/kerby/has/client/HasClientPlugin.java
----------------------------------------------------------------------
diff --git a/has-project/has-client/src/main/java/org/apache/kerby/has/client/HasClientPlugin.java
b/has-project/has-client/src/main/java/org/apache/kerby/has/client/HasClientPlugin.java
new file mode 100644
index 0000000..03b04b6
--- /dev/null
+++ b/has-project/has-client/src/main/java/org/apache/kerby/has/client/HasClientPlugin.java
@@ -0,0 +1,42 @@
+/**
+ * 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.client;
+
+import org.apache.kerby.has.common.HasConfig;
+import org.apache.kerby.kerberos.kerb.type.base.AuthToken;
+
+public interface HasClientPlugin {
+
+    /**
+     * Get the login module type ID, used to distinguish this module from others.
+     * Should correspond to the server side module.
+     *
+     * @return login type
+     */
+    String getLoginType();
+
+    /**
+     * Perform all the client side login logics, the results wrapped in an AuthToken,
+     * will be validated by HAS server.
+     *
+     * @param conf token plugin config
+     * @return user auth token
+     */
+    AuthToken login(HasConfig conf) throws HasLoginException;
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/bcf3ba10/has-project/has-client/src/main/java/org/apache/kerby/has/client/HasLoginException.java
----------------------------------------------------------------------
diff --git a/has-project/has-client/src/main/java/org/apache/kerby/has/client/HasLoginException.java
b/has-project/has-client/src/main/java/org/apache/kerby/has/client/HasLoginException.java
new file mode 100644
index 0000000..2157537
--- /dev/null
+++ b/has-project/has-client/src/main/java/org/apache/kerby/has/client/HasLoginException.java
@@ -0,0 +1,37 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.client;
+
+import org.apache.kerby.has.common.HasException;
+
+public class HasLoginException extends HasException {
+    private static final long serialVersionUID = 4140429098192628252L;
+
+    public HasLoginException(Throwable cause) {
+        super(cause);
+    }
+
+    public HasLoginException(String message) {
+        super(message);
+    }
+
+    public HasLoginException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/bcf3ba10/has-project/has-server/src/main/java/org/apache/kerby/has/server/AbstractHasServerPlugin.java
----------------------------------------------------------------------
diff --git a/has-project/has-server/src/main/java/org/apache/kerby/has/server/AbstractHasServerPlugin.java
b/has-project/has-server/src/main/java/org/apache/kerby/has/server/AbstractHasServerPlugin.java
new file mode 100644
index 0000000..f9d0b33
--- /dev/null
+++ b/has-project/has-server/src/main/java/org/apache/kerby/has/server/AbstractHasServerPlugin.java
@@ -0,0 +1,45 @@
+/**
+ * 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;
+
+import org.apache.kerby.kerberos.kerb.KrbRuntime;
+import org.apache.kerby.kerberos.kerb.type.base.AuthToken;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class AbstractHasServerPlugin implements HasServerPlugin {
+
+    public static final Logger LOG = LoggerFactory.getLogger(AbstractHasServerPlugin.class);
+
+    protected abstract void doAuthenticate(AuthToken userToken, AuthToken authToken)
+        throws HasAuthenException;
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public AuthToken authenticate(AuthToken userToken) throws HasAuthenException {
+
+        AuthToken authToken = KrbRuntime.getTokenProvider("JWT").createTokenFactory().createToken();
+
+        doAuthenticate(userToken, authToken);
+
+        return authToken;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/bcf3ba10/has-project/has-server/src/main/java/org/apache/kerby/has/server/HasAuthenException.java
----------------------------------------------------------------------
diff --git a/has-project/has-server/src/main/java/org/apache/kerby/has/server/HasAuthenException.java
b/has-project/has-server/src/main/java/org/apache/kerby/has/server/HasAuthenException.java
new file mode 100644
index 0000000..57342b1
--- /dev/null
+++ b/has-project/has-server/src/main/java/org/apache/kerby/has/server/HasAuthenException.java
@@ -0,0 +1,37 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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;
+
+import org.apache.kerby.has.common.HasException;
+
+public class HasAuthenException extends HasException {
+    private static final long serialVersionUID = 171016915395892939L;
+
+    public HasAuthenException(Throwable cause) {
+        super(cause);
+    }
+
+    public HasAuthenException(String message) {
+        super(message);
+    }
+
+    public HasAuthenException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/bcf3ba10/has-project/has-server/src/main/java/org/apache/kerby/has/server/HasServerPlugin.java
----------------------------------------------------------------------
diff --git a/has-project/has-server/src/main/java/org/apache/kerby/has/server/HasServerPlugin.java
b/has-project/has-server/src/main/java/org/apache/kerby/has/server/HasServerPlugin.java
new file mode 100644
index 0000000..466e5ff
--- /dev/null
+++ b/has-project/has-server/src/main/java/org/apache/kerby/has/server/HasServerPlugin.java
@@ -0,0 +1,39 @@
+/**
+ * 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;
+
+import org.apache.kerby.kerberos.kerb.type.base.AuthToken;
+
+public interface HasServerPlugin {
+        /**
+         * Get the login module type ID, used to distinguish this module from others.
+         * Should correspond to the client side module.
+         *
+         * @return login type
+         */
+        String getLoginType();
+
+        /**
+         * Perform all the server side authentication logics, the results wrapped in an AuthToken,
+         * will be used to exchange a Kerberos ticket.
+         *
+         * @param userToken user token
+         * @return auth token
+         */
+        AuthToken authenticate(AuthToken userToken) throws HasAuthenException;
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/bcf3ba10/has-project/pom.xml
----------------------------------------------------------------------
diff --git a/has-project/pom.xml b/has-project/pom.xml
index 4ace226..c7ccfb1 100644
--- a/has-project/pom.xml
+++ b/has-project/pom.xml
@@ -17,6 +17,7 @@
   <modules>
     <module>has-common</module>
     <module>has-server</module>
+    <module>has-client</module>
   </modules>
 
 


Mime
View raw message