Package org.bouncycastle.mail.smime

Examples of org.bouncycastle.mail.smime.SMIMESigned


       
        List<SMIMESignerInfo> signers=null;
       
        try {
            Object obj = message.getContent();
            SMIMESigned signed;
            if (obj instanceof MimeMultipart) signed = new SMIMESigned((MimeMultipart)message.getContent());
            else if (obj instanceof SMIMESigned) signed = (SMIMESigned) obj;               
            else if (obj instanceof byte[]) signed = new SMIMESigned(message);
            else signed = null;
           
            if (signed != null) {
                signers = trustedCertificateStore.verifySignatures(signed);
                strippedMessage = signed.getContent();
            } else log("Content not identified as signed");
           
            // These errors are logged but they don't cause the
            // message to change its state. The message
            // is considered as not signed and the process will
View Full Code Here


       
        List signers=null;
       
        try {
            Object obj = message.getContent();
            SMIMESigned signed;
            if (obj instanceof MimeMultipart) signed = new SMIMESigned((MimeMultipart)message.getContent());
            else if (obj instanceof SMIMESigned) signed = (SMIMESigned) obj;               
            else if (obj instanceof byte[]) signed = new SMIMESigned(message);
            else signed = null;
           
            if (signed != null) {
                signers = trustedCertificateStore.verifySignatures(signed);
                strippedMessage = signed.getContent();
            } else log("Content not identified as signed");
           
            // These errors are logged but they don't cause the
            // message to change its state. The message
            // is considered as not signed and the process will
View Full Code Here

       
        List signers=null;
       
        try {
            Object obj = message.getContent();
            SMIMESigned signed;
            if (obj instanceof MimeMultipart) signed = new SMIMESigned((MimeMultipart)message.getContent());
            else if (obj instanceof SMIMESigned) signed = (SMIMESigned) obj;               
            else if (obj instanceof byte[]) signed = new SMIMESigned(message);
            else signed = null;
           
            if (signed != null) {
                signers = trustedCertificateStore.verifySignatures(signed);
                strippedMessage = signed.getContent();
            } else log("Content not identified as signed");
           
            // These errors are logged but they don't cause the
            // message to change its state. The message
            // is considered as not signed and the process will
View Full Code Here

       
        List signers=null;
       
        try {
            Object obj = message.getContent();
            SMIMESigned signed;
            if (obj instanceof MimeMultipart) signed = new SMIMESigned((MimeMultipart)message.getContent());
            else if (obj instanceof SMIMESigned) signed = (SMIMESigned) obj;               
            else if (obj instanceof byte[]) signed = new SMIMESigned(message);
            else signed = null;
           
            if (signed != null) {
                signers = trustedCertificateStore.verifySignatures(signed);
                strippedMessage = signed.getContent();
            } else log("Content not identified as signed");
           
            // These errors are logged but they don't cause the
            // message to change its state. The message
            // is considered as not signed and the process will
View Full Code Here

   {
      return verify(certificate.getPublicKey());
   }
   public boolean verify(PublicKey publicKey) throws Exception
   {
      SMIMESigned signed = new SMIMESigned(body);

      SignerInformationStore signers = signed.getSignerInfos();
      SignerInformation signer = (SignerInformation) signers.getSigners().iterator().next();
      return signer.verify(publicKey, "BC");

   }
View Full Code Here

      MimeBodyPart mbp = (MimeBodyPart) mm.getBodyPart(0);

      output(mbp);

      SMIMESigned signed = new SMIMESigned(mm);

      SignerInformationStore signers = signed.getSignerInfos();
      Assert.assertEquals(1, signers.size());
      SignerInformation signer = (SignerInformation) signers.getSigners().iterator().next();
      Assert.assertTrue(signer.verify(cert.getPublicKey(), "BC"));
   }
View Full Code Here

        MimeMultipart     smm = gen.generate(mp, "BC");
        File              tmpFile = File.createTempFile("bcTest", ".mime");

        MimeMessage       msg = createMimeMessage(tmpFile, smm);

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

        certs = s.getCertificatesAndCRLs("Collection", "BC");

        verifyMessageBytes(mp, s.getContent());

        verifySigners(certs, s.getSignerInfos());

        tmpFile.delete();
    }
View Full Code Here

        MimeBodyPart   mp = encGen.generate(msg, SMIMEEnvelopedGenerator.AES128_CBC, "BC");

        SMIMEEnveloped       env = new SMIMEEnveloped(mp);
        RecipientInformation ri = (RecipientInformation)env.getRecipientInfos().getRecipients().iterator().next();
        MimeBodyPart         mm = SMIMEUtil.toMimeBodyPart(ri.getContentStream(origKP.getPrivate(), "BC"));
        SMIMESigned          s = new SMIMESigned((MimeMultipart)mm.getContent());
        Collection           c = s.getSignerInfos().getSigners();
        Iterator             it = c.iterator();
        CertStore            certs = s.getCertificatesAndCRLs("Collection", "BC");

        while (it.hasNext())
        {
            SignerInformation   signer = (SignerInformation)it.next();
            Collection          certCollection = certs.getCertificates(signer.getSID());
View Full Code Here

        gen.addCertificatesAndCRLs(certs);
       
        MimeBodyPart smm = gen.generateCertificateManagement("BC");
       
        SMIMESigned s = new  SMIMESigned(smm);

        certs = s.getCertificatesAndCRLs("Collection", "BC");

        assertEquals(2, certs.getCertificates(null).size());
    }
View Full Code Here

        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);

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

        byte[] contentDigest = (byte[])gen.getGeneratedDigests().get(SMIMESignedGenerator.DIGEST_SHA1);

        AttributeTable table = ((SignerInformation)s.getSignerInfos().getSigners().iterator().next()).getSignedAttributes();
        Attribute hash = table.get(CMSAttributes.messageDigest);

        assertTrue(MessageDigest.isEqual(contentDigest, ((ASN1OctetString)hash.getAttrValues().getObjectAt(0)).getOctets()));
    }
View Full Code Here

TOP

Related Classes of org.bouncycastle.mail.smime.SMIMESigned

Copyright © 2018 www.massapicom. 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.