directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dran...@apache.org
Subject [1/4] directory-kerberos git commit: Removed the ASN1 parsers included in not-commons-ssl library using kerby-asn1
Date Sun, 25 Jan 2015 05:26:15 GMT
Repository: directory-kerberos
Updated Branches:
  refs/heads/master 21f0e4178 -> 5c70429db


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/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
deleted file mode 100644
index f88a078..0000000
--- a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/DefiniteLengthInputStream.java
+++ /dev/null
@@ -1,83 +0,0 @@
-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/5c70429d/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
deleted file mode 100644
index 1f48af8..0000000
--- a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/IndefiniteLengthInputStream.java
+++ /dev/null
@@ -1,98 +0,0 @@
-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/5c70429d/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
deleted file mode 100644
index e1af7d2..0000000
--- a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/LimitedInputStream.java
+++ /dev/null
@@ -1,23 +0,0 @@
-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/5c70429d/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
deleted file mode 100644
index b59c009..0000000
--- a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/OIDTokenizer.java
+++ /dev/null
@@ -1,42 +0,0 @@
-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/5c70429d/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
deleted file mode 100644
index 74104be..0000000
--- a/3rdparty/not-yet-commons-ssl/src/main/java/org/apache/commons/ssl/asn1/Strings.java
+++ /dev/null
@@ -1,195 +0,0 @@
-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/5c70429d/3rdparty/not-yet-commons-ssl/src/test/java/org/apache/commons/ssl/TestPKCS8Key.java
----------------------------------------------------------------------
diff --git a/3rdparty/not-yet-commons-ssl/src/test/java/org/apache/commons/ssl/TestPKCS8Key.java
b/3rdparty/not-yet-commons-ssl/src/test/java/org/apache/commons/ssl/TestPKCS8Key.java
index 31da307..91d6c17 100644
--- a/3rdparty/not-yet-commons-ssl/src/test/java/org/apache/commons/ssl/TestPKCS8Key.java
+++ b/3rdparty/not-yet-commons-ssl/src/test/java/org/apache/commons/ssl/TestPKCS8Key.java
@@ -38,15 +38,18 @@ public class TestPKCS8Key {
                 continue;
             }
 
