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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:41:27+00:00 2026-06-14T20:41:27+00:00

I have an abstract class (the parent class) with some shared @RequestMapping methods and

  • 0

I have an abstract class (the parent class) with some shared @RequestMapping methods and there are some @Controller classes implementing it (the sub-classes).

I annotated the sub-classes with @Secured at the class level, but the parent class methods are not protected by this. (I.e. the AOP interceptor only considers the methods on the sub-classes, not the parent class).

Unfortunately, the sub-classes each need to be protected by a different role, so it will be impossible to annotate the parent class with a common @Secured restriction. It is possible to override all methods in the parent class so they are protected, but I want to avoid this ugly workaround.

Thus I am wondering is there anything I can override (e.g. the interceptor, advice or the meta data provider so that any method in the class hierarchy will observe the @Secured annotation on the target class)?

Additional info:

It seems the annotation resolution is implemented in
org.springframework.security.access.method.AbstractFallbackMethodSecurityMetadataSource.getAttributes(Method, Class<?>) and indeed it only looked at the declaring class of the method (in my case, the parent class). However, I am not too familiar with proxy programming, so any advice on how to safely implement the changes I want are welcome.

  • 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-14T20:41:29+00:00Added an answer on June 14, 2026 at 8:41 pm

    It seems you can simply override SecuredAnnotationSecurityMetadataSource with something like

    @Override
    public Collection<ConfigAttribute> getAttributes(Method method, Class<?> targetClass) {
        Collection<ConfigAttribute> out = super.getAttributes(method, targetClass);
    
        if (out == null || out.isEmpty()) {
            out = findAttributes(targetClass);
            if (out == null) out = Collections.emptyList();
        }
    
        return out;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a abstract class called Customer which has some attributes shared amongst all
I have a class with some abstract methods, but I want to be able
Let's say I have these class hierarchy : public abstract class Parent { }
I have a model that looks something like this: public abstract class Parent {
I have one parent class, which is abstract class for now, for four different
I have an abstract base class class AbstractClass { Col<AbstractClass> parent public AbstractClass() {
If I have a parent-child that defines some method .foo() like this: class Parent
I have a parent class, like this: public abstract class Business<T> : IBusiness<T> where
I have 4 classes, one Database helper and 3 defined like this: abstract class
I have an abstract class defined as follows: abstract class Abstract Parent extends Zend_Db_Table_Abstract

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.