Spring Security ACL - @PreAuthorize Generics&Interface

问题描述 投票:4回答:1

在使用泛型的接口上使用带有@PreAuthorize注释的Spring ACL似乎不起作用。

例如;我有一个使用泛型的界面;

public interface MyService<T> {
    @PreAuthorize("hasPermission(#objectToProtect, 'WRITE')")
    void doStuff(T objectToProtect, UserIdentity... user);
}

并实施;

public class MyServiceImpl implements MyService<MyObject> {
  @Override
  public synchronized void doStuff(MyObject objectToProtect, UserIdentity... userIdentity) {
    // Do some stuff here... THis should be protected, the authenticated user should have write permissions.
  }
}

我可以看到PrePostAnnotationSecurityMetadataSource正在获取关于实现的注释,但是它看起来像是在AOP中迷失了进一步向上并且在调用acutal方法时它从未使用过。如果我将注释添加到具体实现(即在MyServiceImpl中的doStuff方法上),它就可以工作。

如果我不在我的界面中使用泛型并使用类似Object的东西,它似乎也可以正常工作。这是Spring / Spring Security ACL中的一个错误,或者我们不能使用泛型并期望它们被代理。

我注释的Spring配置看起来像这样;

   <sec:global-method-security pre-post-annotations="enabled" proxy-target-class="true">
        <sec:expression-handler ref="expressionHandler" />
    </sec:global-method-security>

我正在使用最新的GA版Spring(3.2.3)和Spring Security(3.1.4)

java spring generics spring-security acl
1个回答
0
投票

春天Jira有一个开放的虫子:https://jira.spring.io/browse/SPR-16060

© www.soinside.com 2019 - 2024. All rights reserved.