gpt4 book ai didi

java - 用于安全时间戳的露天自定义操作 - 使用 BouncyCaSTLe 时出错

转载 作者:行者123 更新时间:2023-12-01 11:20:26 26 4
gpt4 key购买 nike

我是露天开发的新手,所以这是我的问题。我正在户外开发一个自定义操作,其目标是创建文档的独立安全时间戳。这是我的代码:

    String tsaUrl = "http://ts.cartaodecidadao.pt/tsa/server";
OutputStream out = null;
HttpURLConnection con = null;
MessageDigest hash;
InputStream is = null;
try{
hash = MessageDigest.getInstance("SHA1");
try{
is = new BufferedInputStream(new FileInputStream(file));
final byte[] buffer = new byte[1024];
for (int i = 0; is.read(buffer) != -1;){
hash.update(buffer, 0, i);
}
} catch (FileNotFoundException e){
e.printStackTrace();
}
TimeStampRequestGenerator timeStampRequestGenerator = new TimeStampRequestGenerator();

/*FIXME */
ASN1ObjectIdentifier algorithm = TSPAlgorithms.SHA1;
TimeStampRequest timeStampRequest = timeStampRequestGenerator.generate(algorithm, hash.digest());
byte request[] = timeStampRequest.getEncoded();

URL url = new URL(tsaUrl);
con = (HttpURLConnection) url.openConnection();
con.setDoOutput(true);
con.setDoInput(true);
con.setRequestMethod("POST");
con.setRequestProperty("Content-type",
"application/timestamp-query");
con.setRequestProperty("Content-length",
String.valueOf(request.length));
out = con.getOutputStream();
out.write(request);
out.flush();
out.close();

if (con.getResponseCode() != HttpURLConnection.HTTP_OK)
{
System.out.println("---------- != HttpURLConnection.HTTP_OK");
throw new IOException("Received HTTP error: "
+ con.getResponseCode() + " - "
+ con.getResponseMessage());
}

InputStream in = con.getInputStream();
TimeStampResp resp = TimeStampResp
.getInstance(new ASN1InputStream(in).readObject());
TimeStampResponse response = new TimeStampResponse(resp);

它构建成功,但在尝试该操作时,它会在注释“FIXME”之后的行中抛出错误。错误的堆栈跟踪是

2015-07-09 00:58:32,598  ERROR [extensions.webscripts.AbstractRuntime] [http-bio-8080-exec-8] Exception from executeScript - redirecting to status template error: 06090002 Wrapped Exception (with status template): 06090015 The action failed to execute due to an error.
org.springframework.extensions.webscripts.WebScriptException: 06090002 Wrapped Exception (with status template): 06090015 The action failed to execute due to an error.
at org.springframework.extensions.webscripts.AbstractWebScript.createStatusException(AbstractWebScript.java:1126)
at org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:171)
at org.alfresco.repo.web.scripts.RepositoryContainer$3.execute(RepositoryContainer.java:470)
at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:454)
at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:532)
at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:600)
at org.alfresco.repo.web.scripts.RepositoryContainer.executeScriptInternal(RepositoryContainer.java:380)
at org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:261)
at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:378)
at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:209)
at org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:132)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:61)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.alfresco.service.cmr.action.ActionServiceException: 06090015 The action failed to execute due to an error.
at org.alfresco.repo.action.ActionServiceImpl.executeActionImpl(ActionServiceImpl.java:816)
at org.alfresco.repo.action.ActionServiceImpl.executeAction(ActionServiceImpl.java:573)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor.invoke(AlwaysProceedMethodInterceptor.java:34)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:46)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:159)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at com.sun.proxy.$Proxy53.executeAction(Unknown Source)
at org.alfresco.repo.web.scripts.rule.ActionQueuePost.executeImpl(ActionQueuePost.java:85)
at org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:64)
... 32 more
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.bouncycastle.tsp.TSPAlgorithms
at pt.ubi.release.SecureTimeStamp_repo.action.StampAction.executeImpl(StampAction.java:233)
at org.alfresco.repo.action.executer.ActionExecuterAbstractBase.execute(ActionExecuterAbstractBase.java:265)
at org.alfresco.repo.action.ActionServiceImpl.directActionExecution(ActionServiceImpl.java:839)
at org.alfresco.repo.action.ActionServiceImpl.executeActionImpl(ActionServiceImpl.java:739)

有谁知道为什么它说无法初始化类 org.bouncycaSTLe.tsp.TSPAlgorithms?顺便说一句,我正在使用 1.52 版本的 bouncycaSTLe 库。对不起我的英语,但这不是我的母语。

最佳答案

NoClassDefFoundError 表示负责动态加载类的类加载器找不到您尝试使用的类的 .class 文件。因此,可能 jar 没有添加到类 org.bouncycaSTLe.tsp.TSPAlgorithms

的类路径中

如果您尝试在 Alfresco 中运行此操作,则可能需要在 alfresco/Web-INF/lib 中添加 bouncycaSTLe jar。

关于java - 用于安全时间戳的露天自定义操作 - 使用 BouncyCaSTLe 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31306220/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com