directory-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Wang, Xunhua - wangxx" <wan...@jmu.edu>
Subject ava.io.EOFException: ERR_00021 EOF encountered in middle of object; org.apache.directory.shared.asn1.der.ASN1InputStream.readFully
Date Wed, 29 Feb 2012 17:16:14 GMT
Hi,

Hope I am posting to the right list. If not, please let me know.

I am trying to use the org.apache.directory.server.kerberos.shared.io.decoder.KdcReplyDecoder
and the ErrorMessageDecoder classes to parse an AS_REP message and an error message (In response
to an AS_REQ request).

However, in both cases, I got the following error:
+++++ ERROR BEGINS +++++
java.io.EOFException: ERR_00021 EOF encountered in middle of object.
        at org.apache.directory.shared.asn1.der.ASN1InputStream.readFully(ASN1InputStream.java:176)
        at org.apache.directory.shared.asn1.der.ASN1InputStream.readObject(ASN1InputStream.java:523)
        at org.apache.directory.server.kerberos.shared.io.decoder.KdcReplyDecoder.decode(KdcReplyDecoder.java:64)
        at SimpleDecoder.parseMessages(SimpleDecoder.java:25)
        at SimpleDecoder.main(SimpleDecoder.java:39)
+++++ ERROR ENDS +++++

In the following code, these messages are copied from real Kerberos traffic and they can be
parsed by Wireshark.

What have I done wrong?

Thank you.

Steve

++++++++++ CODE BEGINS ++++++++++
import java.nio.ByteBuffer;

import org.apache.directory.server.kerberos.shared.io.decoder.*;
import org.apache.directory.server.kerberos.shared.messages.*;

public class SimpleDecoder {
	private String asErrorStr = "7e82010e3082010aa003020105a10302011ea411180f32303132303231373033333933355aa505020303b5daa603020119a9131b1143525950544f2e43532e4a4d552e454455aa263024a003020102a11d301b1b066b72627467741b1143525950544f2e43532e4a4d552e454455ac81a104819e30819b3078a103020113a271046f306d3020a003020111a1191b1743525950544f2e43532e4a4d552e45445577616e6778783005a0030201173020a003020103a1191b1743525950544f2e43532e4a4d552e45445577616e6778783020a003020101a1191b1743525950544f2e43532e4a4d552e45445577616e6778783009a103020102a20204003009a103020110a20204003009a10302010fa2020400";

	private String asRepStr = "6b82055f3082055ba003020105a10302010ba231302f302da103020113a226042430223020a003020111a1191b1743525950544f2e43532e4a4d552e45445577616e677878a3131b1143525950544f2e43532e4a4d552e454455a4133011a003020101a10a30081b0677616e677878a58203e1618203dd308203d9a003020105a1131b1143525950544f2e43532e4a4d552e454455a2263024a003020102a11d301b1b066b72627467741b1143525950544f2e43532e4a4d552e454455a38203933082038fa003020117a103020102a28203810482037d644c4202420dc2f8777101f929a1bbe5882d1b53514612b9562722caf3bbde64a3d92a9b46204dfc453e03eed6a2950955c40a7ce04b1bc0b725614ea7a34885903d544de4339e1218e3afc0438598eab59d2fbb59bdec951df6055ecc449dfc041534d125a71851fb9de91eec35af9d8c588a32929e1ea31fdd8d40987af5cdaa70f6ad06cac744cf7989be7c668a4d0af97cf3865e5070c6ff44d3f1abf3fbae432e3336d8b4d06daa0181c98485f4d331d29fafd01a0625673ba3dd9fe65f4317f3c4fa3c45a26ccc3caa6515b585a2bb3c3fa781046274e33bc94518cc2fd27fb60ecbe2479f330b3530a011865ff0a15282d27e5b3f1e2e34131efe28ed819b1c73ce27dfb1c5e5419aa68fcc3c3994bdc37c53e1ac03f645fb00bc24ff3506a9d11c7e63dddde938ac88947f810217be6f5bb1c3d691a07374e4580a34c56b04f0823e6569f0a8c51b3c8c8a0fbb9663859e0ec210e61e22860ae4c56611b2bfe375438838cd11c593d0e2cf6208f3d0f2166d23f6350253bc0171a72dcda3d31d33d64607537dbb19c76b8f684d3c619eba19ed8be70b6510a9a578832568bf844f1ea911896af6055eb3a6bfb126c7aa9f951475f336c7d6fa7ef48cd39e8d9946641291ec6799c304d095875c560056c6c482194d0d095859ae46297b9d757a6120482a2ba7c073cc842cb6a0f39294bd7acc7f19e4e12702278624c0d3000580466be313a59d1f4b47f2a699f6da2213997a42483b18f717eff959b330d73c61bf60b3d6b350528b464302b70207c9cabe51ae10898a36c4e939cf412b6f99a09ca86aac8c0043c117a6c4e5f8b606fcab0caeaefae70f359338e58ad16eb5cd3d20c4f758f852c18eec1302cebb63c0c8f448bccb36c2a62e2be3534aba816b7e26672e76e35af3790f84cb57eaaa05bfb49949f8c7bccbb6d228ec49e19dac51cb67ee8908f5772973e5ab000f0ca600bc87f631d21534f69aca1bd656efbf4f26c659b23435c1357091a5ea4166d21ee3f077b889281b9c996678d257e2849aa2c21d32c2e28406dd64a7521d809db154b6f36a68399bedcb3ac90906f316b8b67ebbc3cd3b5b5e991a25139ee8bff94935340c7ddb2d33783bfdb9b79dc13b62e600c801b0f990830391b7526352bf4c799e309371dc1090765649d2a934f0ca9e07a78f8cd59e42f9c80246c29fe17d33b96b2b7d364b291e8645f0aa6e7263c1eab1e7a3231f5562fa9b77632c2c489609bee158c1a682010b30820107a003020111a103020102a281fa0481f738bfbdef7613dede4f09662460db2ebcad50fa61f8cba9ccbdc15a5048f2de99f6c9ec4a68dff595ed928b9328d104bca86823f85959d821c62f488acf50431840890d521be2d8332571a43e0d238735a8d188a23b5e81776b151770b516c0e3478daabd7533b8d91f80744635b31e6e85dfe01200c716503983e57672e496244a9e156e6adcbd1bba35997e8df93abd1e6a5ff979744db98e180cc5653a5981a38285fcf1323a247887fcf1df760d15a4bf2f2c5f1cc88c8d3ead1f1bd8fa9641f3212c13924d9874756c822c0bebe4d45bc2a47ae41d319a267ed26ad9d7f9671c38a28105e18bbe5c7dd2a00c0af08a481335db9da3";

	private byte asRepBytes[] = null;
	private byte asErrBytes[] = null;

	public void init () {
		asRepBytes = stringToHex (asRepStr, 0);
		asErrBytes = stringToHex (asErrorStr, 0);
	}

	public void parseMessages () {
		try {

			System.out.println ("# of bytes = " + asRepBytes.length);
			ByteBuffer buf = ByteBuffer.wrap (asRepBytes);
			org.apache.directory.server.kerberos.shared.io.decoder.KdcReplyDecoder kryDecoder = new

				org.apache.directory.server.kerberos.shared.io.decoder.KdcReplyDecoder ();
			KdcReply kry = kryDecoder.decode (buf);

			ErrorMessageDecoder emd = new ErrorMessageDecoder ();
			ByteBuffer buf2 = ByteBuffer.wrap (asErrBytes);
			ErrorMessage em = emd.decode (buf2);
			System.out.println (em.toString ());
		} catch (Exception ex) {
			ex.printStackTrace ();
		}
	}

	public static void main (String[] args) {
		SimpleDecoder sd = new SimpleDecoder ();
		sd.init ();
		sd.parseMessages ();
	}

	public static byte[] stringToHex (String inString, int startPos) {
		String strTemplate = "0123456789ABCDEF";

                int length = inString.length();
                int resLen = (length-startPos)/2;
                byte[] res = new byte[resLen];

		// System.out.println ("::stringToHex inString = " + inString);
                
                for (int i = 0; i < resLen; i++) {
                    char c1 = inString.charAt(2*i + startPos);
			int pos1 = strTemplate.indexOf (c1);
                    char c2 = inString.charAt(2*i+1 + startPos);
			int pos2 = strTemplate.indexOf (c2);

			/// System.out.println ("Integers are (" + pos1 + "," + pos2 + ")");

                    res[i] = (byte )(( pos1 << 4 | pos2) & 0xff);
                }
                
                return res;
	}
}
++++++++++ CODE ENDS ++++++++++
Mime
View raw message