Java netscape.javascript.JSObject用于存储cookie [英] Java netscape.javascript.JSObject used for storing cookies

查看:167
本文介绍了Java netscape.javascript.JSObject用于存储cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Java应用程序通过 Webswing 服务器在网络上运行. Webswing服务器将Java转换为HTML5,以确保安全的Web使用.

I have a Java application running on the web through a Webswing server. A Webswing server translates Java to HTML5 for secure web usage.

我使用netscape.javascript.JSObject来存储和读取Java应用程序中的cookie.

I use netscape.javascript.JSObject to store and read cookies from the Java application.

// write
String cookie = "name=userstuff; Expires.... ";
JSObject global = JSObject.getWindow(null);
global.eval("document.cookie=" + "\"" + cookie + "\"");

//read
Object cookies= global.eval("document.cookie");

我还没有在浏览器密码部分中找到一种存储密码的方法.在Chrome中,该部分是:

I have not found a way to store passwords in the browser password section. In Chrome the section is:

chrome://settings/passwords

您能告诉我密码部分中存储密码的机制是否与cookie相同.

Could you tell me if the mechanisms to store passwords in the passwords section is the same as the one for cookies.

推荐答案

请参阅此凭据管理API文档- https://whatwebcando.today/credentials.html

Please refer to this documentation of Credential Management API - https://whatwebcando.today/credentials.html

使用API​​,您可以以编程方式强制向用户显示保存密码对话框,该用户可以决定是否保存密码.该API当前仅在Chrome中受支持.

Using the API you can programmatically force a save password dialog to show to user, who can decide whether to save the password. The API is currently supported only in Chrome.

基本上,此API与Webswing无关,无论如何,您应该能够像使用netscape.javascript.JSObject来使用Cookie一样使用凭据管理API.尝试一下,它对Webswing很有帮助:

Basically this API has nothing to do with Webswing, anyway you should be able to use the Credential Management API same way you use netscape.javascript.JSObject to work with cookies. Try this, it worked for me with Webswing:

global.eval("navigator.credentials.store(new PasswordCredential({id: 'username@email.com', password: 'password', name: 'User Name'}));");

这篇关于Java netscape.javascript.JSObject用于存储cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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