用于签名(通过令牌/智能卡)并将文档上传到 servlet 的 java 小程序

发布于 2024-12-27 05:54:13 字数 336 浏览 2 评论 0原文

关于如何处理这种情况的任何指示:我有一个网络应用程序需要上传本地文件(例如,尚未签名的文本文件),然后使用存储在本地的私钥对其进行签名(因此一个小程序)文本文件(java stuff/api/etc)作者拥有的令牌/智能卡,最后对我选择的 servlet 执行 HTTP(S)/POST?

如果我不必自己编写小程序,那就更好了:),所以我正在寻找可以完成“整个事情”的东西(无论是否开源,因为这里和那里肯定有一些技巧)对我来说,客户端(浏览器)以最干净的方式,例如:打开对话框供用户选择要签名的文件;从令牌/智能卡中选择证书;将原始文档封装在已签名的 XML 中(有效签名),最后对我的 servlet 执行 HTTP/HTTPS POST。

Any directions on how to deal with this scenario: I have one web app that needs to upload a local file (not yet signed, a text file, for example), than sign it locally (so one applet) using the private key stored in a token/smart card owned by the writer of the text file (java stuff/api/etc) and finally do the HTTP(S)/POST to my choosen servlet?

if I do not have to write the applet by myself it would be better :), so I am looking for something (open source or not, since there must be some trickery here and there) that can just do the "whole thing" at the client side (browser) for me in the cleanest way, for instance: Open the dialog for the user to choose the file to be signed; choosing the certificate from the token/smartcard; enveloping (effectivelly signing) the original document in a signed XML and finally doing the HTTP/HTTPS POST to my servlet.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

画骨成沙 2025-01-03 05:54:13

现代浏览器不再支持 java applet 或 ActiveX。您必须使用浏览器扩展,它可以访问本地证书存储以在客户端设备上签署哈希。

对于基于浏览器的签名方案,我公司提供的此类免费 Chrome 扩展程序是 Signer.Digital chrome 扩展程序。要安装在客户端设备上的安装程序可以从 https://download.cnet.com/Signer-Digital-Chrome-Extension/3000-33362_4-78042540.html

安装此主机并重新启动 Chrome 将自动添加 Signer.Digital Chrome 扩展

的实际工作此处说明了此扩展

Javascript 从扩展调用方法:

    //Calculate Sign for the Hash by Calling function from Extension SignerDigital
    SignerDigital.signPdfHash(hash, $("#CertThumbPrint").val(), "SHA-256")      //or "SHA256"
     .then(
            function (signDataResp) {
              //Send signDataResp to Server
        },
            function (errmsg) {
                //Send errmsg to server or display the result in browser.
              }
     );

如果成功,返回 Base64 编码的 pkcs7 签名 - 使用任何 pdf 组件将签名注入 pdf
如果失败,则返回以“SDHost Error:”开头的错误消息

Modern browsers no more support java applets or ActiveX. You will have to use Browser Extension which can access your local Certificate Store to sign hash on client's device.

For browser based signing scenarios, one such free Chrome extension provided by my Company is Signer.Digital chrome extension. Setup to be installed on client device may be downloaded from https://download.cnet.com/Signer-Digital-Chrome-Extension/3000-33362_4-78042540.html

Installing this host and restarting Chrome will automatically add Signer.Digital Chrome Extension

The actual working of this extension is illustrated here

Javascript to call method from extension:

    //Calculate Sign for the Hash by Calling function from Extension SignerDigital
    SignerDigital.signPdfHash(hash, $("#CertThumbPrint").val(), "SHA-256")      //or "SHA256"
     .then(
            function (signDataResp) {
              //Send signDataResp to Server
        },
            function (errmsg) {
                //Send errmsg to server or display the result in browser.
              }
     );

If success, returns Base64 encoded pkcs7 signature - use any pdf component to inject sign to pdf
If Failed, returns error msg starting with "SDHost Error:"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文