Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7705833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:57:39+00:00 2026-05-31T23:57:39+00:00

I have an application that uses SwitchUserFilter . The switching and exiting works fine

  • 0

I have an application that uses SwitchUserFilter. The switching and exiting works fine in normal cases, but if we give the exit url when the user has not actually switched, the user is logged out (expectedly), but when he tries to login again, the application tries to redirect him to the last page that he tried to access (i.e the switch user url).. where again, the user is found to have not switched, and so an error is thrown, the user is logged off, and so the cycle continues.

The following is my spring configuration file :

<?xml version="1.0" encoding="UTF-8"?>

<!-- - Sample namespace-based configuration - -->

<beans:beans xmlns="http://www.springframework.org/schema/security"
    xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                        http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd">

    <global-method-security pre-post-annotations="enabled">
        <!-- AspectJ pointcut expression that locates our "post" method and applies 
            security that way <protect-pointcut expression="execution(* bigbank.*Service.post*(..))" 
            access="ROLE_TELLER"/> -->
    </global-method-security>

    <http use-expressions="true">
        <intercept-url pattern="/**" access="isAuthenticated()" />
        <custom-filter after="FILTER_SECURITY_INTERCEPTOR" ref="switchUserProcessingFilter" />
        <form-login />
        <logout invalidate-session="true" logout-url="/do/logout" />
    </http>
    <!-- Usernames/Passwords are rod/koala dianne/emu scott/wombat peter/opal -->

    <authentication-manager>
        <authentication-provider>
            <user-service id="userService">
                <user name="rod" password="koala" authorities="supervisor, teller, user" />
                <user name="dianne" password="emu" authorities="teller, user" />
                <user name="scott" password="wombat" authorities="user" />
                <user name="peter" password="opal" authorities="user" />
            </user-service>
        </authentication-provider>
    </authentication-manager>

    <beans:bean id="switchUserProcessingFilter"
        class="org.springframework.security.web.authentication.switchuser.SwitchUserFilter">

        <beans:property name="userDetailsService" ref="userService">

        </beans:property>
        <beans:property name="switchUserUrl" value="/switchUser" />
        <beans:property name="exitUserUrl" value="/exitUser" />
        <beans:property name="targetUrl" value="/index.jsp" />
    </beans:bean>

</beans:beans>

Any suggestions as to how can I handle it ?

A practical case could be when I have switched the user, and the session times out. Not knowing that the session has timed out, the user tries to click on the ‘exit user’ url, which then redirects him to the login page, and the above cycle continues.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T23:57:40+00:00Added an answer on May 31, 2026 at 11:57 pm

    As mentioned in this thread, I implemented a custom login success handler, mimicking SavedRequestAwareAuthenticationSuccessHandler, which is the default login success handler. It
    retrieves the url that we tried to access before being redirected to the login page from the request cache (where it was stored by ExceptionTranslationFilter, on seeing that we weren’t authenticated) and redirects to that url. I simply configured it to go to the root url when it encountered something like ‘exitUser‘

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that uses an HTTPWebRequest and works fine on the dev
I have an application that uses a SQLite database and everything works the way
I have an application that uses predefined word lists but I want to extend
I have an application that uses NHibernate as its ORM and sometimes it experiences
I have client application that uses WCF service to insert some data to backend
I have an application that uses the accelerometer. Sometimes, the application will launch without
I have an application that uses window.open() to generate dynamic popups. Unfortunately, I've had
I have an application that uses a cron like job to update a set
We have an application that uses a dual monitor setup - User A will
I have an application that uses DataTables to perform grouping, filtering and aggregation of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.