First of all, this is not a duplicate question, I checked the answers here ! and also here ! but could not get it to work.
I also want to execute it immediately before logging out, so I cannot use logoutSuccessHandler.
So, I need to create a custom LOGOUT_FILTER file, which is really hard for me to get it working with.
here is my spring -security xml in which I tried two methods at first was: -
<custom-filter ref="logoutFilter" position="LOGOUT_FILTER" /> <beans:bean id="logoutFilter" class="org.springframework.security.web.authentication.logout.LogoutFilter"> <beans:constructor-arg index="0" value="/logoutSuccess" /> <beans:constructor-arg index="1"> <beans:list> <beans:bean id="securityContextLogoutHandler" class="org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler" /> <beans:bean id="myLogoutHandler" class="com.fe.cms.listener.SimpleLogoutHandler" /> </beans:list> </beans:constructor-arg> <beans:property name="filterProcessesUrl" value="/logout" /> </beans:bean>
but it gives me an error
Configuration problem: Security namespace does not support decoration of element [custom-filter]
then I tried ..
<beans:bean id="logoutFilter" class="org.springframework.security.web.authentication.logout.LogoutFilter"> <beans:constructor-arg index="0" value="/logout" /> <beans:constructor-arg index="1"> <beans:ref bean="securityContextLogoutHandler" /> <beans:ref bean="myLogoutHandler" /> </beans:constructor-arg> <beans:property name="filterProcessesUrl" value="/logout" /> </beans:bean> <beans:bean id="securityContextLogoutHandler" class="org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler" /> <beans:bean id="myLogoutHandler" class="com.fe.cms.listener.SimpleLogoutHandler" /> <http auto-config="false" entry-point-ref="authenticationManger"> <custom-filter ref="logoutFilter" position="LOGOUT_FILTER" /> </http>
but it gives me an error: -
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.filterChains': Cannot resolve reference to bean 'org.springframework.security.web.DefaultSecurityFilterChain#48' while setting bean property 'sourceList' with key [48]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#48': Cannot create inner bean '(inner bean)' of type [org.springframework.security.web.access.ExceptionTranslationFilter] while setting constructor argument with key [6]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#181': Could not resolve matching constructor (hint: specify index/type/name arguments for simple parameters to avoid type ambiguities)
Please tell me where I am doing wrong. I will publish full xml files if necessary
source share