Examples of SMIMESigned


Examples of org.bouncycastle.mail.smime.SMIMESigned

        gen.addSigner(_signKP.getPrivate(), _signCert, SMIMESignedGenerator.DIGEST_SHA1, new AttributeTable(signedAttrs), null);
        gen.addCertificatesAndCRLs(certs);

        MimeMultipart mm = gen.generate(m, "BC");

        SMIMESigned s = new SMIMESigned(mm, "binary");

        verifySigners(s.getCertificatesAndCRLs("Collection", "BC"), s.getSignerInfos());
    }
View Full Code Here

Examples of org.bouncycastle.mail.smime.SMIMESigned

    public void testQuotable()
        throws Exception
    {
        MimeMessage message = loadMessage("quotable.message");
       
        SMIMESigned s = new SMIMESigned((MimeMultipart)message.getContent());
       
        verifySigners(s.getCertificatesAndCRLs("Collection", "BC"), s.getSignerInfos());
    }
View Full Code Here

Examples of org.bouncycastle.mail.smime.SMIMESigned

    public void testEmbeddedMulti()
        throws Exception
    {
        MimeMessage message = loadMessage("embeddedmulti.message");

        SMIMESigned s = new SMIMESigned((MimeMultipart)message.getContent());

        verifySigners(s.getCertificatesAndCRLs("Collection", "BC"), s.getSignerInfos());
    }
View Full Code Here

Examples of org.bouncycastle.mail.smime.SMIMESigned

    public void testMultiAlternative()
        throws Exception
    {
        MimeMessage message = loadMessage("multi-alternative.eml");

        SMIMESigned s = new SMIMESigned((MimeMultipart)message.getContent());

        verifySigners(s.getCertificatesAndCRLs("Collection", "BC"), s.getSignerInfos());
    }
View Full Code Here

Examples of org.bouncycastle.mail.smime.SMIMESigned

        if(!isSubclass)
        {
            throw new IllegalArgumentException("certPathReviewerClass is not a subclass of " + DEFAULT_CERT_PATH_REVIEWER.getName());
        }

        SMIMESigned s;

        try
        {
            // check if message is multipart signed
            if (message.isMimeType("multipart/signed"))
            {
                MimeMultipart mimemp = (MimeMultipart) message.getContent();
                s = new SMIMESigned(mimemp);
            }
            else if (message.isMimeType("application/pkcs7-mime")
                    || message.isMimeType("application/x-pkcs7-mime"))
            {
                s = new SMIMESigned(message);
            }
            else
            {
                ErrorBundle msg = new ErrorBundle(RESOURCE_NAME,
                        "SignedMailValidator.noSignedMessage");
                throw new SignedMailValidatorException(msg);
            }

            // save certstore and signerInformationStore
            certs = s.getCertificatesAndCRLs("Collection", "BC");
            signers = s.getSignerInfos();

            // save "from" addresses from message
            Address[] froms = message.getFrom();
            fromAddresses = new String[froms.length];
            for (int i = 0; i < froms.length; i++)
View Full Code Here

Examples of org.bouncycastle.mail.smime.SMIMESigned

    public void testBasicAS2()
        throws Exception
    {
        MimeMessage message = loadMessage("basicAS2.message");

        SMIMESigned s = new SMIMESigned((MimeMultipart)message.getContent());

        verifySigners(s.getCertificatesAndCRLs("Collection", "BC"), s.getSignerInfos());
    }
View Full Code Here

Examples of org.bouncycastle.mail.smime.SMIMESigned

        // two parts as we have one part for the content that was signed and
        // one part for the actual signature.
        //
        if (msg.isMimeType("multipart/signed"))
        {
            SMIMESigned             s = new SMIMESigned(
                                            (MimeMultipart)msg.getContent());

            //
            // extract the content
            //
            MimeBodyPart            content = s.getContent();

            System.out.println("Content:");

            Object  cont = content.getContent();

            if (cont instanceof String)
            {
                System.out.println((String)cont);
            }
            else if (cont instanceof Multipart)
            {
                Multipart   mp = (Multipart)cont;
                int count = mp.getCount();
                for (int i = 0; i < count; i++)
                {
                    BodyPart    m = mp.getBodyPart(i);
                    Object      part = m.getContent();

                    System.out.println("Part " + i);
                    System.out.println("---------------------------");

                    if (part instanceof String)
                    {
                        System.out.println((String)part);
                    }
                    else
                    {
                        System.out.println("can't print...");
                    }
                }
            }

            System.out.println("Status:");

            verify(s);
        }
        else if (msg.isMimeType("application/pkcs7-mime")
                || msg.isMimeType("application/x-pkcs7-mime"))
        {
            //
            // in this case the content is wrapped in the signature block.
            //
            SMIMESigned             s = new SMIMESigned(msg);

            //
            // extract the content
            //
            MimeBodyPart            content = s.getContent();

            System.out.println("Content:");

            Object  cont = content.getContent();
View Full Code Here

Examples of org.bouncycastle.mail.smime.SMIMESigned

        MimeBodyPart m = new MimeBodyPart();

        m.setContent(mp);

        MimeMultipart smm = generateMultiPartRsa(SMIMESignedGenerator.DIGEST_SHA1, m);
        SMIMESigned   s = new SMIMESigned(smm);

        verifySigners(s.getCertificatesAndCRLs("Collection", "BC"), s.getSignerInfos());

        AttributeTable attr = ((SignerInformation)s.getSignerInfos().getSigners().iterator().next()).getSignedAttributes();

        Attribute a = attr.get(CMSAttributes.messageDigest);
        byte[] contentDigest = ASN1OctetString.getInstance(a.getAttrValues().getObjectAt(0)).getOctets();

        mp = (MimeMultipart)m.getContent();
View Full Code Here

Examples of org.bouncycastle.mail.smime.SMIMESigned

    public void testSHA1WithRSA()
        throws Exception
    {
        MimeMultipart smm = generateMultiPartRsa(SMIMESignedGenerator.DIGEST_SHA1, msg);         
        SMIMESigned   s = new SMIMESigned(smm);

        verifyMessageBytes(msg, s.getContent());

        verifySigners(s.getCertificatesAndCRLs("Collection", "BC"), s.getSignerInfos());
    }
View Full Code Here

Examples of org.bouncycastle.mail.smime.SMIMESigned

    public void testSHA1WithRSAAddSigners()
        throws Exception
    {
        MimeMultipart smm = generateMultiPartRsa(SMIMESignedGenerator.DIGEST_SHA1, msg);
        SMIMESigned   s = new SMIMESigned(smm);

                List certList = new ArrayList();

        certList.add(_signCert);
        certList.add(_origCert);

        CertStore certs = CertStore.getInstance("Collection",
                        new CollectionCertStoreParameters(certList), "BC");

        SMIMESignedGenerator gen = new SMIMESignedGenerator();

        gen.addSigners(s.getSignerInfos());

        gen.addCertificatesAndCRLs(certs);

        SMIMESigned newS =  new SMIMESigned(gen.generate(msg, "BC"));

        verifyMessageBytes(msg, newS.getContent());

        verifySigners(newS.getCertificatesAndCRLs("Collection", "BC"), newS.getSignerInfos());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.