public ASN1Value decode(Tag implicitTag, InputStream istream) throws InvalidBERException, IOException { SEQUENCE seq = (SEQUENCE) seqt.decode(implicitTag, istream); // ANY infoAny = (ANY)seq.elementAt(0); // byte[] infoEncoding = infoAny.getEncoded(); /*CertificationRequestInfo info = (CertificationRequestInfo) infoAny.decodeWith( CertificationRequestInfo.getTemplate() ); */ CertificationRequestInfo info = (CertificationRequestInfo) seq.elementAt(0); // although signature is a bit string, all algorithms we use // will produce an octet string. BIT_STRING bs = (BIT_STRING) seq.elementAt(2); if (bs.getPadCount() != 0) { throw new InvalidBERException( "signature does not fall into" + " an integral number of bytes"); } byte[] signature = bs.getBits(); return new CertificationRequest( info, // infoEncoding, (AlgorithmIdentifier) seq.elementAt(1), signature); }
public Template() { seqt = new SEQUENCE.Template(); seqt.addElement(CertificationRequestInfo.getTemplate()); // seqt.addElement( new ANY.Template() ); seqt.addElement(AlgorithmIdentifier.getTemplate()); seqt.addElement(BIT_STRING.getTemplate()); }