aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/lowagie/bc/asn1/BEROutputStream.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/lowagie/bc/asn1/BEROutputStream.java')
-rw-r--r--src/main/java/com/lowagie/bc/asn1/BEROutputStream.java36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/main/java/com/lowagie/bc/asn1/BEROutputStream.java b/src/main/java/com/lowagie/bc/asn1/BEROutputStream.java
new file mode 100644
index 0000000..9ae1126
--- /dev/null
+++ b/src/main/java/com/lowagie/bc/asn1/BEROutputStream.java
@@ -0,0 +1,36 @@
+package com.lowagie.bc.asn1;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+public class BEROutputStream
+ extends DEROutputStream
+{
+ public BEROutputStream(
+ OutputStream os)
+ {
+ super(os);
+ }
+
+ public void writeObject(
+ Object obj)
+ throws IOException
+ {
+ if (obj == null)
+ {
+ writeNull();
+ }
+ else if (obj instanceof DERObject)
+ {
+ ((DERObject)obj).encode(this);
+ }
+ else if (obj instanceof DEREncodable)
+ {
+ ((DEREncodable)obj).getDERObject().encode(this);
+ }
+ else
+ {
+ throw new IOException("object not BEREncodable");
+ }
+ }
+}