找不到org.bouncycastle.cms - >无法编译

时间:2017-11-07 07:25:41

标签: java email encryption

我正在升级我的网络项目。然后一些obselete函数不能使用。然后我根据网络搜索下载新的jar并有一些新的编码。但它找不到org.bouncycastle.cms库,即使我已经导入了库,如下图所示:请帮助!!

enter image description here

   import org.bouncycastle.cms.CMSAlgorithm;
    import org.bouncycastle.cms.jcajce.JceCMSContentEncryptorBuilder;
    import org.bouncycastle.cms.jcajce.JceKeyTransRecipientInfoGenerator;

    Security.addProvider(new BouncyCastleProvider());            
    SMIMEEnvelopedGenerator encrypter = new SMIMEEnvelopedGenerator();
    InputStream inStream = new FileInputStream(cert_file);
    CertificateFactory cf = CertificateFactory.getInstance("X.509");
     X509Certificate cert = (X509Certificate)cf.generateCertificate(inStream);


    MessageDigest dig = MessageDigest.getInstance("SHA1", "BC");
                dig.update(SubjectPublicKeyInfo.getInstance(cert.getPublicKey().getEncoded()).getPublicKeyData().getBytes());
 issue here --->   encrypter.addRecipientInfoGenerator(new JceKeyTransRecipientInfoGenerator(dig.digest(),cert.getPublicKey()).setProvider("BC"));
         inStream.close();
    MimeMessage msg = new MimeMessage(mailSession);         
 issue here -->   MimeBodyPart encryptedPart = encrypter.generate(msg, new JceCMSContentEncryptorBuilder(CMSAlgorithm.DES_EDE3_CBC).setProvider("BC").build());

0 个答案:

没有答案