我正在制作一个项目,在该项目中,我们的工作之一是重新制作密码算法和其他算法,然后使用 JCA(java 密码体系结构)规则使用它们。
我制作了一个提供多个类的提供程序。在我尝试使用 getInstance() 之前,一切似乎都运行良好。除其他外,我为 KeyAgreement 的不同用途制作了一个 DH(扩展 KeyAgreementSpi)类
KeyAgreement dh = KeyAgreement.getInstance("DH", myProvider);
我得到:
Exception in thread "Thread-0" java.lang.SecurityException: JCE cannot authenticate the provider Ts001Proj1Provider
at javax.crypto.JceSecurity.getInstance(JceSecurity.java:114)
at javax.crypto.KeyAgreement.getInstance(KeyAgreement.java:263)
at fcul.ts001.proj1.SecuredStream.(SecuredStream.java:194)
at fcul.ts001.proj1.SecureStreamTest.run(SecureStreamTest.java:24)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.SecurityException: Cannot verify jar:file:/*pathToProject*/proj/Main/bin/!/
at javax.crypto.JarVerifier.verifySingleJar(JarVerifier.java:406)
at javax.crypto.JarVerifier.verifyJars(JarVerifier.java:322)
at javax.crypto.JarVerifier.verify(JarVerifier.java:250)
at javax.crypto.JceSecurity.verifyProviderJar(JceSecurity.java:161)
at javax.crypto.JceSecurity.getVerificationResult(JceSecurity.java:187)
at javax.crypto.JceSecurity.getInstance(JceSecurity.java:110)
... 4 more
Caused by: java.security.PrivilegedActionException: java.io.FileNotFoundException: *pathToProject*\proj\Main\bin (Access is denied)
at java.security.AccessController.doPrivileged(Native Method)
at javax.crypto.JarVerifier.verifySingleJar(JarVerifier.java:384)
... 9 more
Caused by: java.io.FileNotFoundException: *pathToProject*\proj\Main\bin (Access is denied)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.(ZipFile.java:214)
at java.util.zip.ZipFile.(ZipFile.java:144)
at java.util.jar.JarFile.(JarFile.java:153)
at java.util.jar.JarFile.(JarFile.java:90)
at sun.net.www.protocol.jar.URLJarFile.(URLJarFile.java:93)
at sun.net.www.protocol.jar.URLJarFile.getJarFile(URLJarFile.java:69)
at sun.net.www.protocol.jar.JarFileFactory.get(JarFileFactory.java:98)
at sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:122)
at sun.net.www.protocol.jar.JarURLConnection.getJarFile(JarURLConnection.java:89)
at javax.crypto.JarVerifier$2.run(JarVerifier.java:399)
... 11 more
最好的部分是这段代码执行得很好:
KeyPairGenerator dhKeyPairGen = KeyPairGenerator.getInstance("DH", myProvider);
为什么我会得到它?
我正在开发 win6.1 x64