使用UploadObjectSingleOperation示例将文件上载到aws s3时出现SecurityException

时间:2014-11-19 13:42:27

标签: java amazon-web-services amazon-s3

我尝试从此处运行示例时捕获此异常: http://docs.aws.amazon.com/AmazonS3/latest/dev/UploadObjSingleOpJava.html 有人可以帮忙吗?

Exception in thread "main" java.lang.ExceptionInInitializerError
at javax.crypto.Mac.getInstance(Mac.java:171)
at com.amazonaws.auth.AbstractAWSSigner.sign(AbstractAWSSigner.java:87)
at com.amazonaws.auth.AbstractAWSSigner.signAndBase64Encode(AbstractAWSSigner.java:69)
at com.amazonaws.auth.AbstractAWSSigner.signAndBase64Encode(AbstractAWSSigner.java:58)
at com.amazonaws.services.s3.internal.S3Signer.sign(S3Signer.java:127)
at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:652)
at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:460)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:295)
at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:3697)
at com.amazonaws.services.s3.AmazonS3Client.putObject(AmazonS3Client.java:1434)
at com.bartoff.s3Utils.UploadObject.main(UploadObject.java:32)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.lang.SecurityException: Can not initialize cryptographic mechanism
at javax.crypto.JceSecurity.<clinit>(JceSecurity.java:86)
... 16 more
Caused by: java.lang.SecurityException: The jurisdiction policy files are not signed by a trusted signer!
at javax.crypto.JarVerifier.verifyPolicySigned(JarVerifier.java:289)
at javax.crypto.JceSecurity.loadPolicies(JceSecurity.java:316)
at javax.crypto.JceSecurity.setupJurisdictionPolicies(JceSecurity.java:265)
at javax.crypto.JceSecurity.access$000(JceSecurity.java:48)
at javax.crypto.JceSecurity$1.run(JceSecurity.java:78)
at java.security.AccessController.doPrivileged(Native Method)
at javax.crypto.JceSecurity.<clinit>(JceSecurity.java:76)
... 16 more

1 个答案:

答案 0 :(得分:1)

这是由于Java的安全问题。

要解决它。

  • 从oracle网站here
  • 下载JCE文件
  • 将文件解压缩到{YOUR_JDK_PATH}/jdk1.7.0_51/jre/lib/security