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

📄 asn1sequence.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:   ASN1Sequence.java

package org.bouncycastle.asn1;

import java.io.IOException;
import java.util.Enumeration;
import java.util.Vector;

// Referenced classes of package org.bouncycastle.asn1:
//			ASN1Object, ASN1TaggedObject, BERSequence, BERTaggedObject, 
//			DEREncodable, DERObject, DERSequence, ASN1SequenceParser, 
//			DEROutputStream, ASN1Set

public abstract class ASN1Sequence extends ASN1Object
{

	private Vector seq;

	public ASN1Sequence()
	{
		seq = new Vector();
	}

	public static ASN1Sequence getInstance(Object obj)
	{
		if (obj == null || (obj instanceof ASN1Sequence))
			return (ASN1Sequence)obj;
		else
			throw new IllegalArgumentException("unknown object in getInstance");
	}

	public static ASN1Sequence getInstance(ASN1TaggedObject obj, boolean explicit)
	{
		if (explicit)
			if (!obj.isExplicit())
				throw new IllegalArgumentException("object implicit - explicit expected.");
			else
				return (ASN1Sequence)obj.getObject();
		if (obj.isExplicit())
			if (obj instanceof BERTaggedObject)
				return new BERSequence(obj.getObject());
			else
				return new DERSequence(obj.getObject());
		if (obj.getObject() instanceof ASN1Sequence)
			return (ASN1Sequence)obj.getObject();
		else
			throw new IllegalArgumentException("unknown object in getInstanceFromTagged");
	}

	public Enumeration getObjects()
	{
		return seq.elements();
	}

	public ASN1SequenceParser parser()
	{
		final ASN1Sequence outer = this;
		return new ASN1SequenceParser() {

			private final int max;
			private int index;
			final ASN1Sequence val$outer;
			final ASN1Sequence this$0;

			public DEREncodable readObject()
				throws IOException
			{
				if (index == max)
					return null;
				DEREncodable obj = getObjectAt(index++);
				if (obj instanceof ASN1Sequence)
					return ((ASN1Sequence)obj).parser();
				if (obj instanceof ASN1Set)
					return ((ASN1Set)obj).parser();
				else
					return obj;
			}

			public DERObject getDERObject()
			{
				return outer;
			}

			
			{
				this$0 = ASN1Sequence.this;
				outer = asn1sequence1;
				super();
				max = size();
			}
		};
	}

	public DEREncodable getObjectAt(int index)
	{
		return (DEREncodable)seq.elementAt(index);
	}

	public int size()
	{
		return seq.size();
	}

	public int hashCode()
	{
		Enumeration e = getObjects();
		int hashCode = 0;
		do
		{
			if (!e.hasMoreElements())
				break;
			Object o = e.nextElement();
			if (o != null)
				hashCode ^= o.hashCode();
		} while (true);
		return hashCode;
	}

	boolean asn1Equals(DERObject o)
	{
		if (!(o instanceof ASN1Sequence))
			return false;
		ASN1Sequence other = (ASN1Sequence)o;
		if (size() != other.size())
			return false;
		Enumeration s1 = getObjects();
		Enumeration s2 = other.getObjects();
		while (s1.hasMoreElements()) 
		{
			DERObject o1 = ((DEREncodable)s1.nextElement()).getDERObject();
			DERObject o2 = ((DEREncodable)s2.nextElement()).getDERObject();
			if (o1 != o2 && (o1 == null || !o1.equals(o2)))
				return false;
		}
		return true;
	}

	protected void addObject(DEREncodable obj)
	{
		seq.addElement(obj);
	}

	abstract void encode(DEROutputStream deroutputstream)
		throws IOException;

	public String toString()
	{
		return seq.toString();
	}
}

⌨️ 快捷键说明

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