directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dran...@apache.org
Subject directory-kerby git commit: DIRKRB-487. Introduced the Asn1 API class
Date Fri, 04 Dec 2015 23:10:32 GMT
Repository: directory-kerby
Updated Branches:
  refs/heads/master 75c648331 -> 4cb4366c3


DIRKRB-487. Introduced the Asn1 API class


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

Branch: refs/heads/master
Commit: 4cb4366c395a6a86e523e2770931eed462a10f57
Parents: 75c6483
Author: Kai Zheng <kai.zheng@intel.com>
Authored: Sat Dec 5 07:10:15 2015 +0800
Committer: Kai Zheng <kai.zheng@intel.com>
Committed: Sat Dec 5 07:10:15 2015 +0800

----------------------------------------------------------------------
 .../main/java/org/apache/kerby/asn1/Asn1.java   | 93 ++++++++++++++++++++
 .../java/org/apache/kerby/asn1/Asn1Dump.java    | 57 ------------
 .../org/apache/kerby/asn1/Asn1Dumpable.java     | 19 ++++
 .../java/org/apache/kerby/asn1/Asn1Dumper.java  |  5 +-
 .../org/apache/kerby/asn1/Asn1InputBuffer.java  | 62 -------------
 .../org/apache/kerby/asn1/Asn1OutputBuffer.java | 67 --------------
 .../org/apache/kerby/asn1/type/Asn1Choice.java  |  3 +-
 .../apache/kerby/asn1/type/Asn1Constructed.java |  3 +-
 .../org/apache/kerby/asn1/type/Asn1Object.java  | 15 ----
 .../org/apache/kerby/asn1/TestAsn1Dump.java     | 41 +++++++++
 .../org/apache/kerby/asn1/TestAsn1Input.java    | 35 --------
 .../apache/kerby/asn1/TestPersonnelRecord.java  |  1 -
 .../apache/kerby/kerberos/kerb/KrbCodec.java    |  5 +-
 13 files changed, 162 insertions(+), 244 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/4cb4366c/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1.java
new file mode 100644
index 0000000..68698a9
--- /dev/null
+++ b/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1.java
@@ -0,0 +1,93 @@
+/**
+ *  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;
+
+import org.apache.kerby.asn1.type.Asn1Item;
+import org.apache.kerby.asn1.type.Asn1Type;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+/**
+ * The shortcut API for ASN1 encoding, decoding and dumping.
+ * TO BE WELL DOCUMENTED.
+ */
+public final class Asn1 {
+
+    private Asn1() {
+
+    }
+
+    public static void encode(ByteBuffer buffer, Asn1Type value) {
+        value.encode(buffer);
+    }
+
+    public static byte[] encode(Asn1Type value) {
+        return value.encode();
+    }
+
+    public static Asn1Header decodeHeader(ByteBuffer content) throws IOException {
+        Asn1Reader1 reader = new Asn1Reader1(content);
+        return reader.readHeader();
+    }
+
+    public static Asn1Type decode(byte[] content) throws IOException {
+        return decode(ByteBuffer.wrap(content));
+    }
+
+    public static Asn1Type decode(ByteBuffer content) throws IOException {
+        Asn1Reader1 reader = new Asn1Reader1(content);
+        Asn1Header header = reader.readHeader();
+
+        Asn1Item result = new Asn1Item(header.getTag(), header.getValueBuffer());
+        result.useDefinitiveLength(header.isDefinitiveLength());
+
+        return result;
+    }
+
+    public static void dump(Asn1Type value) {
+        Asn1Dumper dumper = new Asn1Dumper();
+        dumper.dumpType(0, value);
+        String output = dumper.output();
+        System.out.println(output);
+    }
+
+    public static void dump(String hexStr) throws IOException {
+        System.out.println("Dumping data:");
+        System.out.println(hexStr);
+        Asn1Dumper dumper = new Asn1Dumper();
+        byte[] data = HexUtil.hex2bytes(hexStr);
+        dumper.dump(data);
+    }
+
+    public static void dump(byte[] content) throws IOException {
+        String hexStr = HexUtil.bytesToHex(content);
+        System.out.println("Dumping data:");
+        System.out.println(hexStr);
+        Asn1Dumper dumper = new Asn1Dumper();
+        dumper.dump(content);
+    }
+
+    public static void dump(ByteBuffer content) throws IOException {
+        byte[] bytes = new byte[content.remaining()];
+        content.get(bytes);
+        dump(bytes);
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/4cb4366c/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1Dump.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1Dump.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1Dump.java
deleted file mode 100644
index 188277c..0000000
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1Dump.java
+++ /dev/null
@@ -1,57 +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;
-
-import org.apache.kerby.asn1.type.Asn1Type;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-public class Asn1Dump {
-
-    public static void dump(Asn1Type value) {
-        Asn1Dumper dumper = new Asn1Dumper();
-        dumper.dumpType(0, value);
-        String output = dumper.output();
-        System.out.println(output);
-    }
-
-    public static void dump(String hexStr) throws IOException {
-        System.out.println("Dumping data:");
-        System.out.println(hexStr);
-        Asn1Dumper dumper = new Asn1Dumper();
-        byte[] data = HexUtil.hex2bytes(hexStr);
-        dumper.dump(data);
-    }
-
-    public static void dump(byte[] content) throws IOException {
-        String hexStr = HexUtil.bytesToHex(content);
-        System.out.println("Dumping data:");
-        System.out.println(hexStr);
-        Asn1Dumper dumper = new Asn1Dumper();
-        dumper.dump(content);
-    }
-
-    public static void dump(ByteBuffer content) throws IOException {
-        byte[] bytes = new byte[content.remaining()];
-        content.get(bytes);
-        dump(bytes);
-    }
-}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/4cb4366c/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1Dumpable.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1Dumpable.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1Dumpable.java
index 8bbe4cf..d4ae6d9 100644
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1Dumpable.java
+++ b/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1Dumpable.java
@@ -1,3 +1,22 @@
+/**
+ *  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;
 
 public interface Asn1Dumpable {

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/4cb4366c/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1Dumper.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1Dumper.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1Dumper.java
index ecc4bdd..739e59d 100644
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1Dumper.java
+++ b/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1Dumper.java
@@ -25,7 +25,7 @@ import org.apache.kerby.asn1.type.Asn1Type;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 
-public class Asn1Dumper {
+public final class Asn1Dumper {
 
     private StringBuilder builder = new StringBuilder();
 
@@ -38,8 +38,7 @@ public class Asn1Dumper {
     }
 
     public void dump(ByteBuffer content) throws IOException {
-        Asn1InputBuffer buffer = new Asn1InputBuffer(content);
-        Asn1Type value = buffer.read();
+        Asn1Type value = Asn1.decode(content);
         if (value == null) {
             return;
         }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/4cb4366c/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1InputBuffer.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1InputBuffer.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1InputBuffer.java
deleted file mode 100644
index 3242ccc..0000000
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1InputBuffer.java
+++ /dev/null
@@ -1,62 +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;
-
-import org.apache.kerby.asn1.type.Asn1Object;
-import org.apache.kerby.asn1.type.Asn1Type;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-
-/**
- * Asn1 decoder. Given an input stream, it validates and parses
- * according to ASN1 spec, and the resultant object can be read
- * and read until exhausted.
- */
-public class Asn1InputBuffer {
-    private final ByteBuffer buffer;
-
-    /**
-     * Constructor with bytes.
-     * @param bytes The bytes
-     */
-    public Asn1InputBuffer(byte[] bytes) {
-        this(ByteBuffer.wrap(bytes));
-    }
-
-    /**
-     * Constructor with a ByteBuffer.
-     * @param byteBuffer The byte buffer
-     */
-    public Asn1InputBuffer(ByteBuffer byteBuffer) {
-        this.buffer = byteBuffer;
-    }
-
-    /**
-     * Parse and read ASN1 object from the stream. If it's already
-     * exhausted then null will be returned to indicate the end.
-     * @return an ASN1 object if available otherwise null
-     * @throws IOException e
-     */
-    public Asn1Type read() throws IOException {
-        Asn1Type one = Asn1Object.readOne(buffer);
-        return one;
-    }
-}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/4cb4366c/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1OutputBuffer.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1OutputBuffer.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1OutputBuffer.java
deleted file mode 100644
index 729e042..0000000
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/Asn1OutputBuffer.java
+++ /dev/null
@@ -1,67 +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;
-
-import org.apache.kerby.asn1.type.Asn1Object;
-import org.apache.kerby.asn1.type.Asn1Type;
-
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Asn1 encoder
- */
-public class Asn1OutputBuffer {
-    private List<Asn1Type> objects;
-
-    public Asn1OutputBuffer() {
-        this.objects = new ArrayList<Asn1Type>(3);
-    }
-
-    public void write(Asn1Type value) {
-        objects.add(value);
-    }
-
-    public ByteBuffer getOutput() {
-        int len = encodingLength();
-        ByteBuffer byteBuffer = ByteBuffer.allocate(len);
-        encode(byteBuffer);
-        return byteBuffer;
-    }
-
-    private int encodingLength() {
-        int allLen = 0;
-        for (Asn1Type item : objects) {
-            if (item != null) {
-                allLen += ((Asn1Object) item).encodingLength();
-            }
-        }
-        return allLen;
-    }
-
-    private void encode(ByteBuffer buffer) {
-        for (Asn1Type item : objects) {
-            if (item != null) {
-                item.encode(buffer);
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/4cb4366c/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 2d02bd8..e7eb853 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
@@ -19,6 +19,7 @@
  */
 package org.apache.kerby.asn1.type;
 
+import org.apache.kerby.asn1.Asn1;
 import org.apache.kerby.asn1.Asn1FieldInfo;
 import org.apache.kerby.asn1.EnumType;
 import org.apache.kerby.asn1.TaggingOption;
@@ -74,7 +75,7 @@ public class Asn1Choice extends AbstractAsn1Type<Asn1Type> {
     @Override
     public void decode(ByteBuffer content) throws IOException {
         int foundPos = -1;
-        Asn1Item item = readOne(content);
+        Asn1Item item = (Asn1Item) Asn1.decode(content);
         for (int i = 0; i < fieldInfos.length; ++i) {
             if (item.isContextSpecific()) {
                 if (fieldInfos[i].getTagNo() == item.tagNo()) {

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/4cb4366c/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Constructed.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Constructed.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Constructed.java
index aec8504..6008282 100644
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Constructed.java
+++ b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Constructed.java
@@ -19,6 +19,7 @@
  */
 package org.apache.kerby.asn1.type;
 
+import org.apache.kerby.asn1.Asn1;
 import org.apache.kerby.asn1.Tag;
 
 import java.io.IOException;
@@ -79,7 +80,7 @@ public class Asn1Constructed extends AbstractAsn1Type<List<Asn1Type>>
{
     @Override
     protected void decodeBody(ByteBuffer content) throws IOException {
         while (content.remaining() > 0) {
-            Asn1Item item = readOne(content);
+            Asn1Item item = (Asn1Item) Asn1.decode(content);
             if (item != null) {
                 if (item.isSimple() && !isLazy()) {
                     item.decodeValueAsSimple();

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/4cb4366c/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Object.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Object.java b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Object.java
index 6a3a3a2..70a43a7 100644
--- a/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Object.java
+++ b/kerby-asn1/src/main/java/org/apache/kerby/asn1/type/Asn1Object.java
@@ -287,19 +287,4 @@ public abstract class Asn1Object implements Asn1Type {
             decode(content);
         }
     }
-
-    public static Asn1Header readHeader(ByteBuffer content) throws IOException {
-        Asn1Reader1 reader = new Asn1Reader1(content);
-        return reader.readHeader();
-    }
-
-    public static Asn1Item readOne(ByteBuffer content) throws IOException {
-        Asn1Reader1 reader = new Asn1Reader1(content);
-        Asn1Header header = reader.readHeader();
-
-        Asn1Item result = new Asn1Item(header.getTag(), header.getValueBuffer());
-        result.useDefinitiveLength(header.isDefinitiveLength());
-
-        return result;
-    }
 }

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/4cb4366c/kerby-asn1/src/test/java/org/apache/kerby/asn1/TestAsn1Dump.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/test/java/org/apache/kerby/asn1/TestAsn1Dump.java b/kerby-asn1/src/test/java/org/apache/kerby/asn1/TestAsn1Dump.java
new file mode 100644
index 0000000..540de22
--- /dev/null
+++ b/kerby-asn1/src/test/java/org/apache/kerby/asn1/TestAsn1Dump.java
@@ -0,0 +1,41 @@
+/**
+ *  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;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.io.IOException;
+
+public class TestAsn1Dump {
+
+    @Test
+    public void testDecoding() throws IOException {
+        try {
+            PersonnelRecord pr = TestData.createSamplePersonnel();
+            Asn1.dump(pr);
+
+            byte[] data = TestData.createSammplePersonnelEncodingData();
+            Asn1.dump(data);
+        } catch (Exception e) {
+            Assert.fail();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/4cb4366c/kerby-asn1/src/test/java/org/apache/kerby/asn1/TestAsn1Input.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/test/java/org/apache/kerby/asn1/TestAsn1Input.java b/kerby-asn1/src/test/java/org/apache/kerby/asn1/TestAsn1Input.java
deleted file mode 100644
index 9a5b2c5..0000000
--- a/kerby-asn1/src/test/java/org/apache/kerby/asn1/TestAsn1Input.java
+++ /dev/null
@@ -1,35 +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;
-
-import org.junit.Test;
-
-import java.io.IOException;
-
-public class TestAsn1Input {
-
-    @Test
-    public void testDecoding() throws IOException {
-        //PersonnelRecord expected = TestData.createSamplePersonnel();
-        byte[] data = TestData.createSammplePersonnelEncodingData();
-        //Asn1InputBuffer ib = new Asn1InputBuffer(data);
-        Asn1Dump.dump(data);
-    }
-}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/4cb4366c/kerby-asn1/src/test/java/org/apache/kerby/asn1/TestPersonnelRecord.java
----------------------------------------------------------------------
diff --git a/kerby-asn1/src/test/java/org/apache/kerby/asn1/TestPersonnelRecord.java b/kerby-asn1/src/test/java/org/apache/kerby/asn1/TestPersonnelRecord.java
index 1e77f47..828aec0 100644
--- a/kerby-asn1/src/test/java/org/apache/kerby/asn1/TestPersonnelRecord.java
+++ b/kerby-asn1/src/test/java/org/apache/kerby/asn1/TestPersonnelRecord.java
@@ -36,7 +36,6 @@ public class TestPersonnelRecord {
     @Test
     public void testEncoding() {
         PersonnelRecord pr = TestData.createSamplePersonnel();
-        Asn1Dump.dump(pr);
 
         if (verbose) {
             System.out.println("Name:");

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/4cb4366c/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/KrbCodec.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/KrbCodec.java
b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/KrbCodec.java
index d95c14e..87d5731 100644
--- a/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/KrbCodec.java
+++ b/kerby-kerb/kerb-core/src/main/java/org/apache/kerby/kerberos/kerb/KrbCodec.java
@@ -19,9 +19,9 @@
  */
 package org.apache.kerby.kerberos.kerb;
 
+import org.apache.kerby.asn1.Asn1;
 import org.apache.kerby.asn1.Asn1Header;
 import org.apache.kerby.asn1.Tag;
-import org.apache.kerby.asn1.type.Asn1Object;
 import org.apache.kerby.asn1.type.Asn1Type;
 import org.apache.kerby.kerberos.kerb.type.ap.ApReq;
 import org.apache.kerby.kerberos.kerb.type.base.KrbError;
@@ -65,7 +65,7 @@ public class KrbCodec {
     }
 
     public static KrbMessage decodeMessage(ByteBuffer buffer) throws IOException {
-        Asn1Header header = Asn1Object.readHeader(buffer);
+        Asn1Header header = Asn1.decodeHeader(buffer);
         Tag tag = header.getTag();
 
         KrbMessage msg;
@@ -87,6 +87,7 @@ public class KrbCodec {
         } else {
             throw new IOException("To be supported krb message type with tag: " + tag);
         }
+
         msg.decode(tag, header.getValueBuffer());
         return msg;
     }


Mime
View raw message