001package org.apache.commons.ssl.org.bouncycastle.asn1; 002 003import java.io.IOException; 004import java.io.InputStream; 005 006public class DEROctetStringParser 007 implements ASN1OctetStringParser 008{ 009 private DefiniteLengthInputStream stream; 010 011 DEROctetStringParser( 012 DefiniteLengthInputStream stream) 013 { 014 this.stream = stream; 015 } 016 017 public InputStream getOctetStream() 018 { 019 return stream; 020 } 021 022 public ASN1Primitive getLoadedObject() 023 throws IOException 024 { 025 return new DEROctetString(stream.toByteArray()); 026 } 027 028 public ASN1Primitive toASN1Primitive() 029 { 030 try 031 { 032 return getLoadedObject(); 033 } 034 catch (IOException e) 035 { 036 throw new ASN1ParsingException("IOException converting stream to byte array: " + e.getMessage(), e); 037 } 038 } 039}