You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by co...@apache.org on 2020/01/03 11:12:13 UTC

[directory-kerby] branch trunk updated (01a1dd4 -> 488aee1)

This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a change to branch trunk
in repository https://gitbox.apache.org/repos/asf/directory-kerby.git.


    from 01a1dd4  Change test keys to be 2048 bits.
     new 39bd0fc  Fixing indentation
     new 488aee1  Adding a test-case for KOptions

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../src/main/java/org/apache/kerby/KOptions.java   | 56 ++++++++++----------
 .../kerby/kerberos/kerb/server/ApRequestTest.java  |  1 +
 .../kerberos/kerb/server/PrincipalNameTest.java    | 59 ++++++++++++++++++++++
 3 files changed, 88 insertions(+), 28 deletions(-)
 create mode 100644 kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/PrincipalNameTest.java


[directory-kerby] 02/02: Adding a test-case for KOptions

Posted by co...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/directory-kerby.git

commit 488aee1f181395ed0ccd0ae3d1f7f3c4be9af9b1
Author: Colm O hEigeartaigh <co...@apache.org>
AuthorDate: Fri Jan 3 11:00:39 2020 +0000

    Adding a test-case for KOptions
---
 .../kerby/kerberos/kerb/server/ApRequestTest.java  |  1 +
 .../kerberos/kerb/server/PrincipalNameTest.java    | 59 ++++++++++++++++++++++
 2 files changed, 60 insertions(+)

diff --git a/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/ApRequestTest.java b/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/ApRequestTest.java
index f1cc89d..ec07d93 100644
--- a/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/ApRequestTest.java
+++ b/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/ApRequestTest.java
@@ -48,6 +48,7 @@ public class ApRequestTest extends KdcTestBase {
             tgt = getKrbClient().requestTgt(getClientPrincipal(),
                     getClientPassword());
             assertThat(tgt).isNotNull();
+            assertThat(tgt.getClientPrincipal().getName()).isEqualTo(getClientPrincipal());
 
             tkt = getKrbClient().requestSgt(tgt, getServerPrincipal());
             assertThat(tkt).isNotNull();
diff --git a/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/PrincipalNameTest.java b/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/PrincipalNameTest.java
new file mode 100644
index 0000000..552d52f
--- /dev/null
+++ b/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/PrincipalNameTest.java
@@ -0,0 +1,59 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.kerby.kerberos.kerb.server;
+
+import java.io.IOException;
+
+import org.apache.kerby.KOptions;
+import org.apache.kerby.kerberos.kerb.KrbException;
+import org.apache.kerby.kerberos.kerb.client.KrbOption;
+import org.apache.kerby.kerberos.kerb.type.ticket.TgtTicket;
+import org.junit.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class PrincipalNameTest extends KdcTestBase {
+
+    @Test
+    public void testNTPrincipal() throws IOException, KrbException {
+
+        KOptions options = new KOptions();
+        options.add(KrbOption.CLIENT_PRINCIPAL, getClientPrincipal());
+        options.add(KrbOption.USER_PASSWD, getClientPassword());
+        options.add(KrbOption.USE_PASSWD, true);
+        
+        TgtTicket tgt = getKrbClient().requestTgt(options);
+        assertThat(tgt.getClientPrincipal().getName()).isEqualTo(getClientPrincipal());
+    }
+    
+    @Test
+    @org.junit.Ignore // See https://issues.apache.org/jira/browse/DIRKRB-659
+    public void testNTEnterprisePrincipal() throws IOException, KrbException {
+
+        KOptions options = new KOptions();
+        options.add(KrbOption.CLIENT_PRINCIPAL, getClientPrincipal());
+        options.add(KrbOption.USER_PASSWD, getClientPassword());
+        options.add(KrbOption.USE_PASSWD, true);
+        options.add(KrbOption.AS_ENTERPRISE_PN, true);
+        
+        TgtTicket tgt = getKrbClient().requestTgt(options);
+        assertThat(tgt.getClientPrincipal().getName()).isEqualTo(getClientPrincipal());
+    }
+}


[directory-kerby] 01/02: Fixing indentation

Posted by co...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/directory-kerby.git

commit 39bd0fcbf297b139e5974be2870b96c39a3207aa
Author: Colm O hEigeartaigh <co...@apache.org>
AuthorDate: Fri Jan 3 11:00:17 2020 +0000

    Fixing indentation
---
 .../src/main/java/org/apache/kerby/KOptions.java   | 56 +++++++++++-----------
 1 file changed, 28 insertions(+), 28 deletions(-)

diff --git a/kerby-common/kerby-util/src/main/java/org/apache/kerby/KOptions.java b/kerby-common/kerby-util/src/main/java/org/apache/kerby/KOptions.java
index d564f43..03ab1ed 100644
--- a/kerby-common/kerby-util/src/main/java/org/apache/kerby/KOptions.java
+++ b/kerby-common/kerby-util/src/main/java/org/apache/kerby/KOptions.java
@@ -90,36 +90,36 @@ public class KOptions {
         return true;
     }
 
-  public static int parseDuration(String strValue) {
-    int duration;
-    Matcher matcherColon = Pattern.compile("\\d+(?::\\d+){0,2}").matcher(strValue);
-    Matcher matcherWord = Pattern.compile("(?:(\\d+)D)?(?:(\\d+)H)?(?:(\\d+)M)?(?:(\\d+)S)?",
-        Pattern.CASE_INSENSITIVE).matcher(strValue);
-    if (matcherColon.matches()) {
-      String[] durations = strValue.split(":");
-      if (durations.length == 1) {
-          duration = Integer.parseInt(durations[0]);
-      } else if (durations.length == 2) {
-          duration = Integer.parseInt(durations[0]) * 3600 + Integer.parseInt(durations[1]) * 60;
-      } else {
-          duration = Integer.parseInt(durations[0]) * 3600 + Integer.parseInt(durations[1]) * 60;
-          duration += Integer.parseInt(durations[2]);
-      }
-    } else if (matcherWord.matches()) {
-        int[] durations = new int[4];
-        for (int i = 0; i < 4; i++) {
-          String durationMatch = matcherWord.group(i + 1);
-          if (durationMatch != null) {
-            durations[i] = Integer.parseInt(durationMatch);
-          }
+    public static int parseDuration(String strValue) {
+        int duration;
+        Matcher matcherColon = Pattern.compile("\\d+(?::\\d+){0,2}").matcher(strValue);
+        Matcher matcherWord = Pattern.compile("(?:(\\d+)D)?(?:(\\d+)H)?(?:(\\d+)M)?(?:(\\d+)S)?",
+                                              Pattern.CASE_INSENSITIVE).matcher(strValue);
+        if (matcherColon.matches()) {
+            String[] durations = strValue.split(":");
+            if (durations.length == 1) {
+                duration = Integer.parseInt(durations[0]);
+            } else if (durations.length == 2) {
+                duration = Integer.parseInt(durations[0]) * 3600 + Integer.parseInt(durations[1]) * 60;
+            } else {
+                duration = Integer.parseInt(durations[0]) * 3600 + Integer.parseInt(durations[1]) * 60;
+                duration += Integer.parseInt(durations[2]);
+            }
+        } else if (matcherWord.matches()) {
+            int[] durations = new int[4];
+            for (int i = 0; i < 4; i++) {
+                String durationMatch = matcherWord.group(i + 1);
+                if (durationMatch != null) {
+                    durations[i] = Integer.parseInt(durationMatch);
+                }
+            }
+            duration = durations[0] * 86400 + durations[1] * 3600 + durations[2] * 60 + durations[3];
+        } else {
+            throw new IllegalArgumentException("Text can't be parsed to a Duration: " + strValue);
         }
-        duration = durations[0] * 86400 + durations[1] * 3600 + durations[2] * 60 + durations[3];
-    } else {
-        throw new IllegalArgumentException("Text can't be parsed to a Duration: " + strValue);
-    }
 
-    return duration;
-  }
+        return duration;
+    }
 
     public void add(KOption option) {
         if (option != null) {