int tag = in.read(); if (tag == -1) throw new EOFException(); encBuf.write(tag); int len = readLength(); DERValue value = null; if ((tag & CONSTRUCTED) == CONSTRUCTED) { in.mark(2048); byte[] encoded = new byte[len]; in.read(encoded); encBuf.write(encoded); value = new DERValue(tag, len, CONSTRUCTED_VALUE, encBuf.toByteArray()); in.reset(); encBuf.reset(); return value; } switch (tag & 0xC0) { case UNIVERSAL: value = new DERValue(tag, len, readUniversal(tag, len), encBuf.toByteArray()); encBuf.reset(); break; case CONTEXT: byte[] encoded = new byte[len]; in.read(encoded); encBuf.write(encoded); value = new DERValue(tag, len, encoded, encBuf.toByteArray()); encBuf.reset(); break; case APPLICATION:   throw new DEREncodingException("non-constructed APPLICATION data"); default: throw new DEREncodingException("PRIVATE class not supported"); } return value;
return new DERReader(encoded).read();
  public DERValue read() throws IOException  {    int tag = in.read();    if (tag == -1)      throw new EOFException();    encBuf.write(tag);    int len = readLength();    DERValue value = null;    if ((tag & CONSTRUCTED) == CONSTRUCTED)      {        in.mark(2048);        byte[] encoded = new byte[len];        in.read(encoded);        encBuf.write(encoded);        value = new DERValue(tag, len, CONSTRUCTED_VALUE, encBuf.toByteArray());        in.reset();        encBuf.reset();        return value;      }    switch (tag & 0xC0)      {        case UNIVERSAL:          value = new DERValue(tag, len, readUniversal(tag, len),            encBuf.toByteArray());          encBuf.reset();          break;        case CONTEXT:          byte[] encoded = new byte[len];          in.read(encoded);          encBuf.write(encoded);          value = new DERValue(tag, len, encoded, encBuf.toByteArray());          encBuf.reset();          break;        case APPLICATION:          // This should not be reached, since (I think) APPLICATION is          // always constructed.          throw new DEREncodingException("non-constructed APPLICATION data");        default:          throw new DEREncodingException("PRIVATE class not supported");      }    return value;  }