java servlet转发cookie
我想开发一个能够在其他服务器上通过 HTTP 协议进行身份验证的 java servlet。该服务器向我的 servlet 发送回一个 cookie,我想将该 cookie 转发回浏览器并将浏览器重定向到另一个 url。
我不知道如何通过 servlet 拦截和发送 cookie。
您对要使用的方法或类有什么建议吗?
I want to develop a java servlet able to authenticate via HTTP protocol on an other server. That server sends back a cookie to my servlet and i want to forward back to the browser that cookie and redirect the browser to another url.
I can not figure out how to intercept and sendBack cookie via servlet.
Do you have any suggestions on method or class to be used?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这当然是非法的;篡改另一个域的 cookie。
Java 对 Open-ID 有良好的支持,这可能恰好适合您的情况。
对于 java 站点,会话 ID 可以同时用作 cookie 和 URL 参数(通常为 JSESSIONID)。在这种情况下,您可以使用 JSESSIONID 参数。
通常,网站的登录后会继续访问某个页面(例如 login.html?url=...)。
在这种情况下,您可以尝试重定向到登录表单 GET 提交。
要查找该 URL:调用正在注销的书签 URL。
我有些怀疑是否存在这样的漏洞。
This is of course illegal; tampering with a cookie of another domain.
Java has good support for Open-ID, which might happen to be usable in your case.
In the case of a java site the session ID may both be used as cookie and as URL parameter (JSESSIONID often). In that case you could use the JSESSIONID parameter.
Often a site has a login with a continue to some page (something like login.html?url=...).
In that case you might try redirecting to login-form GET-submit.
To find that URL: call a bookmarked URL being logged out.
I have some doubts that there is such a loop hole though.
我没有明白你的意思是“拦截 cookie”,但是发回 cookie 非常简单,只需将 cookie 添加到响应对象即可。
然后转发您的请求:
希望对您有帮助。
I didn't catch what you mean 'intercept cookie', but sending back cookie is quite simple just add cookie to response object.
And then forward your request:
Hope it's helpful for you.