This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
Win a copy of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Stripes interceptor - what are you using them for?

 
Rancher
Posts: 43011
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On my continuing quest into Stripes, I've started to get into interceptors. The SecurityInterceptor mentioned in the documentation actually answers neatly the question I had of how to avoid checking for an existing session everywhere in my action beans.

While a few areas they can be applied to are obvious -e.g. for everything a regular web app would use servlet filters for- I'm wondering what other things they make possible, since one can get at the ActionBean and ActionBeanContext objects through them. Does anyone have some use cases they thought particularly fitting for interceptors?
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interceptors provide a nice plug-in like architecture for Stripes. As you know there are already a few built in interceptors that ship with stripes. A while back I blogged about writing Stripes interceptors and my example using @NoCache made it into Stripes 1.5 as @HttpCache. It's pretty typical that an interceptor uses annotation to drive its configuration.

There is another interceptor out there (need to find a link) that allows you to specify @Session on action bean properties and the interceptor automatically retrieves and injects properties into the session for you. So there is another possible use case.

Unfortunately I've had my head buried in PHP the last few days so I am not thinking straight. As I think of some use cases I'll post them here.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On a project I was working on a few months ago I used an Interceptor to ensure requests were made via SSL (https). I also wrote a white list interceptor that runs a regex on request params and cleans them (poor mans XSS prevention).
 
Ulf Dittmer
Rancher
Posts: 43011
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah yes, there's also an XSS filter and the @Session interceptor you mention.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Ulf Dittmer:
Ah yes, there's also an XSS filter and the @Session interceptor you mention.



I didn't actually use that XSS filter. The code on the wiki is incomplete. It is probably better than the one I wrote but I couldn't ever get that one to work.
 
Maybe he went home and went to bed. And took this tiny ad with him:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!