2012-08-28 69 views
0

我使用基於Spring註解的配置的osgi。 (使用處女座部署應用程序)
@preauthoration對impl方法不起作用的註釋。
儘管沒有角色,但它允許用戶訪問它。
彈簧框架安全@preauthorize註釋不在osgi中工作

如果我在界面上放了相同的註釋,它會爲所有用戶拋出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> 

我使用彈簧安全3.0.4.RELEASE

回答

0

我用@Preauthorize註釋在一個包和定義的全局法 - 在另一個捆綁中安全
將問題移至同一捆綁包後得到解決。