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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:56:41+00:00 2026-06-05T15:56:41+00:00

In our project we’re mixing xml and annotations based spring mvc security configuration. We’ve

  • 0

In our project we’re mixing xml and annotations based spring mvc security configuration. We’ve got quite a few lot of roles, a lot of controlers and frequently changing requirements about who should be able to do what. I thought it would be nice to have util class which will generate permission matrix like this.

What I’ve done so far is wrote simple classpath scanner which looks for all classes marked with @Controller and extract values of @PreAuthorize. Naming convention for controllers is straightforward: {Action}{Type}Controller (eg. NewOrderController) so its easy to generate human(and by human I mean non-programmer) readable csv file.

The problem is classpath scanning for annotation doesn’t cover what we’ve got in xml config.

I was wondering if there is any other way to query metadata used for access resolution by spring mvc itself.

EDIT:

Example xml configuration (largely simplified):

<security:http pattern="/static/**" security="none" />

<security:http auto-config="false"
               use-expressions="true"
               entry-point-ref="entryPoint"
               security-context-repository-ref="securityContextRepository">
    <security:intercept-url pattern="/product/**" access="hasAnyRole('PRODUCT_USER')" />
    <security:intercept-url pattern="/admin/**" access="hasAnyRole('ADMIN_USER')" />
    <!-- No security configuration for /order/** -->
</security:http>

Example of annotation driven configuration:

@Controller
@RequestMapping("/order/new/{id}")
public class NewOrderController {

    @Autowired
    public NewOrderController() {
    }

    @RequestMapping(method = RequestMethod.GET)
    @PreAuthorize("hasRole('ORDER_USER')")
    public ModelAndView display() {
        return new ModelAndView(/*...*/);
    }

    @RequestMapping(method = RequestMethod.POST)
    @PreAuthorize("hasRole('ORDER_USER')")
    public RedirectView process() {
        return new RedirectView(/*...*/);
    }

}
  • 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-05T15:56:42+00:00Added an answer on June 5, 2026 at 3:56 pm

    I suppose this answer will help you construct the solution to parse and load the meta data on URL interceptors in order to gather the configured roles.

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

Sidebar

Related Questions

We've got our project running on JBoss 6 with Spring 3.0.5. Everything went smooth
Our project represents a web application on ASP.NET MVC base. It has a lot
In our project every day there will be lot of deliveries to integration stream.
Our project is using constructor-based Dependency Injection (we're using Unity as our container) and
Our project is working within fairly close quarters code-wise (a lot of changes happening
Our project already has a StyleCop configuration. I am using ReSharper and I would
Our project has two application contexts: application-context.xml application-context-test.xml Currently each file has duplicate bean
In our project we use jackrabbit with spring and tomcat to manage pdf files.
Our project is based on J2EE and we would like to know if there
Our project contains a lot of c++ sources, up until now we were sing

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.