首页 > 其他 > 详细

How to create custom methods for use in spring security expression language annotations

时间:2014-03-08 20:18:27      阅读:491      评论:0      收藏:0      [点我收藏+]

From:http://stackoverflow.com/questions/6632982/how-to-create-custom-methods-for-use-in-spring-security-expression-language-anno

None of the mentioned techniques will work anymore. It seems as though Spring has gone through great lengths to prevent users from overriding the SecurityExpressionRoot. Instead, create a bean like this:

@Component("mySecurityService")publicclassMySecurityService{publicboolean hasPermission(String key){returntrue;}}

Then do something like this in your jsp:

<sec:authorize access="@mySecurityService.hasPermission(‘special‘)"><input type="button" value="Special Button"/></sec:authorize>

Or annotate a method:

@PreAuthorize("@mySecurityService.hasPermission(‘special‘)")publicvoid doSpecialStuff(){...}

And remember: if you are using Spring and you have to solve a problem by extending classes, overriding methods, implementing interfaces, etc... then you‘re probably doing something wrong. It‘s all annotations and xml, that‘s why we love Spring so much and not (old versions of) EJB.

How to create custom methods for use in spring security expression language annotations,布布扣,bubuko.com

How to create custom methods for use in spring security expression language annotations

原文:http://www.cnblogs.com/sun_moon_earth/p/3587679.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!