简体   繁体   English

如何在Google App Engine上使用Spring Framework创建表单登录名

[英]How to create a form login with Spring Framework on Google App Engine

I'm new to Spring and GAE, and I assume this is easy, so don't overlook the simple answer. 我是Spring和GAE的新手,我认为这很简单,因此请不要忽略简单的答案。

In spring I understand that I need to create an implementation of UserDetailsService which populates UserDetails for the security framework on authentication. 在春季,我了解到我需要创建UserDetailsService的实现,该实现将在身份验证的安全框架中填充UserDetails

After doing this I got a NotSerializableException on my SpringUserDetailsService bean, if I serialize it (as shown) I get a NotSerializableException on the DAO eventually. 完成此操作后,我在SpringUserDetailsService Bean上收到一个NotSerializableException ,如果我对其进行序列化(如图所示),则最终在DAO上得到了NotSerializableException GAE stores the session in a data store, and as far as I understand from reading Spring Web Security framework uses the session. GAE将会话存储在数据存储中,据我阅读Spring Web Security框架所了解的使用该会话。

If I add @Scope("session) to my service I got the following exception that I don't understand really. Also it doesn't seem to make sense to make a separate copy of this class for each session, they should all just reference the singleton. 如果我在服务中添加@Scope("session) ,则会收到以下我并不真正理解的异常。此外,为每个会话单独创建此类的副本似乎也没有意义,它们应该参考单例。

BeanCreationException: Error creating bean with name 'testService': Scope 'session' is not active for the current thread; BeanCreationException:创建名称为'testService'的bean时出错:作用域'session'对于当前线程无效; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; 如果您打算从单例中引用它,请考虑为此bean定义作用域代理。 nested exception is java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? 嵌套异常为java.lang.IllegalStateException:未找到线程绑定的请求:您是在实际Web请求之外引用请求属性,还是在原始接收线程之外处理请求? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request. 如果您实际上是在Web请求中操作并且仍然收到此消息,则您的代码可能在DispatcherServlet / DispatcherPortlet之外运行:在这种情况下,请使用RequestContextListener或RequestContextFilter公开当前请求。

@Service("springUserDetailsService")
public class SpringUserDetailsService implements UserDetailsService, Serializable {
 @Resource(name="userDao")
 private IUserDao userDao;

    @Override
    public UserDetails loadUserByUsername(String username){...}
}

For an easy task like form login, this is kicking my butt, can anyone help untangle my brain? 对于诸如表单登录之类的简单任务,这很麻烦,有人可以帮忙解开我的大脑吗?

Check out this article. 查看这篇文章。 It should get you started: 它应该使您开始:

http://blog.springsource.com/2010/08/02/spring-security-in-google-app-engine/ http://blog.springsource.com/2010/08/02/spring-security-in-google-app-engine/

Grant 格兰特

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM