Sai
Sai

Reputation: 376

Conditional Spring Security

I want to have spring security that should be configurable through a boolean flag- switch on/off kind of functionality.

For example,

<bean class="org.springframework.ws.server...">
<property name="interceptors">
<list>
----> Here I would like an if condition test based on external property i.e. if true, register the interceptor, else do nothing
   <ref local="wsSecurityInterceptor">
--> other interceptors like logging etc.
</list>
</property>
</bean>

Is this possible in config.xml? Thanks a lot.

Upvotes: 4

Views: 1747

Answers (2)

boozy
boozy

Reputation: 323

You can do something like below added snipped:

<security:intercept-url pattern="/api/**" access="isAuthenticated() and #{SAMLUtil.isStateOne()}" />

where #{boolean_function}

Upvotes: 1

Ketan
Ketan

Reputation: 1012

If you are using Spring 3.1, you may try using new feature called Profile. An Example

Let me know, if you need more details on it.

Upvotes: 6

Related Questions