ASN1Sequence seq = (ASN1Sequence) new DERInputStream(new ByteArrayInputStream(scepmsg)).readObject();
ASN1Sequence seq = (ASN1Sequence) new ASN1InputStream(new ByteArrayInputStream(scepmsg)).readObject();
    private void init() throws IOException {        log.debug(">init");        // Parse and verify the entegrity of the PKIOperation message PKCS#7        /* If this would have been done using the newer CMS it would have made me so much happier... */        ASN1Sequence seq = (ASN1Sequence) new DERInputStream(new ByteArrayInputStream(scepmsg)).readObject();        ContentInfo ci = new ContentInfo(seq);        String ctoid = ci.getContentType().getId();        if (ctoid.equals(CMSObjectIdentifiers.signedData.getId())) {            // This is SignedData so it is a pkcsCertReqSigned,            //  pkcsGetCertInitialSigned, pkcsGetCertSigned, pkcsGetCRLSigned            // (could also be pkcsRepSigned or certOnly, but we don't receive them on the server side            // Try to find out what kind of message this is            sd = new SignedData((ASN1Sequence) ci.getContent());            // Get self signed cert to identify the senders public key            ASN1Set certs = sd.getCertificates();            if (certs.size() > 0) {                // There should be only one...                DEREncodable dercert = certs.getObjectAt(0);                if (dercert != null) {                    // Requestors self-signed certificate is requestKeyInfo                    ByteArrayOutputStream bOut = new ByteArrayOutputStream();                    DEROutputStream dOut = new DEROutputStream(bOut);                    dOut.writeObject(dercert);                    if (bOut.size() > 0 ) {                        requestKeyInfo = bOut.toByteArray();                    }                }            }            Enumeration sis = sd.getSignerInfos().getObjects();            if (sis.hasMoreElements()) {                SignerInfo si = new SignerInfo((ASN1Sequence) sis.nextElement());                Enumeration attr = si.getAuthenticatedAttributes().getObjects();                while (attr.hasMoreElements()) {                    Attribute a = new Attribute((ASN1Sequence) attr.nextElement());                    log.debug("Found attribute: " + a.getAttrType().getId());                    if (a.getAttrType().getId().equals(id_senderNonce)) {                        Enumeration values = a.getAttrValues().getObjects();                        ASN1OctetString str = ASN1OctetString.getInstance(values.nextElement());                        senderNonce = new String(Base64.encode(str.getOctets(),false));                        log.debug("senderNonce = " + senderNonce);                    }                    if (a.getAttrType().getId().equals(id_transId)) {                        Enumeration values = a.getAttrValues().getObjects();                        DERPrintableString str = DERPrintableString.getInstance(values.nextElement());                        transactionId = str.getString();                        log.debug("transactionId = " + transactionId);                    }                    if (a.getAttrType().getId().equals(id_messageType)) {                        Enumeration values = a.getAttrValues().getObjects();                        DERPrintableString str = DERPrintableString.getInstance(values.nextElement());                        messageType = Integer.parseInt(str.getString());                        log.debug("messagetype = " + messageType);                    }                }            }            // If this is a PKCSReq            if (messageType == 19) {                // Extract the contents, which is an encrypted PKCS10                ci = sd.getEncapContentInfo();                ctoid = ci.getContentType().getId();                if (ctoid.equals(CMSObjectIdentifiers.data.getId())) {                    DEROctetString content = (DEROctetString) ci.getContent();                    log.debug("envelopedData is " + content.getOctets().length + " bytes.");                    ASN1Sequence seq1 = (ASN1Sequence) new DERInputStream(new ByteArrayInputStream(                                content.getOctets())).readObject();                    envEncData = new ContentInfo(seq1);                    ctoid = envEncData.getContentType().getId();                    if (ctoid.equals(CMSObjectIdentifiers.envelopedData.getId())) {                        envData = new EnvelopedData((ASN1Sequence) envEncData.getContent());                        ASN1Set recipientInfos = envData.getRecipientInfos();                        Enumeration e = recipientInfos.getObjects();                        while (e.hasMoreElements()) {                            RecipientInfo ri = RecipientInfo.getInstance(e.nextElement());                            KeyTransRecipientInfo recipientInfo = KeyTransRecipientInfo.getInstance(ri.getInfo());                            RecipientIdentifier rid = recipientInfo.getRecipientIdentifier();                            IssuerAndSerialNumber iasn = IssuerAndSerialNumber.getInstance(rid.getId());                            issuerDN = iasn.getName().toString();                            log.debug("IssuerDN: "+issuerDN);                        }                                            } else {                        errorText = "EncapsulatedContentInfo does not contain PKCS7 envelopedData: ";                        log.error(errorText + ctoid);                        error = 2;                    }                } else {                    errorText = "EncapsulatedContentInfo is not of type 'data': ";                    log.error(errorText + ctoid);                    error = 3;                }            } else {                errorText = "This is not a certification request!";                log.error(errorText);                error = 4;            }        } else {            errorText = "PKCSReq does not contain 'signedData': ";            log.error(errorText + ctoid);            error = 1;        }        log.debug("<init");    }