001package org.apache.commons.ssl.org.bouncycastle.asn1; 002 003import java.io.IOException; 004import java.io.OutputStream; 005 006public class BEROutputStream 007 extends DEROutputStream 008{ 009 public BEROutputStream( 010 OutputStream os) 011 { 012 super(os); 013 } 014 015 public void writeObject( 016 Object obj) 017 throws IOException 018 { 019 if (obj == null) 020 { 021 writeNull(); 022 } 023 else if (obj instanceof ASN1Primitive) 024 { 025 ((ASN1Primitive)obj).encode(this); 026 } 027 else if (obj instanceof ASN1Encodable) 028 { 029 ((ASN1Encodable)obj).toASN1Primitive().encode(this); 030 } 031 else 032 { 033 throw new IOException("object not BEREncodable"); 034 } 035 } 036}