You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by dr...@apache.org on 2015/03/21 01:06:05 UTC
[1/2] directory-kerby git commit: Refined client-tool and server-tool
layouts
Repository: directory-kerby
Updated Branches:
refs/heads/master 7b686b200 -> 2e1de10bc
Refined client-tool and server-tool layouts
Project: http://git-wip-us.apache.org/repos/asf/directory-kerby/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-kerby/commit/0c1d0e79
Tree: http://git-wip-us.apache.org/repos/asf/directory-kerby/tree/0c1d0e79
Diff: http://git-wip-us.apache.org/repos/asf/directory-kerby/diff/0c1d0e79
Branch: refs/heads/master
Commit: 0c1d0e79c123c4f046800a55aaf6e2a5ca3fa936
Parents: 7b686b2
Author: Drankye <dr...@gmail.com>
Authored: Sat Mar 21 08:00:21 2015 +0800
Committer: Drankye <dr...@gmail.com>
Committed: Sat Mar 21 08:00:21 2015 +0800
----------------------------------------------------------------------
kdc-backend/README | 5 -
kdc-backend/README.md | 1 +
kdc-tool/README | 1 -
kdc-tool/README.md | 2 +
kdc-tool/client-tool/pom.xml | 13 +-
.../kerberos/tool/token/AuthzDataEntry.java | 52 +++++
.../kerby/kerberos/tool/token/TokenCache.java | 82 ++++++++
.../kerberos/tool/token/TokenExtractor.java | 102 ++++++++++
.../kerby/kerberos/tool/token/TokenTool.java | 125 ++++++++++++
kdc-tool/kadmin-tool/pom.xml | 75 --------
.../kerby/kerberos/tool/kadmin/Kadmin.java | 139 --------------
.../kadmin/executor/AddPrincipalExecutor.java | 191 -------------------
.../kadmin/executor/KadminCommandExecutor.java | 28 ---
kdc-tool/pom.xml | 3 +-
kdc-tool/server-tool/pom.xml | 75 ++++++++
.../kerby/kerberos/tool/kadmin/Kadmin.java | 139 ++++++++++++++
.../kadmin/executor/AddPrincipalExecutor.java | 191 +++++++++++++++++++
.../kadmin/executor/KadminCommandExecutor.java | 28 +++
kdc-tool/token-tool/pom.xml | 49 -----
.../org/apache/kerby/token/AuthzDataEntry.java | 52 -----
.../java/org/apache/kerby/token/TokenCache.java | 82 --------
.../org/apache/kerby/token/TokenExtractor.java | 102 ----------
.../java/org/apache/kerby/token/TokenTool.java | 125 ------------
kerby-dist/tool-dist/pom.xml | 15 +-
kerby-kdc/README.md | 1 +
kerby-kerb/README | 2 -
kerby-kerb/README.md | 2 +
lib/README.md | 1 +
28 files changed, 817 insertions(+), 866 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/0c1d0e79/kdc-backend/README
----------------------------------------------------------------------
diff --git a/kdc-backend/README b/kdc-backend/README
deleted file mode 100644
index 583763c..0000000
--- a/kdc-backend/README
+++ /dev/null
@@ -1,5 +0,0 @@
-A KDC implementation that integrates PKI and OAuth Token with an LDAP backend.
-The KDC server can be standalone.
-The LDAP backend can be standalone or embedded.
-Various tools like kinit, kadmin will be provided or
-at least, existing tools can be supported.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/0c1d0e79/kdc-backend/README.md
----------------------------------------------------------------------
diff --git a/kdc-backend/README.md b/kdc-backend/README.md
new file mode 100644
index 0000000..a399471
--- /dev/null
+++ b/kdc-backend/README.md
@@ -0,0 +1 @@
+This contains all kinds of identity back ends for Kerby KDC.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/0c1d0e79/kdc-tool/README
----------------------------------------------------------------------
diff --git a/kdc-tool/README b/kdc-tool/README
deleted file mode 100644
index a261812..0000000
--- a/kdc-tool/README
+++ /dev/null
@@ -1 +0,0 @@
-This will contain all kinds of tools provided by or serving for Kerby KDC.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/0c1d0e79/kdc-tool/README.md
----------------------------------------------------------------------
diff --git a/kdc-tool/README.md b/kdc-tool/README.md
new file mode 100644
index 0000000..b65c688
--- /dev/null
+++ b/kdc-tool/README.md
@@ -0,0 +1,2 @@
+This contains all kinds of tools provided by or serving for Kerby KDC,
+including both client side and server side.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/0c1d0e79/kdc-tool/client-tool/pom.xml
----------------------------------------------------------------------
diff --git a/kdc-tool/client-tool/pom.xml b/kdc-tool/client-tool/pom.xml
index 2c49764..c87174c 100644
--- a/kdc-tool/client-tool/pom.xml
+++ b/kdc-tool/client-tool/pom.xml
@@ -21,9 +21,9 @@
<version>1.0-SNAPSHOT</version>
</parent>
- <artifactId>kinit</artifactId>
- <name>Kinit</name>
- <description>Kerby KDC kinit tool</description>
+ <artifactId>client-tool</artifactId>
+ <name>Client Tool</name>
+ <description>Kerby KDC client tool</description>
<dependencies>
<dependency>
@@ -44,6 +44,13 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>com.nimbusds</groupId>
+ <artifactId>nimbus-jose-jwt</artifactId>
+ <version>3.8.2</version>
+ </dependency>
+
</dependencies>
</project>
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/0c1d0e79/kdc-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/token/AuthzDataEntry.java
----------------------------------------------------------------------
diff --git a/kdc-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/token/AuthzDataEntry.java b/kdc-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/token/AuthzDataEntry.java
new file mode 100644
index 0000000..2d57fbf
--- /dev/null
+++ b/kdc-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/token/AuthzDataEntry.java
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.kerby.kerberos.tool.token;
+
+import org.apache.kerby.asn1.type.Asn1FieldInfo;
+import org.apache.kerby.asn1.type.Asn1Integer;
+import org.apache.kerby.asn1.type.Asn1OctetString;
+import org.apache.kerby.asn1.type.Asn1SequenceType;
+
+/**
+ AuthorizationData ::= SEQUENCE OF SEQUENCE {
+ ad-type [0] Int32,
+ ad-data [1] OCTET STRING
+ }
+ */
+public class AuthzDataEntry extends Asn1SequenceType {
+ static int AD_TYPE = 0;
+ static int AD_DATA = 1;
+
+ public AuthzDataEntry() {
+ super(new Asn1FieldInfo[] {
+ new Asn1FieldInfo(AD_TYPE, Asn1Integer.class),
+ new Asn1FieldInfo(AD_DATA, Asn1OctetString.class)
+ });
+ }
+
+ public int getAuthzType() {
+ Integer value = getFieldAsInteger(AD_TYPE);
+ return value;
+ }
+
+ public byte[] getAuthzData() {
+ return getFieldAsOctets(AD_DATA);
+ }
+}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/0c1d0e79/kdc-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/token/TokenCache.java
----------------------------------------------------------------------
diff --git a/kdc-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/token/TokenCache.java b/kdc-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/token/TokenCache.java
new file mode 100644
index 0000000..d737085
--- /dev/null
+++ b/kdc-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/token/TokenCache.java
@@ -0,0 +1,82 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.kerby.kerberos.tool.token;
+
+import java.io.*;
+
+public class TokenCache {
+ private static final String DEFAULT_TOKEN_CACHE_PATH = ".tokenauth";
+ private static final String TOKEN_CACHE_FILE = ".tokenauth.token";
+
+ public static String readToken(String tokenCacheFile) {
+ File cacheFile = null;
+
+ if (tokenCacheFile != null && ! tokenCacheFile.isEmpty()) {
+ cacheFile = new File(tokenCacheFile);
+ if (!cacheFile.exists()) {
+ throw new RuntimeException("Invalid token cache specified: " + tokenCacheFile);
+ };
+ } else {
+ cacheFile = getDefaultTokenCache();
+ if (!cacheFile.exists()) {
+ throw new RuntimeException("No token cache available by default");
+ };
+ }
+
+ String token = null;
+ try {
+ BufferedReader reader = new BufferedReader(new FileReader(cacheFile));
+ String line = reader.readLine();
+ reader.close();
+ if (line != null) {
+ token = line;
+ }
+ } catch (IOException ex) {
+ //NOP
+ }
+
+ return token;
+ }
+
+ public static void writeToken(String token) {
+ File cacheFile = getDefaultTokenCache();
+
+ try {
+ Writer writer = new FileWriter(cacheFile);
+ writer.write(token.toString());
+ writer.close();
+ // sets read-write permissions to owner only
+ cacheFile.setReadable(false, false);
+ cacheFile.setReadable(true, true);
+ cacheFile.setWritable(true, true);
+ }
+ catch (IOException ioe) {
+ // if case of any error we just delete the cache, if user-only
+ // write permissions are not properly set a security exception
+ // is thrown and the file will be deleted.
+ cacheFile.delete();
+ }
+ }
+
+ public static File getDefaultTokenCache() {
+ String homeDir = System.getProperty("user.home", DEFAULT_TOKEN_CACHE_PATH);
+ return new File(homeDir, TOKEN_CACHE_FILE);
+ }
+}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/0c1d0e79/kdc-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/token/TokenExtractor.java
----------------------------------------------------------------------
diff --git a/kdc-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/token/TokenExtractor.java b/kdc-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/token/TokenExtractor.java
new file mode 100644
index 0000000..3b570b7
--- /dev/null
+++ b/kdc-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/token/TokenExtractor.java
@@ -0,0 +1,102 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.kerby.kerberos.tool.token;
+
+import com.sun.security.jgss.AuthorizationDataEntry;
+import com.sun.security.jgss.ExtendedGSSContext;
+import com.sun.security.jgss.InquireType;
+import org.apache.kerby.asn1.type.Asn1SequenceOf;
+import org.apache.kerby.kerberos.kerb.spec.base.AuthToken;
+import org.ietf.jgss.GSSContext;
+import org.ietf.jgss.GSSException;
+
+import java.io.IOException;
+import java.util.List;
+
+public class TokenExtractor {
+ static final int JWT_AUTHZ_DATA_TYPE = 81;
+ public static final int AD_IF_RELEVANT_TYPE = 1;
+
+ /**
+ AuthorizationData ::= SEQUENCE OF SEQUENCE {
+ ad-type [0] Int32,
+ ad-data [1] OCTET STRING
+ }
+ */
+ public static class AuthorizationData extends Asn1SequenceOf<AuthzDataEntry> {
+
+ }
+
+ public static AuthToken checkAuthzData(GSSContext context) throws GSSException, IOException {
+ System.out.println("Looking for token from authorization data in GSSContext");
+
+ Object authzData = null;
+ if (context instanceof ExtendedGSSContext) {
+ ExtendedGSSContext ex = (ExtendedGSSContext)context;
+ authzData = ex.inquireSecContext(
+ InquireType.KRB5_GET_AUTHZ_DATA);
+ }
+
+ if (authzData != null) {
+ AuthorizationDataEntry[] authzEntries = (AuthorizationDataEntry[]) authzData;
+ AuthToken resultToken = null;
+ for (int i = 0; i < authzEntries.length; ++i) {
+ resultToken = getAuthzToken(authzEntries[i]);
+ if (resultToken != null) {
+ return resultToken;
+ }
+ }
+ }
+ return null;
+ }
+
+ public static AuthToken getAuthzToken(AuthorizationDataEntry authzDataEntry) throws IOException {
+ if (authzDataEntry.getType() == AD_IF_RELEVANT_TYPE) {
+ String token = getToken(authzDataEntry);
+ if (token == null) {
+ return null;
+ }
+
+ try {
+ return TokenTool.fromJwtToken(token);
+ } catch (Exception e) {
+ // noop when not jwt token
+ }
+ }
+
+ return null;
+ }
+
+ public static String getToken(AuthorizationDataEntry authzDataEntry) throws IOException {
+ List<AuthzDataEntry> entries = decode(authzDataEntry);
+ for (AuthzDataEntry entry : entries) {
+ if (entry.getAuthzType() == JWT_AUTHZ_DATA_TYPE) {
+ return new String(entry.getAuthzData());
+ }
+ }
+ return null;
+ }
+
+ public static List<AuthzDataEntry> decode(AuthorizationDataEntry authzDataEntry) throws IOException {
+ AuthorizationData authzData = new AuthorizationData();
+ authzData.decode(authzDataEntry.getData());
+ return authzData.getElements();
+ }
+}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/0c1d0e79/kdc-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/token/TokenTool.java
----------------------------------------------------------------------
diff --git a/kdc-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/token/TokenTool.java b/kdc-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/token/TokenTool.java
new file mode 100644
index 0000000..0aea7e6
--- /dev/null
+++ b/kdc-tool/client-tool/src/main/java/org/apache/kerby/kerberos/tool/token/TokenTool.java
@@ -0,0 +1,125 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.kerby.kerberos.tool.token;
+
+import com.nimbusds.jose.PlainHeader;
+import com.nimbusds.jwt.JWT;
+import com.nimbusds.jwt.JWTClaimsSet;
+import com.nimbusds.jwt.PlainJWT;
+import org.apache.kerby.kerberos.kerb.spec.base.AuthToken;
+
+import java.text.ParseException;
+import java.util.*;
+
+public class TokenTool {
+
+ public static JWT issueToken(String principal, String group, String role) {
+ // must have for kerb-token
+ String krbPrincipal = principal + "@SH.INTEL.COM";
+
+ PlainHeader header = new PlainHeader();
+ //header.setCustomParameter("krbPrincipal", krbPrincipal);
+
+ JWTClaimsSet jwtClaims = new JWTClaimsSet();
+
+ String iss = "token-service";
+ jwtClaims.setIssuer(iss);
+
+ String sub = principal;
+ jwtClaims.setSubject(sub);
+
+ // must have for kerb-token
+ jwtClaims.setSubject(krbPrincipal);
+
+ jwtClaims.setClaim("group", group);
+ if (role != null) {
+ jwtClaims.setClaim("role", role);
+ }
+
+ List<String> aud = new ArrayList<String>();
+ aud.add("krb5kdc-with-token-extension");
+ jwtClaims.setAudience(aud);
+
+ // Set expiration in 60 minutes
+ final Date NOW = new Date(new Date().getTime() / 1000 * 1000);
+ Date exp = new Date(NOW.getTime() + 1000 * 60 * 60);
+ jwtClaims.setExpirationTime(exp);
+
+ Date nbf = NOW;
+ jwtClaims.setNotBeforeTime(nbf);
+
+ Date iat = NOW;
+ jwtClaims.setIssueTime(iat);
+
+ String jti = UUID.randomUUID().toString();
+ jwtClaims.setJWTID(jti);
+
+ PlainJWT jwt = new PlainJWT(header, jwtClaims);
+ return jwt;
+ }
+
+ public static JWT decodeToken(String token) throws ParseException {
+ PlainJWT jwt = PlainJWT.parse(token);
+
+ return jwt;
+ }
+
+ public static AuthToken fromJwtToken(String token) throws ParseException {
+ Map<String, Object> attrs = decodeAndExtractTokenAttributes(token);
+ return null;//new AuthToken(attrs);
+ }
+
+ public static Map<String, Object> decodeAndExtractTokenAttributes(String token) throws ParseException {
+ PlainJWT jwt = PlainJWT.parse(token);
+
+ Map<String, Object> attrs = new HashMap<String, Object>();
+ attrs.putAll(jwt.getJWTClaimsSet().getAllClaims());
+ //attrs.putAll(jwt.getHeader().getCustomParameters());
+
+ return attrs;
+ }
+
+ public static void main(String[] args) throws ParseException {
+ String principal, group, role = null;
+
+ if (args.length != 2 && args.length != 3) {
+ System.out.println("This is a simple token issuing tool just for kerb-token PoC usage\n");
+ System.out.println("tokeninit <username> <group> [role]\n");
+ System.exit(1);
+ }
+ principal = args[0];
+ group = args[1];
+ if (args.length > 2) {
+ role = args[2];
+ }
+
+ JWT jwt = issueToken(principal, group, role);
+ String token = jwt.serialize();
+
+ TokenCache.writeToken(token);
+ System.out.println("Issued token: " + token);
+
+ /*
+ JWT jwt2 = decodeToken(token);
+ String krbPrincipal = (String) jwt2.getHeader().getCustomParameter("krbPrincipal");
+ System.out.println("Decoded token with krbprincipal: " + krbPrincipal);
+ */
+ }
+}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/0c1d0e79/kdc-tool/kadmin-tool/pom.xml
----------------------------------------------------------------------
diff --git a/kdc-tool/kadmin-tool/pom.xml b/kdc-tool/kadmin-tool/pom.xml
deleted file mode 100644
index b122526..0000000
--- a/kdc-tool/kadmin-tool/pom.xml
+++ /dev/null
@@ -1,75 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed 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. See accompanying LICENSE file.
--->
-<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/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.kerby</groupId>
- <artifactId>kdc-tool</artifactId>
- <version>1.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>kadmin</artifactId>
- <name>Kadmin</name>
- <description>Kerby KDC kadmin tool</description>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.kerby</groupId>
- <artifactId>kerby-config</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.kerby</groupId>
- <artifactId>kerb-identity</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.kerby</groupId>
- <artifactId>kerb-server</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-
- <profiles>
- <profile>
- <id>dist</id>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-assembly-plugin</artifactId>
- <version>2.2</version>
- <executions>
- <execution>
- <id>package-all</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- <configuration>
- <descriptorRefs>
- <descriptorRef>jar-with-dependencies</descriptorRef>
- </descriptorRefs>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-
-</project>
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/0c1d0e79/kdc-tool/kadmin-tool/src/main/java/org/apache/kerby/kerberos/tool/kadmin/Kadmin.java
----------------------------------------------------------------------
diff --git a/kdc-tool/kadmin-tool/src/main/java/org/apache/kerby/kerberos/tool/kadmin/Kadmin.java b/kdc-tool/kadmin-tool/src/main/java/org/apache/kerby/kerberos/tool/kadmin/Kadmin.java
deleted file mode 100644
index 6e0c0f1..0000000
--- a/kdc-tool/kadmin-tool/src/main/java/org/apache/kerby/kerberos/tool/kadmin/Kadmin.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerby.kerberos.tool.kadmin;
-
-import org.apache.kerby.config.Conf;
-import org.apache.kerby.kerberos.kerb.server.KdcConfig;
-import org.apache.kerby.kerberos.tool.kadmin.executor.AddPrincipalExecutor;
-import org.apache.kerby.kerberos.tool.kadmin.executor.KadminCommandExecutor;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Scanner;
-
-public class Kadmin {
- private static final String PROMPT = Kadmin.class.getSimpleName() + ".local";
- private static final String REQUEST_LIST = "Available " + PROMPT + " requests:\n" +
- "\n" +
- "add_principal, addprinc, ank\n" +
- " Add principal\n" +
- "delete_principal, delprinc\n" +
- " Delete principal\n" +
- "modify_principal, modprinc\n" +
- " Modify principal\n" +
- "rename_principal, renprinc\n" +
- " Rename principal\n" +
- "change_password, cpw Change password\n" +
- "get_principal, getprinc Get principal\n" +
- "list_principals, listprincs, get_principals, getprincs\n" +
- " List principals\n" +
- "add_policy, addpol Add policy\n" +
- "modify_policy, modpol Modify policy\n" +
- "delete_policy, delpol Delete policy\n" +
- "get_policy, getpol Get policy\n" +
- "list_policies, listpols, get_policies, getpols\n" +
- " List policies\n" +
- "get_privs, getprivs Get privileges\n" +
- "ktadd, xst Add entry(s) to a keytab\n" +
- "ktremove, ktrem Remove entry(s) from a keytab\n" +
- "lock Lock database exclusively (use with extreme caution!)\n" +
- "unlock Release exclusive database lock\n" +
- "purgekeys Purge previously retained old keys from a principal\n" +
- "get_strings, getstrs Show string attributes on a principal\n" +
- "set_string, setstr Set a string attribute on a principal\n" +
- "del_string, delstr Delete a string attribute on a principal\n" +
- "list_requests, lr, ? List available requests.\n" +
- "quit, exit, q Exit program.";
-
- private static KdcConfig kdcConfig;
- private static Conf backendConfig;
-
- private static void execute(String command) {
- if (command.equals("list_requests") ||
- command.equals("lr") ||
- command.equals("?")) {
- System.out.println(REQUEST_LIST);
- return;
- }
-
- KadminCommandExecutor executor = null;
- if (command.startsWith("add_principal") ||
- command.startsWith("addprinc") ||
- command.startsWith("ank")) {
- executor = new AddPrincipalExecutor(kdcConfig, backendConfig);
- }
-
- if (executor == null) {
- System.out.println("Unknown request \"" + command + "\". Type \"?\" for a request list.");
- return;
- }
- executor.execute(command);
- }
-
- private static void initConfig(String[] args) {
- File confDir;
- if (args.length == 0) {
- confDir = new File("/etc/kerby/");// for Linux. TODO: fix for Win etc.
- } else {
- confDir = new File(args[0]);
- }
-
- if (confDir.exists()) {
- File kdcConfFile = new File(confDir, "kdc.conf");
- if (kdcConfFile.exists()) {
- kdcConfig = new KdcConfig();
- try {
- kdcConfig.addIniConfig(kdcConfFile);
- } catch (IOException e) {
- System.err.println("Can not load the kdc configuration file " + kdcConfFile.getAbsolutePath());
- e.printStackTrace();
- }
- }
-
- File backendConfigFile = new File(confDir, "backend.conf");
- if (backendConfigFile.exists()) {
- backendConfig = new Conf();
- try {
- backendConfig.addIniConfig(backendConfigFile);
- } catch (IOException e) {
- System.err.println("Can not load the backend configuration file " + backendConfigFile.getAbsolutePath());
- e.printStackTrace();
- }
- }
- } else {
- throw new RuntimeException("Can not find configuration directory");
- }
- }
-
- public static void main(String[] args) {
- initConfig(args);
- System.out.print(PROMPT + ": ");
- Scanner scanner = new Scanner(System.in);
- String input = scanner.nextLine();
-
- while (!(input.equals("quit") ||
- input.equals("exit") ||
- input.equals("q"))) {
- execute(input);
- System.out.print(PROMPT + ": ");
- input = scanner.nextLine();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/0c1d0e79/kdc-tool/kadmin-tool/src/main/java/org/apache/kerby/kerberos/tool/kadmin/executor/AddPrincipalExecutor.java
----------------------------------------------------------------------
diff --git a/kdc-tool/kadmin-tool/src/main/java/org/apache/kerby/kerberos/tool/kadmin/executor/AddPrincipalExecutor.java b/kdc-tool/kadmin-tool/src/main/java/org/apache/kerby/kerberos/tool/kadmin/executor/AddPrincipalExecutor.java
deleted file mode 100644
index d67a16e..0000000
--- a/kdc-tool/kadmin-tool/src/main/java/org/apache/kerby/kerberos/tool/kadmin/executor/AddPrincipalExecutor.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerby.kerberos.tool.kadmin.executor;
-
-import org.apache.kerby.config.Config;
-import org.apache.kerby.kerberos.kerb.KrbException;
-import org.apache.kerby.kerberos.kerb.common.EncryptionUtil;
-import org.apache.kerby.kerberos.kerb.identity.KrbIdentity;
-import org.apache.kerby.kerberos.kerb.identity.backend.IdentityBackend;
-import org.apache.kerby.kerberos.kerb.server.KdcConfig;
-import org.apache.kerby.kerberos.kerb.server.KdcConfigKey;
-import org.apache.kerby.kerberos.kerb.spec.KerberosTime;
-import org.apache.kerby.kerberos.kerb.spec.base.EncryptionKey;
-
-import java.io.Console;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Scanner;
-
-public class AddPrincipalExecutor implements KadminCommandExecutor{
- private static final String USAGE = "usage: add_principal [options] principal\n" +
- "\toptions are:\n" +
- "\t\t[-randkey|-nokey] [-x db_princ_args]* [-expire expdate] [-pwexpire pwexpdate] [-maxlife maxtixlife]\n" +
- "\t\t[-kvno kvno] [-policy policy] [-clearpolicy]\n" +
- "\t\t[-pw password] [-maxrenewlife maxrenewlife]\n" +
- "\t\t[-e keysaltlist]\n" +
- "\t\t[{+|-}attribute]\n" +
- "\tattributes are:\n" +
- "\t\tallow_postdated allow_forwardable allow_tgs_req allow_renewable\n" +
- "\t\tallow_proxiable allow_dup_skey allow_tix requires_preauth\n" +
- "\t\trequires_hwauth needchange allow_svr password_changing_service\n" +
- "\t\tok_as_delegate ok_to_auth_as_delegate no_auth_data_required\n" +
- "\n" +
- "where,\n" +
- "\t[-x db_princ_args]* - any number of database specific arguments.\n" +
- "\t\t\tLook at each database documentation for supported arguments";
-
- private KdcConfig kdcConfig;
- private Config backendConfig;
-
- public AddPrincipalExecutor(KdcConfig kdcConfig, Config backendConfig) {
- this.kdcConfig = kdcConfig;
- this.backendConfig = backendConfig;
- }
-
- @Override
- public void execute(String input) {
- String[] commands = input.split(" ");
- if (commands.length < 2) {
- System.err.println(USAGE);
- return;
- }
-
- parseOptions(commands);
- String principal = commands[commands.length - 1];
- String password = getPassword(principal);
-
- if (password == null) {
- return;
- }
-
- addPrincipal(principal, password);
- System.out.println("Principal \"" + principal + "\" created.");
- }
-
- private void parseOptions(String[] commands) {
- //TODO
- }
-
- /**
- * Get password for the input principal from console
- */
- private String getPassword(String principal) {
- String passwordOnce;
- String passwordTwice;
-
- Console console = System.console();
- 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);
- passwordOnce = getPassword(scanner,
- "Enter password for principal \"" + principal + "\":");
- passwordTwice = getPassword(scanner,
- "Re-enter password for principal \"" + principal + "\":");
-
- } else {
- passwordOnce = getPassword(console,
- "Enter password for principal \"" + principal + "\":");
- passwordTwice = getPassword(console,
- "Re-enter password for principal \"" + principal + "\":");
- }
-
- if (!passwordOnce.equals(passwordTwice)) {
- System.err.println("add_principal: Password mismatch while reading password for \"" + principal + "\".");
- return null;
- }
- return passwordOnce;
- }
-
- private String getPassword(Scanner scanner, String prompt) {
- System.out.println(prompt);
- return scanner.nextLine().trim();
- }
-
- private String getPassword(Console console, String prompt) {
- console.printf(prompt);
- char[] passwordChars = console.readPassword();
- String password = new String(passwordChars).trim();
- Arrays.fill(passwordChars, ' ');
- return password;
- }
-
- private void addPrincipal(String principal, String password) {
- IdentityBackend backend = initBackend();
-
- KrbIdentity identity = createIdentity(principal, password);
- backend.addIdentity(identity);
- }
-
- private IdentityBackend initBackend() {
- String backendClassName = backendConfig.getString(
- KdcConfigKey.KDC_IDENTITY_BACKEND);
- if (backendClassName == null) {
- throw new RuntimeException("Can not find the IdentityBackend class");
- }
-
- Class backendClass = null;
- try {
- backendClass = Class.forName(backendClassName);
- } catch (ClassNotFoundException e) {
- throw new RuntimeException("Failed to load backend class: "
- + backendClassName);
- }
-
- IdentityBackend backend;
- try {
- backend = (IdentityBackend) backendClass.newInstance();
- } catch (InstantiationException | IllegalAccessException e) {
- throw new RuntimeException("Failed to create backend: "
- + backendClassName);
- }
-
- backend.setConfig(backendConfig);
- backend.initialize();
- return backend;
- }
-
- protected KrbIdentity createIdentity(String principal, String password) {
- KrbIdentity kid = new KrbIdentity(principal);
- kid.setCreatedTime(KerberosTime.now());
- kid.setExpireTime(KerberosTime.NEVER);
- kid.setDisabled(false);
- kid.setKeyVersion(1);
- kid.setLocked(false);
-
- kid.addKeys(generateKeys(kid.getPrincipalName(), password));
-
- return kid;
- }
-
- protected List<EncryptionKey> generateKeys(String principal, String password) {
- try {
- return EncryptionUtil.generateKeys(principal, password, kdcConfig.getEncryptionTypes());
- } catch (KrbException e) {
- throw new RuntimeException("Failed to create keys", e);
- }
- }
-
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/0c1d0e79/kdc-tool/kadmin-tool/src/main/java/org/apache/kerby/kerberos/tool/kadmin/executor/KadminCommandExecutor.java
----------------------------------------------------------------------
diff --git a/kdc-tool/kadmin-tool/src/main/java/org/apache/kerby/kerberos/tool/kadmin/executor/KadminCommandExecutor.java b/kdc-tool/kadmin-tool/src/main/java/org/apache/kerby/kerberos/tool/kadmin/executor/KadminCommandExecutor.java
deleted file mode 100644
index 3c22bbd..0000000
--- a/kdc-tool/kadmin-tool/src/main/java/org/apache/kerby/kerberos/tool/kadmin/executor/KadminCommandExecutor.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerby.kerberos.tool.kadmin.executor;
-
-public interface KadminCommandExecutor {
-
- /**
- * Execute the kadmin command.
- */
- public void execute(String input);
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/0c1d0e79/kdc-tool/pom.xml
----------------------------------------------------------------------
diff --git a/kdc-tool/pom.xml b/kdc-tool/pom.xml
index cc9948a..0176d43 100644
--- a/kdc-tool/pom.xml
+++ b/kdc-tool/pom.xml
@@ -28,8 +28,7 @@
<modules>
<module>client-tool</module>
- <module>token-tool</module>
- <module>kadmin-tool</module>
+ <module>server-tool</module>
</modules>
</project>
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/0c1d0e79/kdc-tool/server-tool/pom.xml
----------------------------------------------------------------------
diff --git a/kdc-tool/server-tool/pom.xml b/kdc-tool/server-tool/pom.xml
new file mode 100644
index 0000000..de1f5e7
--- /dev/null
+++ b/kdc-tool/server-tool/pom.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed 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. See accompanying LICENSE file.
+-->
+<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/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.kerby</groupId>
+ <artifactId>kdc-tool</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>server-tool</artifactId>
+ <name>Server Tool</name>
+ <description>Kerby KDC server tool</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.kerby</groupId>
+ <artifactId>kerby-config</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.kerby</groupId>
+ <artifactId>kerb-identity</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.kerby</groupId>
+ <artifactId>kerb-server</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>dist</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.2</version>
+ <executions>
+ <execution>
+ <id>package-all</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <descriptorRefs>
+ <descriptorRef>jar-with-dependencies</descriptorRef>
+ </descriptorRefs>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+</project>
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/0c1d0e79/kdc-tool/server-tool/src/main/java/org/apache/kerby/kerberos/tool/kadmin/Kadmin.java
----------------------------------------------------------------------
diff --git a/kdc-tool/server-tool/src/main/java/org/apache/kerby/kerberos/tool/kadmin/Kadmin.java b/kdc-tool/server-tool/src/main/java/org/apache/kerby/kerberos/tool/kadmin/Kadmin.java
new file mode 100644
index 0000000..6e0c0f1
--- /dev/null
+++ b/kdc-tool/server-tool/src/main/java/org/apache/kerby/kerberos/tool/kadmin/Kadmin.java
@@ -0,0 +1,139 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.kerby.kerberos.tool.kadmin;
+
+import org.apache.kerby.config.Conf;
+import org.apache.kerby.kerberos.kerb.server.KdcConfig;
+import org.apache.kerby.kerberos.tool.kadmin.executor.AddPrincipalExecutor;
+import org.apache.kerby.kerberos.tool.kadmin.executor.KadminCommandExecutor;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Scanner;
+
+public class Kadmin {
+ private static final String PROMPT = Kadmin.class.getSimpleName() + ".local";
+ private static final String REQUEST_LIST = "Available " + PROMPT + " requests:\n" +
+ "\n" +
+ "add_principal, addprinc, ank\n" +
+ " Add principal\n" +
+ "delete_principal, delprinc\n" +
+ " Delete principal\n" +
+ "modify_principal, modprinc\n" +
+ " Modify principal\n" +
+ "rename_principal, renprinc\n" +
+ " Rename principal\n" +
+ "change_password, cpw Change password\n" +
+ "get_principal, getprinc Get principal\n" +
+ "list_principals, listprincs, get_principals, getprincs\n" +
+ " List principals\n" +
+ "add_policy, addpol Add policy\n" +
+ "modify_policy, modpol Modify policy\n" +
+ "delete_policy, delpol Delete policy\n" +
+ "get_policy, getpol Get policy\n" +
+ "list_policies, listpols, get_policies, getpols\n" +
+ " List policies\n" +
+ "get_privs, getprivs Get privileges\n" +
+ "ktadd, xst Add entry(s) to a keytab\n" +
+ "ktremove, ktrem Remove entry(s) from a keytab\n" +
+ "lock Lock database exclusively (use with extreme caution!)\n" +
+ "unlock Release exclusive database lock\n" +
+ "purgekeys Purge previously retained old keys from a principal\n" +
+ "get_strings, getstrs Show string attributes on a principal\n" +
+ "set_string, setstr Set a string attribute on a principal\n" +
+ "del_string, delstr Delete a string attribute on a principal\n" +
+ "list_requests, lr, ? List available requests.\n" +
+ "quit, exit, q Exit program.";
+
+ private static KdcConfig kdcConfig;
+ private static Conf backendConfig;
+
+ private static void execute(String command) {
+ if (command.equals("list_requests") ||
+ command.equals("lr") ||
+ command.equals("?")) {
+ System.out.println(REQUEST_LIST);
+ return;
+ }
+
+ KadminCommandExecutor executor = null;
+ if (command.startsWith("add_principal") ||
+ command.startsWith("addprinc") ||
+ command.startsWith("ank")) {
+ executor = new AddPrincipalExecutor(kdcConfig, backendConfig);
+ }
+
+ if (executor == null) {
+ System.out.println("Unknown request \"" + command + "\". Type \"?\" for a request list.");
+ return;
+ }
+ executor.execute(command);
+ }
+
+ private static void initConfig(String[] args) {
+ File confDir;
+ if (args.length == 0) {
+ confDir = new File("/etc/kerby/");// for Linux. TODO: fix for Win etc.
+ } else {
+ confDir = new File(args[0]);
+ }
+
+ if (confDir.exists()) {
+ File kdcConfFile = new File(confDir, "kdc.conf");
+ if (kdcConfFile.exists()) {
+ kdcConfig = new KdcConfig();
+ try {
+ kdcConfig.addIniConfig(kdcConfFile);
+ } catch (IOException e) {
+ System.err.println("Can not load the kdc configuration file " + kdcConfFile.getAbsolutePath());
+ e.printStackTrace();
+ }
+ }
+
+ File backendConfigFile = new File(confDir, "backend.conf");
+ if (backendConfigFile.exists()) {
+ backendConfig = new Conf();
+ try {
+ backendConfig.addIniConfig(backendConfigFile);
+ } catch (IOException e) {
+ System.err.println("Can not load the backend configuration file " + backendConfigFile.getAbsolutePath());
+ e.printStackTrace();
+ }
+ }
+ } else {
+ throw new RuntimeException("Can not find configuration directory");
+ }
+ }
+
+ public static void main(String[] args) {
+ initConfig(args);
+ System.out.print(PROMPT + ": ");
+ Scanner scanner = new Scanner(System.in);
+ String input = scanner.nextLine();
+
+ while (!(input.equals("quit") ||
+ input.equals("exit") ||
+ input.equals("q"))) {
+ execute(input);
+ System.out.print(PROMPT + ": ");
+ input = scanner.nextLine();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/0c1d0e79/kdc-tool/server-tool/src/main/java/org/apache/kerby/kerberos/tool/kadmin/executor/AddPrincipalExecutor.java
----------------------------------------------------------------------
diff --git a/kdc-tool/server-tool/src/main/java/org/apache/kerby/kerberos/tool/kadmin/executor/AddPrincipalExecutor.java b/kdc-tool/server-tool/src/main/java/org/apache/kerby/kerberos/tool/kadmin/executor/AddPrincipalExecutor.java
new file mode 100644
index 0000000..d67a16e
--- /dev/null
+++ b/kdc-tool/server-tool/src/main/java/org/apache/kerby/kerberos/tool/kadmin/executor/AddPrincipalExecutor.java
@@ -0,0 +1,191 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.kerby.kerberos.tool.kadmin.executor;
+
+import org.apache.kerby.config.Config;
+import org.apache.kerby.kerberos.kerb.KrbException;
+import org.apache.kerby.kerberos.kerb.common.EncryptionUtil;
+import org.apache.kerby.kerberos.kerb.identity.KrbIdentity;
+import org.apache.kerby.kerberos.kerb.identity.backend.IdentityBackend;
+import org.apache.kerby.kerberos.kerb.server.KdcConfig;
+import org.apache.kerby.kerberos.kerb.server.KdcConfigKey;
+import org.apache.kerby.kerberos.kerb.spec.KerberosTime;
+import org.apache.kerby.kerberos.kerb.spec.base.EncryptionKey;
+
+import java.io.Console;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Scanner;
+
+public class AddPrincipalExecutor implements KadminCommandExecutor{
+ private static final String USAGE = "usage: add_principal [options] principal\n" +
+ "\toptions are:\n" +
+ "\t\t[-randkey|-nokey] [-x db_princ_args]* [-expire expdate] [-pwexpire pwexpdate] [-maxlife maxtixlife]\n" +
+ "\t\t[-kvno kvno] [-policy policy] [-clearpolicy]\n" +
+ "\t\t[-pw password] [-maxrenewlife maxrenewlife]\n" +
+ "\t\t[-e keysaltlist]\n" +
+ "\t\t[{+|-}attribute]\n" +
+ "\tattributes are:\n" +
+ "\t\tallow_postdated allow_forwardable allow_tgs_req allow_renewable\n" +
+ "\t\tallow_proxiable allow_dup_skey allow_tix requires_preauth\n" +
+ "\t\trequires_hwauth needchange allow_svr password_changing_service\n" +
+ "\t\tok_as_delegate ok_to_auth_as_delegate no_auth_data_required\n" +
+ "\n" +
+ "where,\n" +
+ "\t[-x db_princ_args]* - any number of database specific arguments.\n" +
+ "\t\t\tLook at each database documentation for supported arguments";
+
+ private KdcConfig kdcConfig;
+ private Config backendConfig;
+
+ public AddPrincipalExecutor(KdcConfig kdcConfig, Config backendConfig) {
+ this.kdcConfig = kdcConfig;
+ this.backendConfig = backendConfig;
+ }
+
+ @Override
+ public void execute(String input) {
+ String[] commands = input.split(" ");
+ if (commands.length < 2) {
+ System.err.println(USAGE);
+ return;
+ }
+
+ parseOptions(commands);
+ String principal = commands[commands.length - 1];
+ String password = getPassword(principal);
+
+ if (password == null) {
+ return;
+ }
+
+ addPrincipal(principal, password);
+ System.out.println("Principal \"" + principal + "\" created.");
+ }
+
+ private void parseOptions(String[] commands) {
+ //TODO
+ }
+
+ /**
+ * Get password for the input principal from console
+ */
+ private String getPassword(String principal) {
+ String passwordOnce;
+ String passwordTwice;
+
+ Console console = System.console();
+ 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);
+ passwordOnce = getPassword(scanner,
+ "Enter password for principal \"" + principal + "\":");
+ passwordTwice = getPassword(scanner,
+ "Re-enter password for principal \"" + principal + "\":");
+
+ } else {
+ passwordOnce = getPassword(console,
+ "Enter password for principal \"" + principal + "\":");
+ passwordTwice = getPassword(console,
+ "Re-enter password for principal \"" + principal + "\":");
+ }
+
+ if (!passwordOnce.equals(passwordTwice)) {
+ System.err.println("add_principal: Password mismatch while reading password for \"" + principal + "\".");
+ return null;
+ }
+ return passwordOnce;
+ }
+
+ private String getPassword(Scanner scanner, String prompt) {
+ System.out.println(prompt);
+ return scanner.nextLine().trim();
+ }
+
+ private String getPassword(Console console, String prompt) {
+ console.printf(prompt);
+ char[] passwordChars = console.readPassword();
+ String password = new String(passwordChars).trim();
+ Arrays.fill(passwordChars, ' ');
+ return password;
+ }
+
+ private void addPrincipal(String principal, String password) {
+ IdentityBackend backend = initBackend();
+
+ KrbIdentity identity = createIdentity(principal, password);
+ backend.addIdentity(identity);
+ }
+
+ private IdentityBackend initBackend() {
+ String backendClassName = backendConfig.getString(
+ KdcConfigKey.KDC_IDENTITY_BACKEND);
+ if (backendClassName == null) {
+ throw new RuntimeException("Can not find the IdentityBackend class");
+ }
+
+ Class backendClass = null;
+ try {
+ backendClass = Class.forName(backendClassName);
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException("Failed to load backend class: "
+ + backendClassName);
+ }
+
+ IdentityBackend backend;
+ try {
+ backend = (IdentityBackend) backendClass.newInstance();
+ } catch (InstantiationException | IllegalAccessException e) {
+ throw new RuntimeException("Failed to create backend: "
+ + backendClassName);
+ }
+
+ backend.setConfig(backendConfig);
+ backend.initialize();
+ return backend;
+ }
+
+ protected KrbIdentity createIdentity(String principal, String password) {
+ KrbIdentity kid = new KrbIdentity(principal);
+ kid.setCreatedTime(KerberosTime.now());
+ kid.setExpireTime(KerberosTime.NEVER);
+ kid.setDisabled(false);
+ kid.setKeyVersion(1);
+ kid.setLocked(false);
+
+ kid.addKeys(generateKeys(kid.getPrincipalName(), password));
+
+ return kid;
+ }
+
+ protected List<EncryptionKey> generateKeys(String principal, String password) {
+ try {
+ return EncryptionUtil.generateKeys(principal, password, kdcConfig.getEncryptionTypes());
+ } catch (KrbException e) {
+ throw new RuntimeException("Failed to create keys", e);
+ }
+ }
+
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/0c1d0e79/kdc-tool/server-tool/src/main/java/org/apache/kerby/kerberos/tool/kadmin/executor/KadminCommandExecutor.java
----------------------------------------------------------------------
diff --git a/kdc-tool/server-tool/src/main/java/org/apache/kerby/kerberos/tool/kadmin/executor/KadminCommandExecutor.java b/kdc-tool/server-tool/src/main/java/org/apache/kerby/kerberos/tool/kadmin/executor/KadminCommandExecutor.java
new file mode 100644
index 0000000..3c22bbd
--- /dev/null
+++ b/kdc-tool/server-tool/src/main/java/org/apache/kerby/kerberos/tool/kadmin/executor/KadminCommandExecutor.java
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.kerby.kerberos.tool.kadmin.executor;
+
+public interface KadminCommandExecutor {
+
+ /**
+ * Execute the kadmin command.
+ */
+ public void execute(String input);
+}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/0c1d0e79/kdc-tool/token-tool/pom.xml
----------------------------------------------------------------------
diff --git a/kdc-tool/token-tool/pom.xml b/kdc-tool/token-tool/pom.xml
deleted file mode 100644
index 10c3e1e..0000000
--- a/kdc-tool/token-tool/pom.xml
+++ /dev/null
@@ -1,49 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed 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. See accompanying LICENSE file.
--->
-<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">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.kerby</groupId>
- <artifactId>kdc-tool</artifactId>
- <version>1.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>token-tool</artifactId>
- <name>Token Tool Project</name>
- <version>1.0-SNAPSHOT</version>
- <packaging>jar</packaging>
-
- <dependencies>
- <dependency>
- <groupId>com.nimbusds</groupId>
- <artifactId>nimbus-jose-jwt</artifactId>
- <version>3.8.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.kerby</groupId>
- <artifactId>kerb-core</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.kerby</groupId>
- <artifactId>kerby-asn1</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-
-</project>
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/0c1d0e79/kdc-tool/token-tool/src/main/java/org/apache/kerby/token/AuthzDataEntry.java
----------------------------------------------------------------------
diff --git a/kdc-tool/token-tool/src/main/java/org/apache/kerby/token/AuthzDataEntry.java b/kdc-tool/token-tool/src/main/java/org/apache/kerby/token/AuthzDataEntry.java
deleted file mode 100644
index d4bfedb..0000000
--- a/kdc-tool/token-tool/src/main/java/org/apache/kerby/token/AuthzDataEntry.java
+++ /dev/null
@@ -1,52 +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.token;
-
-import org.apache.kerby.asn1.type.Asn1FieldInfo;
-import org.apache.kerby.asn1.type.Asn1Integer;
-import org.apache.kerby.asn1.type.Asn1OctetString;
-import org.apache.kerby.asn1.type.Asn1SequenceType;
-
-/**
- AuthorizationData ::= SEQUENCE OF SEQUENCE {
- ad-type [0] Int32,
- ad-data [1] OCTET STRING
- }
- */
-public class AuthzDataEntry extends Asn1SequenceType {
- static int AD_TYPE = 0;
- static int AD_DATA = 1;
-
- public AuthzDataEntry() {
- super(new Asn1FieldInfo[] {
- new Asn1FieldInfo(AD_TYPE, Asn1Integer.class),
- new Asn1FieldInfo(AD_DATA, Asn1OctetString.class)
- });
- }
-
- public int getAuthzType() {
- Integer value = getFieldAsInteger(AD_TYPE);
- return value;
- }
-
- public byte[] getAuthzData() {
- return getFieldAsOctets(AD_DATA);
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/0c1d0e79/kdc-tool/token-tool/src/main/java/org/apache/kerby/token/TokenCache.java
----------------------------------------------------------------------
diff --git a/kdc-tool/token-tool/src/main/java/org/apache/kerby/token/TokenCache.java b/kdc-tool/token-tool/src/main/java/org/apache/kerby/token/TokenCache.java
deleted file mode 100644
index 51e3593..0000000
--- a/kdc-tool/token-tool/src/main/java/org/apache/kerby/token/TokenCache.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.kerby.token;
-
-import java.io.*;
-
-public class TokenCache {
- private static final String DEFAULT_TOKEN_CACHE_PATH = ".tokenauth";
- private static final String TOKEN_CACHE_FILE = ".tokenauth.token";
-
- public static String readToken(String tokenCacheFile) {
- File cacheFile = null;
-
- if (tokenCacheFile != null && ! tokenCacheFile.isEmpty()) {
- cacheFile = new File(tokenCacheFile);
- if (!cacheFile.exists()) {
- throw new RuntimeException("Invalid token cache specified: " + tokenCacheFile);
- };
- } else {
- cacheFile = getDefaultTokenCache();
- if (!cacheFile.exists()) {
- throw new RuntimeException("No token cache available by default");
- };
- }
-
- String token = null;
- try {
- BufferedReader reader = new BufferedReader(new FileReader(cacheFile));
- String line = reader.readLine();
- reader.close();
- if (line != null) {
- token = line;
- }
- } catch (IOException ex) {
- //NOP
- }
-
- return token;
- }
-
- public static void writeToken(String token) {
- File cacheFile = getDefaultTokenCache();
-
- try {
- Writer writer = new FileWriter(cacheFile);
- writer.write(token.toString());
- writer.close();
- // sets read-write permissions to owner only
- cacheFile.setReadable(false, false);
- cacheFile.setReadable(true, true);
- cacheFile.setWritable(true, true);
- }
- catch (IOException ioe) {
- // if case of any error we just delete the cache, if user-only
- // write permissions are not properly set a security exception
- // is thrown and the file will be deleted.
- cacheFile.delete();
- }
- }
-
- public static File getDefaultTokenCache() {
- String homeDir = System.getProperty("user.home", DEFAULT_TOKEN_CACHE_PATH);
- return new File(homeDir, TOKEN_CACHE_FILE);
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/0c1d0e79/kdc-tool/token-tool/src/main/java/org/apache/kerby/token/TokenExtractor.java
----------------------------------------------------------------------
diff --git a/kdc-tool/token-tool/src/main/java/org/apache/kerby/token/TokenExtractor.java b/kdc-tool/token-tool/src/main/java/org/apache/kerby/token/TokenExtractor.java
deleted file mode 100644
index ceb03db..0000000
--- a/kdc-tool/token-tool/src/main/java/org/apache/kerby/token/TokenExtractor.java
+++ /dev/null
@@ -1,102 +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.token;
-
-import com.sun.security.jgss.AuthorizationDataEntry;
-import com.sun.security.jgss.ExtendedGSSContext;
-import com.sun.security.jgss.InquireType;
-import org.apache.kerby.asn1.type.Asn1SequenceOf;
-import org.apache.kerby.kerberos.kerb.spec.base.AuthToken;
-import org.ietf.jgss.GSSContext;
-import org.ietf.jgss.GSSException;
-
-import java.io.IOException;
-import java.util.List;
-
-public class TokenExtractor {
- static final int JWT_AUTHZ_DATA_TYPE = 81;
- public static final int AD_IF_RELEVANT_TYPE = 1;
-
- /**
- AuthorizationData ::= SEQUENCE OF SEQUENCE {
- ad-type [0] Int32,
- ad-data [1] OCTET STRING
- }
- */
- public static class AuthorizationData extends Asn1SequenceOf<AuthzDataEntry> {
-
- }
-
- public static AuthToken checkAuthzData(GSSContext context) throws GSSException, IOException {
- System.out.println("Looking for token from authorization data in GSSContext");
-
- Object authzData = null;
- if (context instanceof ExtendedGSSContext) {
- ExtendedGSSContext ex = (ExtendedGSSContext)context;
- authzData = ex.inquireSecContext(
- InquireType.KRB5_GET_AUTHZ_DATA);
- }
-
- if (authzData != null) {
- AuthorizationDataEntry[] authzEntries = (AuthorizationDataEntry[]) authzData;
- AuthToken resultToken = null;
- for (int i = 0; i < authzEntries.length; ++i) {
- resultToken = getAuthzToken(authzEntries[i]);
- if (resultToken != null) {
- return resultToken;
- }
- }
- }
- return null;
- }
-
- public static AuthToken getAuthzToken(AuthorizationDataEntry authzDataEntry) throws IOException {
- if (authzDataEntry.getType() == AD_IF_RELEVANT_TYPE) {
- String token = getToken(authzDataEntry);
- if (token == null) {
- return null;
- }
-
- try {
- return TokenTool.fromJwtToken(token);
- } catch (Exception e) {
- // noop when not jwt token
- }
- }
-
- return null;
- }
-
- public static String getToken(AuthorizationDataEntry authzDataEntry) throws IOException {
- List<AuthzDataEntry> entries = decode(authzDataEntry);
- for (AuthzDataEntry entry : entries) {
- if (entry.getAuthzType() == JWT_AUTHZ_DATA_TYPE) {
- return new String(entry.getAuthzData());
- }
- }
- return null;
- }
-
- public static List<AuthzDataEntry> decode(AuthorizationDataEntry authzDataEntry) throws IOException {
- AuthorizationData authzData = new AuthorizationData();
- authzData.decode(authzDataEntry.getData());
- return authzData.getElements();
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/0c1d0e79/kdc-tool/token-tool/src/main/java/org/apache/kerby/token/TokenTool.java
----------------------------------------------------------------------
diff --git a/kdc-tool/token-tool/src/main/java/org/apache/kerby/token/TokenTool.java b/kdc-tool/token-tool/src/main/java/org/apache/kerby/token/TokenTool.java
deleted file mode 100644
index 4cda20e..0000000
--- a/kdc-tool/token-tool/src/main/java/org/apache/kerby/token/TokenTool.java
+++ /dev/null
@@ -1,125 +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.token;
-
-import com.nimbusds.jose.PlainHeader;
-import com.nimbusds.jwt.JWT;
-import com.nimbusds.jwt.JWTClaimsSet;
-import com.nimbusds.jwt.PlainJWT;
-import org.apache.kerby.kerberos.kerb.spec.base.AuthToken;
-
-import java.text.ParseException;
-import java.util.*;
-
-public class TokenTool {
-
- public static JWT issueToken(String principal, String group, String role) {
- // must have for kerb-token
- String krbPrincipal = principal + "@SH.INTEL.COM";
-
- PlainHeader header = new PlainHeader();
- //header.setCustomParameter("krbPrincipal", krbPrincipal);
-
- JWTClaimsSet jwtClaims = new JWTClaimsSet();
-
- String iss = "token-service";
- jwtClaims.setIssuer(iss);
-
- String sub = principal;
- jwtClaims.setSubject(sub);
-
- // must have for kerb-token
- jwtClaims.setSubject(krbPrincipal);
-
- jwtClaims.setClaim("group", group);
- if (role != null) {
- jwtClaims.setClaim("role", role);
- }
-
- List<String> aud = new ArrayList<String>();
- aud.add("krb5kdc-with-token-extension");
- jwtClaims.setAudience(aud);
-
- // Set expiration in 60 minutes
- final Date NOW = new Date(new Date().getTime() / 1000 * 1000);
- Date exp = new Date(NOW.getTime() + 1000 * 60 * 60);
- jwtClaims.setExpirationTime(exp);
-
- Date nbf = NOW;
- jwtClaims.setNotBeforeTime(nbf);
-
- Date iat = NOW;
- jwtClaims.setIssueTime(iat);
-
- String jti = UUID.randomUUID().toString();
- jwtClaims.setJWTID(jti);
-
- PlainJWT jwt = new PlainJWT(header, jwtClaims);
- return jwt;
- }
-
- public static JWT decodeToken(String token) throws ParseException {
- PlainJWT jwt = PlainJWT.parse(token);
-
- return jwt;
- }
-
- public static AuthToken fromJwtToken(String token) throws ParseException {
- Map<String, Object> attrs = decodeAndExtractTokenAttributes(token);
- return null;//new AuthToken(attrs);
- }
-
- public static Map<String, Object> decodeAndExtractTokenAttributes(String token) throws ParseException {
- PlainJWT jwt = PlainJWT.parse(token);
-
- Map<String, Object> attrs = new HashMap<String, Object>();
- attrs.putAll(jwt.getJWTClaimsSet().getAllClaims());
- //attrs.putAll(jwt.getHeader().getCustomParameters());
-
- return attrs;
- }
-
- public static void main(String[] args) throws ParseException {
- String principal, group, role = null;
-
- if (args.length != 2 && args.length != 3) {
- System.out.println("This is a simple token issuing tool just for kerb-token PoC usage\n");
- System.out.println("tokeninit <username> <group> [role]\n");
- System.exit(1);
- }
- principal = args[0];
- group = args[1];
- if (args.length > 2) {
- role = args[2];
- }
-
- JWT jwt = issueToken(principal, group, role);
- String token = jwt.serialize();
-
- TokenCache.writeToken(token);
- System.out.println("Issued token: " + token);
-
- /*
- JWT jwt2 = decodeToken(token);
- String krbPrincipal = (String) jwt2.getHeader().getCustomParameter("krbPrincipal");
- System.out.println("Decoded token with krbprincipal: " + krbPrincipal);
- */
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/0c1d0e79/kerby-dist/tool-dist/pom.xml
----------------------------------------------------------------------
diff --git a/kerby-dist/tool-dist/pom.xml b/kerby-dist/tool-dist/pom.xml
index e31cca5..009b2bf 100644
--- a/kerby-dist/tool-dist/pom.xml
+++ b/kerby-dist/tool-dist/pom.xml
@@ -29,17 +29,12 @@
<dependencies>
<dependency>
<groupId>org.apache.kerby</groupId>
- <artifactId>kinit</artifactId>
+ <artifactId>client-tool</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.kerby</groupId>
- <artifactId>kadmin</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.kerby</groupId>
- <artifactId>token-tool</artifactId>
+ <artifactId>server-tool</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
@@ -51,15 +46,15 @@
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
- <version>1.8</version>
+ <version>1.7</version>
<executions>
<execution>
<phase>package</phase>
<configuration>
<tasks>
<copy file="../../kerby-kerb/kerb-client/target/kerb-client-${project.version}-jar-with-dependencies.jar" tofile="lib/kerb-client-${project.version}-jar-with-dependencies.jar"/>
- <copy file="../../kdc-tool/client-tool/target/kinit-${project.version}.jar" tofile="lib/kinit-${project.version}.jar"/>
- <copy file="../../kdc-tool/kadmin-tool/target/kadmin-${project.version}-jar-with-dependencies.jar" tofile="lib/kadmin-${project.version}-jar-with-dependencies.jar"/>
+ <copy file="../../kdc-tool/client-tool/target/client-tool-${project.version}.jar" tofile="lib/client-tool-${project.version}.jar"/>
+ <copy file="../../kdc-tool/server-tool/target/server-tool-${project.version}.jar" tofile="lib/server-tool-${project.version}.jar"/>
</tasks>
</configuration>
<goals>
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/0c1d0e79/kerby-kdc/README.md
----------------------------------------------------------------------
diff --git a/kerby-kdc/README.md b/kerby-kdc/README.md
new file mode 100644
index 0000000..4e5782e
--- /dev/null
+++ b/kerby-kdc/README.md
@@ -0,0 +1 @@
+This is the standalone KDC server.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/0c1d0e79/kerby-kerb/README
----------------------------------------------------------------------
diff --git a/kerby-kerb/README b/kerby-kerb/README
deleted file mode 100644
index e0a1507..0000000
--- a/kerby-kerb/README
+++ /dev/null
@@ -1,2 +0,0 @@
-A Kerberos protocol and standards implementation with least dependencies (only relying on JCE).
-The provided APIs and facilities can be used as embedded.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/0c1d0e79/kerby-kerb/README.md
----------------------------------------------------------------------
diff --git a/kerby-kerb/README.md b/kerby-kerb/README.md
new file mode 100644
index 0000000..e48a10b
--- /dev/null
+++ b/kerby-kerb/README.md
@@ -0,0 +1,2 @@
+A Kerberos protocol and standards implementation with least dependencies (only relying on JCE).
+The provided APIs and facilities can be used as Kerberos library.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/0c1d0e79/lib/README.md
----------------------------------------------------------------------
diff --git a/lib/README.md b/lib/README.md
new file mode 100644
index 0000000..92c7329
--- /dev/null
+++ b/lib/README.md
@@ -0,0 +1 @@
+This contains all the libraries that the Kerberos implementation relies on.
\ No newline at end of file
[2/2] directory-kerby git commit: Fixed script wrapers
Posted by dr...@apache.org.
Fixed script wrapers
Project: http://git-wip-us.apache.org/repos/asf/directory-kerby/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-kerby/commit/2e1de10b
Tree: http://git-wip-us.apache.org/repos/asf/directory-kerby/tree/2e1de10b
Diff: http://git-wip-us.apache.org/repos/asf/directory-kerby/diff/2e1de10b
Branch: refs/heads/master
Commit: 2e1de10bca564fa618b171fed21cca4117a3ac68
Parents: 0c1d0e7
Author: Drankye <dr...@gmail.com>
Authored: Sat Mar 21 08:05:50 2015 +0800
Committer: Drankye <dr...@gmail.com>
Committed: Sat Mar 21 08:05:50 2015 +0800
----------------------------------------------------------------------
kerby-dist/tool-dist/bin/kadmin.sh | 4 +++-
kerby-dist/tool-dist/bin/kinit.sh | 4 +++-
2 files changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/2e1de10b/kerby-dist/tool-dist/bin/kadmin.sh
----------------------------------------------------------------------
diff --git a/kerby-dist/tool-dist/bin/kadmin.sh b/kerby-dist/tool-dist/bin/kadmin.sh
index 093a6d4..5f80f35 100644
--- a/kerby-dist/tool-dist/bin/kadmin.sh
+++ b/kerby-dist/tool-dist/bin/kadmin.sh
@@ -1,2 +1,4 @@
#!/bin/bash
-java -Xdebug -Xrunjdwp:transport=dt_socket,address=1046,server=y,suspend=n -cp ../lib/kadmin-1.0-SNAPSHOT-jar-with-dependencies.jar org.apache.kerby.kerberos.tool.kadmin.Kadmin $@
\ No newline at end of file
+java -Xdebug -Xrunjdwp:transport=dt_socket,address=1046,server=y,suspend=n \
+-cp -cp ../lib/kerb-client-1.0-SNAPSHOT-jar-with-dependencies.jar:../lib/client-tool-1.0-SNAPSHOT.jar \
+../lib/server-tool-1.0-SNAPSHOT.jar org.apache.kerby.kerberos.tool.kadmin.Kadmin $@
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/2e1de10b/kerby-dist/tool-dist/bin/kinit.sh
----------------------------------------------------------------------
diff --git a/kerby-dist/tool-dist/bin/kinit.sh b/kerby-dist/tool-dist/bin/kinit.sh
index c39df45..4c465c2 100644
--- a/kerby-dist/tool-dist/bin/kinit.sh
+++ b/kerby-dist/tool-dist/bin/kinit.sh
@@ -1,2 +1,4 @@
#!/bin/bash
-java -Xdebug -Xrunjdwp:transport=dt_socket,address=1045,server=y,suspend=n -cp ../lib/kerb-client-1.0-SNAPSHOT-jar-with-dependencies.jar:../lib/kinit-1.0-SNAPSHOT.jar org.apache.kerby.kerberos.tool.kinit.Kinit $@
+java -Xdebug -Xrunjdwp:transport=dt_socket,address=1045,server=y,suspend=n \
+-cp ../lib/kerb-client-1.0-SNAPSHOT-jar-with-dependencies.jar:../lib/client-tool-1.0-SNAPSHOT.jar \
+org.apache.kerby.kerberos.tool.kinit.Kinit $@