html input type=file 和 java applet 之间的互操作
我目前正在开发一个网络应用程序,在其中使用葡萄牙公民卡和 java 小程序对表单进行数字签名。
常规表单的一切都很顺利,直到我遇到文件类型输入的问题。该应用程序支持附件,因此我创建了一个单独的附件管理器,用户可以在其中提交或查看附件。提交时必须有两种方式:正常上传或对文件进行签名然后上传。
我的第一个想法是让用户在输入类型=“文件”中选择文件,如果他/她单击“签名并上传”,它将启动一个java小程序来生成要放入隐藏输入中的签名。问题在于 html 的安全限制,这使得某些浏览器中的 javascript(也拒绝访问 java applet)无法访问文件选择的值。
我还考虑过计算要在服务器端签名的文件的哈希值,然后在客户端对其进行签名,但这也不是一个选择。哈希及其签名的确定必须全部在客户端(法律原因)。
另一个想法是使用 JUpload 之类的东西,但它不支持某些情况,即通过带有客户端证书的 SSL 通道进行连接(这可能会发生,具体取决于 Web 应用程序上的登录方式)。
最后,我什至有一个荒谬的想法,即在小程序上打开文件,对其进行签名,然后将其存储在 Base64 的隐藏输入中。显然,这对文件大小造成了巨大的限制。
所以我的问题是:解决这个问题的最佳方法是什么?有什么建议吗?
提前致谢 ;)
I'm currently developing a web app where I make use of digital signing of forms using the portuguese citizen card and java applets.
Everything have been going smoothly with the regular forms until I reached a problem with inputs of type file. The app supports attachments so I created a separated attachment manager where the user can submit or review the attachments. When submitting it is necessary to be there two ways of doing it: normal upload or sign the file and then upload.
My first idea was to let the user select the file in the input type="file" and if he/she clicked on "sign and upload" it would launch a java applet to generate the signature to be putted in a hidden input. The problem lies in the security restrictions of html that makes the file chosen value inaccessible from javascript (which also denies access to the java applet) in some browsers.
I also thought of calculating the hash of the file to be signed on server side and then sign it on client side but that also isn't an option. The determination of the hash and it's signature must all be on client side (legal reasons).
Another idea was to use something like JUpload but it doesn't support some cases were the connection is over a SSL channel with client certificate (which can happen depending on how the login was made on the web app).
Lastly I even had this absurd idea of open the file on the applet, sign it and then store it on a hidden input in base64. Obviously this creates a huge constrain on file size.
So my question is: What is the best approach to this problem? Any suggestions?
Thanks in advance ;)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
显然,从JS或Flash中访问浏览器中选择的文件是不可能的。所以唯一的办法就是使用可信的Java applet。但这并不是一种优雅的方式。另外,如果您的用户拥有客户端证书 - 当通信通道加密时,签名它的原因是什么?
Obviously, it is impossible to access a file selected in browser from JS or Flash. So the only way is to use a trusted Java applet. It is not an elegant way, though. Also, if your users have client certificates - what is the reason to sign it, when the communication channel is encrypted??