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/01/25 06:26:18 UTC
[4/4] directory-kerberos git commit: Removed the ASN1 parsers
included in not-commons-ssl library using kerby-asn1
Removed the ASN1 parsers included in not-commons-ssl library using kerby-asn1
Project: http://git-wip-us.apache.org/repos/asf/directory-kerberos/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-kerberos/commit/5c70429d
Tree: http://git-wip-us.apache.org/repos/asf/directory-kerberos/tree/5c70429d
Diff: http://git-wip-us.apache.org/repos/asf/directory-kerberos/diff/5c70429d
Branch: refs/heads/master
Commit: 5c70429db4545ad6847d7f668e38ff9aee3844f4
Parents: 21f0e41
Author: Drankye <dr...@gmail.com>
Authored: Sun Jan 25 21:23:11 2015 +0800
Committer: Drankye <dr...@gmail.com>
Committed: Sun Jan 25 21:23:11 2015 +0800
----------------------------------------------------------------------
3rdparty/not-yet-commons-ssl/pom.xml | 5 +
.../org/apache/commons/ssl/ASN1Structure.java | 112 -----
.../java/org/apache/commons/ssl/ASN1Util.java | 211 ----------
.../apache/commons/ssl/Asn1PkcsStructure.java | 107 +++++
.../org/apache/commons/ssl/Asn1PkcsUtil.java | 185 ++++++++
.../org/apache/commons/ssl/KeyStoreBuilder.java | 78 ++--
.../java/org/apache/commons/ssl/PKCS8Key.java | 103 ++---
.../org/apache/commons/ssl/asn1/ASN1Choice.java | 13 -
.../apache/commons/ssl/asn1/ASN1Encodable.java | 74 ----
.../commons/ssl/asn1/ASN1EncodableVector.java | 10 -
.../apache/commons/ssl/asn1/ASN1Generator.java | 13 -
.../commons/ssl/asn1/ASN1InputStream.java | 420 -------------------
.../org/apache/commons/ssl/asn1/ASN1Null.java | 30 --
.../org/apache/commons/ssl/asn1/ASN1Object.java | 34 --
.../commons/ssl/asn1/ASN1ObjectParser.java | 55 ---
.../commons/ssl/asn1/ASN1OctetString.java | 137 ------
.../commons/ssl/asn1/ASN1OctetStringParser.java | 8 -
.../commons/ssl/asn1/ASN1OutputStream.java | 26 --
.../apache/commons/ssl/asn1/ASN1Sequence.java | 183 --------
.../commons/ssl/asn1/ASN1SequenceParser.java | 9 -
.../org/apache/commons/ssl/asn1/ASN1Set.java | 281 -------------
.../apache/commons/ssl/asn1/ASN1SetParser.java | 9 -
.../commons/ssl/asn1/ASN1StreamParser.java | 193 ---------
.../commons/ssl/asn1/ASN1TaggedObject.java | 177 --------
.../ssl/asn1/ASN1TaggedObjectParser.java | 11 -
.../ssl/asn1/BERConstructedOctetString.java | 137 ------
.../ssl/asn1/BERConstructedSequence.java | 29 --
.../apache/commons/ssl/asn1/BERGenerator.java | 82 ----
.../apache/commons/ssl/asn1/BERInputStream.java | 179 --------
.../org/apache/commons/ssl/asn1/BERNull.java | 22 -
.../ssl/asn1/BEROctetStringGenerator.java | 86 ----
.../commons/ssl/asn1/BEROctetStringParser.java | 36 --
.../commons/ssl/asn1/BEROutputStream.java | 26 --
.../apache/commons/ssl/asn1/BERSequence.java | 44 --
.../commons/ssl/asn1/BERSequenceGenerator.java | 36 --
.../commons/ssl/asn1/BERSequenceParser.java | 21 -
.../org/apache/commons/ssl/asn1/BERSet.java | 51 ---
.../apache/commons/ssl/asn1/BERSetParser.java | 21 -
.../commons/ssl/asn1/BERTaggedObject.java | 94 -----
.../commons/ssl/asn1/BERTaggedObjectParser.java | 118 ------
.../ssl/asn1/ConstructedOctetStream.java | 92 ----
.../ssl/asn1/DERApplicationSpecific.java | 143 -------
.../apache/commons/ssl/asn1/DERBMPString.java | 104 -----
.../apache/commons/ssl/asn1/DERBitString.java | 245 -----------
.../org/apache/commons/ssl/asn1/DERBoolean.java | 96 -----
.../ssl/asn1/DERConstructedSequence.java | 46 --
.../commons/ssl/asn1/DERConstructedSet.java | 63 ---
.../apache/commons/ssl/asn1/DEREncodable.java | 5 -
.../commons/ssl/asn1/DEREncodableVector.java | 31 --
.../apache/commons/ssl/asn1/DEREnumerated.java | 96 -----
.../commons/ssl/asn1/DERGeneralString.java | 75 ----
.../commons/ssl/asn1/DERGeneralizedTime.java | 242 -----------
.../apache/commons/ssl/asn1/DERGenerator.java | 108 -----
.../apache/commons/ssl/asn1/DERIA5String.java | 142 -------
.../apache/commons/ssl/asn1/DERInputStream.java | 237 -----------
.../org/apache/commons/ssl/asn1/DERInteger.java | 114 -----
.../org/apache/commons/ssl/asn1/DERNull.java | 20 -
.../commons/ssl/asn1/DERNumericString.java | 148 -------
.../org/apache/commons/ssl/asn1/DERObject.java | 18 -
.../commons/ssl/asn1/DERObjectIdentifier.java | 245 -----------
.../apache/commons/ssl/asn1/DEROctetString.java | 23 -
.../commons/ssl/asn1/DEROutputStream.java | 73 ----
.../commons/ssl/asn1/DERPrintableString.java | 172 --------
.../apache/commons/ssl/asn1/DERSequence.java | 62 ---
.../commons/ssl/asn1/DERSequenceGenerator.java | 39 --
.../org/apache/commons/ssl/asn1/DERSet.java | 76 ----
.../org/apache/commons/ssl/asn1/DERString.java | 6 -
.../apache/commons/ssl/asn1/DERT61String.java | 103 -----
.../commons/ssl/asn1/DERTaggedObject.java | 74 ----
.../org/apache/commons/ssl/asn1/DERTags.java | 35 --
.../org/apache/commons/ssl/asn1/DERUTCTime.java | 214 ----------
.../apache/commons/ssl/asn1/DERUTF8String.java | 83 ----
.../commons/ssl/asn1/DERUniversalString.java | 100 -----
.../apache/commons/ssl/asn1/DERUnknownTag.java | 71 ----
.../commons/ssl/asn1/DERVisibleString.java | 103 -----
.../ssl/asn1/DefiniteLengthInputStream.java | 83 ----
.../ssl/asn1/IndefiniteLengthInputStream.java | 98 -----
.../commons/ssl/asn1/LimitedInputStream.java | 23 -
.../apache/commons/ssl/asn1/OIDTokenizer.java | 42 --
.../org/apache/commons/ssl/asn1/Strings.java | 195 ---------
.../org/apache/commons/ssl/TestPKCS8Key.java | 21 +-
.../apache/kerby/asn1/type/Asn1BigInteger.java | 48 ---
.../org/apache/kerby/asn1/type/Asn1Choice.java | 2 +-
.../kerby/asn1/type/Asn1CollectionType.java | 4 +-
.../org/apache/kerby/asn1/type/Asn1Integer.java | 18 +-
.../org/apache/kerby/asn1/type/Asn1Null.java | 10 +-
.../org/apache/kerby/asn1/type/Asn1Simple.java | 12 +-
.../org/apache/kerby/asn1/PersonnelRecord.java | 4 +-
.../org/apache/kerby/asn1/TestAsn1Integer.java | 4 +-
.../kerby/kerberos/kerb/spec/KrbIntegers.java | 2 +-
90 files changed, 419 insertions(+), 7117 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/5c70429d/3rdparty/not-yet-commons-ssl/pom.xml
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/pom.xml b/3rdparty/not-yet-commons-ssl/pom.xml
index 92dcd42..ae3bf0f 100644
--- a/3rdparty/not-yet-commons-ssl/pom.xml
+++ b/3rdparty/not-yet-commons-ssl/pom.xml
@@ -63,6 +63,11 @@
<dependencies>
<dependency>
+ <groupId>org.apache.kerby</groupId>
+ <artifactId>kerby-asn1</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-ext-jdk15on</artifactId>
<version>1.51</version>
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/5c70429d/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/ASN1Structure.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/ASN1Structure.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/ASN1Structure.java
deleted file mode 100644
index d9df5b9..0000000
--- a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/ASN1Structure.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * $HeadURL: http://juliusdavies.ca/svn/not-yet-commons-ssl/tags/commons-ssl-0.3.16/src/java/org/apache/commons/ssl/ASN1Structure.java $
- * $Revision: 121 $
- * $Date: 2007-11-13 21:26:57 -0800 (Tue, 13 Nov 2007) $
- *
- * ====================================================================
- * 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- */
-
-package org.apache.commons.ssl;
-
-import org.apache.commons.ssl.util.Hex;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
-
-/**
- * @author Credit Union Central of British Columbia
- * @author <a href="http://www.cucbc.com/">www.cucbc.com</a>
- * @author <a href="mailto:juliusdavies@cucbc.com">juliusdavies@cucbc.com</a>
- * @since 16-Nov-2005
- */
-class ASN1Structure {
- List derIntegers = new LinkedList();
- Set oids = new TreeSet();
- String oid1;
- String oid2;
- String oid3;
- byte[] salt;
- byte[] iv;
- int iterationCount;
- int keySize;
- byte[] bigPayload;
- byte[] smallPayload;
-
- public String toString() {
- StringBuffer buf = new StringBuffer(256);
- buf.append("------ ASN.1 PKCS Structure ------");
- buf.append("\noid1: ");
- buf.append(oid1);
- if (oid2 != null) {
- buf.append("\noid2: ");
- buf.append(oid2);
- }
- buf.append("\nsalt: ");
- if (salt != null) {
- buf.append(Hex.encode(salt));
- } else {
- buf.append("[null]");
- }
- buf.append("\nic: ");
- buf.append(Integer.toString(iterationCount));
- if (keySize != 0) {
- buf.append("\nkeySize: ");
- buf.append(Integer.toString(keySize * 8));
- }
- if (oid2 != null) {
- buf.append("\noid3: ");
- buf.append(oid3);
- }
- if (oid2 != null) {
- buf.append("\niv: ");
- if (iv != null) {
- buf.append(Hex.encode(iv));
- } else {
- buf.append("[null]");
- }
- }
- if (bigPayload != null) {
- buf.append("\nbigPayload-length: ");
- buf.append(bigPayload.length);
- }
- if (smallPayload != null) {
- buf.append("\nsmallPayload-length: ");
- buf.append(smallPayload.length);
- }
- if (!oids.isEmpty()) {
- Iterator it = oids.iterator();
- buf.append("\nAll oids:");
- while (it.hasNext()) {
- buf.append("\n");
- buf.append((String) it.next());
- }
- }
- return buf.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/5c70429d/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/ASN1Util.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/ASN1Util.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/ASN1Util.java
deleted file mode 100644
index 1cb7764..0000000
--- a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/ASN1Util.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * $HeadURL: http://juliusdavies.ca/svn/not-yet-commons-ssl/tags/commons-ssl-0.3.16/src/java/org/apache/commons/ssl/ASN1Util.java $
- * $Revision: 121 $
- * $Date: 2007-11-13 21:26:57 -0800 (Tue, 13 Nov 2007) $
- *
- * ====================================================================
- * 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- */
-
-package org.apache.commons.ssl;
-
-import org.apache.commons.ssl.asn1.ASN1InputStream;
-import org.apache.commons.ssl.asn1.DEREncodable;
-import org.apache.commons.ssl.asn1.DERInteger;
-import org.apache.commons.ssl.asn1.DERObjectIdentifier;
-import org.apache.commons.ssl.asn1.DEROctetString;
-import org.apache.commons.ssl.asn1.DERPrintableString;
-import org.apache.commons.ssl.asn1.DERSequence;
-import org.apache.commons.ssl.asn1.DERSet;
-import org.apache.commons.ssl.asn1.DERTaggedObject;
-import org.apache.commons.ssl.util.Hex;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.math.BigInteger;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.Vector;
-
-/**
- * @author Credit Union Central of British Columbia
- * @author <a href="http://www.cucbc.com/">www.cucbc.com</a>
- * @author <a href="mailto:juliusdavies@cucbc.com">juliusdavies@cucbc.com</a>
- * @since 16-Nov-2005
- */
-public class ASN1Util {
- public static boolean DEBUG = false;
- public final static BigInteger BIGGEST =
- new BigInteger(Integer.toString(Integer.MAX_VALUE));
-
- public static ASN1Structure analyze(byte[] asn1)
- throws IOException {
- ASN1InputStream asn = new ASN1InputStream(asn1);
- DERSequence seq = (DERSequence) asn.readObject();
- ASN1Structure pkcs8 = new ASN1Structure();
- ASN1Util.analyze(seq, pkcs8, 0);
- return pkcs8;
- }
-
- public static void main(String[] args) throws Exception {
- DEBUG = true;
- FileInputStream in = new FileInputStream(args[0]);
- byte[] bytes = Util.streamToBytes(in);
- List list = PEMUtil.decode(bytes);
- if (!list.isEmpty()) {
- bytes = ((PEMItem) list.get(0)).getDerBytes();
- }
-
- ASN1Structure asn1 = analyze(bytes);
- while (asn1.bigPayload != null) {
- System.out.println("------------------------------------------");
- System.out.println(asn1);
- System.out.println("------------------------------------------");
- asn1 = analyze(asn1.bigPayload);
- }
- }
-
-
- public static void analyze(DEREncodable seq, ASN1Structure pkcs8,
- int depth) {
- String tag = null;
- if (depth >= 2) {
- pkcs8.derIntegers = null;
- }
- Enumeration en;
- if (seq instanceof DERSequence) {
- en = ((DERSequence) seq).getObjects();
- } else if (seq instanceof DERSet) {
- en = ((DERSet) seq).getObjects();
- } else if (seq instanceof DERTaggedObject) {
- DERTaggedObject derTag = (DERTaggedObject) seq;
- tag = Integer.toString(derTag.getTagNo());
- Vector v = new Vector();
- v.add(derTag.getObject());
- en = v.elements();
- } else {
- throw new IllegalArgumentException("DEREncodable must be one of: DERSequence, DERSet, DERTaggedObject");
- }
- while (en != null && en.hasMoreElements()) {
- DEREncodable obj = (DEREncodable) en.nextElement();
- if (!(obj instanceof DERSequence) &&
- !(obj instanceof DERSet) &&
- !(obj instanceof DERTaggedObject)) {
- String str = obj.toString();
- String name = obj.getClass().getName();
- name = name.substring(name.lastIndexOf('.') + 1);
- if (tag != null) {
- name = " [tag=" + tag + "] " + name;
- }
- for (int i = 0; i < depth; i++) {
- name = " " + name;
- }
- if (obj instanceof DERInteger) {
- DERInteger dInt = (DERInteger) obj;
- if (pkcs8.derIntegers != null) {
- pkcs8.derIntegers.add(dInt);
- }
- BigInteger big = dInt.getValue();
- int intValue = big.intValue();
- if (BIGGEST.compareTo(big) >= 0 && intValue > 0) {
- if (pkcs8.iterationCount == 0) {
- pkcs8.iterationCount = intValue;
- } else if (pkcs8.keySize == 0) {
- pkcs8.keySize = intValue;
- }
- }
- str = dInt.getValue().toString();
- } else if (obj instanceof DERObjectIdentifier) {
- DERObjectIdentifier id = (DERObjectIdentifier) obj;
- str = id.getId();
- pkcs8.oids.add(str);
- if (pkcs8.oid1 == null) {
- pkcs8.oid1 = str;
- } else if (pkcs8.oid2 == null) {
- pkcs8.oid2 = str;
- } else if (pkcs8.oid3 == null) {
- pkcs8.oid3 = str;
- }
- } else {
- pkcs8.derIntegers = null;
- if (obj instanceof DEROctetString) {
- DEROctetString oct = (DEROctetString) obj;
- byte[] octets = oct.getOctets();
- int len = Math.min(10, octets.length);
- boolean probablyBinary = false;
- for (int i = 0; i < len; i++) {
- byte b = octets[i];
- boolean isBinary = b > 128 || b < 0;
- if (isBinary) {
- probablyBinary = true;
- break;
- }
- }
- if (probablyBinary && octets.length > 64) {
- if (pkcs8.bigPayload == null) {
- pkcs8.bigPayload = octets;
- }
- str = "probably binary";
- } else {
- str = Hex.encode(octets);
- if (octets.length <= 64) {
- if (octets.length % 8 == 0) {
- if (pkcs8.salt == null) {
- pkcs8.salt = octets;
- } else if (pkcs8.iv == null) {
- pkcs8.iv = octets;
- }
- } else {
- if (pkcs8.smallPayload == null) {
- pkcs8.smallPayload = octets;
- }
- }
- }
- }
- str += " (length=" + octets.length + ")";
- } else if (obj instanceof DERPrintableString) {
- DERPrintableString dps = (DERPrintableString) obj;
- str = dps.getString();
- }
- }
-
- if (DEBUG) {
- System.out.println(name + ": [" + str + "]");
- }
- } else {
- if (tag != null && DEBUG) {
- String name = obj.getClass().getName();
- name = name.substring(name.lastIndexOf('.') + 1);
- name = " [tag=" + tag + "] " + name;
- for (int i = 0; i < depth; i++) {
- name = " " + name;
- }
- System.out.println(name);
- }
- analyze(obj, pkcs8, depth + 1);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/5c70429d/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/Asn1PkcsStructure.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/Asn1PkcsStructure.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/Asn1PkcsStructure.java
new file mode 100644
index 0000000..e00d58d
--- /dev/null
+++ b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/Asn1PkcsStructure.java
@@ -0,0 +1,107 @@
+/*
+ * 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.
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.commons.ssl;
+
+import org.apache.commons.ssl.util.Hex;
+import org.apache.kerby.asn1.type.Asn1Integer;
+
+import java.util.*;
+
+/**
+ * @author Credit Union Central of British Columbia
+ * @author <a href="http://www.cucbc.com/">www.cucbc.com</a>
+ * @author <a href="mailto:juliusdavies@cucbc.com">juliusdavies@cucbc.com</a>
+ * @since 16-Nov-2005
+ */
+
+/**
+ * Adapted from not-yet-commons-ssl ASN1Structure
+ */
+class Asn1PkcsStructure {
+ List<Asn1Integer> derIntegers = new LinkedList<Asn1Integer>();
+ Set oids = new TreeSet();
+ String oid1;
+ String oid2;
+ String oid3;
+ byte[] salt;
+ byte[] iv;
+ int iterationCount;
+ int keySize;
+ byte[] bigPayload;
+ byte[] smallPayload;
+
+ public String toString() {
+ StringBuffer buf = new StringBuffer(256);
+ buf.append("------ ASN.1 PKCS Structure ------");
+ buf.append("\noid1: ");
+ buf.append(oid1);
+ if (oid2 != null) {
+ buf.append("\noid2: ");
+ buf.append(oid2);
+ }
+ buf.append("\nsalt: ");
+ if (salt != null) {
+ buf.append(Hex.encode(salt));
+ } else {
+ buf.append("[null]");
+ }
+ buf.append("\nic: ");
+ buf.append(Integer.toString(iterationCount));
+ if (keySize != 0) {
+ buf.append("\nkeySize: ");
+ buf.append(Integer.toString(keySize * 8));
+ }
+ if (oid2 != null) {
+ buf.append("\noid3: ");
+ buf.append(oid3);
+ }
+ if (oid2 != null) {
+ buf.append("\niv: ");
+ if (iv != null) {
+ buf.append(Hex.encode(iv));
+ } else {
+ buf.append("[null]");
+ }
+ }
+ if (bigPayload != null) {
+ buf.append("\nbigPayload-length: ");
+ buf.append(bigPayload.length);
+ }
+ if (smallPayload != null) {
+ buf.append("\nsmallPayload-length: ");
+ buf.append(smallPayload.length);
+ }
+ if (!oids.isEmpty()) {
+ Iterator it = oids.iterator();
+ buf.append("\nAll oids:");
+ while (it.hasNext()) {
+ buf.append("\n");
+ buf.append((String) it.next());
+ }
+ }
+ return buf.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/5c70429d/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/Asn1PkcsUtil.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/Asn1PkcsUtil.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/Asn1PkcsUtil.java
new file mode 100644
index 0000000..4f6823a
--- /dev/null
+++ b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/Asn1PkcsUtil.java
@@ -0,0 +1,185 @@
+/*
+ * 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.
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.commons.ssl;
+
+import org.apache.commons.ssl.util.Hex;
+import org.apache.kerby.asn1.Asn1InputBuffer;
+import org.apache.kerby.asn1.type.*;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.math.BigInteger;
+import java.util.List;
+
+/**
+ * @author Credit Union Central of British Columbia
+ * @author <a href="http://www.cucbc.com/">www.cucbc.com</a>
+ * @author <a href="mailto:juliusdavies@cucbc.com">juliusdavies@cucbc.com</a>
+ * @since 16-Nov-2005
+ */
+
+/**
+ * Adapted from ASN1Util in not-yet-commons-ssl
+ */
+public class Asn1PkcsUtil {
+
+ public final static BigInteger BIGGEST =
+ new BigInteger(Integer.toString(Integer.MAX_VALUE));
+
+ public static Asn1PkcsStructure analyze(byte[] asn1)
+ throws IOException {
+ Asn1InputBuffer asn = new Asn1InputBuffer(asn1);
+ Asn1Type asn1Obj;
+
+ Asn1PkcsStructure pkcs8 = new Asn1PkcsStructure();
+ while ((asn1Obj = asn.read()) != null) {
+ if (asn1Obj instanceof Asn1Collection) {
+ Asn1PkcsUtil.analyze((Asn1Collection) asn1Obj, pkcs8, 0);
+ } else {
+ Asn1PkcsUtil.analyze(asn1Obj, pkcs8, 0);
+ }
+ }
+
+ return pkcs8;
+ }
+
+ public static void analyze(Asn1Collection asn1Coll, Asn1PkcsStructure pkcs8, int depth) {
+ if (depth >= 2) {
+ pkcs8.derIntegers = null;
+ }
+
+ List<Asn1Item> items = asn1Coll.getValue();
+ for (Asn1Item item : items) {
+ if (! item.isCollection()) {
+ analyze(item.getValue(), pkcs8, depth);
+ } else {
+ try {
+ item.decodeValueAsCollection();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ analyze((Asn1Collection) item.getValue(), pkcs8, depth + 1);
+ }
+ }
+ }
+
+ public static void analyze(Asn1Type obj, Asn1PkcsStructure pkcs8, int depth) {
+ String tag = null;
+ if (depth >= 2) {
+ pkcs8.derIntegers = null;
+ }
+
+ String str = obj.toString();
+ String name = obj.getClass().getName();
+ name = name.substring(name.lastIndexOf('.') + 1);
+ if (tag != null) {
+ name = " [tag=" + tag + "] " + name;
+ }
+ for (int i = 0; i < depth; i++) {
+ name = " " + name;
+ }
+
+ if (obj instanceof Asn1Integer) {
+ Asn1Integer dInt = (Asn1Integer) obj;
+ if (pkcs8.derIntegers != null) {
+ pkcs8.derIntegers.add(dInt);
+ }
+ BigInteger big = dInt.getValue();
+ int intValue = big.intValue();
+ if (BIGGEST.compareTo(big) >= 0 && intValue > 0) {
+ if (pkcs8.iterationCount == 0) {
+ pkcs8.iterationCount = intValue;
+ } else if (pkcs8.keySize == 0) {
+ pkcs8.keySize = intValue;
+ }
+ }
+ } else if (obj instanceof Asn1ObjectIdentifier) {
+ Asn1ObjectIdentifier id = (Asn1ObjectIdentifier) obj;
+ str = id.getValue();
+ pkcs8.oids.add(str);
+ if (pkcs8.oid1 == null) {
+ pkcs8.oid1 = str;
+ } else if (pkcs8.oid2 == null) {
+ pkcs8.oid2 = str;
+ } else if (pkcs8.oid3 == null) {
+ pkcs8.oid3 = str;
+ }
+ } else {
+ pkcs8.derIntegers = null;
+ if (obj instanceof Asn1OctetString) {
+ Asn1OctetString oct = (Asn1OctetString) obj;
+ byte[] octets = oct.getValue();
+ int len = Math.min(10, octets.length);
+ boolean probablyBinary = false;
+ for (int i = 0; i < len; i++) {
+ byte b = octets[i];
+ boolean isBinary = b > 128 || b < 0;
+ if (isBinary) {
+ probablyBinary = true;
+ break;
+ }
+ }
+ if (probablyBinary && octets.length > 64) {
+ if (pkcs8.bigPayload == null) {
+ pkcs8.bigPayload = octets;
+ }
+ } else {
+ str = Hex.encode(octets);
+ if (octets.length <= 64) {
+ if (octets.length % 8 == 0) {
+ if (pkcs8.salt == null) {
+ pkcs8.salt = octets;
+ } else if (pkcs8.iv == null) {
+ pkcs8.iv = octets;
+ }
+ } else {
+ if (pkcs8.smallPayload == null) {
+ pkcs8.smallPayload = octets;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ FileInputStream in = new FileInputStream(args[0]);
+ byte[] bytes = Util.streamToBytes(in);
+ List list = PEMUtil.decode(bytes);
+ if (!list.isEmpty()) {
+ bytes = ((PEMItem) list.get(0)).getDerBytes();
+ }
+
+ Asn1PkcsStructure asn1 = analyze(bytes);
+ while (asn1.bigPayload != null) {
+ System.out.println("------------------------------------------");
+ System.out.println(asn1);
+ System.out.println("------------------------------------------");
+ asn1 = analyze(asn1.bigPayload);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/5c70429d/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/KeyStoreBuilder.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/KeyStoreBuilder.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/KeyStoreBuilder.java
index 9f635ae..398f1a6 100644
--- a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/KeyStoreBuilder.java
+++ b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/KeyStoreBuilder.java
@@ -31,26 +31,12 @@
package org.apache.commons.ssl;
-import org.apache.commons.ssl.asn1.ASN1EncodableVector;
-import org.apache.commons.ssl.asn1.DERInteger;
-import org.apache.commons.ssl.asn1.DERSequence;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
+import org.apache.kerby.asn1.type.Asn1Integer;
+import org.apache.kerby.asn1.type.Asn1Sequence;
+
+import java.io.*;
import java.math.BigInteger;
-import java.security.GeneralSecurityException;
-import java.security.InvalidKeyException;
-import java.security.Key;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.PrivateKey;
-import java.security.PublicKey;
-import java.security.UnrecoverableKeyException;
+import java.security.*;
import java.security.cert.Certificate;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
@@ -59,13 +45,7 @@ import java.security.interfaces.DSAParams;
import java.security.interfaces.DSAPrivateKey;
import java.security.interfaces.RSAPrivateCrtKey;
import java.security.interfaces.RSAPublicKey;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
+import java.util.*;
/**
* Builds Java Key Store files out of pkcs12 files, or out of pkcs8 files +
@@ -363,13 +343,13 @@ public class KeyStoreBuilder {
boolean isProbablyPKCS12 = false;
boolean isASN = false;
- ASN1Structure asn1 = null;
+ Asn1PkcsStructure asn1 = null;
try {
- asn1 = ASN1Util.analyze(stuff);
+ asn1 = Asn1PkcsUtil.analyze(stuff);
isASN = true;
isProbablyPKCS12 = asn1.oids.contains(PKCS7_ENCRYPTED);
if (!isProbablyPKCS12 && asn1.bigPayload != null) {
- asn1 = ASN1Util.analyze(asn1.bigPayload);
+ asn1 = Asn1PkcsUtil.analyze(asn1.bigPayload);
isProbablyPKCS12 = asn1.oids.contains(PKCS7_ENCRYPTED);
}
}
@@ -632,18 +612,17 @@ public class KeyStoreBuilder {
byte[] pkcs8DerBytes = null;
if (key instanceof RSAPrivateCrtKey) {
RSAPrivateCrtKey rsa = (RSAPrivateCrtKey) key;
- ASN1EncodableVector vec = new ASN1EncodableVector();
- vec.add(new DERInteger(BigInteger.ZERO));
- vec.add(new DERInteger(rsa.getModulus()));
- vec.add(new DERInteger(rsa.getPublicExponent()));
- vec.add(new DERInteger(rsa.getPrivateExponent()));
- vec.add(new DERInteger(rsa.getPrimeP()));
- vec.add(new DERInteger(rsa.getPrimeQ()));
- vec.add(new DERInteger(rsa.getPrimeExponentP()));
- vec.add(new DERInteger(rsa.getPrimeExponentQ()));
- vec.add(new DERInteger(rsa.getCrtCoefficient()));
- DERSequence seq = new DERSequence(vec);
- byte[] derBytes = PKCS8Key.encode(seq);
+ Asn1Sequence seq = new Asn1Sequence();
+ seq.addItem(new Asn1Integer(BigInteger.ZERO));
+ seq.addItem(new Asn1Integer(rsa.getModulus()));
+ seq.addItem(new Asn1Integer(rsa.getPublicExponent()));
+ seq.addItem(new Asn1Integer(rsa.getPrivateExponent()));
+ seq.addItem(new Asn1Integer(rsa.getPrimeP()));
+ seq.addItem(new Asn1Integer(rsa.getPrimeQ()));
+ seq.addItem(new Asn1Integer(rsa.getPrimeExponentP()));
+ seq.addItem(new Asn1Integer(rsa.getPrimeExponentQ()));
+ seq.addItem(new Asn1Integer(rsa.getCrtCoefficient()));
+ byte[] derBytes = seq.encode();
PKCS8Key pkcs8 = new PKCS8Key(derBytes, null);
pkcs8DerBytes = pkcs8.getDecryptedBytes();
} else if (key instanceof DSAPrivateKey) {
@@ -655,15 +634,14 @@ public class KeyStoreBuilder {
BigInteger x = dsa.getX();
BigInteger y = q.modPow(x, p);
- ASN1EncodableVector vec = new ASN1EncodableVector();
- vec.add(new DERInteger(BigInteger.ZERO));
- vec.add(new DERInteger(p));
- vec.add(new DERInteger(q));
- vec.add(new DERInteger(g));
- vec.add(new DERInteger(y));
- vec.add(new DERInteger(x));
- DERSequence seq = new DERSequence(vec);
- byte[] derBytes = PKCS8Key.encode(seq);
+ Asn1Sequence seq = new Asn1Sequence();
+ seq.addItem(new Asn1Integer(BigInteger.ZERO));
+ seq.addItem(new Asn1Integer(p));
+ seq.addItem(new Asn1Integer(q));
+ seq.addItem(new Asn1Integer(g));
+ seq.addItem(new Asn1Integer(y));
+ seq.addItem(new Asn1Integer(x));
+ byte[] derBytes = seq.encode();
PKCS8Key pkcs8 = new PKCS8Key(derBytes, null);
pkcs8DerBytes = pkcs8.getDecryptedBytes();
}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/5c70429d/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/PKCS8Key.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/PKCS8Key.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/PKCS8Key.java
index 986edda..f63d4e3 100644
--- a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/PKCS8Key.java
+++ b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/PKCS8Key.java
@@ -31,7 +31,7 @@
package org.apache.commons.ssl;
-import org.apache.commons.ssl.asn1.*;
+import org.apache.kerby.asn1.type.*;
import javax.crypto.*;
import javax.crypto.spec.IvParameterSpec;
@@ -182,9 +182,9 @@ public class PKCS8Key {
}
}
- ASN1Structure pkcs8;
+ Asn1PkcsStructure pkcs8;
try {
- pkcs8 = ASN1Util.analyze(derBytes);
+ pkcs8 = Asn1PkcsUtil.analyze(derBytes);
}
catch (Exception e) {
throw new ProbablyNotPKCS8Exception("asn1 parse failure: " + e);
@@ -239,7 +239,7 @@ public class PKCS8Key {
}
if (encrypted) {
try {
- pkcs8 = ASN1Util.analyze(decryptedPKCS8);
+ pkcs8 = Asn1PkcsUtil.analyze(decryptedPKCS8);
}
catch (Exception e) {
throw new ProbablyBadPasswordException("Decrypted stream not ASN.1. Probably bad decryption password.");
@@ -438,7 +438,7 @@ public class PKCS8Key {
return new DecryptResult(transformation, keySize, decryptedBytes);
}
- private static DecryptResult decryptPKCS8(ASN1Structure pkcs8,
+ private static DecryptResult decryptPKCS8(Asn1PkcsStructure pkcs8,
char[] password)
throws GeneralSecurityException {
boolean isVersion1 = true;
@@ -898,57 +898,50 @@ public class PKCS8Key {
}
public static byte[] formatAsPKCS8(byte[] privateKey, String oid,
- ASN1Structure pkcs8) {
- DERInteger derZero = new DERInteger(BigInteger.ZERO);
- ASN1EncodableVector outterVec = new ASN1EncodableVector();
- ASN1EncodableVector innerVec = new ASN1EncodableVector();
- DEROctetString octetsToAppend;
- try {
- DERObjectIdentifier derOID = new DERObjectIdentifier(oid);
- innerVec.add(derOID);
- if (DSA_OID.equals(oid)) {
- if (pkcs8 == null) {
- try {
- pkcs8 = ASN1Util.analyze(privateKey);
- }
- catch (Exception e) {
- throw new RuntimeException("asn1 parse failure " + e);
- }
+ Asn1PkcsStructure pkcs8) {
+ Asn1Integer derZero = new Asn1Integer(BigInteger.ZERO);
+ Asn1Sequence outterSeq = new Asn1Sequence();
+ Asn1Sequence innerSeq = new Asn1Sequence();
+ Asn1OctetString octetsToAppend;
+ Asn1ObjectIdentifier derOID = new Asn1ObjectIdentifier(oid);
+ innerSeq.addItem(derOID);
+ if (DSA_OID.equals(oid)) {
+ if (pkcs8 == null) {
+ try {
+ pkcs8 = Asn1PkcsUtil.analyze(privateKey);
}
- if (pkcs8.derIntegers == null || pkcs8.derIntegers.size() < 6) {
- throw new RuntimeException("invalid DSA key - can't find P, Q, G, X");
+ catch (Exception e) {
+ throw new RuntimeException("asn1 parse failure " + e);
}
-
- DERInteger[] ints = new DERInteger[pkcs8.derIntegers.size()];
- pkcs8.derIntegers.toArray(ints);
- DERInteger p = ints[1];
- DERInteger q = ints[2];
- DERInteger g = ints[3];
- DERInteger x = ints[5];
-
- byte[] encodedX = encode(x);
- octetsToAppend = new DEROctetString(encodedX);
- ASN1EncodableVector pqgVec = new ASN1EncodableVector();
- pqgVec.add(p);
- pqgVec.add(q);
- pqgVec.add(g);
- DERSequence pqg = new DERSequence(pqgVec);
- innerVec.add(pqg);
- } else {
- innerVec.add(DERNull.INSTANCE);
- octetsToAppend = new DEROctetString(privateKey);
+ }
+ if (pkcs8.derIntegers == null || pkcs8.derIntegers.size() < 6) {
+ throw new RuntimeException("invalid DSA key - can't find P, Q, G, X");
}
- DERSequence inner = new DERSequence(innerVec);
- outterVec.add(derZero);
- outterVec.add(inner);
- outterVec.add(octetsToAppend);
- DERSequence outter = new DERSequence(outterVec);
- return encode(outter);
- }
- catch (IOException ioe) {
- throw JavaImpl.newRuntimeException(ioe);
+ Asn1Integer[] ints = new Asn1Integer[pkcs8.derIntegers.size()];
+ pkcs8.derIntegers.toArray(ints);
+ Asn1Integer p = ints[1];
+ Asn1Integer q = ints[2];
+ Asn1Integer g = ints[3];
+ Asn1Integer x = ints[5];
+
+ byte[] encodedX = x.encode();
+ octetsToAppend = new Asn1OctetString(encodedX);
+ Asn1Sequence pqgSeq = new Asn1Sequence();
+ pqgSeq.addItem(p);
+ pqgSeq.addItem(q);
+ pqgSeq.addItem(g);
+ innerSeq.addItem(pqgSeq);
+ } else {
+ innerSeq.addItem(Asn1Null.INSTANCE);
+ octetsToAppend = new Asn1OctetString(privateKey);
}
+
+ outterSeq.addItem(derZero);
+ outterSeq.addItem(innerSeq);
+ outterSeq.addItem(octetsToAppend);
+
+ return outterSeq.encode();
}
private static boolean allZeroes(byte[] b) {
@@ -960,14 +953,6 @@ public class PKCS8Key {
return true;
}
- public static byte[] encode(DEREncodable der) throws IOException {
- ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
- ASN1OutputStream out = new ASN1OutputStream(baos);
- out.writeObject(der);
- out.close();
- return baos.toByteArray();
- }
-
public static void main(String[] args) throws Exception {
String password = "changeit";
if (args.length == 0) {
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/5c70429d/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1Choice.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1Choice.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1Choice.java
deleted file mode 100644
index c08485e..0000000
--- a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1Choice.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.apache.commons.ssl.asn1;
-
-/**
- * Marker interface for CHOICE objects - if you implement this in a role your
- * own object any attempt to tag the object implicitly will convert the tag to
- * an explicit one as the encoding rules require.
- * <p/>
- * If you use this interface your class should also implement the getInstance
- * pattern which takes a tag object and the tagging mode used.
- */
-public interface ASN1Choice {
- // marker interface
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/5c70429d/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1Encodable.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1Encodable.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1Encodable.java
deleted file mode 100644
index 99900cb..0000000
--- a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1Encodable.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package org.apache.commons.ssl.asn1;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-
-public abstract class ASN1Encodable
- implements DEREncodable {
- public static final String DER = "DER";
- public static final String BER = "BER";
-
- public byte[] getEncoded()
- throws IOException {
- ByteArrayOutputStream bOut = new ByteArrayOutputStream();
- ASN1OutputStream aOut = new ASN1OutputStream(bOut);
-
- aOut.writeObject(this);
-
- return bOut.toByteArray();
- }
-
- public byte[] getEncoded(
- String encoding)
- throws IOException {
- if (encoding.equals(DER)) {
- ByteArrayOutputStream bOut = new ByteArrayOutputStream();
- DEROutputStream dOut = new DEROutputStream(bOut);
-
- dOut.writeObject(this);
-
- return bOut.toByteArray();
- }
-
- return this.getEncoded();
- }
-
- /**
- * Return the DER encoding of the object, null if the DER encoding can not be made.
- *
- * @return a DER byte array, null otherwise.
- */
- public byte[] getDEREncoded() {
- try {
- return this.getEncoded(DER);
- }
- catch (IOException e) {
- return null;
- }
- }
-
- public int hashCode() {
- return this.toASN1Object().hashCode();
- }
-
- public boolean equals(
- Object o) {
- if (this == o) {
- return true;
- }
-
- if (!(o instanceof DEREncodable)) {
- return false;
- }
-
- DEREncodable other = (DEREncodable) o;
-
- return this.toASN1Object().equals(other.getDERObject());
- }
-
- public DERObject getDERObject() {
- return this.toASN1Object();
- }
-
- public abstract DERObject toASN1Object();
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/5c70429d/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1EncodableVector.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1EncodableVector.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1EncodableVector.java
deleted file mode 100644
index b769758..0000000
--- a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1EncodableVector.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.apache.commons.ssl.asn1;
-
-/** the parent class for this will eventually disappear. Use this one! */
-public class ASN1EncodableVector
- extends DEREncodableVector {
- // migrating from DEREncodeableVector
- public ASN1EncodableVector() {
-
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/5c70429d/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1Generator.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1Generator.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1Generator.java
deleted file mode 100644
index b39d994..0000000
--- a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1Generator.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.apache.commons.ssl.asn1;
-
-import java.io.OutputStream;
-
-public abstract class ASN1Generator {
- protected OutputStream _out;
-
- public ASN1Generator(OutputStream out) {
- _out = out;
- }
-
- public abstract OutputStream getRawOutputStream();
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/5c70429d/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1InputStream.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1InputStream.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1InputStream.java
deleted file mode 100644
index e68c231..0000000
--- a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1InputStream.java
+++ /dev/null
@@ -1,420 +0,0 @@
-package org.apache.commons.ssl.asn1;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.EOFException;
-import java.io.FilterInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Vector;
-
-/**
- * a general purpose ASN.1 decoder - note: this class differs from the
- * others in that it returns null after it has read the last object in
- * the stream. If an ASN.1 NULL is encountered a DER/BER Null object is
- * returned.
- */
-public class ASN1InputStream
- extends FilterInputStream
- implements DERTags {
- private static final DERObject END_OF_STREAM = new DERObject() {
- void encode(
- DEROutputStream out)
- throws IOException {
- throw new IOException("Eeek!");
- }
- public int hashCode() {
- return 0;
- }
- public boolean equals(
- Object o) {
- return o == this;
- }
- };
-
- boolean eofFound = false;
- int limit = Integer.MAX_VALUE;
-
- public ASN1InputStream(
- InputStream is) {
- super(is);
- }
-
- /**
- * Create an ASN1InputStream based on the input byte array. The length of DER objects in
- * the stream is automatically limited to the length of the input array.
- *
- * @param input array containing ASN.1 encoded data.
- */
- public ASN1InputStream(
- byte[] input) {
- this(new ByteArrayInputStream(input), input.length);
- }
-
- /**
- * Create an ASN1InputStream where no DER object will be longer than limit.
- *
- * @param input stream containing ASN.1 encoded data.
- * @param limit maximum size of a DER encoded object.
- */
- public ASN1InputStream(
- InputStream input,
- int limit) {
- super(input);
- this.limit = limit;
- }
-
- protected int readLength()
- throws IOException {
- int length = read();
- if (length < 0) {
- throw new IOException("EOF found when length expected");
- }
-
- if (length == 0x80) {
- return -1; // indefinite-length encoding
- }
-
- if (length > 127) {
- int size = length & 0x7f;
-
- if (size > 4) {
- throw new IOException("DER length more than 4 bytes");
- }
-
- length = 0;
- for (int i = 0; i < size; i++) {
- int next = read();
-
- if (next < 0) {
- throw new IOException("EOF found reading length");
- }
-
- length = (length << 8) + next;
- }
-
- if (length < 0) {
- throw new IOException("corrupted stream - negative length found");
- }
-
- if (length >= limit) // after all we must have read at least 1 byte
- {
- throw new IOException("corrupted stream - out of bounds length found");
- }
- }
-
- return length;
- }
-
- protected void readFully(
- byte[] bytes)
- throws IOException {
- int left = bytes.length;
- int len;
-
- if (left == 0) {
- return;
- }
-
- while ((len = read(bytes, bytes.length - left, left)) > 0) {
- if ((left -= len) == 0) {
- return;
- }
- }
-
- if (left != 0) {
- throw new EOFException("EOF encountered in middle of object");
- }
- }
-
- /** build an object given its tag and the number of bytes to construct it from. */
- protected DERObject buildObject(
- int tag,
- int tagNo,
- int length)
- throws IOException {
- if ((tag & APPLICATION) != 0) {
- return new DERApplicationSpecific(tagNo, readDefiniteLengthFully(length));
- }
-
- boolean isConstructed = (tag & CONSTRUCTED) != 0;
-
- if (isConstructed) {
- switch (tag) {
- case SEQUENCE | CONSTRUCTED:
- return new DERSequence(buildDerEncodableVector(length));
- case SET | CONSTRUCTED:
- return new DERSet(buildDerEncodableVector(length), false);
- case OCTET_STRING | CONSTRUCTED:
- return buildDerConstructedOctetString(length);
- default: {
- //
- // with tagged object tag number is bottom 5 bits
- //
- if ((tag & TAGGED) != 0) {
- if (length == 0) // empty tag!
- {
- return new DERTaggedObject(false, tagNo, new DERSequence());
- }
-
- ASN1EncodableVector v = buildDerEncodableVector(length);
-
- if (v.size() == 1) {
- //
- // explicitly tagged (probably!) - if it isn't we'd have to
- // tell from the context
- //
- return new DERTaggedObject(tagNo, v.get(0));
- }
-
- return new DERTaggedObject(false, tagNo, new DERSequence(v));
- }
-
- return new DERUnknownTag(tag, readDefiniteLengthFully(length));
- }
- }
- }
-
- byte[] bytes = readDefiniteLengthFully(length);
-
- switch (tag) {
- case NULL:
- return DERNull.INSTANCE;
- case BOOLEAN:
- return new DERBoolean(bytes);
- case INTEGER:
- return new DERInteger(bytes);
- case ENUMERATED:
- return new DEREnumerated(bytes);
- case OBJECT_IDENTIFIER:
- return new DERObjectIdentifier(bytes);
- case BIT_STRING: {
- int padBits = bytes[0];
- byte[] data = new byte[bytes.length - 1];
-
- System.arraycopy(bytes, 1, data, 0, bytes.length - 1);
-
- return new DERBitString(data, padBits);
- }
- case NUMERIC_STRING:
- return new DERNumericString(bytes);
- case UTF8_STRING:
- return new DERUTF8String(bytes);
- case PRINTABLE_STRING:
- return new DERPrintableString(bytes);
- case IA5_STRING:
- return new DERIA5String(bytes);
- case T61_STRING:
- return new DERT61String(bytes);
- case VISIBLE_STRING:
- return new DERVisibleString(bytes);
- case GENERAL_STRING:
- return new DERGeneralString(bytes);
- case UNIVERSAL_STRING:
- return new DERUniversalString(bytes);
- case BMP_STRING:
- return new DERBMPString(bytes);
- case OCTET_STRING:
- return new DEROctetString(bytes);
- case UTC_TIME:
- return new DERUTCTime(bytes);
- case GENERALIZED_TIME:
- return new DERGeneralizedTime(bytes);
- default: {
- //
- // with tagged object tag number is bottom 5 bits
- //
- if ((tag & TAGGED) != 0) {
- if (bytes.length == 0) // empty tag!
- {
- return new DERTaggedObject(false, tagNo, DERNull.INSTANCE);
- }
-
- //
- // simple type - implicit... return an octet string
- //
- return new DERTaggedObject(false, tagNo, new DEROctetString(bytes));
- }
-
- return new DERUnknownTag(tag, bytes);
- }
- }
- }
-
- private byte[] readDefiniteLengthFully(int length)
- throws IOException {
- byte[] bytes = new byte[length];
- readFully(bytes);
- return bytes;
- }
-
- /** read a string of bytes representing an indefinite length object. */
- private byte[] readIndefiniteLengthFully()
- throws IOException {
- ByteArrayOutputStream bOut = new ByteArrayOutputStream();
- int b, b1;
-
- b1 = read();
-
- while ((b = read()) >= 0) {
- if (b1 == 0 && b == 0) {
- break;
- }
-
- bOut.write(b1);
- b1 = b;
- }
-
- return bOut.toByteArray();
- }
-
- private BERConstructedOctetString buildConstructedOctetString(DERObject sentinel)
- throws IOException {
- Vector octs = new Vector();
- DERObject o;
-
- while ((o = readObject()) != sentinel) {
- octs.addElement(o);
- }
-
- return new BERConstructedOctetString(octs);
- }
-
- //
- // yes, people actually do this...
- //
- private BERConstructedOctetString buildDerConstructedOctetString(int length)
- throws IOException {
- DefiniteLengthInputStream dIn = new DefiniteLengthInputStream(this, length);
- ASN1InputStream aIn = new ASN1InputStream(dIn, length);
-
- return aIn.buildConstructedOctetString(null);
- }
-
- private ASN1EncodableVector buildEncodableVector(DERObject sentinel)
- throws IOException {
- ASN1EncodableVector v = new ASN1EncodableVector();
- DERObject o;
-
- while ((o = readObject()) != sentinel) {
- v.add(o);
- }
-
- return v;
- }
-
- private ASN1EncodableVector buildDerEncodableVector(int length)
- throws IOException {
- DefiniteLengthInputStream dIn = new DefiniteLengthInputStream(this, length);
- ASN1InputStream aIn = new ASN1InputStream(dIn, length);
-
- return aIn.buildEncodableVector(null);
- }
-
- public DERObject readObject()
- throws IOException {
- int tag = read();
- if (tag == -1) {
- if (eofFound) {
- throw new EOFException("attempt to read past end of file.");
- }
-
- eofFound = true;
-
- return null;
- }
-
- int tagNo = 0;
-
- if ((tag & TAGGED) != 0 || (tag & APPLICATION) != 0) {
- tagNo = readTagNumber(tag);
- }
-
- int length = readLength();
-
- if (length < 0) // indefinite length method
- {
- switch (tag) {
- case NULL:
- return BERNull.INSTANCE;
- case SEQUENCE | CONSTRUCTED:
- return new BERSequence(buildEncodableVector(END_OF_STREAM));
- case SET | CONSTRUCTED:
- return new BERSet(buildEncodableVector(END_OF_STREAM), false);
- case OCTET_STRING | CONSTRUCTED:
- return buildConstructedOctetString(END_OF_STREAM);
- default: {
- //
- // with tagged object tag number is bottom 5 bits
- //
- if ((tag & TAGGED) != 0) {
- //
- // simple type - implicit... return an octet string
- //
- if ((tag & CONSTRUCTED) == 0) {
- byte[] bytes = readIndefiniteLengthFully();
-
- return new BERTaggedObject(false, tagNo, new DEROctetString(bytes));
- }
-
- //
- // either constructed or explicitly tagged
- //
- ASN1EncodableVector v = buildEncodableVector(END_OF_STREAM);
-
- if (v.size() == 0) // empty tag!
- {
- return new DERTaggedObject(tagNo);
- }
-
- if (v.size() == 1) {
- //
- // explicitly tagged (probably!) - if it isn't we'd have to
- // tell from the context
- //
- return new BERTaggedObject(tagNo, v.get(0));
- }
-
- return new BERTaggedObject(false, tagNo, new BERSequence(v));
- }
-
- throw new IOException("unknown BER object encountered");
- }
- }
- } else {
- if (tag == 0 && length == 0) // end of contents marker.
- {
- return END_OF_STREAM;
- }
-
- return buildObject(tag, tagNo, length);
- }
- }
-
- private int readTagNumber(int tag)
- throws IOException {
- int tagNo = tag & 0x1f;
-
- if (tagNo == 0x1f) {
- int b = read();
-
- tagNo = 0;
-
- while ((b >= 0) && ((b & 0x80) != 0)) {
- tagNo |= (b & 0x7f);
- tagNo <<= 7;
- b = read();
- }
-
- if (b < 0) {
- eofFound = true;
- throw new EOFException("EOF found inside tag value.");
- }
-
- tagNo |= (b & 0x7f);
- }
-
- return tagNo;
- }
-}
-
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/5c70429d/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1Null.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1Null.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1Null.java
deleted file mode 100644
index 7f56bbd..0000000
--- a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1Null.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package org.apache.commons.ssl.asn1;
-
-import java.io.IOException;
-
-/** A NULL object. */
-public abstract class ASN1Null
- extends ASN1Object {
- public ASN1Null() {
- }
-
- public int hashCode() {
- return 0;
- }
-
- boolean asn1Equals(
- DERObject o) {
- if (!(o instanceof ASN1Null)) {
- return false;
- }
-
- return true;
- }
-
- abstract void encode(DEROutputStream out)
- throws IOException;
-
- public String toString() {
- return "NULL";
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/5c70429d/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1Object.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1Object.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1Object.java
deleted file mode 100644
index a2ec57a..0000000
--- a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1Object.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package org.apache.commons.ssl.asn1;
-
-import java.io.IOException;
-
-public abstract class ASN1Object
- extends DERObject {
- /**
- * Create a base ASN.1 object from a byte stream.
- *
- * @param data the byte stream to parse.
- * @return the base ASN.1 object represented by the byte stream.
- * @throws java.io.IOException if there is a problem parsing the data.
- */
- public static ASN1Object fromByteArray(byte[] data)
- throws IOException {
- ASN1InputStream aIn = new ASN1InputStream(data);
-
- return (ASN1Object) aIn.readObject();
- }
-
- public final boolean equals(Object o) {
- if (this == o) {
- return true;
- }
-
- return (o instanceof DEREncodable) && asn1Equals(((DEREncodable) o).getDERObject());
- }
-
- public abstract int hashCode();
-
- abstract void encode(DEROutputStream out) throws IOException;
-
- abstract boolean asn1Equals(DERObject o);
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/5c70429d/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1ObjectParser.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1ObjectParser.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1ObjectParser.java
deleted file mode 100644
index ca2a576..0000000
--- a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1ObjectParser.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package org.apache.commons.ssl.asn1;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-public class ASN1ObjectParser {
- private int _baseTag;
- private int _tagNumber;
-
- private ASN1StreamParser _aIn;
-
- protected ASN1ObjectParser(
- int baseTag,
- int tagNumber,
- InputStream contentStream) {
- _baseTag = baseTag;
- _tagNumber = tagNumber;
- _aIn = new ASN1StreamParser(contentStream);
- }
-
- /**
- * Return the tag number for this object.
- *
- * @return the tag number.
- */
- int getTagNumber() {
- return _tagNumber;
- }
-
- int getBaseTag() {
- return _baseTag;
- }
-
- DEREncodable readObject()
- throws IOException {
- return _aIn.readObject();
- }
-
- ASN1EncodableVector readVector()
- throws IllegalStateException {
- ASN1EncodableVector v = new ASN1EncodableVector();
- DEREncodable obj;
-
- try {
- while ((obj = readObject()) != null) {
- v.add(obj.getDERObject());
- }
- }
- catch (IOException e) {
- throw new IllegalStateException(e.getMessage());
- }
-
- return v;
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/5c70429d/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1OctetString.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1OctetString.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1OctetString.java
deleted file mode 100644
index 10ab72e..0000000
--- a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1OctetString.java
+++ /dev/null
@@ -1,137 +0,0 @@
-package org.apache.commons.ssl.asn1;
-
-import org.apache.commons.ssl.util.Hex;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Enumeration;
-import java.util.Vector;
-
-public abstract class ASN1OctetString
- extends ASN1Object
- implements ASN1OctetStringParser {
- byte[] string;
-
- /**
- * return an Octet String from a tagged object.
- *
- * @param obj the tagged object holding the object we want.
- * @param explicit true if the object is meant to be explicitly
- * tagged false otherwise.
- * @throws IllegalArgumentException if the tagged object cannot
- * be converted.
- */
- public static ASN1OctetString getInstance(
- ASN1TaggedObject obj,
- boolean explicit) {
- return getInstance(obj.getObject());
- }
-
- /**
- * return an Octet String from the given object.
- *
- * @param obj the object we want converted.
- * @throws IllegalArgumentException if the object cannot be converted.
- */
- public static ASN1OctetString getInstance(
- Object obj) {
- if (obj == null || obj instanceof ASN1OctetString) {
- return (ASN1OctetString) obj;
- }
-
- if (obj instanceof ASN1TaggedObject) {
- return getInstance(((ASN1TaggedObject) obj).getObject());
- }
-
- if (obj instanceof ASN1Sequence) {
- Vector v = new Vector();
- Enumeration e = ((ASN1Sequence) obj).getObjects();
-
- while (e.hasMoreElements()) {
- v.addElement(e.nextElement());
- }
-
- return new BERConstructedOctetString(v);
- }
-
- throw new IllegalArgumentException("illegal object in getInstance: " + obj.getClass().getName());
- }
-
- /** @param string the octets making up the octet string. */
- public ASN1OctetString(
- byte[] string) {
- this.string = string;
- }
-
- public ASN1OctetString(
- DEREncodable obj) {
- try {
- ByteArrayOutputStream bOut = new ByteArrayOutputStream();
- DEROutputStream dOut = new DEROutputStream(bOut);
-
- dOut.writeObject(obj);
- dOut.close();
-
- this.string = bOut.toByteArray();
- }
- catch (IOException e) {
- throw new IllegalArgumentException("Error processing object : " + e.toString());
- }
- }
-
- public InputStream getOctetStream() {
- return new ByteArrayInputStream(string);
- }
-
- public ASN1OctetStringParser parser() {
- return this;
- }
-
- public byte[] getOctets() {
- return string;
- }
-
- public int hashCode() {
- byte[] b = this.getOctets();
- int value = 0;
-
- for (int i = 0; i != b.length; i++) {
- value ^= (b[i] & 0xff) << (i % 4);
- }
-
- return value;
- }
-
- boolean asn1Equals(
- DERObject o) {
- if (!(o instanceof ASN1OctetString)) {
- return false;
- }
-
- ASN1OctetString other = (ASN1OctetString) o;
-
- byte[] b1 = other.string;
- byte[] b2 = this.string;
-
- if (b1.length != b2.length) {
- return false;
- }
-
- for (int i = 0; i != b1.length; i++) {
- if (b1[i] != b2[i]) {
- return false;
- }
- }
-
- return true;
- }
-
- abstract void encode(DEROutputStream out)
- throws IOException;
-
- public String toString() {
- return "#" + Hex.encode(string);
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/5c70429d/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1OctetStringParser.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1OctetStringParser.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1OctetStringParser.java
deleted file mode 100644
index b958534..0000000
--- a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1OctetStringParser.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package org.apache.commons.ssl.asn1;
-
-import java.io.InputStream;
-
-public interface ASN1OctetStringParser
- extends DEREncodable {
- public InputStream getOctetStream();
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/5c70429d/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1OutputStream.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1OutputStream.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1OutputStream.java
deleted file mode 100644
index 2cac08d..0000000
--- a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1OutputStream.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.apache.commons.ssl.asn1;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-public class ASN1OutputStream
- extends DEROutputStream {
- public ASN1OutputStream(
- OutputStream os) {
- super(os);
- }
-
- public void writeObject(
- Object obj)
- throws IOException {
- if (obj == null) {
- writeNull();
- } else if (obj instanceof DERObject) {
- ((DERObject) obj).encode(this);
- } else if (obj instanceof DEREncodable) {
- ((DEREncodable) obj).getDERObject().encode(this);
- } else {
- throw new IOException("object not ASN1Encodable");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/5c70429d/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1Sequence.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1Sequence.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1Sequence.java
deleted file mode 100644
index 699edd1..0000000
--- a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1Sequence.java
+++ /dev/null
@@ -1,183 +0,0 @@
-package org.apache.commons.ssl.asn1;
-
-import java.io.IOException;
-import java.util.Enumeration;
-import java.util.Vector;
-
-public abstract class ASN1Sequence
- extends ASN1Object {
- private Vector seq = new Vector();
-
- /**
- * return an ASN1Sequence from the given object.
- *
- * @param obj the object we want converted.
- * @throws IllegalArgumentException if the object cannot be converted.
- */
- public static ASN1Sequence getInstance(
- Object obj) {
- if (obj == null || obj instanceof ASN1Sequence) {
- return (ASN1Sequence) obj;
- }
-
- throw new IllegalArgumentException("unknown object in getInstance");
- }
-
- /**
- * Return an ASN1 sequence from a tagged object. There is a special
- * case here, if an object appears to have been explicitly tagged on
- * reading but we were expecting it to be implictly tagged in the
- * normal course of events it indicates that we lost the surrounding
- * sequence - so we need to add it back (this will happen if the tagged
- * object is a sequence that contains other sequences). If you are
- * dealing with implicitly tagged sequences you really <b>should</b>
- * be using this method.
- *
- * @param obj the tagged object.
- * @param explicit true if the object is meant to be explicitly tagged,
- * false otherwise.
- * @throws IllegalArgumentException if the tagged object cannot
- * be converted.
- */
- public static ASN1Sequence getInstance(
- ASN1TaggedObject obj,
- boolean explicit) {
- if (explicit) {
- if (!obj.isExplicit()) {
- throw new IllegalArgumentException("object implicit - explicit expected.");
- }
-
- return (ASN1Sequence) obj.getObject();
- } else {
- //
- // constructed object which appears to be explicitly tagged
- // when it should be implicit means we have to add the
- // surrounding sequence.
- //
- if (obj.isExplicit()) {
- if (obj instanceof BERTaggedObject) {
- return new BERSequence(obj.getObject());
- } else {
- return new DERSequence(obj.getObject());
- }
- } else {
- if (obj.getObject() instanceof ASN1Sequence) {
- return (ASN1Sequence) obj.getObject();
- }
- }
- }
-
- throw new IllegalArgumentException(
- "unknown object in getInstanceFromTagged");
- }
-
- public Enumeration getObjects() {
- return seq.elements();
- }
-
- public ASN1SequenceParser parser() {
- final ASN1Sequence outer = this;
-
- return new ASN1SequenceParser() {
- private final int max = size();
-
- private int index;
-
- public DEREncodable readObject() throws IOException {
- if (index == max) {
- return null;
- }
-
- DEREncodable obj = getObjectAt(index++);
- if (obj instanceof ASN1Sequence) {
- return ((ASN1Sequence) obj).parser();
- }
- if (obj instanceof ASN1Set) {
- return ((ASN1Set) obj).parser();
- }
-
- return obj;
- }
-
- public DERObject getDERObject() {
- return outer;
- }
- };
- }
-
- /**
- * return the object at the sequence postion indicated by index.
- *
- * @param index the sequence number (starting at zero) of the object
- * @return the object at the sequence postion indicated by index.
- */
- public DEREncodable getObjectAt(
- int index) {
- return (DEREncodable) seq.elementAt(index);
- }
-
- /**
- * return the number of objects in this sequence.
- *
- * @return the number of objects in this sequence.
- */
- public int size() {
- return seq.size();
- }
-
- public int hashCode() {
- Enumeration e = this.getObjects();
- int hashCode = 0;
-
- while (e.hasMoreElements()) {
- Object o = e.nextElement();
-
- if (o != null) {
- hashCode ^= o.hashCode();
- }
- }
-
- return hashCode;
- }
-
- boolean asn1Equals(
- DERObject o) {
- if (!(o instanceof ASN1Sequence)) {
- return false;
- }
-
- ASN1Sequence other = (ASN1Sequence) o;
-
- if (this.size() != other.size()) {
- return false;
- }
-
- Enumeration s1 = this.getObjects();
- Enumeration s2 = other.getObjects();
-
- while (s1.hasMoreElements()) {
- DERObject o1 = ((DEREncodable) s1.nextElement()).getDERObject();
- DERObject o2 = ((DEREncodable) s2.nextElement()).getDERObject();
-
- if (o1 == o2 || (o1 != null && o1.equals(o2))) {
- continue;
- }
-
- return false;
- }
-
- return true;
- }
-
- protected void addObject(
- DEREncodable obj) {
- seq.addElement(obj);
- }
-
- abstract void encode(DEROutputStream out)
- throws IOException;
-
- public String toString() {
- return seq.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/5c70429d/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1SequenceParser.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1SequenceParser.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1SequenceParser.java
deleted file mode 100644
index c64c93e..0000000
--- a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/ASN1SequenceParser.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package org.apache.commons.ssl.asn1;
-
-import java.io.IOException;
-
-public interface ASN1SequenceParser
- extends DEREncodable {
- DEREncodable readObject()
- throws IOException;
-}