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 7506683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:19:54+00:00 2026-05-29T22:19:54+00:00

i use spring security to organize the security and user management in my GWT

  • 0

i use spring security to organize the security and user management in my GWT application. If i login as “admin”, logout, and login as another user the “SecurityContextHolder.getContext()” still returns me the “admin” authentication though i use the standard spring security logout URL (/j_spring_security_logout) and after logout have to login again to access the page… somebody has a hint? I’m at the end of my knowledge =/

filters in my web.xml:

   <filter>
      <filter-name>springSecurityFilterChain</filter-name>
      <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
   </filter>
   <filter-mapping>
     <filter-name>springSecurityFilterChain</filter-name>
     <url-pattern>/*</url-pattern>
   </filter-mapping>
   <listener>
      <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
   </listener>

applicationcontext.xml:

<bean class="service.security.DefaultPermissionEvaluator" id="permissionEvaluator"/>
<bean class="org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler" id="expressionHandler">
    <property name="permissionEvaluator" ref="permissionEvaluator"/>
</bean>
<sec:global-method-security pre-post-annotations="enabled">
  <sec:expression-handler ref="expressionHandler"/>
</sec:global-method-security> 
<bean class="service.security.DefaultAuthenticationProvider" id="authenticationProvider"/>
<bean class="service.security.DefaultUserDetailsManager" id="userDetailsManager"/>
<bean class="service.security.DefaultAuthenticationListener" id="customAuthListener"/>
<sec:authentication-manager>
  <sec:authentication-provider ref="authenticationProvider">
  </sec:authentication-provider>
</sec:authentication-manager>     
<sec:http auto-config="true" use-expressions="true">
  <sec:form-login default-target-url="/Index.html" always-use-default-target="true"/>
  <sec:logout invalidate-session="true" logout-success-url="/" logout-url="/j_spring_security_logout"/>
  <sec:intercept-url pattern="/service/admin/**" access="hasRole('ADMIN')"/>
  <sec:intercept-url pattern="/**" access="hasRole('USER')"/>
</sec:http> 
  • 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-29T22:19:56+00:00Added an answer on May 29, 2026 at 10:19 pm

    The problem was i did this:

    class ServiceExample extends HttpServlet {
        private final Authentication auth;
        public ServiceExample() {
            this.auth = SecurityContextHolder.getContext().getAuthentication()
        }
    
        public User getCurrentUser() {
            return (User) this.auth.getPrincipal();
        }
    }
    

    instead of:

    class ServiceExample extends HttpServlet {
        public ServiceExample() {
        }
    
        public User getCurrentUser() {
            return (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        }
    }
    

    Which makes the SecurityContext initialize once when somebody logs in (Jetty behavior) and not changing when somebody else logs in cause of jetty using the same instance…

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

Sidebar

Related Questions

I use the spring-security-core plugin in my application. My user class extends SecUser and
I use Spring Security 3 in my jsf2 web app. When a non-authenticated user
I want to use Spring Security to manage user, group and permissions. I want
I want to use method level security on my GWT application. I'm trying to
I need to use the Spring Security User, Role/Authority and the UserRole-join classes both
I wanted to use MongoDB in my Grails application and also Spring Security. I
I am trying to use Spring Security 3.0.5 in my web application. Basically, I
I need to use Spring Security 3 in my application which is composed by
I use Spring and Spring Security 3 at my application. All my clients side
I have a java web application that use spring security for log in users,

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.