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