title: How to parse the ASN1 data by using bouncycastle
body: <p>I have the byte array which is in the form of asn1 format..now i want to parse this data to get required information..Here is the code they have written for c++..now i want to do the same in java.could any one help on this.</p>
  
  <p>ASN1 asn1(in);      </p>
  
  <pre><code> int startPos = in.tellg();
   asn1.enterObject(asn1.getTag());
   int endPos = asn1.getCurrentLength() + in.tellg();
  
   ubytearray acctId, valData;
  
   while (in.tellg() &lt; endPos) {
       asn1.enterObject(0x30); //0x30 TAG_SEQ
  
       // read the name
       ubytearray nameData = asn1.getContent(ASN1_TAG_UTF8_STRING);
       ubytearray octstr =  asn1.getContent(ASN1_TAG_OCTET_STRING);
  </code></pre>
  
  <p>ASN1 asn2(octstr);
           asn2.enterObject(0x30);
           ustring urlstr(asn2.getContent(ASN1_TAG_UTF8_STRING));
           ustring nameStr(asn2.getContent(ASN1_TAG_UTF8_STRING));
           asn2.enterObject(0x30);
           ubytearray certs = asn2.getContent(ASN1_TAG_OCTET_STRING);</p>
  
  <pre><code>     if ((urlstr.length() &gt; 0)  &amp;&amp; (nameStr.length() &gt; 0) &amp;&amp; (certs.length() &gt; 0)) {
           printf("url %s\n", urlstr.c_str());
           printf("name %s\n", nameStr.c_str());
           printf("certs len:%d\n", certs.length());  
  </code></pre>
  
  <p>}
  } </p>