【问题标题】:spring framework security @preauthorize annotation not working in osgiSpring框架安全@preauthorize注释在osgi中不起作用
【发布时间】:2012-08-22 21:51:03
【问题描述】:

我正在使用 osgi 和基于 spring 注释的配置。 (使用 virgo 部署应用)
方法 impl 上的 @preauthorize 注释不起作用。
它允许用户在没有角色的情况下访问它。

如果我在界面上放置相同的注释,它会为所有用户抛出 AccessDenied 异常。 例外:

org.springframework.security.access.AccessDeniedException: Access is denied 
 252881 [http-bio-8080-exec-3] ERROR c.w.HomeController  - handleAccessDeniedException####Access is denied 
    at org.springframework.security.access.vote.AffirmativeBased.decide(AffirmativeBased.java:71) 
    at org.springframework.security.access.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:203
    at org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:64) 
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) 
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) 
    at $Proxy421.save(Unknown Source) 
    at c.w.controllers.HomeController.home(HomeController.java:125) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 
    at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176) 
    at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapte
    at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414) 

这是我的配置:

  <bean id="expressionHandler"
      class="org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler">
        <property name="permissionEvaluator" ref="aclPermissionEvaluator"/>
  </bean>
  <global-method-security pre-post-annotations="enabled" run-as-manager-ref="runAsManager"
    secured-annotations="enabled">
    <expression-handler ref="expressionHandler" />
  </global-method-security> 

我正在使用 spring-security 3.0.4.RELEASE

【问题讨论】:

    标签: spring-security osgi eclipse-virgo


    【解决方案1】:

    我在一个包中使用了@Preauthorize 注释,并在另一个包中定义了 global-method-security
    将其移至同一捆绑包后,该问题得到解决。

    【讨论】:

      猜你喜欢
      • 2012-08-04
      • 2015-06-20
      • 1970-01-01
      • 1970-01-01
      • 2019-04-27
      • 2018-02-22
      • 2012-01-01
      • 2017-01-10
      • 2015-09-20
      相关资源
      最近更新 更多