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/10 14:31:02 UTC

[18/42] directory-kerberos git commit: Initially import Haox codebase (https://github.com/drankye/haox)

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERSequence.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERSequence.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERSequence.java
new file mode 100644
index 0000000..9416a2d
--- /dev/null
+++ b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERSequence.java
@@ -0,0 +1,62 @@
+package org.apache.commons.ssl.asn1;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Enumeration;
+
+public class DERSequence
+    extends ASN1Sequence {
+    /** create an empty sequence */
+    public DERSequence() {
+    }
+
+    /** create a sequence containing one object */
+    public DERSequence(
+        DEREncodable obj) {
+        this.addObject(obj);
+    }
+
+    /** create a sequence containing a vector of objects. */
+    public DERSequence(
+        DEREncodableVector v) {
+        for (int i = 0; i != v.size(); i++) {
+            this.addObject(v.get(i));
+        }
+    }
+
+    /** create a sequence containing an array of objects. */
+    public DERSequence(
+        ASN1Encodable[] a) {
+        for (int i = 0; i != a.length; i++) {
+            this.addObject(a[i]);
+        }
+    }
+
+    /*
+    * A note on the implementation:
+    * <p>
+    * As DER requires the constructed, definite-length model to
+    * be used for structured types, this varies slightly from the
+    * ASN.1 descriptions given. Rather than just outputing SEQUENCE,
+    * we also have to specify CONSTRUCTED, and the objects length.
+    */
+    void encode(
+        DEROutputStream out)
+        throws IOException {
+        ByteArrayOutputStream bOut = new ByteArrayOutputStream();
+        DEROutputStream dOut = new DEROutputStream(bOut);
+        Enumeration e = this.getObjects();
+
+        while (e.hasMoreElements()) {
+            Object obj = e.nextElement();
+
+            dOut.writeObject(obj);
+        }
+
+        dOut.close();
+
+        byte[] bytes = bOut.toByteArray();
+
+        out.writeEncoded(SEQUENCE | CONSTRUCTED, bytes);
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERSequenceGenerator.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERSequenceGenerator.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERSequenceGenerator.java
new file mode 100644
index 0000000..4fd7003
--- /dev/null
+++ b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERSequenceGenerator.java
@@ -0,0 +1,39 @@
+package org.apache.commons.ssl.asn1;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+public class DERSequenceGenerator
+    extends DERGenerator {
+    private final ByteArrayOutputStream _bOut = new ByteArrayOutputStream();
+
+    public DERSequenceGenerator(
+        OutputStream out)
+        throws IOException {
+        super(out);
+    }
+
+    public DERSequenceGenerator(
+        OutputStream out,
+        int tagNo,
+        boolean isExplicit)
+        throws IOException {
+        super(out, tagNo, isExplicit);
+    }
+
+    public void addObject(
+        DEREncodable object)
+        throws IOException {
+        object.getDERObject().encode(new DEROutputStream(_bOut));
+    }
+
+    public OutputStream getRawOutputStream() {
+        return _bOut;
+    }
+
+    public void close()
+        throws IOException {
+        writeDEREncoded(DERTags.CONSTRUCTED | DERTags.SEQUENCE, _bOut.toByteArray());
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERSet.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERSet.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERSet.java
new file mode 100644
index 0000000..4fbb0f8
--- /dev/null
+++ b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERSet.java
@@ -0,0 +1,76 @@
+package org.apache.commons.ssl.asn1;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Enumeration;
+
+/** A DER encoded set object */
+public class DERSet
+    extends ASN1Set {
+    /** create an empty set */
+    public DERSet() {
+    }
+
+    /** @param obj - a single object that makes up the set. */
+    public DERSet(
+        DEREncodable obj) {
+        this.addObject(obj);
+    }
+
+    /** @param v - a vector of objects making up the set. */
+    public DERSet(
+        DEREncodableVector v) {
+        this(v, true);
+    }
+
+    /** create a set from an array of objects. */
+    public DERSet(
+        ASN1Encodable[] a) {
+        for (int i = 0; i != a.length; i++) {
+            this.addObject(a[i]);
+        }
+
+        this.sort();
+    }
+
+    /** @param v - a vector of objects making up the set. */
+    DERSet(
+        DEREncodableVector v,
+        boolean needsSorting) {
+        for (int i = 0; i != v.size(); i++) {
+            this.addObject(v.get(i));
+        }
+
+        if (needsSorting) {
+            this.sort();
+        }
+    }
+
+    /*
+     * A note on the implementation:
+     * <p>
+     * As DER requires the constructed, definite-length model to
+     * be used for structured types, this varies slightly from the
+     * ASN.1 descriptions given. Rather than just outputing SET,
+     * we also have to specify CONSTRUCTED, and the objects length.
+     */
+    void encode(
+        DEROutputStream out)
+        throws IOException {
+        ByteArrayOutputStream bOut = new ByteArrayOutputStream();
+        DEROutputStream dOut = new DEROutputStream(bOut);
+        Enumeration e = this.getObjects();
+
+        while (e.hasMoreElements()) {
+            Object obj = e.nextElement();
+
+            dOut.writeObject(obj);
+        }
+
+        dOut.close();
+
+        byte[] bytes = bOut.toByteArray();
+
+        out.writeEncoded(SET | CONSTRUCTED, bytes);
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERString.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERString.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERString.java
new file mode 100644
index 0000000..71565b0
--- /dev/null
+++ b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERString.java
@@ -0,0 +1,6 @@
+package org.apache.commons.ssl.asn1;
+
+/** basic interface for DER string objects. */
+public interface DERString {
+    public String getString();
+}

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERT61String.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERT61String.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERT61String.java
new file mode 100644
index 0000000..bd92539
--- /dev/null
+++ b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERT61String.java
@@ -0,0 +1,103 @@
+package org.apache.commons.ssl.asn1;
+
+import java.io.IOException;
+
+/** DER T61String (also the teletex string) */
+public class DERT61String
+    extends ASN1Object
+    implements DERString {
+    String string;
+
+    /**
+     * return a T61 string from the passed in object.
+     *
+     * @throws IllegalArgumentException if the object cannot be converted.
+     */
+    public static DERT61String getInstance(
+        Object obj) {
+        if (obj == null || obj instanceof DERT61String) {
+            return (DERT61String) obj;
+        }
+
+        if (obj instanceof ASN1OctetString) {
+            return new DERT61String(((ASN1OctetString) obj).getOctets());
+        }
+
+        if (obj instanceof ASN1TaggedObject) {
+            return getInstance(((ASN1TaggedObject) obj).getObject());
+        }
+
+        throw new IllegalArgumentException("illegal object in getInstance: " + obj.getClass().getName());
+    }
+
+    /**
+     * return an T61 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 DERT61String getInstance(
+        ASN1TaggedObject obj,
+        boolean explicit) {
+        return getInstance(obj.getObject());
+    }
+
+    /** basic constructor - with bytes. */
+    public DERT61String(
+        byte[] string) {
+        char[] cs = new char[string.length];
+
+        for (int i = 0; i != cs.length; i++) {
+            cs[i] = (char) (string[i] & 0xff);
+        }
+
+        this.string = new String(cs);
+    }
+
+    /** basic constructor - with string. */
+    public DERT61String(
+        String string) {
+        this.string = string;
+    }
+
+    public String getString() {
+        return string;
+    }
+
+    public String toString() {
+        return string;
+    }
+
+    void encode(
+        DEROutputStream out)
+        throws IOException {
+        out.writeEncoded(T61_STRING, this.getOctets());
+    }
+
+    public byte[] getOctets() {
+        char[] cs = string.toCharArray();
+        byte[] bs = new byte[cs.length];
+
+        for (int i = 0; i != cs.length; i++) {
+            bs[i] = (byte) cs[i];
+        }
+
+        return bs;
+    }
+
+    boolean asn1Equals(
+        DERObject o) {
+        if (!(o instanceof DERT61String)) {
+            return false;
+        }
+
+        return this.getString().equals(((DERT61String) o).getString());
+    }
+
+    public int hashCode() {
+        return this.getString().hashCode();
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERTaggedObject.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERTaggedObject.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERTaggedObject.java
new file mode 100644
index 0000000..6dd457c
--- /dev/null
+++ b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERTaggedObject.java
@@ -0,0 +1,74 @@
+package org.apache.commons.ssl.asn1;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+/**
+ * DER TaggedObject - in ASN.1 nottation this is any object proceeded by
+ * a [n] where n is some number - these are assume to follow the construction
+ * rules (as with sequences).
+ */
+public class DERTaggedObject
+    extends ASN1TaggedObject {
+    /**
+     * @param tagNo the tag number for this object.
+     * @param obj   the tagged object.
+     */
+    public DERTaggedObject(
+        int tagNo,
+        DEREncodable obj) {
+        super(tagNo, obj);
+    }
+
+    /**
+     * @param explicit true if an explicitly tagged object.
+     * @param tagNo    the tag number for this object.
+     * @param obj      the tagged object.
+     */
+    public DERTaggedObject(
+        boolean explicit,
+        int tagNo,
+        DEREncodable obj) {
+        super(explicit, tagNo, obj);
+    }
+
+    /**
+     * create an implicitly tagged object that contains a zero
+     * length sequence.
+     */
+    public DERTaggedObject(
+        int tagNo) {
+        super(false, tagNo, new DERSequence());
+    }
+
+    void encode(
+        DEROutputStream out)
+        throws IOException {
+        if (!empty) {
+            ByteArrayOutputStream bOut = new ByteArrayOutputStream();
+            DEROutputStream dOut = new DEROutputStream(bOut);
+
+            dOut.writeObject(obj);
+            dOut.close();
+
+            byte[] bytes = bOut.toByteArray();
+
+            if (explicit) {
+                out.writeEncoded(CONSTRUCTED | TAGGED | tagNo, bytes);
+            } else {
+                //
+                // need to mark constructed types...
+                //
+                if ((bytes[0] & CONSTRUCTED) != 0) {
+                    bytes[0] = (byte) (CONSTRUCTED | TAGGED | tagNo);
+                } else {
+                    bytes[0] = (byte) (TAGGED | tagNo);
+                }
+
+                out.write(bytes);
+            }
+        } else {
+            out.writeEncoded(CONSTRUCTED | TAGGED | tagNo, new byte[0]);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERTags.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERTags.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERTags.java
new file mode 100644
index 0000000..9fb9b41
--- /dev/null
+++ b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERTags.java
@@ -0,0 +1,35 @@
+package org.apache.commons.ssl.asn1;
+
+public interface DERTags {
+    public static final int BOOLEAN = 0x01;
+    public static final int INTEGER = 0x02;
+    public static final int BIT_STRING = 0x03;
+    public static final int OCTET_STRING = 0x04;
+    public static final int NULL = 0x05;
+    public static final int OBJECT_IDENTIFIER = 0x06;
+    public static final int EXTERNAL = 0x08;
+    public static final int ENUMERATED = 0x0a;
+    public static final int SEQUENCE = 0x10;
+    public static final int SEQUENCE_OF = 0x10; // for completeness
+    public static final int SET = 0x11;
+    public static final int SET_OF = 0x11; // for completeness
+
+
+    public static final int NUMERIC_STRING = 0x12;
+    public static final int PRINTABLE_STRING = 0x13;
+    public static final int T61_STRING = 0x14;
+    public static final int VIDEOTEX_STRING = 0x15;
+    public static final int IA5_STRING = 0x16;
+    public static final int UTC_TIME = 0x17;
+    public static final int GENERALIZED_TIME = 0x18;
+    public static final int GRAPHIC_STRING = 0x19;
+    public static final int VISIBLE_STRING = 0x1a;
+    public static final int GENERAL_STRING = 0x1b;
+    public static final int UNIVERSAL_STRING = 0x1c;
+    public static final int BMP_STRING = 0x1e;
+    public static final int UTF8_STRING = 0x0c;
+
+    public static final int CONSTRUCTED = 0x20;
+    public static final int APPLICATION = 0x40;
+    public static final int TAGGED = 0x80;
+}

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERUTCTime.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERUTCTime.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERUTCTime.java
new file mode 100644
index 0000000..57d38c7
--- /dev/null
+++ b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERUTCTime.java
@@ -0,0 +1,214 @@
+package org.apache.commons.ssl.asn1;
+
+import java.io.IOException;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.SimpleTimeZone;
+
+/** UTC time object. */
+public class DERUTCTime
+    extends ASN1Object {
+    String time;
+
+    /**
+     * return an UTC Time from the passed in object.
+     *
+     * @throws IllegalArgumentException if the object cannot be converted.
+     */
+    public static DERUTCTime getInstance(
+        Object obj) {
+        if (obj == null || obj instanceof DERUTCTime) {
+            return (DERUTCTime) obj;
+        }
+
+        if (obj instanceof ASN1OctetString) {
+            return new DERUTCTime(((ASN1OctetString) obj).getOctets());
+        }
+
+        throw new IllegalArgumentException("illegal object in getInstance: " + obj.getClass().getName());
+    }
+
+    /**
+     * return an UTC Time 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 DERUTCTime getInstance(
+        ASN1TaggedObject obj,
+        boolean explicit) {
+        return getInstance(obj.getObject());
+    }
+
+    /**
+     * The correct format for this is YYMMDDHHMMSSZ (it used to be that seconds were
+     * never encoded. When you're creating one of these objects from scratch, that's
+     * what you want to use, otherwise we'll try to deal with whatever gets read from
+     * the input stream... (this is why the input format is different from the getTime()
+     * method output).
+     * <p/>
+     *
+     * @param time the time string.
+     */
+    public DERUTCTime(
+        String time) {
+        this.time = time;
+        try {
+            this.getDate();
+        }
+        catch (ParseException e) {
+            throw new IllegalArgumentException("invalid date string: " + e.getMessage());
+        }
+    }
+
+    /** base constructer from a java.util.date object */
+    public DERUTCTime(
+        Date time) {
+        SimpleDateFormat dateF = new SimpleDateFormat("yyMMddHHmmss'Z'");
+
+        dateF.setTimeZone(new SimpleTimeZone(0, "Z"));
+
+        this.time = dateF.format(time);
+    }
+
+    DERUTCTime(
+        byte[] bytes) {
+        //
+        // explicitly convert to characters
+        //
+        char[] dateC = new char[bytes.length];
+
+        for (int i = 0; i != dateC.length; i++) {
+            dateC[i] = (char) (bytes[i] & 0xff);
+        }
+
+        this.time = new String(dateC);
+    }
+
+    /**
+     * return the time as a date based on whatever a 2 digit year will return. For
+     * standardised processing use getAdjustedDate().
+     *
+     * @return the resulting date
+     * @throws java.text.ParseException if the date string cannot be parsed.
+     */
+    public Date getDate()
+        throws ParseException {
+        SimpleDateFormat dateF = new SimpleDateFormat("yyMMddHHmmssz");
+
+        return dateF.parse(getTime());
+    }
+
+    /**
+     * return the time as an adjusted date
+     * in the range of 1950 - 2049.
+     *
+     * @return a date in the range of 1950 to 2049.
+     * @throws java.text.ParseException if the date string cannot be parsed.
+     */
+    public Date getAdjustedDate()
+        throws ParseException {
+        SimpleDateFormat dateF = new SimpleDateFormat("yyyyMMddHHmmssz");
+
+        dateF.setTimeZone(new SimpleTimeZone(0, "Z"));
+
+        return dateF.parse(getAdjustedTime());
+    }
+
+    /**
+     * return the time - always in the form of
+     * YYMMDDhhmmssGMT(+hh:mm|-hh:mm).
+     * <p/>
+     * Normally in a certificate we would expect "Z" rather than "GMT",
+     * however adding the "GMT" means we can just use:
+     * <pre>
+     *     dateF = new SimpleDateFormat("yyMMddHHmmssz");
+     * </pre>
+     * To read in the time and get a date which is compatible with our local
+     * time zone.
+     * <p/>
+     * <b>Note:</b> In some cases, due to the local date processing, this
+     * may lead to unexpected results. If you want to stick the normal
+     * convention of 1950 to 2049 use the getAdjustedTime() method.
+     */
+    public String getTime() {
+        //
+        // standardise the format.
+        //
+        if (time.indexOf('-') < 0 && time.indexOf('+') < 0) {
+            if (time.length() == 11) {
+                return time.substring(0, 10) + "00GMT+00:00";
+            } else {
+                return time.substring(0, 12) + "GMT+00:00";
+            }
+        } else {
+            int index = time.indexOf('-');
+            if (index < 0) {
+                index = time.indexOf('+');
+            }
+            String d = time;
+
+            if (index == time.length() - 3) {
+                d += "00";
+            }
+
+            if (index == 10) {
+                return d.substring(0, 10) + "00GMT" + d.substring(10, 13) + ":" + d.substring(13, 15);
+            } else {
+                return d.substring(0, 12) + "GMT" + d.substring(12, 15) + ":" + d.substring(15, 17);
+            }
+        }
+    }
+
+    /**
+     * return a time string as an adjusted date with a 4 digit year. This goes
+     * in the range of 1950 - 2049.
+     */
+    public String getAdjustedTime() {
+        String d = this.getTime();
+
+        if (d.charAt(0) < '5') {
+            return "20" + d;
+        } else {
+            return "19" + d;
+        }
+    }
+
+    private byte[] getOctets() {
+        char[] cs = time.toCharArray();
+        byte[] bs = new byte[cs.length];
+
+        for (int i = 0; i != cs.length; i++) {
+            bs[i] = (byte) cs[i];
+        }
+
+        return bs;
+    }
+
+    void encode(
+        DEROutputStream out)
+        throws IOException {
+        out.writeEncoded(UTC_TIME, this.getOctets());
+    }
+
+    boolean asn1Equals(
+        DERObject o) {
+        if (!(o instanceof DERUTCTime)) {
+            return false;
+        }
+
+        return time.equals(((DERUTCTime) o).time);
+    }
+
+    public int hashCode() {
+        return time.hashCode();
+    }
+
+    public String toString() {
+        return time;
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERUTF8String.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERUTF8String.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERUTF8String.java
new file mode 100644
index 0000000..768c525
--- /dev/null
+++ b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERUTF8String.java
@@ -0,0 +1,83 @@
+package org.apache.commons.ssl.asn1;
+
+import java.io.IOException;
+
+/** DER UTF8String object. */
+public class DERUTF8String
+    extends ASN1Object
+    implements DERString {
+    String string;
+
+    /**
+     * return an UTF8 string from the passed in object.
+     *
+     * @throws IllegalArgumentException if the object cannot be converted.
+     */
+    public static DERUTF8String getInstance(Object obj) {
+        if (obj == null || obj instanceof DERUTF8String) {
+            return (DERUTF8String) obj;
+        }
+
+        if (obj instanceof ASN1OctetString) {
+            return new DERUTF8String(((ASN1OctetString) obj).getOctets());
+        }
+
+        if (obj instanceof ASN1TaggedObject) {
+            return getInstance(((ASN1TaggedObject) obj).getObject());
+        }
+
+        throw new IllegalArgumentException("illegal object in getInstance: "
+                                           + obj.getClass().getName());
+    }
+
+    /**
+     * return an UTF8 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 DERUTF8String getInstance(
+        ASN1TaggedObject obj,
+        boolean explicit) {
+        return getInstance(obj.getObject());
+    }
+
+    /** basic constructor - byte encoded string. */
+    DERUTF8String(byte[] string) {
+        this.string = Strings.fromUTF8ByteArray(string);
+    }
+
+    /** basic constructor */
+    public DERUTF8String(String string) {
+        this.string = string;
+    }
+
+    public String getString() {
+        return string;
+    }
+
+    public String toString() {
+        return string;
+    }
+
+    public int hashCode() {
+        return this.getString().hashCode();
+    }
+
+    boolean asn1Equals(DERObject o) {
+        if (!(o instanceof DERUTF8String)) {
+            return false;
+        }
+
+        DERUTF8String s = (DERUTF8String) o;
+
+        return this.getString().equals(s.getString());
+    }
+
+    void encode(DEROutputStream out)
+        throws IOException {
+        out.writeEncoded(UTF8_STRING, Strings.toUTF8ByteArray(string));
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERUniversalString.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERUniversalString.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERUniversalString.java
new file mode 100644
index 0000000..29be4bf
--- /dev/null
+++ b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERUniversalString.java
@@ -0,0 +1,100 @@
+package org.apache.commons.ssl.asn1;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+/** DER UniversalString object. */
+public class DERUniversalString
+    extends ASN1Object
+    implements DERString {
+    private static final char[] table = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
+    private byte[] string;
+
+    /**
+     * return a Universal String from the passed in object.
+     *
+     * @throws IllegalArgumentException if the object cannot be converted.
+     */
+    public static DERUniversalString getInstance(
+        Object obj) {
+        if (obj == null || obj instanceof DERUniversalString) {
+            return (DERUniversalString) obj;
+        }
+
+        if (obj instanceof ASN1OctetString) {
+            return new DERUniversalString(((ASN1OctetString) obj).getOctets());
+        }
+
+        throw new IllegalArgumentException("illegal object in getInstance: " + obj.getClass().getName());
+    }
+
+    /**
+     * return a Universal 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 DERUniversalString getInstance(
+        ASN1TaggedObject obj,
+        boolean explicit) {
+        return getInstance(obj.getObject());
+    }
+
+    /** basic constructor - byte encoded string. */
+    public DERUniversalString(
+        byte[] string) {
+        this.string = string;
+    }
+
+    public String getString() {
+        StringBuffer buf = new StringBuffer("#");
+        ByteArrayOutputStream bOut = new ByteArrayOutputStream();
+        ASN1OutputStream aOut = new ASN1OutputStream(bOut);
+
+        try {
+            aOut.writeObject(this);
+        }
+        catch (IOException e) {
+            throw new RuntimeException("internal error encoding BitString");
+        }
+
+        byte[] string = bOut.toByteArray();
+
+        for (int i = 0; i != string.length; i++) {
+            buf.append(table[(string[i] >>> 4) & 0xf]);
+            buf.append(table[string[i] & 0xf]);
+        }
+
+        return buf.toString();
+    }
+
+    public String toString() {
+        return getString();
+    }
+
+    public byte[] getOctets() {
+        return string;
+    }
+
+    void encode(
+        DEROutputStream out)
+        throws IOException {
+        out.writeEncoded(UNIVERSAL_STRING, this.getOctets());
+    }
+
+    boolean asn1Equals(
+        DERObject o) {
+        if (!(o instanceof DERUniversalString)) {
+            return false;
+        }
+
+        return this.getString().equals(((DERUniversalString) o).getString());
+    }
+
+    public int hashCode() {
+        return this.getString().hashCode();
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERUnknownTag.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERUnknownTag.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERUnknownTag.java
new file mode 100644
index 0000000..5a02fde
--- /dev/null
+++ b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERUnknownTag.java
@@ -0,0 +1,71 @@
+package org.apache.commons.ssl.asn1;
+
+import java.io.IOException;
+
+/** We insert one of these when we find a tag we don't recognise. */
+public class DERUnknownTag
+    extends DERObject {
+    int tag;
+    byte[] data;
+
+    /**
+     * @param tag  the tag value.
+     * @param data the octets making up the time.
+     */
+    public DERUnknownTag(
+        int tag,
+        byte[] data) {
+        this.tag = tag;
+        this.data = data;
+    }
+
+    public int getTag() {
+        return tag;
+    }
+
+    public byte[] getData() {
+        return data;
+    }
+
+    void encode(
+        DEROutputStream out)
+        throws IOException {
+        out.writeEncoded(tag, data);
+    }
+
+    public boolean equals(
+        Object o) {
+        if (!(o instanceof DERUnknownTag)) {
+            return false;
+        }
+
+        DERUnknownTag other = (DERUnknownTag) o;
+
+        if (tag != other.tag) {
+            return false;
+        }
+
+        if (data.length != other.data.length) {
+            return false;
+        }
+
+        for (int i = 0; i < data.length; i++) {
+            if (data[i] != other.data[i]) {
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+    public int hashCode() {
+        byte[] b = this.getData();
+        int value = 0;
+
+        for (int i = 0; i != b.length; i++) {
+            value ^= (b[i] & 0xff) << (i % 4);
+        }
+
+        return value ^ this.getTag();
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERVisibleString.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERVisibleString.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERVisibleString.java
new file mode 100644
index 0000000..0b8ec89
--- /dev/null
+++ b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DERVisibleString.java
@@ -0,0 +1,103 @@
+package org.apache.commons.ssl.asn1;
+
+import java.io.IOException;
+
+/** DER VisibleString object. */
+public class DERVisibleString
+    extends ASN1Object
+    implements DERString {
+    String string;
+
+    /**
+     * return a Visible String from the passed in object.
+     *
+     * @throws IllegalArgumentException if the object cannot be converted.
+     */
+    public static DERVisibleString getInstance(
+        Object obj) {
+        if (obj == null || obj instanceof DERVisibleString) {
+            return (DERVisibleString) obj;
+        }
+
+        if (obj instanceof ASN1OctetString) {
+            return new DERVisibleString(((ASN1OctetString) obj).getOctets());
+        }
+
+        if (obj instanceof ASN1TaggedObject) {
+            return getInstance(((ASN1TaggedObject) obj).getObject());
+        }
+
+        throw new IllegalArgumentException("illegal object in getInstance: " + obj.getClass().getName());
+    }
+
+    /**
+     * return a Visible 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 DERVisibleString getInstance(
+        ASN1TaggedObject obj,
+        boolean explicit) {
+        return getInstance(obj.getObject());
+    }
+
+    /** basic constructor - byte encoded string. */
+    public DERVisibleString(
+        byte[] string) {
+        char[] cs = new char[string.length];
+
+        for (int i = 0; i != cs.length; i++) {
+            cs[i] = (char) (string[i] & 0xff);
+        }
+
+        this.string = new String(cs);
+    }
+
+    /** basic constructor */
+    public DERVisibleString(
+        String string) {
+        this.string = string;
+    }
+
+    public String getString() {
+        return string;
+    }
+
+    public String toString() {
+        return string;
+    }
+
+    public byte[] getOctets() {
+        char[] cs = string.toCharArray();
+        byte[] bs = new byte[cs.length];
+
+        for (int i = 0; i != cs.length; i++) {
+            bs[i] = (byte) cs[i];
+        }
+
+        return bs;
+    }
+
+    void encode(
+        DEROutputStream out)
+        throws IOException {
+        out.writeEncoded(VISIBLE_STRING, this.getOctets());
+    }
+
+    boolean asn1Equals(
+        DERObject o) {
+        if (!(o instanceof DERVisibleString)) {
+            return false;
+        }
+
+        return this.getString().equals(((DERVisibleString) o).getString());
+    }
+
+    public int hashCode() {
+        return this.getString().hashCode();
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DefiniteLengthInputStream.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DefiniteLengthInputStream.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DefiniteLengthInputStream.java
new file mode 100644
index 0000000..f88a078
--- /dev/null
+++ b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DefiniteLengthInputStream.java
@@ -0,0 +1,83 @@
+package org.apache.commons.ssl.asn1;
+
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.InputStream;
+
+class DefiniteLengthInputStream
+    extends LimitedInputStream {
+    private int _length;
+
+    DefiniteLengthInputStream(
+        InputStream in,
+        int length) {
+        super(in);
+
+        if (length < 0) {
+            throw new IllegalArgumentException("negative lengths not allowed");
+        }
+
+        this._length = length;
+    }
+
+    public int read()
+        throws IOException {
+        if (_length > 0) {
+            int b = _in.read();
+
+            if (b < 0) {
+                throw new EOFException();
+            }
+
+            --_length;
+            return b;
+        }
+
+        setParentEofDetect(true);
+
+        return -1;
+    }
+
+    public int read(byte[] buf, int off, int len)
+        throws IOException {
+        if (_length > 0) {
+            int toRead = Math.min(len, _length);
+            int numRead = _in.read(buf, off, toRead);
+
+            if (numRead < 0)
+                throw new EOFException();
+
+            _length -= numRead;
+            return numRead;
+        }
+
+        setParentEofDetect(true);
+
+        return -1;
+    }
+
+    byte[] toByteArray()
+        throws IOException {
+        byte[] bytes = new byte[_length];
+
+        if (_length > 0) {
+            int pos = 0;
+            do {
+                int read = _in.read(bytes, pos, _length - pos);
+
+                if (read < 0) {
+                    throw new EOFException();
+                }
+
+                pos += read;
+            }
+            while (pos < _length);
+
+            _length = 0;
+        }
+
+        setParentEofDetect(true);
+
+        return bytes;
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/IndefiniteLengthInputStream.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/IndefiniteLengthInputStream.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/IndefiniteLengthInputStream.java
new file mode 100644
index 0000000..1f48af8
--- /dev/null
+++ b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/IndefiniteLengthInputStream.java
@@ -0,0 +1,98 @@
+package org.apache.commons.ssl.asn1;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+class IndefiniteLengthInputStream
+    extends LimitedInputStream {
+    private int _b1;
+    private int _b2;
+    private boolean _eofReached = false;
+    private boolean _eofOn00 = true;
+
+    IndefiniteLengthInputStream(
+        InputStream in)
+        throws IOException {
+        super(in);
+
+        _b1 = in.read();
+        _b2 = in.read();
+        _eofReached = (_b2 < 0);
+    }
+
+    void setEofOn00(
+        boolean eofOn00) {
+        _eofOn00 = eofOn00;
+    }
+
+    boolean checkForEof() {
+        if (_eofOn00 && (_b1 == 0x00 && _b2 == 0x00)) {
+            _eofReached = true;
+            setParentEofDetect(true);
+        }
+        return _eofReached;
+    }
+
+    public int read(byte[] b, int off, int len)
+        throws IOException {
+        // Only use this optimisation if we aren't checking for 00
+        if (_eofOn00 || len < 3) {
+            return super.read(b, off, len);
+        }
+
+        if (_eofReached) {
+            return -1;
+        }
+
+        int numRead = _in.read(b, off + 2, len - 2);
+
+        if (numRead < 0) {
+//          throw new EOFException();
+            _eofReached = true;
+            return -1;
+        }
+
+        b[off] = (byte) _b1;
+        b[off + 1] = (byte) _b2;
+
+        _b1 = _in.read();
+        _b2 = _in.read();
+
+        if (_b2 < 0) {
+            // Corrupted stream
+//            throw new EOFException();
+            _eofReached = true;
+            // Just fall thru...
+        }
+
+        return numRead + 2;
+    }
+
+    public int read()
+        throws IOException {
+        if (checkForEof()) {
+            return -1;
+        }
+
+        int b = _in.read();
+
+        //
+        // strictly speaking we should return b1 and b2, but if this happens the stream
+        // is corrupted so we are already in trouble.
+        //
+        if (b < 0) {
+            // Corrupted stream
+//            throw new EOFException();
+            _eofReached = true;
+
+            return -1;
+        }
+
+        int v = _b1;
+
+        _b1 = _b2;
+        _b2 = b;
+
+        return v;
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/LimitedInputStream.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/LimitedInputStream.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/LimitedInputStream.java
new file mode 100644
index 0000000..e1af7d2
--- /dev/null
+++ b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/LimitedInputStream.java
@@ -0,0 +1,23 @@
+package org.apache.commons.ssl.asn1;
+
+import java.io.InputStream;
+
+abstract class LimitedInputStream
+    extends InputStream {
+    protected final InputStream _in;
+
+    LimitedInputStream(
+        InputStream in) {
+        this._in = in;
+    }
+
+    InputStream getUnderlyingStream() {
+        return _in;
+    }
+
+    protected void setParentEofDetect(boolean on) {
+        if (_in instanceof IndefiniteLengthInputStream) {
+            ((IndefiniteLengthInputStream) _in).setEofOn00(on);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/OIDTokenizer.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/OIDTokenizer.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/OIDTokenizer.java
new file mode 100644
index 0000000..b59c009
--- /dev/null
+++ b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/OIDTokenizer.java
@@ -0,0 +1,42 @@
+package org.apache.commons.ssl.asn1;
+
+/**
+ * class for breaking up an OID into it's component tokens, ala
+ * java.util.StringTokenizer. We need this class as some of the
+ * lightweight Java environment don't support classes like
+ * StringTokenizer.
+ */
+public class OIDTokenizer {
+    private String oid;
+    private int index;
+
+    public OIDTokenizer(
+        String oid) {
+        this.oid = oid;
+        this.index = 0;
+    }
+
+    public boolean hasMoreTokens() {
+        return (index != -1);
+    }
+
+    public String nextToken() {
+        if (index == -1) {
+            return null;
+        }
+
+        String token;
+        int end = oid.indexOf('.', index);
+
+        if (end == -1) {
+            token = oid.substring(index);
+            index = -1;
+            return token;
+        }
+
+        token = oid.substring(index, end);
+
+        index = end + 1;
+        return token;
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/Strings.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/Strings.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/Strings.java
new file mode 100644
index 0000000..74104be
--- /dev/null
+++ b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/Strings.java
@@ -0,0 +1,195 @@
+package org.apache.commons.ssl.asn1;
+
+import java.io.ByteArrayOutputStream;
+import java.util.Vector;
+
+public final class Strings {
+    public static String fromUTF8ByteArray(byte[] bytes) {
+        int i = 0;
+        int length = 0;
+
+        while (i < bytes.length) {
+            length++;
+            if ((bytes[i] & 0xf0) == 0xf0) {
+                // surrogate pair
+                length++;
+                i += 4;
+            } else if ((bytes[i] & 0xe0) == 0xe0) {
+                i += 3;
+            } else if ((bytes[i] & 0xc0) == 0xc0) {
+                i += 2;
+            } else {
+                i += 1;
+            }
+        }
+
+        char[] cs = new char[length];
+
+        i = 0;
+        length = 0;
+
+        while (i < bytes.length) {
+            char ch;
+
+            if ((bytes[i] & 0xf0) == 0xf0) {
+                int codePoint = ((bytes[i] & 0x03) << 18) | ((bytes[i + 1] & 0x3F) << 12) | ((bytes[i + 2] & 0x3F) << 6) | (bytes[i + 3] & 0x3F);
+                int U = codePoint - 0x10000;
+                char W1 = (char) (0xD800 | (U >> 10));
+                char W2 = (char) (0xDC00 | (U & 0x3FF));
+                cs[length++] = W1;
+                ch = W2;
+                i += 4;
+            } else if ((bytes[i] & 0xe0) == 0xe0) {
+                ch = (char) (((bytes[i] & 0x0f) << 12)
+                             | ((bytes[i + 1] & 0x3f) << 6) | (bytes[i + 2] & 0x3f));
+                i += 3;
+            } else if ((bytes[i] & 0xd0) == 0xd0) {
+                ch = (char) (((bytes[i] & 0x1f) << 6) | (bytes[i + 1] & 0x3f));
+                i += 2;
+            } else if ((bytes[i] & 0xc0) == 0xc0) {
+                ch = (char) (((bytes[i] & 0x1f) << 6) | (bytes[i + 1] & 0x3f));
+                i += 2;
+            } else {
+                ch = (char) (bytes[i] & 0xff);
+                i += 1;
+            }
+
+            cs[length++] = ch;
+        }
+
+        return new String(cs);
+    }
+
+    public static byte[] toUTF8ByteArray(String string) {
+        ByteArrayOutputStream bOut = new ByteArrayOutputStream();
+        char[] c = string.toCharArray();
+        int i = 0;
+
+        while (i < c.length) {
+            char ch = c[i];
+
+            if (ch < 0x0080) {
+                bOut.write(ch);
+            } else if (ch < 0x0800) {
+                bOut.write(0xc0 | (ch >> 6));
+                bOut.write(0x80 | (ch & 0x3f));
+            }
+            // surrogate pair
+            else if (ch >= 0xD800 && ch <= 0xDFFF) {
+                // in error - can only happen, if the Java String class has a
+                // bug.
+                if (i + 1 >= c.length) {
+                    throw new IllegalStateException("invalid UTF-16 codepoint");
+                }
+                char W1 = ch;
+                ch = c[++i];
+                char W2 = ch;
+                // in error - can only happen, if the Java String class has a
+                // bug.
+                if (W1 > 0xDBFF) {
+                    throw new IllegalStateException("invalid UTF-16 codepoint");
+                }
+                int codePoint = (((W1 & 0x03FF) << 10) | (W2 & 0x03FF)) + 0x10000;
+                bOut.write(0xf0 | (codePoint >> 18));
+                bOut.write(0x80 | ((codePoint >> 12) & 0x3F));
+                bOut.write(0x80 | ((codePoint >> 6) & 0x3F));
+                bOut.write(0x80 | (codePoint & 0x3F));
+            } else {
+                bOut.write(0xe0 | (ch >> 12));
+                bOut.write(0x80 | ((ch >> 6) & 0x3F));
+                bOut.write(0x80 | (ch & 0x3F));
+            }
+
+            i++;
+        }
+
+        return bOut.toByteArray();
+    }
+
+    /**
+     * A locale independent version of toUpperCase.
+     *
+     * @param string input to be converted
+     * @return a US Ascii uppercase version
+     */
+    public static String toUpperCase(String string) {
+        boolean changed = false;
+        char[] chars = string.toCharArray();
+
+        for (int i = 0; i != chars.length; i++) {
+            char ch = chars[i];
+            if ('a' <= ch && 'z' >= ch) {
+                changed = true;
+                chars[i] = (char) (ch - 'a' + 'A');
+            }
+        }
+
+        if (changed) {
+            return new String(chars);
+        }
+
+        return string;
+    }
+
+    /**
+     * A locale independent version of toLowerCase.
+     *
+     * @param string input to be converted
+     * @return a US ASCII lowercase version
+     */
+    public static String toLowerCase(String string) {
+        boolean changed = false;
+        char[] chars = string.toCharArray();
+
+        for (int i = 0; i != chars.length; i++) {
+            char ch = chars[i];
+            if ('A' <= ch && 'Z' >= ch) {
+                changed = true;
+                chars[i] = (char) (ch - 'A' + 'a');
+            }
+        }
+
+        if (changed) {
+            return new String(chars);
+        }
+
+        return string;
+    }
+
+    public static byte[] toByteArray(String string) {
+        byte[] bytes = new byte[string.length()];
+
+        for (int i = 0; i != bytes.length; i++) {
+            char ch = string.charAt(i);
+
+            bytes[i] = (byte) ch;
+        }
+
+        return bytes;
+    }
+
+    public static String[] split(String input, char delimiter) {
+        Vector v = new Vector();
+        boolean moreTokens = true;
+        String subString;
+
+        while (moreTokens) {
+            int tokenLocation = input.indexOf(delimiter);
+            if (tokenLocation > 0) {
+                subString = input.substring(0, tokenLocation);
+                v.addElement(subString);
+                input = input.substring(tokenLocation + 1);
+            } else {
+                moreTokens = false;
+                v.addElement(input);
+            }
+        }
+
+        String[] res = new String[v.size()];
+
+        for (int i = 0; i != res.length; i++) {
+            res[i] = (String) v.elementAt(i);
+        }
+        return res;
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/rmi/DateRMI.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/rmi/DateRMI.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/rmi/DateRMI.java
new file mode 100644
index 0000000..d6248b9
--- /dev/null
+++ b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/rmi/DateRMI.java
@@ -0,0 +1,69 @@
+/*
+ * $HeadURL: http://juliusdavies.ca/svn/not-yet-commons-ssl/tags/commons-ssl-0.3.16/src/java/org/apache/commons/ssl/rmi/DateRMI.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.rmi;
+
+import java.io.Serializable;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.server.UnicastRemoteObject;
+import java.util.Date;
+
+/**
+ * @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 22-Feb-2007
+ */
+public class DateRMI extends UnicastRemoteObject
+    implements Remote, Serializable, RemoteDate {
+    private Date d;
+
+    public DateRMI() throws RemoteException {
+        super();
+        this.d = new Date();
+    }
+
+    public Date getDate() throws RemoteException {
+        return d;
+    }
+
+    public boolean equals(Object o) {
+        RemoteDate rd = (RemoteDate) o;
+        try {
+            return d.equals(rd.getDate());
+        }
+        catch (RemoteException re) {
+            return false;
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/rmi/IntegerRMI.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/rmi/IntegerRMI.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/rmi/IntegerRMI.java
new file mode 100644
index 0000000..a9c1237
--- /dev/null
+++ b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/rmi/IntegerRMI.java
@@ -0,0 +1,69 @@
+/*
+ * $HeadURL: http://juliusdavies.ca/svn/not-yet-commons-ssl/tags/commons-ssl-0.3.16/src/java/org/apache/commons/ssl/rmi/IntegerRMI.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.rmi;
+
+import java.io.Serializable;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.server.UnicastRemoteObject;
+
+/**
+ * @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 22-Feb-2007
+ */
+public class IntegerRMI extends UnicastRemoteObject
+    implements Remote, Serializable, RemoteInteger {
+    private int i;
+
+    public IntegerRMI() throws RemoteException {
+        super();
+        this.i = (int) Math.round(Math.random() * 1000000.0);
+    }
+
+    public int getInt() throws RemoteException {
+        return i;
+    }
+
+    public boolean equals(Object o) {
+        RemoteInteger ri = (RemoteInteger) o;
+        try {
+            return i == ri.getInt();
+        }
+        catch (RemoteException re) {
+            return false;
+        }
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/rmi/RemoteDate.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/rmi/RemoteDate.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/rmi/RemoteDate.java
new file mode 100644
index 0000000..07bfaf8
--- /dev/null
+++ b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/rmi/RemoteDate.java
@@ -0,0 +1,46 @@
+/*
+ * $HeadURL: http://juliusdavies.ca/svn/not-yet-commons-ssl/tags/commons-ssl-0.3.16/src/java/org/apache/commons/ssl/rmi/RemoteDate.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.rmi;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.util.Date;
+
+/**
+ * @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 22-Feb-2007
+ */
+public interface RemoteDate extends Remote {
+    public Date getDate() throws RemoteException;
+}

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/rmi/RemoteInteger.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/rmi/RemoteInteger.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/rmi/RemoteInteger.java
new file mode 100644
index 0000000..8a0e5f7
--- /dev/null
+++ b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/rmi/RemoteInteger.java
@@ -0,0 +1,45 @@
+/*
+ * $HeadURL: http://juliusdavies.ca/svn/not-yet-commons-ssl/tags/commons-ssl-0.3.16/src/java/org/apache/commons/ssl/rmi/RemoteInteger.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.rmi;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+/**
+ * @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 22-Feb-2007
+ */
+public interface RemoteInteger extends Remote {
+    public int getInt() throws RemoteException;
+}

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/rmi/Test.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/rmi/Test.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/rmi/Test.java
new file mode 100644
index 0000000..ba81efc
--- /dev/null
+++ b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/rmi/Test.java
@@ -0,0 +1,200 @@
+/*
+ * $HeadURL: http://juliusdavies.ca/svn/not-yet-commons-ssl/tags/commons-ssl-0.3.16/src/java/org/apache/commons/ssl/rmi/Test.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.rmi;
+
+import org.apache.commons.ssl.LogWrapper;
+import org.apache.commons.ssl.RMISocketFactoryImpl;
+
+import java.net.MalformedURLException;
+import java.rmi.Naming;
+import java.rmi.NotBoundException;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.server.RMISocketFactory;
+
+/**
+ * @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 22-Feb-2007
+ */
+public class Test {
+    private final static LogWrapper log = LogWrapper.getLogger(Test.class);
+    private final static String TEST_DATE_NAME = "/org.apache.commons.ssl.rmi.testdate";
+    private final static String TEST_INT_NAME = "/org.apache.commons.ssl.rmi.testint";
+    protected final static int PORT;
+    protected final static String URL;
+
+    private static boolean rmiRunning = false;
+
+    static {
+        int port = 1099;
+        String host = "127.0.0.1";
+        PORT = port;
+        // e.g. "rmi://localhost:1099/"
+        URL = "rmi://" + host + ":" + port;
+    }
+
+    /**
+     * <p/>
+     * JNDI/RMI lookup wrapper.  Appends "java:" if we expect
+     * binding/lookup to occur in the same JVM.  Otherwise, appends "rmi:".
+     * </p>
+     *
+     * @param ref String reference.
+     * @return Object  Object previously bound with String reference.
+     * @throws java.rmi.RemoteException       rmi problem
+     * @throws java.rmi.NotBoundException     rmi problem
+     * @throws java.net.MalformedURLException rmi problem
+     */
+    public static Object lookup(String ref)
+        throws RemoteException, NotBoundException, MalformedURLException {
+        return Naming.lookup(URL + ref);
+    }
+
+    /**
+     * <p/>
+     * JNDI/RMI rebind wrapper for the UCS.  Appends "java:" if we expect
+     * binding/lookup to occur in the same JVM.  Otherwise, append "rmi:".
+     * </p><p>
+     * Also attempts to start a naming server on the localhost if one is
+     * not already running.  Currently we use RMI.
+     * </p>
+     *
+     * @param ref String reference to bind with.
+     * @param obj Object to bind.
+     * @throws java.rmi.RemoteException       rmi problem
+     * @throws java.net.MalformedURLException rmi problem
+     */
+    public static void rebind(String ref, Remote obj)
+        throws RemoteException, MalformedURLException {
+        requireNameServer();
+        String realRef = URL + ref;
+        Naming.rebind(realRef, obj);
+        try {
+            Object o = lookup(ref);
+            log.debug("Bound " + o.getClass().getName() + " to [" + realRef + "]");
+        }
+        catch (NotBoundException nbe) {
+            log.debug("Error binding " + obj.getClass().getName() + " to [" + realRef + "]");
+        }
+    }
+
+    private static void rebindTest() throws Exception {
+        Remote remoteTest = new DateRMI();
+        Naming.rebind(URL + TEST_DATE_NAME, remoteTest);
+        Object o = Naming.lookup(URL + TEST_DATE_NAME);
+        if (!remoteTest.equals(o)) {
+            throw new RuntimeException("rmi: Test failed. Lookup != Rebind");
+        }
+    }
+
+    /**
+     * <p/>
+     * Attempts to start a naming server on the localhost if one is not
+     * already running.
+     * </p>
+     */
+    private synchronized static void requireNameServer() {
+        if (rmiRunning) {
+            // We've already established that the name server is running.
+            return;
+        }
+        try {
+            // If this rebind works, then the naming server is running.
+            rebindTest();
+            rmiRunning = true;
+        }
+        catch (Exception e) {
+            Test.tryToStartNameServer();
+            try {
+                // Okay, we've started our naming server.  Now we must perform a
+                // quick test to see that it's actually doing something.
+                rebindTest();
+                log.debug(Test.class.getName() + " successfully started.");
+                rmiRunning = true;
+                return;
+            }
+            catch (Exception e2) {
+                e2.printStackTrace();
+                log.error(e2.getMessage(), e2);
+            }
+
+            String msg = Test.class.getName() + " cannot start.";
+            log.error(msg);
+            throw new RuntimeException(msg);
+        }
+    }
+
+    public static void tryToStartNameServer() {
+        String className = Test.class.getName();
+        log.debug(className + " probably not running.   Trying to start one.");
+        try {
+            LocateRegistry.createRegistry(PORT);
+            log.debug("registry on " + PORT + " started!");
+        }
+        catch (Exception problem) {
+            // bah - no luck
+            problem.printStackTrace();
+            log.warn(problem, problem);
+        }
+    }
+
+
+    public static void main(String[] args) throws Exception {
+        System.setProperty(RMISocketFactoryImpl.RMI_HOSTNAME_KEY, "localhost");
+        RMISocketFactoryImpl impl = new RMISocketFactoryImpl();
+        RMISocketFactory.setSocketFactory(impl);
+
+        if (args.length > 0) {
+
+        } else {
+            Test.requireNameServer();
+            Test.rebindTest();
+
+            IntegerRMI remoteInt = new IntegerRMI();
+            Test.rebind(TEST_INT_NAME, remoteInt);
+        }
+
+        Object o = Test.lookup(TEST_DATE_NAME);
+        RemoteDate rd = (RemoteDate) o;
+        System.out.println("The remote-date is: " + rd.getDate());
+
+        o = Test.lookup(TEST_INT_NAME);
+        RemoteInteger ri = (RemoteInteger) o;
+        System.out.println("The remote-int  is: " + ri.getInt());
+
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/util/ByteArrayReadLine.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/util/ByteArrayReadLine.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/util/ByteArrayReadLine.java
new file mode 100644
index 0000000..88d0a29
--- /dev/null
+++ b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/util/ByteArrayReadLine.java
@@ -0,0 +1,32 @@
+package org.apache.commons.ssl.util;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+
+public class ByteArrayReadLine extends ReadLine {
+
+    public ByteArrayReadLine(ByteArrayInputStream in) { super(in); }
+
+    public String next() { return next(1); }
+
+    public String next(int lines) {
+        try {
+            return super.next(lines);
+        } catch (IOException ioe) {
+            // impossible since we're using ByteArrayInputStream
+            throw new RuntimeException("impossible", ioe);
+        }
+    }
+
+    public byte[] nextAsBytes() { return nextAsBytes(1); }
+
+    public byte[] nextAsBytes(int lines) {
+        try {
+            return super.nextAsBytes(lines);
+        } catch (IOException ioe) {
+            // impossible since we're using ByteArrayInputStream
+            throw new RuntimeException("impossible", ioe);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/util/Hex.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/util/Hex.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/util/Hex.java
new file mode 100644
index 0000000..2acebd1
--- /dev/null
+++ b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/util/Hex.java
@@ -0,0 +1,83 @@
+/*
+ * $HeadURL: http://juliusdavies.ca/svn/not-yet-commons-ssl/tags/commons-ssl-0.3.16/src/java/org/apache/commons/ssl/util/Hex.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.util;
+
+/**
+ * Utility class for dealing with hex-encoding of binary data.
+ *
+ * @author <a href="mailto:juliusdavies@cucbc.com">juliusdavies@gmail.com</a>
+ * @since 13-Nov-2007
+ */
+public class Hex {
+
+    public static byte[] decode(String s) {
+        byte[] b = new byte[s.length() / 2];
+        for (int i = 0; i < b.length; i++) {
+            String hex = s.substring(2 * i, 2 * (i + 1));
+            b[i] = (byte) Integer.parseInt(hex, 16);
+        }
+        return b;
+    }
+
+    public static byte[] decode(byte[] hexString) {
+        byte[] b = new byte[hexString.length / 2];
+        char[] chars = new char[2];
+        for (int i = 0; i < b.length; i++) {
+            chars[0] = (char) hexString[2 * i];
+            chars[1] = (char) hexString[2 * i + 1];
+            String hex = new String(chars);
+            b[i] = (byte) Integer.parseInt(hex, 16);
+        }
+        return b;
+    }
+
+    public static String encode(byte[] b) {
+        return encode(b, 0, b.length);
+    }
+
+    public static String encode(byte[] b, int offset, int length) {
+        StringBuffer buf = new StringBuffer();
+        int len = Math.min(offset + length, b.length);
+        for (int i = offset; i < len; i++) {
+            int c = (int) b[i];
+            if (c < 0) {
+                c = c + 256;
+            }
+            if (c >= 0 && c <= 15) {
+                buf.append('0');
+            }
+            buf.append(Integer.toHexString(c));
+        }
+        return buf.toString();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/util/IPAddressParser.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/util/IPAddressParser.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/util/IPAddressParser.java
new file mode 100644
index 0000000..b0da817
--- /dev/null
+++ b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/util/IPAddressParser.java
@@ -0,0 +1,183 @@
+/*
+ * $HeadURL: http://juliusdavies.ca/svn/not-yet-commons-ssl/trunk/src/java/org/apache/commons/ssl/util/IPAddressParser.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.util;
+
+/**
+ * Parses String representations of IPv4 and IPv6 addresses, and converts
+ * them to byte[].  Returns null if the supplied String is not a valid IP
+ * address.
+ * <p/>
+ * IPv6 addresses are allowed to include square brackets (e.g., "[::a:b:c:d]"),
+ * but IPv4 addresses are not.  This is to help in situation where an IPv6
+ * literal address is encoded directly inside a URL (the square brackets allow
+ * the web client to separate the IPv6 address from its port, since the colon
+ * character is overloaded in that context).
+ */
+public class IPAddressParser {
+
+    /**
+     * Converts the supplied IPv4 literal to byte[], or null if the
+     * IPv4 address was invalid.
+     *
+     * @param s Literal IPv4 address.
+     * @return byte[] array or null if the supplied IPv4 address was invalid.
+     */
+    public static byte[] parseIPv4Literal(String s) {
+        s = s != null ? s.trim() : "";
+        String[] toks = s.split("\\.");
+        byte[] ip = new byte[4];
+        if (toks.length == 4) {
+            for (int i = 0; i < ip.length; i++) {
+                try {
+                    int val = Integer.parseInt(toks[i]);
+                    if (val < 0 || val > 255) {
+                        return null;
+                    }
+                    ip[i] = (byte) val;
+                } catch (NumberFormatException nfe) {
+                    return null;
+                }
+            }
+            return ip;
+        }
+        return null;
+    }
+
+    /**
+     * Converts the supplied IPv6 literal to byte[], or null if the
+     * IPv6 address was invalid.
+     *
+     * @param s Literal IPv6 address.
+     * @return byte[] array or null if the supplied IPv6 address was invalid.
+     */
+    public static byte[] parseIPv6Literal(String s) {
+        s = s != null ? s.trim() : "";
+        if (s.length() > 0 && s.charAt(0) == '[' && s.charAt(s.length() - 1) == ']') {
+            s = s.substring(1, s.length() - 1).trim();
+        }
+        int x = s.lastIndexOf(':');
+        int y = s.indexOf('.');
+        // Contains a dot!  Look for IPv4 literal suffix.
+        if (x >= 0 && y > x) {
+            byte[] ip4Suffix = parseIPv4Literal(s.substring(x + 1));
+            if (ip4Suffix == null) {
+                return null;
+            }
+            s = s.substring(0, x) + ":" + ip4ToHex(ip4Suffix);
+        }
+
+        // Check that we only have a single occurence of "::".
+        x = s.indexOf("::");
+        if (x >= 0) {
+            if (s.indexOf("::", x + 1) >= 0) {
+                return null;
+            }
+        }
+
+        // This array helps us expand the "::" into the zeroes it represents.
+        String[] raw = new String[]{"0000", "0000", "0000", "0000", "0000", "0000", "0000", "0000"};
+        if (s.indexOf("::") >= 0) {
+            String[] split = s.split("::", -1);
+            String[] prefix = splitOnColon(split[0]);
+            String[] suffix = splitOnColon(split[1]);
+
+            // Make sure the "::" zero-expander has some room to expand!
+            if (prefix.length + suffix.length > 7) {
+                return null;
+            }
+            for (int i = 0; i < prefix.length; i++) {
+                raw[i] = prependZeroes(prefix[i]);
+            }
+            int startPos = raw.length - suffix.length;
+            for (int i = 0; i < suffix.length; i++) {
+                raw[startPos + i] = prependZeroes(suffix[i]);
+            }
+        } else {
+            // Okay, whew, no "::" zero-expander, but we still have to make sure
+            // each element contains 4 hex characters.
+            raw = splitOnColon(s);
+            if (raw.length != 8) {
+                return null;
+            }
+            for (int i = 0; i < raw.length; i++) {
+                raw[i] = prependZeroes(raw[i]);
+            }
+        }
+
+        byte[] ip6 = new byte[16];
+        int i = 0;
+        for (int j = 0; j < raw.length; j++) {
+            String tok = raw[j];
+            if (tok.length() > 4) {
+                return null;
+            }
+            String prefix = tok.substring(0, 2);
+            String suffix = tok.substring(2, 4);
+            try {
+                ip6[i++] = (byte) Integer.parseInt(prefix, 16);
+                ip6[i++] = (byte) Integer.parseInt(suffix, 16);
+            } catch (NumberFormatException nfe) {
+                return null;
+            }
+        }
+        return ip6;
+    }
+
+    private static String prependZeroes(String s) {
+        switch (s.length()) {
+            case 0: return "0000";
+            case 1: return "000" + s;
+            case 2: return "00" + s;
+            case 3: return "0" + s;
+            default: return s;
+        }
+    }
+
+    private static String[] splitOnColon(String s) {
+        if ("".equals(s)) {
+            return new String[]{};
+        } else {
+            return s.split(":");
+        }
+    }
+
+    private static String ip4ToHex(byte[] b) {
+        return b2s(b[0]) + b2s(b[1]) + ":" + b2s(b[2]) + b2s(b[3]);
+    }
+
+    private static String b2s(byte b) {
+        String s = Integer.toHexString(b >= 0 ? b : 256 + b);
+        if (s.length() < 2) {
+            s = "0" + s;
+        }
+        return s;
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/util/PublicKeyDeriver.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/util/PublicKeyDeriver.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/util/PublicKeyDeriver.java
new file mode 100644
index 0000000..1ff15a0
--- /dev/null
+++ b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/util/PublicKeyDeriver.java
@@ -0,0 +1,82 @@
+/*
+ * $HeadURL: http://juliusdavies.ca/svn/not-yet-commons-ssl/trunk/src/java/org/apache/commons/ssl/Certificates.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.util;
+
+import java.math.BigInteger;
+import java.security.GeneralSecurityException;
+import java.security.KeyException;
+import java.security.KeyFactory;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+import java.security.interfaces.DSAParams;
+import java.security.interfaces.DSAPrivateKey;
+import java.security.interfaces.RSAPrivateCrtKey;
+import java.security.spec.DSAPublicKeySpec;
+import java.security.spec.RSAPublicKeySpec;
+
+/**
+ * Utility class for deriving a public key from a given private key.
+ *
+ * @author Chad La Joie <lajoie OF georgetown.edu>
+ * @since November 14th, 2007
+ */
+public class PublicKeyDeriver {
+
+    /**
+     * Utility method for deriving a public key from a given private key.
+     *
+     * @param key private key for which we need a public key (DSA or RSA).
+     * @return the corresponding public key
+     * @throws java.security.GeneralSecurityException if it didn't work
+     */
+    public static PublicKey derivePublicKey(PrivateKey key) throws GeneralSecurityException {
+        if (key instanceof DSAPrivateKey) {
+            DSAPrivateKey dsaKey = (DSAPrivateKey) key;
+            DSAParams keyParams = dsaKey.getParams();
+            BigInteger g = keyParams.getG();
+            BigInteger p = keyParams.getP();
+            BigInteger q = keyParams.getQ();
+            BigInteger x = dsaKey.getX();
+            BigInteger y = q.modPow(x, p);
+            DSAPublicKeySpec keySpec = new DSAPublicKeySpec(y, p, q, g);
+            return KeyFactory.getInstance("DSA").generatePublic(keySpec);
+        } else if (key instanceof RSAPrivateCrtKey) {
+            RSAPrivateCrtKey rsaKey = (RSAPrivateCrtKey) key;
+            BigInteger modulus = rsaKey.getModulus();
+            BigInteger exponent = rsaKey.getPublicExponent();
+            RSAPublicKeySpec keySpec = new RSAPublicKeySpec(modulus, exponent);
+            return KeyFactory.getInstance("RSA").generatePublic(keySpec);
+        } else {
+            throw new KeyException("Private key was not a DSA or RSA key");
+        }
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/util/ReadLine.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/util/ReadLine.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/util/ReadLine.java
new file mode 100644
index 0000000..ee68016
--- /dev/null
+++ b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/util/ReadLine.java
@@ -0,0 +1,91 @@
+package org.apache.commons.ssl.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * @author Julius Davies
+ * @author 23-Dec-2007
+ */
+public class ReadLine {
+
+    final InputStream in;
+    final byte[] bytes = new byte[8192];
+    int pos = 0;
+    int avail = 0;
+
+    public ReadLine(InputStream in) { this.in = in; }
+
+    public String next() throws IOException { return next(1); }
+
+    public String next(int lines) throws IOException {
+        if (lines < 1) {
+            lines = 1;
+        }
+        StringBuffer buf = new StringBuffer(128 * lines);
+        if (avail <= 0 || pos >= avail) {
+            pos = 0;
+            avail = in.read(bytes);
+        }
+        while (avail >= 0) {
+            while (pos < avail) {
+                char c = (char) bytes[pos++];
+                switch (c) {
+                    case '\n':
+                    case '\r':
+                        lines--;
+                        if (lines < 1 && buf.length() > 0) {
+                            return buf.toString();
+                        }
+                        break;
+                    default:
+                        buf.append(c);
+                        break;
+                }
+            }
+            pos = 0;
+            avail = in.read(bytes);
+        }
+        return buf.length() > 0 ? buf.toString() : null;
+    }
+
+    public byte[] nextAsBytes() throws IOException { return nextAsBytes(1); }
+
+    public byte[] nextAsBytes(int lines) throws IOException {
+        if (lines < 1) {
+            lines = 1;
+        }
+        byte[] buf = new byte[8192];
+        int bufPos = 0;
+        if (avail <= 0 || pos >= avail) {
+            pos = 0;
+            avail = in.read(bytes);
+        }
+        while (avail >= 0) {
+            while (pos < avail) {
+                byte b = bytes[pos++];
+                switch (b) {
+                    case '\n':
+                    case '\r':
+                        lines--;
+                        if (lines == 0 && bufPos > 0) {
+                            return buf;
+                        }
+                        break;
+                    default:
+                        if (bufPos >= buf.length) {
+                            byte[] moreBuff = new byte[buf.length * 2];
+                            System.arraycopy(buf, 0, moreBuff, 0, buf.length);
+                            buf = moreBuff;
+                        }
+                        buf[bufPos++] = b;
+                        break;
+                }
+            }
+            pos = 0;
+            avail = in.read(bytes);
+        }
+        return bufPos > 0 ? buf : null;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/23c1fd12/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/util/UTF8.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/util/UTF8.java b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/util/UTF8.java
new file mode 100644
index 0000000..8fa771a
--- /dev/null
+++ b/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/util/UTF8.java
@@ -0,0 +1,22 @@
+package org.apache.commons.ssl.util;
+
+import java.io.UnsupportedEncodingException;
+
+public class UTF8 {
+
+    public static String toString(byte[] bytes) {
+        try {
+            return new String(bytes, "UTF-8");
+        } catch (UnsupportedEncodingException uee) {
+            throw new RuntimeException("UTF8 unavailable", uee);
+        }
+    }
+
+    public static byte[] toBytes(String s) {
+        try {
+            return s.getBytes("UTF-8");
+        } catch (UnsupportedEncodingException uee) {
+            throw new RuntimeException("UTF8 unavailable", uee);
+        }
+    }
+}