TBSRequest.java
资源名称:security.rar [点击查看]
上传用户:lior1029
上传日期:2013-05-07
资源大小:209k
文件大小:3k
源码类别:
CA认证
开发平台:
Java
- package org.bouncycastle.asn1.ocsp;
- import org.bouncycastle.asn1.ASN1Sequence;
- import org.bouncycastle.asn1.ASN1TaggedObject;
- import org.bouncycastle.asn1.DERSequence;
- import org.bouncycastle.asn1.DERTaggedObject;
- import org.bouncycastle.asn1.DERObject;
- import org.bouncycastle.asn1.DERInteger;
- import org.bouncycastle.asn1.DEREncodable;
- import org.bouncycastle.asn1.ASN1EncodableVector;
- import org.bouncycastle.asn1.x509.GeneralName;
- import org.bouncycastle.asn1.x509.X509Extensions;
- public class TBSRequest
- implements DEREncodable
- {
- DERInteger version;
- GeneralName requestorName;
- ASN1Sequence requestList;
- X509Extensions requestExtensions;
- public TBSRequest(
- ASN1Sequence seq)
- {
- version = DERInteger.getInstance((ASN1TaggedObject)seq.getObjectAt(0), true);
- int index = 1;
- if (seq.getObjectAt(index) instanceof ASN1TaggedObject)
- {
- requestorName = GeneralName.getInstance((ASN1TaggedObject)seq.getObjectAt(index++), true);
- }
- requestList = (ASN1Sequence)seq.getObjectAt(index++);
- if (seq.size() == (index + 1))
- {
- requestExtensions = X509Extensions.getInstance((ASN1TaggedObject)seq.getObjectAt(index), true);
- }
- }
- public static TBSRequest getInstance(
- ASN1TaggedObject obj,
- boolean explicit)
- {
- return getInstance(ASN1Sequence.getInstance(obj, explicit));
- }
- public static TBSRequest getInstance(
- Object obj)
- {
- if (obj == null || obj instanceof TBSRequest)
- {
- return (TBSRequest)obj;
- }
- else if (obj instanceof ASN1Sequence)
- {
- return new TBSRequest((ASN1Sequence)obj);
- }
- throw new IllegalArgumentException("unknown object in factory");
- }
- public DERInteger getVersion()
- {
- return version;
- }
- public GeneralName getRequestorName()
- {
- return requestorName;
- }
- public ASN1Sequence getRequestList()
- {
- return requestList;
- }
- public X509Extensions getRequestExtensions()
- {
- return requestExtensions;
- }
- /**
- * <pre>
- * TBSRequest ::= SEQUENCE {
- * version [0] EXPLICIT Version DEFAULT v1,
- * requestorName [1] EXPLICIT GeneralName OPTIONAL,
- * requestList SEQUENCE OF Request,
- * requestExtensions [2] EXPLICIT Extensions OPTIONAL }
- * </pre>
- */
- public DERObject getDERObject()
- {
- ASN1EncodableVector v = new ASN1EncodableVector();
- v.add(new DERTaggedObject(true, 0, version));
- v.add(new DERTaggedObject(true, 1, requestorName));
- v.add(requestList);
- v.add(new DERTaggedObject(true, 2, requestExtensions));
- return new DERSequence(v);
- }
- }