001package org.apache.commons.ssl.org.bouncycastle.asn1.cms; 002 003import org.apache.commons.ssl.org.bouncycastle.asn1.ASN1Encodable; 004import org.apache.commons.ssl.org.bouncycastle.asn1.ASN1EncodableVector; 005import org.apache.commons.ssl.org.bouncycastle.asn1.ASN1Object; 006import org.apache.commons.ssl.org.bouncycastle.asn1.ASN1ObjectIdentifier; 007import org.apache.commons.ssl.org.bouncycastle.asn1.ASN1Primitive; 008import org.apache.commons.ssl.org.bouncycastle.asn1.ASN1Sequence; 009import org.apache.commons.ssl.org.bouncycastle.asn1.ASN1TaggedObject; 010import org.apache.commons.ssl.org.bouncycastle.asn1.DERSequence; 011 012/** 013 * <a href="http://tools.ietf.org/html/rfc5652#section-10.2.1">RFC 5652</a>: OtherRevocationInfoFormat object. 014 * <p> 015 * <pre> 016 * OtherRevocationInfoFormat ::= SEQUENCE { 017 * otherRevInfoFormat OBJECT IDENTIFIER, 018 * otherRevInfo ANY DEFINED BY otherRevInfoFormat } 019 * </pre> 020 */ 021public class OtherRevocationInfoFormat 022 extends ASN1Object 023{ 024 private ASN1ObjectIdentifier otherRevInfoFormat; 025 private ASN1Encodable otherRevInfo; 026 027 public OtherRevocationInfoFormat( 028 ASN1ObjectIdentifier otherRevInfoFormat, 029 ASN1Encodable otherRevInfo) 030 { 031 this.otherRevInfoFormat = otherRevInfoFormat; 032 this.otherRevInfo = otherRevInfo; 033 } 034 035 private OtherRevocationInfoFormat( 036 ASN1Sequence seq) 037 { 038 otherRevInfoFormat = ASN1ObjectIdentifier.getInstance(seq.getObjectAt(0)); 039 otherRevInfo = seq.getObjectAt(1); 040 } 041 042 /** 043 * Return a OtherRevocationInfoFormat object from a tagged object. 044 * 045 * @param obj the tagged object holding the object we want. 046 * @param explicit true if the object is meant to be explicitly 047 * tagged false otherwise. 048 * @exception IllegalArgumentException if the object held by the 049 * tagged object cannot be converted. 050 */ 051 public static OtherRevocationInfoFormat getInstance( 052 ASN1TaggedObject obj, 053 boolean explicit) 054 { 055 return getInstance(ASN1Sequence.getInstance(obj, explicit)); 056 } 057 058 /** 059 * Return a OtherRevocationInfoFormat object from the given object. 060 * <p> 061 * Accepted inputs: 062 * <ul> 063 * <li> null → null 064 * <li> {@link OtherRevocationInfoFormat} object 065 * <li> {@link org.bouncycastle.asn1.ASN1Sequence#getInstance(java.lang.Object) ASN1Sequence} input formats with OtherRevocationInfoFormat structure inside 066 * </ul> 067 * 068 * @param obj the object we want converted. 069 * @exception IllegalArgumentException if the object cannot be converted. 070 */ 071 public static OtherRevocationInfoFormat getInstance( 072 Object obj) 073 { 074 if (obj instanceof OtherRevocationInfoFormat) 075 { 076 return (OtherRevocationInfoFormat)obj; 077 } 078 079 if (obj != null) 080 { 081 return new OtherRevocationInfoFormat(ASN1Sequence.getInstance(obj)); 082 } 083 084 return null; 085 } 086 087 public ASN1ObjectIdentifier getInfoFormat() 088 { 089 return otherRevInfoFormat; 090 } 091 092 public ASN1Encodable getInfo() 093 { 094 return otherRevInfo; 095 } 096 097 /** 098 * Produce an object suitable for an ASN1OutputStream. 099 */ 100 public ASN1Primitive toASN1Primitive() 101 { 102 ASN1EncodableVector v = new ASN1EncodableVector(); 103 104 v.add(otherRevInfoFormat); 105 v.add(otherRevInfo); 106 107 return new DERSequence(v); 108 } 109}