directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ha...@apache.org
Subject directory-kerberos git commit: Simplify the load method of Keytab.
Date Fri, 06 Feb 2015 13:53:59 GMT
Repository: directory-kerberos
Updated Branches:
  refs/heads/master 58b44ebed -> 44a42d10d


Simplify the load method of Keytab.


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

Branch: refs/heads/master
Commit: 44a42d10de01f0c4ff51d82a501a3c42dab39c0e
Parents: 58b44eb
Author: Lin <linchen7@foxmail.com>
Authored: Fri Feb 6 21:53:26 2015 +0800
Committer: Lin <linchen7@foxmail.com>
Committed: Fri Feb 6 21:53:26 2015 +0800

----------------------------------------------------------------------
 .../kerb/codec/kerberos/KerberosCredentials.java        |  3 +--
 .../org/apache/kerby/kerberos/kerb/keytab/Keytab.java   | 12 ++++++++++++
 .../apache/kerby/kerberos/kerb/util/EncryptionTest.java |  3 +--
 .../org/apache/kerby/kerberos/kerb/util/KeysTest.java   |  3 +--
 .../org/apache/kerby/kerberos/kerb/util/KeytabTest.java |  6 ++----
 5 files changed, 17 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/44a42d10/kerby-kerb/kerb-core-test/src/test/java/org/apache/kerby/kerberos/kerb/codec/kerberos/KerberosCredentials.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core-test/src/test/java/org/apache/kerby/kerberos/kerb/codec/kerberos/KerberosCredentials.java
b/kerby-kerb/kerb-core-test/src/test/java/org/apache/kerby/kerberos/kerb/codec/kerberos/KerberosCredentials.java
index 087fe42..aaad88e 100644
--- a/kerby-kerb/kerb-core-test/src/test/java/org/apache/kerby/kerberos/kerb/codec/kerberos/KerberosCredentials.java
+++ b/kerby-kerb/kerb-core-test/src/test/java/org/apache/kerby/kerberos/kerb/codec/kerberos/KerberosCredentials.java
@@ -34,8 +34,7 @@ public class KerberosCredentials {
 
     private static void init() throws IOException {
         InputStream kis = KerberosCredentials.class.getResourceAsStream("/server.keytab");
-        keytab = new Keytab();
-        keytab.load(kis);
+        keytab = Keytab.loadKeytab(kis);
     }
 
     public static EncryptionKey getServerKey(EncryptionType etype) throws IOException {

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/44a42d10/kerby-kerb/kerb-util/src/main/java/org/apache/kerby/kerberos/kerb/keytab/Keytab.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-util/src/main/java/org/apache/kerby/kerberos/kerb/keytab/Keytab.java
b/kerby-kerb/kerb-util/src/main/java/org/apache/kerby/kerberos/kerb/keytab/Keytab.java
index 4ffd058..f892abd 100644
--- a/kerby-kerb/kerb-util/src/main/java/org/apache/kerby/kerberos/kerb/keytab/Keytab.java
+++ b/kerby-kerb/kerb-util/src/main/java/org/apache/kerby/kerberos/kerb/keytab/Keytab.java
@@ -98,6 +98,18 @@ public class Keytab implements KrbKeytab {
         return null;
     }
 
+    public static Keytab loadKeytab(File keytabFile) throws IOException {
+        Keytab keytab = new Keytab();
+        keytab.load(keytabFile);
+        return keytab;
+    }
+
+    public static Keytab loadKeytab(InputStream inputStream) throws IOException {
+        Keytab keytab = new Keytab();
+        keytab.load(inputStream);
+        return keytab;
+    }
+
     @Override
     public void load(File keytabFile) throws IOException {
         if (! keytabFile.exists() || ! keytabFile.canRead()) {

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/44a42d10/kerby-kerb/kerb-util/src/test/java/org/apache/kerby/kerberos/kerb/util/EncryptionTest.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-util/src/test/java/org/apache/kerby/kerberos/kerb/util/EncryptionTest.java
b/kerby-kerb/kerb-util/src/test/java/org/apache/kerby/kerberos/kerb/util/EncryptionTest.java
index bbf7f93..9fb6f9e 100644
--- a/kerby-kerb/kerb-util/src/test/java/org/apache/kerby/kerberos/kerb/util/EncryptionTest.java
+++ b/kerby-kerb/kerb-util/src/test/java/org/apache/kerby/kerberos/kerb/util/EncryptionTest.java
@@ -59,8 +59,7 @@ public class EncryptionTest {
     @Before
     public void setUp() throws IOException {
         InputStream kis = EncryptionTest.class.getResourceAsStream("/krbtgt.keytab");
-        keytab = new Keytab();
-        keytab.load(kis);
+        keytab = Keytab.loadKeytab(kis);
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/44a42d10/kerby-kerb/kerb-util/src/test/java/org/apache/kerby/kerberos/kerb/util/KeysTest.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-util/src/test/java/org/apache/kerby/kerberos/kerb/util/KeysTest.java
b/kerby-kerb/kerb-util/src/test/java/org/apache/kerby/kerberos/kerb/util/KeysTest.java
index 8246e71..6cc98b1 100644
--- a/kerby-kerb/kerb-util/src/test/java/org/apache/kerby/kerberos/kerb/util/KeysTest.java
+++ b/kerby-kerb/kerb-util/src/test/java/org/apache/kerby/kerberos/kerb/util/KeysTest.java
@@ -56,8 +56,7 @@ public class KeysTest {
     @Before
     public void setUp() throws IOException {
         InputStream kis = KeysTest.class.getResourceAsStream("/test.keytab");
-        keytab = new Keytab();
-        keytab.load(kis);
+        keytab = Keytab.loadKeytab(kis);
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/44a42d10/kerby-kerb/kerb-util/src/test/java/org/apache/kerby/kerberos/kerb/util/KeytabTest.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-util/src/test/java/org/apache/kerby/kerberos/kerb/util/KeytabTest.java
b/kerby-kerb/kerb-util/src/test/java/org/apache/kerby/kerberos/kerb/util/KeytabTest.java
index 9c48c3b..63b9e5e 100644
--- a/kerby-kerb/kerb-util/src/test/java/org/apache/kerby/kerberos/kerb/util/KeytabTest.java
+++ b/kerby-kerb/kerb-util/src/test/java/org/apache/kerby/kerberos/kerb/util/KeytabTest.java
@@ -52,8 +52,7 @@ public class KeytabTest {
     @Before
     public void setUp() throws IOException {
         InputStream kis = KeytabTest.class.getResourceAsStream("/test.keytab");
-        keytab = new Keytab();
-        keytab.load(kis);
+        keytab = Keytab.loadKeytab(kis);
     }
 
     @Test
@@ -70,8 +69,7 @@ public class KeytabTest {
 
     public static void main(String[] args) throws IOException {
         InputStream kis = KeytabTest.class.getResourceAsStream("test.keytab");
-        Keytab keytab = new Keytab();
-        keytab.load(kis);
+        Keytab keytab = Keytab.loadKeytab(kis);
         System.out.println("Principals:" + keytab.getPrincipals().size());
     }
 }


Mime
View raw message