设置如下: 打包 Java Applet 组件并使用基于表单的身份验证的 Web 应用程序(EAR 文件)已部署到 WebSphere 8。 工作站正在使用 Java 1.7.0_45。
验证登录表单后从 IE11 进行连接时,WebSphere 将返回一个包含 Applet 标记的 Html 页面。然后从 WebSphere 正确下载 Applet Jar 文件并启动 Applet。
使用 Chrome 时,Applet Jar 文件的下载失败,就像身份验证 token 丢失一样。
以下是 Java 插件跟踪文件的摘录:
IE11(好)
network: Connecting http://myserver:9088/MOBILE/jam.jar with proxy=DIRECT
network: Connecting http://myserver:9088/ with proxy=DIRECT
network: Connecting http://myserver:9088/MOBILE/jam.jar with cookie "LtpaToken2=..."
network: Downloading resource: http://myserver:9088/MOBILE/jam.jar
Content-Length: 632,160
Content-Encoding: null
Chrome(不好)
network: Connecting http://myserver:9088/MOBILE/jam.jar with proxy=DIRECT
network: Connecting http://myserver:9088/ with proxy=DIRECT
network: Server http://myserver:9088/MOBILE/jam.jar requesting to set-cookie with "WASReqURL=http://myserver:9088/MOBILE/jam.jar; Path=/; HttpOnly"
network: Cache entry not found [url: http://myserver:9088/MOBILE/adminLogin.html, version: null]
network: Connecting http://myserver:9088/MOBILE/adminLogin.html with proxy=DIRECT
network: Connecting http://myserver:9088/ with proxy=DIRECT
network: Downloading resource: http://myserver:9088/MOBILE/adminLogin.html
Content-Length: 1,187
Content-Encoding: null
java.io.IOException: Invalid jar file
at com.sun.deploy.net.HttpDownloadHelper.download(Unknown Source)
请注意 IE11 如何发送 LtpaToken2 token cookie,而 Chrome 显示“请求设置 cookie”消息。
欢迎任何建议。
最佳答案
实际上恰恰相反;-)
IE (bad)
Chrome (good)
由于 websphere 有 HttpOnly 标志 activated by default (使用谷歌翻译,没有找到英文的)chrome 表现正常。 IE 只是忽略该标志并仍然发送 cookie,从而违反了规范。如果您希望允许 java applet 访问 cookie,您必须在 websphere settings 中禁用 HttpOnly 设置。 (全局)或在您的 webapplication 中(本地)。
关于具有基于表单的身份验证的 Java Applet 在 IE 上工作但在 Chrome 上失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20967173/