001package org.apache.commons.ssl.org.bouncycastle.asn1.esf; 002 003import java.io.IOException; 004 005import org.apache.commons.ssl.org.bouncycastle.asn1.ASN1Encodable; 006import org.apache.commons.ssl.org.bouncycastle.asn1.ASN1EncodableVector; 007import org.apache.commons.ssl.org.bouncycastle.asn1.ASN1Encoding; 008import org.apache.commons.ssl.org.bouncycastle.asn1.ASN1Object; 009import org.apache.commons.ssl.org.bouncycastle.asn1.ASN1ObjectIdentifier; 010import org.apache.commons.ssl.org.bouncycastle.asn1.ASN1Primitive; 011import org.apache.commons.ssl.org.bouncycastle.asn1.ASN1Sequence; 012import org.apache.commons.ssl.org.bouncycastle.asn1.DERSequence; 013 014/** 015 * <pre> 016 * OtherRevRefs ::= SEQUENCE { 017 * otherRevRefType OtherRevRefType, 018 * otherRevRefs ANY DEFINED BY otherRevRefType 019 * } 020 * 021 * OtherRevRefType ::= OBJECT IDENTIFIER 022 * </pre> 023 */ 024public class OtherRevRefs 025 extends ASN1Object 026{ 027 028 private ASN1ObjectIdentifier otherRevRefType; 029 private ASN1Encodable otherRevRefs; 030 031 public static OtherRevRefs getInstance(Object obj) 032 { 033 if (obj instanceof OtherRevRefs) 034 { 035 return (OtherRevRefs)obj; 036 } 037 else if (obj != null) 038 { 039 return new OtherRevRefs(ASN1Sequence.getInstance(obj)); 040 } 041 042 return null; 043 } 044 045 private OtherRevRefs(ASN1Sequence seq) 046 { 047 if (seq.size() != 2) 048 { 049 throw new IllegalArgumentException("Bad sequence size: " 050 + seq.size()); 051 } 052 this.otherRevRefType = new ASN1ObjectIdentifier(((ASN1ObjectIdentifier)seq.getObjectAt(0)).getId()); 053 try 054 { 055 this.otherRevRefs = ASN1Primitive.fromByteArray(seq.getObjectAt(1) 056 .toASN1Primitive().getEncoded(ASN1Encoding.DER)); 057 } 058 catch (IOException e) 059 { 060 throw new IllegalStateException(); 061 } 062 } 063 064 public OtherRevRefs(ASN1ObjectIdentifier otherRevRefType, ASN1Encodable otherRevRefs) 065 { 066 this.otherRevRefType = otherRevRefType; 067 this.otherRevRefs = otherRevRefs; 068 } 069 070 public ASN1ObjectIdentifier getOtherRevRefType() 071 { 072 return this.otherRevRefType; 073 } 074 075 public ASN1Encodable getOtherRevRefs() 076 { 077 return this.otherRevRefs; 078 } 079 080 public ASN1Primitive toASN1Primitive() 081 { 082 ASN1EncodableVector v = new ASN1EncodableVector(); 083 v.add(this.otherRevRefType); 084 v.add(this.otherRevRefs); 085 return new DERSequence(v); 086 } 087}