directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dran...@apache.org
Subject [1/2] directory-kerby git commit: PKIX. Renamed a package
Date Sat, 26 Dec 2015 21:50:36 GMT
Repository: directory-kerby
Updated Branches:
  refs/heads/master 15bb462ee -> a793d8642


PKIX. Renamed a package


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

Branch: refs/heads/master
Commit: f808cf34261a28d822ccaa42ac7415ce74fb8fd2
Parents: 15bb462
Author: Kai Zheng <kai.zheng@intel.com>
Authored: Sun Dec 27 04:41:40 2015 +0800
Committer: Kai Zheng <kai.zheng@intel.com>
Committed: Sun Dec 27 04:41:40 2015 +0800

----------------------------------------------------------------------
 .../kerby/kerberos/kdc/PkinitKdcTest.java       |   2 +-
 .../java/org/apache/kerby/pki/PkiLoader.java    | 114 -------------------
 .../java/org/apache/kerby/pkix/PkiLoader.java   | 114 +++++++++++++++++++
 .../org/apache/kerby/x509/PkiLoaderTest.java    |   2 +-
 4 files changed, 116 insertions(+), 116 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/f808cf34/kerby-kdc-test/src/test/java/org/apache/kerby/kerberos/kdc/PkinitKdcTest.java
----------------------------------------------------------------------
diff --git a/kerby-kdc-test/src/test/java/org/apache/kerby/kerberos/kdc/PkinitKdcTest.java
b/kerby-kdc-test/src/test/java/org/apache/kerby/kerberos/kdc/PkinitKdcTest.java
index 7a11eff..f226a97 100644
--- a/kerby-kdc-test/src/test/java/org/apache/kerby/kerberos/kdc/PkinitKdcTest.java
+++ b/kerby-kdc-test/src/test/java/org/apache/kerby/kerberos/kdc/PkinitKdcTest.java
@@ -25,7 +25,7 @@ import org.apache.kerby.kerberos.kerb.server.KdcConfigKey;
 import org.apache.kerby.kerberos.kerb.server.KdcTestBase;
 import org.apache.kerby.kerberos.kerb.type.ticket.SgtTicket;
 import org.apache.kerby.kerberos.kerb.type.ticket.TgtTicket;
-import org.apache.kerby.pki.PkiLoader;
+import org.apache.kerby.pkix.PkiLoader;
 import org.junit.Before;
 import org.junit.Test;
 

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/f808cf34/kerby-pkix/src/main/java/org/apache/kerby/pki/PkiLoader.java
----------------------------------------------------------------------
diff --git a/kerby-pkix/src/main/java/org/apache/kerby/pki/PkiLoader.java b/kerby-pkix/src/main/java/org/apache/kerby/pki/PkiLoader.java
deleted file mode 100644
index 7523f39..0000000
--- a/kerby-pkix/src/main/java/org/apache/kerby/pki/PkiLoader.java
+++ /dev/null
@@ -1,114 +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.pki;
-
-import org.apache.commons.ssl.PKCS8Key;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.security.GeneralSecurityException;
-import java.security.KeyFactory;
-import java.security.PrivateKey;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateFactory;
-import java.security.spec.PKCS8EncodedKeySpec;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-public class PkiLoader {
-
-    public List<Certificate> loadCerts(String certFile) throws IOException {
-        InputStream is;
-        try {
-            is = new FileInputStream(new File(certFile));
-        } catch (FileNotFoundException e) {
-            throw new IOException("No cert file found", e);
-        }
-        return loadCerts(is);
-    }
-
-    public List<Certificate> loadCerts(InputStream inputStream) throws IOException
{
-        CertificateFactory certFactory = null;
-        try {
-            certFactory = CertificateFactory.getInstance("X.509");
-            Collection<? extends Certificate> certs = (Collection<? extends Certificate>)
-                    certFactory.generateCertificates(inputStream);
-            return new ArrayList<Certificate>(certs);
-        } catch (CertificateException e) {
-            throw new IOException("Failed to load certificates", e);
-        }
-    }
-
-    public PrivateKey loadPrivateKey(String keyFile, String password) throws IOException
{
-        InputStream in = null;
-        try {
-            in = new FileInputStream("/path/to/pkcs8_private_key.der");
-        } catch (FileNotFoundException e) {
-            throw new IOException("No cert file found", e);
-        }
-        return loadPrivateKey(in, password);
-    }
-
-    public PrivateKey loadPrivateKey(InputStream inputStream, String password) throws IOException
{
-        try {
-            return doLoadPrivateKey(inputStream, password);
-        } catch (GeneralSecurityException e) {
-            throw new IOException("Failed to load private key", e);
-        } catch (IOException e) {
-            throw new IOException("Failed to load private key", e);
-        }
-    }
-
-    private PrivateKey doLoadPrivateKey(
-            InputStream inputStream, String password) throws GeneralSecurityException, IOException
{
-        if (password == null) {
-            password = "";
-        }
-        // If the provided InputStream is encrypted, we need a password to decrypt
-        // it. If the InputStream is not encrypted, then the password is ignored
-        // (can be null).  The InputStream can be DER (raw ASN.1) or PEM (base64).
-        PKCS8Key pkcs8 = new PKCS8Key(inputStream, password.toCharArray());
-
-        // If an unencrypted PKCS8 key was provided, then this actually returns
-        // exactly what was originally passed inputStream (with no changes).  If an OpenSSL
-        // key was provided, it gets reformatted as PKCS #8 first, and so these
-        // bytes will still be PKCS #8, not OpenSSL.
-        byte[] decrypted = pkcs8.getDecryptedBytes();
-        PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(decrypted);
-
-        // A Java PrivateKey object is born.
-        PrivateKey pk = null;
-        if (pkcs8.isDSA()) {
-            pk = KeyFactory.getInstance("DSA").generatePrivate(spec);
-        } else if (pkcs8.isRSA()) {
-            pk = KeyFactory.getInstance("RSA").generatePrivate(spec);
-        }
-
-        // For lazier types:
-        pk = pkcs8.getPrivateKey();
-
-        return pk;
-    }
-}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/f808cf34/kerby-pkix/src/main/java/org/apache/kerby/pkix/PkiLoader.java
----------------------------------------------------------------------
diff --git a/kerby-pkix/src/main/java/org/apache/kerby/pkix/PkiLoader.java b/kerby-pkix/src/main/java/org/apache/kerby/pkix/PkiLoader.java
new file mode 100644
index 0000000..402e5d4
--- /dev/null
+++ b/kerby-pkix/src/main/java/org/apache/kerby/pkix/PkiLoader.java
@@ -0,0 +1,114 @@
+/**
+ *  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.pkix;
+
+import org.apache.commons.ssl.PKCS8Key;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.GeneralSecurityException;
+import java.security.KeyFactory;
+import java.security.PrivateKey;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.security.spec.PKCS8EncodedKeySpec;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+public class PkiLoader {
+
+    public List<Certificate> loadCerts(String certFile) throws IOException {
+        InputStream is;
+        try {
+            is = new FileInputStream(new File(certFile));
+        } catch (FileNotFoundException e) {
+            throw new IOException("No cert file found", e);
+        }
+        return loadCerts(is);
+    }
+
+    public List<Certificate> loadCerts(InputStream inputStream) throws IOException
{
+        CertificateFactory certFactory = null;
+        try {
+            certFactory = CertificateFactory.getInstance("X.509");
+            Collection<? extends Certificate> certs =
+                certFactory.generateCertificates(inputStream);
+            return new ArrayList<>(certs);
+        } catch (CertificateException e) {
+            throw new IOException("Failed to load certificates", e);
+        }
+    }
+
+    public PrivateKey loadPrivateKey(String keyFile, String password) throws IOException
{
+        InputStream in = null;
+        try {
+            in = new FileInputStream("/path/to/pkcs8_private_key.der");
+        } catch (FileNotFoundException e) {
+            throw new IOException("No cert file found", e);
+        }
+        return loadPrivateKey(in, password);
+    }
+
+    public PrivateKey loadPrivateKey(InputStream inputStream, String password) throws IOException
{
+        try {
+            return doLoadPrivateKey(inputStream, password);
+        } catch (GeneralSecurityException e) {
+            throw new IOException("Failed to load private key", e);
+        } catch (IOException e) {
+            throw new IOException("Failed to load private key", e);
+        }
+    }
+
+    private PrivateKey doLoadPrivateKey(
+            InputStream inputStream, String password) throws GeneralSecurityException, IOException
{
+        if (password == null) {
+            password = "";
+        }
+        // If the provided InputStream is encrypted, we need a password to decrypt
+        // it. If the InputStream is not encrypted, then the password is ignored
+        // (can be null).  The InputStream can be DER (raw ASN.1) or PEM (base64).
+        PKCS8Key pkcs8 = new PKCS8Key(inputStream, password.toCharArray());
+
+        // If an unencrypted PKCS8 key was provided, then this actually returns
+        // exactly what was originally passed inputStream (with no changes).  If an OpenSSL
+        // key was provided, it gets reformatted as PKCS #8 first, and so these
+        // bytes will still be PKCS #8, not OpenSSL.
+        byte[] decrypted = pkcs8.getDecryptedBytes();
+        PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(decrypted);
+
+        // A Java PrivateKey object is born.
+        PrivateKey pk = null;
+        if (pkcs8.isDSA()) {
+            pk = KeyFactory.getInstance("DSA").generatePrivate(spec);
+        } else if (pkcs8.isRSA()) {
+            pk = KeyFactory.getInstance("RSA").generatePrivate(spec);
+        }
+
+        // For lazier types:
+        pk = pkcs8.getPrivateKey();
+
+        return pk;
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/f808cf34/kerby-pkix/src/test/java/org/apache/kerby/x509/PkiLoaderTest.java
----------------------------------------------------------------------
diff --git a/kerby-pkix/src/test/java/org/apache/kerby/x509/PkiLoaderTest.java b/kerby-pkix/src/test/java/org/apache/kerby/x509/PkiLoaderTest.java
index b78e466..c150fc4 100644
--- a/kerby-pkix/src/test/java/org/apache/kerby/x509/PkiLoaderTest.java
+++ b/kerby-pkix/src/test/java/org/apache/kerby/x509/PkiLoaderTest.java
@@ -19,7 +19,7 @@
  */
 package org.apache.kerby.x509;
 
-import org.apache.kerby.pki.PkiLoader;
+import org.apache.kerby.pkix.PkiLoader;
 import org.junit.Before;
 import org.junit.Test;
 


Mime
View raw message