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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T09:51:18+00:00 2026-06-07T09:51:18+00:00

I am using Spring and Spring-Security in a Vaadin application. I want to check

  • 0

I am using Spring and Spring-Security in a Vaadin application.

I want to check if the user has a certain role using SecurityContextHolderAwareRequestWrapper.isUserInRole(…) but cannot figure out how to get a reference to the wrapper (I tried injecting this using @Autowired, NB: I did not manually configure an instance of it as I believe the DelegatingFilterProxy is already doing this behind the scenes).

This stack overflow issue provided me with the solution, but I cannot uncover how to access or instantiate the wrapper properly.

My other alternative is to access the SecurityContext directly and iterate though the GrantedAuthorities as per the other suggestions in the linked SO issue.

How should I access/instantiate the wrapper?

  • 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-06-07T09:51:20+00:00Added an answer on June 7, 2026 at 9:51 am

    It should work out of the box, at least in Spring Security 3.1 (every HttpServletRequest in security chain should be instance of SecurityContextHolderAwareRequestWrapper).

    servlet-api-provision attribute of <http> element adds to stack:

    Provides versions of HttpServletRequest security methods such as
    isUserInRole() and getPrincipal() which are implemented by adding a
    SecurityContextHolderAwareRequestFilter bean to the stack. Defaults to
    true.

    The filter SecurityContextHolderAwareRequestFilter is simple and only wraps HttpServletRequest in SecurityContextHolderAwareRequestWrapper:

    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
            throws IOException, ServletException {
        chain.doFilter(new SecurityContextHolderAwareRequestWrapper(
                (HttpServletRequest) req, rolePrefix), res);
    }
    

    (Watch out bug #SEC-1943 – the filter has wrong name assigned to alias SERVLET_API_SUPPORT_FILTER.)

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

Sidebar

Related Questions

I am using Spring security feature in my application, but I found out that
I'm using Spring Security which works great to make sure that a user has
I am using Spring Security with LDAP for an application and I want to
My web application is using Spring Security but it returning a BadCredentialsException when processing
hi I have a j2ee application using Spring webflow and Spring Security. I want
I'm using spring security in my web application, and now I want to have
I am trying to programatically validate a user login/pass using Spring Security, so I
I'm having trouble using Spring Security successfully in my Grails application. I installed the
I'm using Spring Security 3.0.2 form based authentication. But I can't figure out how
I am using spring security 3.0.5 in my web application based on Spring MVC.

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.