I have problem with @PreAuthorize and accessing bean in expression. Running Spring Security version is 3.1.0RC2.
applicationContext.xml:Code:INFO [SpringSecurityCoreVersion:29] : You are running with Spring Security Core 3.1.0.RC2 INFO [SecurityNamespaceHandler:57] : Spring Security 'config' module version is 3.1.0.RC2
Controller code:Code:<security:global-method-security secured-annotations="enabled" pre-post-annotations="enabled" />
I get error:Code:@Controller class TestController { public boolean isOk() { return true; } @PreAuthorize("testController.isOk()") @RequestMapping("/test") public String testPage() { return "test"; } }
Anybody knows what is wrong with that ?Code:java.lang.IllegalArgumentException: Failed to evaluate expression 'testController.isOk()' ... Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 0): Field or property 'testController' cannot be found on object of type 'org.springframework.security.access.expression.method.MethodSecurityExpressionRoot' at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:207) at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:71) at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:52) at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:102) at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:97) at org.springframework.security.access.expression.ExpressionUtils.evaluateAsBoolean(ExpressionUtils.java:11) ... 79 more


Reply With Quote