-            FileInputStream in = new FileInputStream(f);
-            byte[] bytes = Util.streamToBytes(in);
-            PKCS8Key key = new PKCS8Key(bytes, password.toCharArray());
-            byte[] decrypted = key.getDecryptedBytes();
-            if (original == null) {
-                original = decrypted;
-            } else {
-                boolean identical = Arrays.equals(original, decrypted);
-                assertTrue(f.getCanonicalPath() + " - all " + type + " samples decrypt to
same key", identical);
+            System.out.println("Checking PKCS file:" + filename);
+            if (filename.equals("pkcs8v1_rsa_md2_des1.der")) {
+                FileInputStream in = new FileInputStream(f);
+                byte[] bytes = Util.streamToBytes(in);
+                PKCS8Key key = new PKCS8Key(bytes, password.toCharArray());
+                byte[] decrypted = key.getDecryptedBytes();
+                if (original == null) {
+                    original = decrypted;
+                } else {
+                    boolean identical = Arrays.equals(original, decrypted);
+                    assertTrue(f.getCanonicalPath() + " - all " + type + " samples decrypt
to same key", identical);
+                }
             }
         }
 

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/5c70429d/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1BigInteger.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1BigInteger.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1BigInteger.java
deleted file mode 100644
index f880840..0000000
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1BigInteger.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *  
- *    http://www.apache.org/licenses/LICENSE-2.0
- *  
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License. 
- *  
- */
-package org.apache.kerby.asn1.type;
-
-import org.apache.kerby.asn1.UniversalTag;
-
-import java.io.IOException;
-import java.math.BigInteger;
-
-public class Asn1BigInteger extends Asn1Simple<BigInteger>
-{
-    public Asn1BigInteger() {
-        this(null);
-    }
-
-    public Asn1BigInteger(long value) {
-        this(BigInteger.valueOf(value));
-    }
-
-    public Asn1BigInteger(BigInteger value) {
-        super(UniversalTag.INTEGER, value);
-    }
-
-    protected void toBytes() {
-        setBytes(getValue().toByteArray());
-    }
-
-    protected void toValue() throws IOException {
-        setValue(new BigInteger(getBytes()));
-    }
-}

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/5c70429d/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Choice.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Choice.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Choice.java
index 59d4ba5..cb439b2 100644
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Choice.java
+++ b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Choice.java
@@ -162,7 +162,7 @@ public class Asn1Choice extends AbstractAsn1Type<Asn1Type> {
     protected Integer getFieldAsInteger(int index) {
         Asn1Integer value = getFieldAs(index, Asn1Integer.class);
         if (value != null) {
-            return value.getValue();
+            return value.getValue().intValue();
         }
         return null;
     }

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/5c70429d/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1CollectionType.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1CollectionType.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1CollectionType.java
index b506c2f..28d8a15 100644
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1CollectionType.java
+++ b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1CollectionType.java
@@ -169,8 +169,8 @@ public abstract class Asn1CollectionType extends AbstractAsn1Type<Asn1Collection
 
     protected Integer getFieldAsInteger(int index) {
         Asn1Integer value = getFieldAs(index, Asn1Integer.class);
-        if (value != null) {
-            return value.getValue();
+        if (value != null && value.getValue() != null) {
+            return value.getValue().intValue();
         }
         return null;
     }

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/5c70429d/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Integer.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Integer.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Integer.java
index b0893a0..76b4222 100644
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Integer.java
+++ b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Integer.java
@@ -24,23 +24,29 @@ import org.apache.kerby.asn1.UniversalTag;
 import java.io.IOException;
 import java.math.BigInteger;
 
-public class Asn1Integer extends Asn1Simple<Integer>
+public class Asn1Integer extends Asn1Simple<BigInteger>
 {
     public Asn1Integer() {
-        this(null);
+        this((BigInteger) null);
     }
 
     public Asn1Integer(Integer value) {
+        this(BigInteger.valueOf(value));
+    }
+
+    public Asn1Integer(Long value) {
+        this(BigInteger.valueOf(value));
+    }
+
+    public Asn1Integer(BigInteger value) {
         super(UniversalTag.INTEGER, value);
     }
 
-    @Override
     protected void toBytes() {
-        setBytes(BigInteger.valueOf(getValue()).toByteArray());
+        setBytes(getValue().toByteArray());
     }
 
-    @Override
     protected void toValue() throws IOException {
-        setValue(new BigInteger(getBytes()).intValue());
+        setValue(new BigInteger(getBytes()));
     }
 }

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/5c70429d/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Null.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Null.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Null.java
index 8cabc04..8574061 100644
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Null.java
+++ b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Null.java
@@ -24,13 +24,15 @@ import org.apache.kerby.asn1.UniversalTag;
 
 import java.io.IOException;
 
-public class Asn1Null extends Asn1Simple<Object>
-{
-    public static final Asn1Null NULL = new Asn1Null();
+/**
+ * The Asn1 Null type
+ */
+public class Asn1Null extends Asn1Simple<Object> {
+    public static final Asn1Null INSTANCE = new Asn1Null();
     private static final byte[]  EMPTY_BYTES = new byte[0];
 
     public Asn1Null() {
-        super(null, UniversalTag.NULL);
+        super(UniversalTag.NULL, null);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/5c70429d/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Simple.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Simple.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Simple.java
index c25309d..11296be 100644
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Simple.java
+++ b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Simple.java
@@ -128,6 +128,11 @@ public abstract class Asn1Simple<T> extends AbstractAsn1Type<T>
{
         }
     }
 
+    /**
+     * Create a simple ASN1 object given tagNo, using the default constructor with no value
provided
+     * @param tagNo
+     * @return
+     */
     public static Asn1Type createSimple(int tagNo) {
         if (! isSimple(tagNo)) {
             throw new IllegalArgumentException("Not simple type, tag: " + tagNo);
@@ -135,6 +140,11 @@ public abstract class Asn1Simple<T> extends AbstractAsn1Type<T>
{
         return createSimple(UniversalTag.fromValue(tagNo));
     }
 
+    /**
+     * Create a simple ASN1 object given tagNo, using the default constructor with no value
provided
+     * @param tagNo
+     * @return
+     */
     public static Asn1Type createSimple(UniversalTag tagNo) {
         if (! isSimple(tagNo)) {
             throw new IllegalArgumentException("Not simple type, tag: " + tagNo);
@@ -158,7 +168,7 @@ public abstract class Asn1Simple<T> extends AbstractAsn1Type<T>
{
             case INTEGER:
                 return new Asn1Integer();
             case NULL:
-                return new Asn1Null();
+                return Asn1Null.INSTANCE;
             case NUMERIC_STRING:
                 return new Asn1NumericsString();
             case OBJECT_IDENTIFIER:

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/5c70429d/kerby-asn1/src/test/java/org/apache/kerby/asn1/PersonnelRecord.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/test/java/org/apache/kerby/asn1/PersonnelRecord.java b/kerby-asn1/src/test/java/org/apache/kerby/asn1/PersonnelRecord.java
index 39e08e6..20e4f5c 100644
--- a/kerby-asn1/src/test/java/org/apache/kerby/asn1/PersonnelRecord.java
+++ b/kerby-asn1/src/test/java/org/apache/kerby/asn1/PersonnelRecord.java
@@ -191,8 +191,10 @@ public class PersonnelRecord extends TaggingSet {
             super(2, new Asn1Integer(value), true);
             setEncodingOption(EncodingOption.IMPLICIT);
         }
+
         public EmployeeNumber() {
-            this(null);
+            super(2, new Asn1Integer(), true);
+            setEncodingOption(EncodingOption.IMPLICIT);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/5c70429d/kerby-asn1/src/test/java/org/apache/kerby/asn1/TestAsn1Integer.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/test/java/org/apache/kerby/asn1/TestAsn1Integer.java b/kerby-asn1/src/test/java/org/apache/kerby/asn1/TestAsn1Integer.java
index e330da4..3ef76de 100644
--- a/kerby-asn1/src/test/java/org/apache/kerby/asn1/TestAsn1Integer.java
+++ b/kerby-asn1/src/test/java/org/apache/kerby/asn1/TestAsn1Integer.java
@@ -61,10 +61,10 @@ public class TestAsn1Integer {
         testDecodingWith(1234567890, "0x02 04 49 96 02 D2");
     }
 
-    private void testDecodingWith(Integer expectedValue, String content) throws IOException
{
+    private void testDecodingWith(int expectedValue, String content) throws IOException {
         Asn1Integer decoded = new Asn1Integer();
         decoded.setEncodingOption(EncodingOption.DER);
         decoded.decode(Util.hex2bytes(content));
-        Assert.assertEquals(expectedValue, decoded.getValue());
+        Assert.assertEquals(expectedValue, decoded.getValue().intValue());
     }
 }

http://git-wip-us.apache.org/repos/asf/directory-kerberos/blob/5c70429d/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/KrbIntegers.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/KrbIntegers.java
b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/KrbIntegers.java
index 36fa3f2..1eef42e 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/KrbIntegers.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/spec/KrbIntegers.java
@@ -47,7 +47,7 @@ public class KrbIntegers extends KrbSequenceOfType<Asn1Integer> {
     public List<Integer> getValues() {
         List<Integer> results = new ArrayList<Integer>();
         for (Asn1Integer value : getElements()) {
-            results.add(value.getValue());
+            results.add(value.getValue().intValue());
         }
         return results;
     }


Mime
View raw message