1package org.bouncycastle.asn1; 2 3import java.io.IOException; 4import java.io.InputStream; 5 6public class DEROctetStringParser 7 implements ASN1OctetStringParser 8{ 9 private DefiniteLengthInputStream stream; 10 11 DEROctetStringParser( 12 DefiniteLengthInputStream stream) 13 { 14 this.stream = stream; 15 } 16 17 public InputStream getOctetStream() 18 { 19 return stream; 20 } 21 22 public ASN1Primitive getLoadedObject() 23 throws IOException 24 { 25 return new DEROctetString(stream.toByteArray()); 26 } 27 28 public ASN1Primitive toASN1Primitive() 29 { 30 try 31 { 32 return getLoadedObject(); 33 } 34 catch (IOException e) 35 { 36 throw new ASN1ParsingException("IOException converting stream to byte array: " + e.getMessage(), e); 37 } 38 } 39} 40