上文中详细描述了问题的表现情况,由于这个特性严重影响到目前为公司设计的一套前台统一认证方案,因此不得不特别关注。好在resin的源代码是公开的,直接从resin的官网将resin的源代码拿下来,看resin到底是如何处理的。
首先找到com.caucho.server.http.HttpRequest,发现是extends AbstractHttpRequest
在AbstractHttpRequest中找到方法
public HttpSession getSession(boolean create)
发现调用
_session = createSession(create, hasOldSession);
这里有一段注释解释了重用jsessonid的行为:
Must accept old ids because different applications in the same server must share the same cookie
But, if the session group doesn't match, then create a new session.
在createSession方法中找到
manager.createSession(id, now, this, _isSessionIdFromCookie);
打开com.caucho.server.session.SessionManager的createSession()方法,
发现有注释: @param oldId the id passed to the request. Reuse if possible.
看代码:
String id = oldId;
if (id == null || id.length() < 4 ||
! isInSessionGroup(id) || ! reuseSessionId(fromCookie)) {
id = createSessionId(request, true);
}
SessionImpl session = create(id, now, true);
我们关注! reuseSessionId(fromCookie)这句,打开看函数
/**
* True if the server should reuse the current session id if the
* session doesn't exist.
*/
public boolean reuseSessionId(boolean fromCookie)
{
int reuseSessionId = _reuseSessionId;
return reuseSessionId == TRUE || fromCookie && reuseSessionId == COOKIE;
}
注:非常不喜欢resin的这种代码风格,一般我宁可写成下面的这种,看代码时容易理解
return (reuseSessionId == TRUE) || (fromCookie && (reuseSessionId == COOKIE));
再看
/**
* True if the server should reuse the current session id if the
* session doesn't exist.
*/
public void setReuseSessionId(String reuse)
throws ConfigException
{
if (reuse == null)
_reuseSessionId = COOKIE;
else if (reuse.equalsIgnoreCase("true") ||
reuse.equalsIgnoreCase("yes") ||
reuse.equalsIgnoreCase("cookie"))
_reuseSessionId = COOKIE;
else if (reuse.equalsIgnoreCase("false") || reuse.equalsIgnoreCase("no"))
_reuseSessionId = FALSE;
else if (reuse.equalsIgnoreCase("all"))
_reuseSessionId = TRUE;
else
throw new ConfigException(L.l("'{0}' is an invalid value for reuse-session-id. 'true' or 'false' are the allowed values.",
reuse));
}
并且可以看到默认值为COOKIE
private int _reuseSessionId = COOKIE;
翻一下resin的文档,可以发现在resin.conf的<session-config>有reuse-session-id这个配置项,resin文档的说明如下:
"reuse-session-id defaults to true so that Resin can share the session id amongst different web-apps."
默认情况下reuse-session-id设置为true,setReuseSessionId("true")会使得_reuseSessionId=COOKIE,而reuseSessionId()方法中的表达式可以简化:
(reuseSessionId == TRUE) || (fromCookie && (reuseSessionId == COOKIE));
--> (COOKIE == TRUE) || (fromCookie && (COOKIE == COOKIE))
--> (false) || (fromCookie && true)
--> fromCookie
因此默认情况下jsessionid用cookie传递就可以做到重用,否则就要生成新的jsessionid.
按照这个思路,只要将reuse-session-id配置项设置为"all",就可以做到即使使用url rewrite也可以重用jsessionid.
ok,问题解决
分享到:
相关推荐
资源来自pypi官网。 资源全名:text-reuse-retrieve-0.1.10.tar.gz
本资源文件为angular路由复用的代码实例,实现多tab页切换和路有缓存的angular实现源码,资源仅供参考
Adaptive partialfrequency reuse in LTE-Advanced relay networks
数据重用技术在盲均衡算法中的应用。在军事通信中,小数据包运用比较多,但很多盲均衡算法不能够在小数据包的情况下收敛,所以采用数据重用的技术来克服。
关于软频率复用的matlab仿真,最后仿真出功率的分配
重用以前的网络数据 重用以前的网络数据来创建网络
Wavelength reuse for short-reach optical access network utilizing MDM
「安全架构」crauEmu - your IDE for code-reuse attacks - 安全研究 安全漏洞 网络安全 防火墙 渗透测试 安全管理
labview_Hamburger-Menu-Reuse- 菜单的全部代码,,,
WP2.3-关于OSH设计重用的指南文档 指南就像一个手提箱,上面放着很多东西,包括方法,过程,基础设施,标准,最佳实践,模板,规范,工作流程,这些都需要弄清楚以定义我们的旅程。
Blazor-如何重用组件并通过字典配置其状态 在您的应用程序中,您有多个组件。 例如,将其设为DataGrid。 一些网格具有一组设置-其他网格-其他设置: Group 1 < DxDataGrid PageSize = " 5 " ShowFilterRow = ...
在大型源代码收集2015中检测源代码重用 抽象的 现有的pla窃检测技术基于确定两个源代码之间的语法差异或比较语法树。 所有这些技术都缺乏源代码的优化。 通过循环展开,代码提升,将计算移至某个变量,宏函数和强度...
重用计算器 可能比较难理解,是一个移动自由标签的示例应用,如下图所示。 使用 Eclipse 导入为 Maven 项目。 支持 android 4.0.3 或更高版本。
Reuse Methodology Manual Third Edition
In this work we present a novel tightly-coupled Visual-Inertial Simultaneous Localization and Mapping system that is able to close loops and reuse its map to achieve zero-drift localization in ...
语言:English 打开外部链接时,请重复使用并防止重复。
清晰版!!SOC/IP设计以及可重用设计的宝典!主要以mentor和synopssy的设计工具为流程,讲述了SOC/IP可重用设计,验证设计的基本方法。
码头-so_reuseport-example 执照 大部分代码取自 jetty-ml。 也可以看看
Visual-Inertial Monocular SLAM with Map Reuse 仅用于个人学习,勿用于商业目的
这是Mathy Vanhoef关于破解wifi加密协议WPA/WPA2使用的密钥重安装攻击方法的论文Key Reinstallation Atacks Forcing Nonce Reuse in WPA2的翻译