我们可以从java桌面应用程序中读取浏览器保存的cookie吗?

时间:2021-08-10 00:11:34

I want to transfer web login session to my java desktop application ,so that once again I don't want to login in my desktop application.

我想将Web登录会话转移到我的java桌面应用程序,这样我再也不想登录桌面应用程序了。

Once the user logs into my web application, I set some cookies on the user system, once he starts my standalone application I would like to use the credentials stored here to log my user into the application without asking to re-login.

一旦用户登录我的Web应用程序,我在用户系统上设置了一些cookie,一旦他启动我的独立应用程序,我想使用此处存储的凭据将我的用户登录到应用程序而无需重新登录。

My questions: - Can I access the cookies to read Auth token and other params? Is this the proper solution? - To achieve the above requirement , is there any proper solution.

我的问题: - 我可以访问cookie来读取Auth令牌和其他参数吗?这是正确的解决方案吗? - 要达到上述要求,是否有适当的解决方案。

Cookie seemed like a solution for me here. But in essence I want a seamless integration between the web application and the standalone application. What kind of solutions are available for this?

Cookie对我来说似乎是一个解决方案。但实质上,我希望在Web应用程序和独立应用程序之间实现无缝集成。有哪些解决方案?

3 个解决方案

#1


3  

For the above requirement we need to use Java Web Start technology Here is the link http://docs.oracle.com/javase/tutorial/deployment/webstart/

对于上述要求,我们需要使用Java Web Start技术这里是链接http://docs.oracle.com/javase/tutorial/deployment/webstart/

#2


1  

Not sure how Skype does it, but it looks like both WebEx and GotoMeeting rely on custom browser extensions that require a permission to "Communicate with cooperating native applications" (example setting from Chrome).

不确定Skype是如何做到的,但看起来WebEx和GotoMeeting都依赖于自定义浏览器扩展,这些扩展需要“与协作的本机应用程序通信”的权限(来自Chrome的示例设置)。

I couldn't find anything that's native to JNLP that allows you to read browser cookies since it's supposed to be sandboxed. However, after logging via the Java app, you should be able to use the JNLP Persistence APIs, if that helps.

我找不到任何JNLP原生的东西,它允许你读取浏览器cookie,因为它应该是沙箱。但是,在通过Java应用程序进行日志记录之后,您应该能够使用JNLP持久性API,如果这有帮助的话。

#3


1  

I think you should do reversely, when you login on web, transfer some Session ID to desktop application.

我认为您应该反向操作,当您在Web上登录时,将一些会话ID传输到桌面应用程序。

My idea is running a localhost server in your desktop app on some port (use Jetty). When you login on web, it will call a url to that local server to transfer session ID. Ex:

我的想法是在某个端口上的桌面应用程序中运行localhost服务器(使用Jetty)。当您在Web上登录时,它将调用该本地服务器的URL来传输会话ID。例如:

localhost:8888/authen?sessionID=123456

Then the local server will get that sessionID param.

然后本地服务器将获得该sessionID参数。

If you feel this is suitable for you, I will explain more detail

如果您认为这适合您,我会解释更多细节

#1


3  

For the above requirement we need to use Java Web Start technology Here is the link http://docs.oracle.com/javase/tutorial/deployment/webstart/

对于上述要求,我们需要使用Java Web Start技术这里是链接http://docs.oracle.com/javase/tutorial/deployment/webstart/

#2


1  

Not sure how Skype does it, but it looks like both WebEx and GotoMeeting rely on custom browser extensions that require a permission to "Communicate with cooperating native applications" (example setting from Chrome).

不确定Skype是如何做到的,但看起来WebEx和GotoMeeting都依赖于自定义浏览器扩展,这些扩展需要“与协作的本机应用程序通信”的权限(来自Chrome的示例设置)。

I couldn't find anything that's native to JNLP that allows you to read browser cookies since it's supposed to be sandboxed. However, after logging via the Java app, you should be able to use the JNLP Persistence APIs, if that helps.

我找不到任何JNLP原生的东西,它允许你读取浏览器cookie,因为它应该是沙箱。但是,在通过Java应用程序进行日志记录之后,您应该能够使用JNLP持久性API,如果这有帮助的话。

#3


1  

I think you should do reversely, when you login on web, transfer some Session ID to desktop application.

我认为您应该反向操作,当您在Web上登录时,将一些会话ID传输到桌面应用程序。

My idea is running a localhost server in your desktop app on some port (use Jetty). When you login on web, it will call a url to that local server to transfer session ID. Ex:

我的想法是在某个端口上的桌面应用程序中运行localhost服务器(使用Jetty)。当您在Web上登录时,它将调用该本地服务器的URL来传输会话ID。例如:

localhost:8888/authen?sessionID=123456

Then the local server will get that sessionID param.

然后本地服务器将获得该sessionID参数。

If you feel this is suitable for you, I will explain more detail

如果您认为这适合您,我会解释更多细节