Spring Security has built-in “remember-me” authentication capability to remember the identity of a user (principle) between session.
However, default implementations for “persistent token” only support in-memory (for testing) and JDBC. I wanted to implement this with App Engine using Objectify for persistence.
All it takes is to implement a custom
PersistentTokenRepository and configure Spring Security to use it. This post assumes that Spring Security has been configured to work correctly with App Engine.
I started with a Spring Java configuration that looks like this:
1 2 3 4 5 6
Collection<RelatedService> is telling Spring to look for all beans matching the type of
RelatedService and put them in a
Collection for me to use in
Then I wanted to make
relatedServices an optional dependency. Ideally, I would like to be able to do something like this:
1 2 3 4 5 6 7
@Autowired cannot annotate a parameter. This is what I end up doing.
1 2 3 4 5 6 7 8 9
I would prefer to limit the visibility/scope of
relatedServices within the method but it does not look possible.
bower link feature makes it easy to change & test packages while using it as a dependency in other packages. If you are using Bower, you should be using this.
Google AppEngine (Java) provides ability to mock
UserService in JUnit test cases with the help of
LocalUserServiceTestConfig. However, switching user within a test case is not so simple.
Groovy has a unique quality that other dynamic/scripting languages does not – you can write plain Java code in a Groovy class.
This attribute makes it an excellent choice for Java developers trying to pick up this dynamic language – start by writing Java and ease into Groovy’s style as you practice.
Composing blog posts in Markdown is great but it would be even better if I can see how pages are rendered live. So, let’s have that.