P2P(浏览器到浏览器)与Java [英] P2P (browser to browser) with Java

查看:147
本文介绍了P2P(浏览器到浏览器)与Java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现它运行在网页上,并允许Java应用程序:

I would like to implement a Java application which runs on a webpage and allows:


  • 用户A(从浏览器)可以请求一个文件到用户B(其浏览器中打开)。当然,用户A知道用户B的IP和端口。

  • 用户B可以响应从浏览器这一请求。

哪些选项(Java库,技术,...)我有吗?

Which options (Java libraries, technologies,...) do I have?

谢谢!

推荐答案

如果您在浏览器中的Java想,去的唯一途径就是小程序。

If you want Java in the browser, the only way to go is applets.

但是,一个正常的(不受信任)的小程序:

But a normal (untrusted) applet:


  • 在本地系统上无法访问文件

  • 在任何端口不能听

  • 只能这么来在服务器上打开插座。

这是出于安全方面的原因:一个applet不应该伤害到其计算机运行在用户

This is for security reasons: an applet should not be able to harm the user whose computer it runs on.

所以,如果你想要做你说什么,你需要用户信任你,给你更多的权限。对于文件的访问,要走的路将是JNLP API(即JNLP文件启动小程序,然后在的javax.jnlp ,特别FileOpenService和FileSaveService,用户则需要选择一个文件,一个文件选择前确认访问。

So, if you want to do what you said, you need the user to trust you and give you more permissions. For the file access, the way to go would be the JNLP API (i.e. start your applet with a jnlp file, and then use the API in javax.jnlp, specially FileOpenService and FileSaveService. The user then needs to confirm the access before choosing a file with a file chooser.

这仍然没有帮助网络访问 - 你的小程序需要有适当的SocketPermissions那里,如果你不希望你的服务器上代理一切(这将不会对等网络)。为此,您需要登录您的小程序,并要求从该用户的所有权限(没有细粒度仅给予必要的SocketPermissions,我认为)。您可以在JNLP文件做到这一点。

This still does not help for the network access - your applets need to have suitable SocketPermissions there, if you don't want to proxy everything on your server (which would not be peer-to-peer). For this, you need to sign your applet, and request all permissions from the user (there is no finer-grained way to give only the necessary SocketPermissions, I think). You can do this in the jnlp-file.

这篇关于P2P(浏览器到浏览器)与Java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