问题描述
tomcat会话的默认行为是在关机时持久保存它们,并在启动后还原它们.这可以按预期在我的简单测试应用程序上工作.但是,当我添加基于表单的身份验证时,在tomcat重新启动时,用户登录名(用户主体)将无法恢复.
The default behaviour of tomcat sessions is to persist them on shutdown and restore them after startup. This works on my simple test application as expected.But when I add form based authentication the user login (User principal) won't get restored on tomcat restart.
即使位于/examples/jsp/security/protected/index.jsp下的示例应用程序也无法恢复登录.
Even the example application located under /examples/jsp/security/protected/index.jsp does not restore the login.
有没有什么方法可以实现会话/身份验证恢复,而没有其他建议中的群集/复制?
Is there any way to achieve session/authentication restoration without clustering/replication as suggested elsewhere?
我正在使用Tomcat 7.
I am using Tomcat 7.
推荐答案
在该示例中,您将不会使用tomcat和基于标准表单的身份验证对其进行存档(它使用UserDatabaseRealm).看一下注释: http://tomcat.apache.org/tomcat-7.0-doc/realm -howto.html
You will not archive that with tomcat and standard form based authentication at the example (it uses UserDatabaseRealm).Take a look at the notes:http://tomcat.apache.org/tomcat-7.0-doc/realm-howto.html
未在会话序列化之间保存和还原缓存的用户."除了"JAASRealm"之外,所有领域的实现都可以使用,或者说是文档.
"The cached user is not saved and restored across sessions serialisations." with all realm implementations but "JAASRealm", or so says documentation.
因此,您可以实现自己的JAAS登录模块以与tomcat中的表单身份验证一起使用,也可以将框架用作春季安全性",网络上有非常简单的教程,例如 http://www.mkyong.com/spring-security/spring-security-form-login -example/
So you can implement your own JAAS login module to be used with forms authentication in tomcat or you can use a framework as "spring security", there are very simple tutorials on the web, for example http://www.mkyong.com/spring-security/spring-security-form-login-example/
我已经成功测试了该示例(tomcat重新启动后会记住会话登录).
I have successfuly tested that example (the session login is remembered after tomcat restart).
希望这对您有所帮助.
关于,乔斯
这篇关于Tomcat 7重新启动后恢复用户登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!