简体   繁体   English

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

[英]Can we read browser saved cookies from a java desktop application?

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? 我的问题:-我可以访问cookie来读取Auth令牌和其他参数吗? Is this the proper solution? 这是正确的解决方案吗? - To achieve the above requirement , is there any proper solution. -为了达到上述要求,是否有适当的解决方案。

Cookie seemed like a solution for me here. Cookie在这里对我来说似乎是一种解决方案。 But in essence I want a seamless integration between the web application and the standalone application. 但从本质上讲,我希望Web应用程序与独立应用程序之间实现无缝集成。 What kind of solutions are available for this? 有什么样的解决方案?

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

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. 我找不到JNLP固有的任何内容,因为它应该是沙盒的,因此您可以读取浏览器cookie。 However, after logging via the Java app, you should be able to use the JNLP Persistence APIs , if that helps. 但是,通过Java应用程序登录后,应该可以使用JNLP Persistence API ,如果有帮助的话。

I think you should do reversely, when you login on web, transfer some Session ID to desktop application. 我认为您应该做相反的事情,当您登录Web时,将一些Session ID转移到桌面应用程序。

My idea is running a localhost server in your desktop app on some port (use Jetty). 我的想法是在某个端口上的桌面应用程序中运行本地主机服务器(使用Jetty)。 When you login on web, it will call a url to that local server to transfer session ID. 当您登录Web时,它将调用该本地服务器的URL来传输会话ID。 Ex: 例如:

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 如果您觉得这很适合您,我将详细说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM