Ganesh Ganesh - 20 days ago 9
Java Question

Convert multiple securiy http configuration from xml to java configuration

I have multiple

security:http
configurations in my xml with different entry-point-ref. I am trying to convert this config to java config.

I have read that this is possible using multiple sub classes extending
WebSecurityConfigurerAdapter
.

How should I configure the entry-point-ref for each of these in java config?

follwing is the xml config.

<security:http request-matcher-ref="preReqMatcher" auto-config="false" use-expressions="false" entry-point- ref="preAuthenticatedProcessingFilterEntryPoint">
<custom-filter position="PRE_AUTH_FILTER" ref="preAuthFilter" />
<custom-filter after="CAS_FILTER" ref="attrFilter" />
<intercept-url pattern="/**" access="ROLE_USER" />
<csrf disabled="true"/>
</security:http>

<security:http auto-config="true" entry-point-ref="casEntryPoint" use-expressions="false" disable-url-rewriting="false">
<custom-filter position="CAS_FILTER" ref="casFilter" />
<custom-filter after="CAS_FILTER" ref="attrFilter" />
<intercept-url pattern="/**" access="ROLE_USER" />
<custom-filter ref="testFilter" before="CAS_FILTER" />
<csrf disabled="true"/>
</security:http>

Answer

Following is the way I figured out to configure the entry-point.

http.httpBasic().authenticationEntryPoint(preAuthenticatedProcessingFilterEntryPoint);