⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 berinputstream.java

📁 java 文件下载器。可自定义
💻 JAVA
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   BERInputStream.java

package org.bouncycastle.asn1;

import java.io.*;
import java.util.Vector;

// Referenced classes of package org.bouncycastle.asn1:
//			DERInputStream, ASN1EncodableVector, BERConstructedOctetString, BERConstructedSequence, 
//			BERSet, BERTaggedObject, DEROctetString, DERTaggedObject, 
//			DERObject, DEROutputStream

/**
 * @deprecated Class BERInputStream is deprecated
 */

public class BERInputStream extends DERInputStream
{

	private static final DERObject END_OF_STREAM = new DERObject() {

		void encode(DEROutputStream out)
			throws IOException
		{
			throw new IOException("Eeek!");
		}

		public int hashCode()
		{
			return 0;
		}

		public boolean equals(Object o)
		{
			return o == this;
		}

	};

	public BERInputStream(InputStream is)
	{
		super(is);
	}

	private byte[] readIndefiniteLengthFully()
		throws IOException
	{
		ByteArrayOutputStream bOut = new ByteArrayOutputStream();
		int b;
		for (int b1 = read(); (b = read()) >= 0 && (b1 != 0 || b != 0); b1 = b)
			bOut.write(b1);

		return bOut.toByteArray();
	}

	private BERConstructedOctetString buildConstructedOctetString()
		throws IOException
	{
		Vector octs = new Vector();
		do
		{
			DERObject o = readObject();
			if (o != END_OF_STREAM)
				octs.addElement(o);
			else
				return new BERConstructedOctetString(octs);
		} while (true);
	}

	public DERObject readObject()
		throws IOException
	{
		int tag = read();
		if (tag == -1)
			throw new EOFException();
		int length = readLength();
		if (length < 0)
		{
			switch (tag)
			{
			case 5: // '\005'
				return null;

			case 48: // '0'
				BERConstructedSequence seq = new BERConstructedSequence();
				do
				{
					DERObject obj = readObject();
					if (obj != END_OF_STREAM)
						seq.addObject(obj);
					else
						return seq;
				} while (true);

			case 36: // '$'
				return buildConstructedOctetString();

			case 49: // '1'
				ASN1EncodableVector v = new ASN1EncodableVector();
				do
				{
					DERObject obj = readObject();
					if (obj != END_OF_STREAM)
						v.add(obj);
					else
						return new BERSet(v);
				} while (true);
			}
			if ((tag & 0x80) != 0)
			{
				if ((tag & 0x1f) == 31)
					throw new IOException("unsupported high tag encountered");
				if ((tag & 0x20) == 0)
				{
					byte bytes[] = readIndefiniteLengthFully();
					return new BERTaggedObject(false, tag & 0x1f, new DEROctetString(bytes));
				}
				DERObject dObj = readObject();
				if (dObj == END_OF_STREAM)
					return new DERTaggedObject(tag & 0x1f);
				DERObject next = readObject();
				if (next == END_OF_STREAM)
					return new BERTaggedObject(tag & 0x1f, dObj);
				BERConstructedSequence seq = new BERConstructedSequence();
				seq.addObject(dObj);
				do
				{
					seq.addObject(next);
					next = readObject();
				} while (next != END_OF_STREAM);
				return new BERTaggedObject(false, tag & 0x1f, seq);
			} else
			{
				throw new IOException("unknown BER object encountered");
			}
		}
		if (tag == 0 && length == 0)
		{
			return END_OF_STREAM;
		} else
		{
			byte bytes[] = new byte[length];
			readFully(bytes);
			return buildObject(tag, bytes);
		}
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -