• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Stripes: how to set interceptor only for a group of actions?

 
Vadim Vararu
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to write an interceptor that checked id user is logged, or not. But i need this to work only for a group of Actions (CMS). I don't need it to intercept for frontend. Is it possible?
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An interceptor will intercept all requests for a given set of LifecyclePhases. There is nothing that you can tag the interceptor with to specify which actions. However, you can, in your interceptor, determine which Actions are acted upon. So the interceptor will execute every time, but you decide which actions matter.

 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've used something like the following to constrain an interceptor to particular actions.


It's also possible to restrict intercepts to particular methods using the Before and After annotations, either positively:@Before(on="save") or negatively: @Before(on="!save").
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In addition to what Ulf said, seeing as how you could have a huge amount of Actions to test against, you could use the servlet path:

String servletPath = executionContext.getActionBeanContext().getRequest().getServletPath();

This means all your "front-end" actions would reside in a specific path and your secure actions in a different path

http://yourserver.com/public/action
http://yourserver.com/protected/action
 
Vadim Vararu
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much guys! I guess last variant will be more suitable for my case cause my actions paths differs in ..../frontend/... and .../backend/...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic