How to create custom methods for use in spring security expression language annotations
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的更多相关文章
- How to Create Custom Filters in AngularJs
http://www.codeproject.com/Tips/829025/How-to-Create-Custom-Filters-in-AngularJs Introduction Filter ...
- create custom launcher icon 细节介绍
create custom launcher icon 是创建你的Android app的图标 点击下一步的时候,出现的界面就是创建你的Android的图标 Foreground: ” Foregro ...
- [转]How to Create Custom Filters in AngularJs
本文转自:http://www.codeproject.com/Tips/829025/How-to-Create-Custom-Filters-in-AngularJs Introduction F ...
- How to: Create Custom Configuration Sections Using ConfigurationSection
https://msdn.microsoft.com/en-us/library/2tw134k3.aspx You can extend ASP.NET configuration settings ...
- 3.2Adding custom methods to mappers(在映射器中添加自定义方法)
3.2Adding custom methods to mappers(在映射器中添加自定义方法) 有些情况下,我们需要实现一些MapStruct无法直接自动生成的复杂类型间映射.一种方式是复用其他已 ...
- Linux shell create file methods
Linux shell create file methods touch, cat, echo, EOF touch $ touch file.py $ touch file1.txt file2. ...
- java中如何创建自定义异常Create Custom Exception
9.创建自定义异常 Create Custom Exception 马克-to-win:我们可以创建自己的异常:checked或unchecked异常都可以, 规则如前面我们所介绍,反正如果是chec ...
- Spring security 3.1 +JSF 2.0 . problem with annotating methods in ManagedBeans?
Hy .What i am trying to do is to integrate Spring security with a Jsf+spring IOC +hibernate applicat ...
- php foreach 报 “Cannot create references to elements of a temporary array expression”
今天在项目中用php foreach数据库查询结果时,为了方便没有判断数据是否存在,直接用(array)强制转换数据时,刚开始网页始终打不开,就报502,一头懵,突然间php报“Cannot crea ...
随机推荐
- Azure PowerShell 1.0.0以上版本在中国Azure使用的注意事项
随着Azure PowerShell 1.0.0+的推出,越来越多的客户开始使用新的版本的Azure PowerShell.此版本的PowerShell最大的改变在于将原先的Switch-AzureM ...
- java实现的kmp算法
package DataStructure; import java.util.ArrayList; import java.util.List; //KMP算法的实现 //以下代码由freedom结 ...
- ecshop 模版商品详情页,不同商品调用不同模板
1.在goods.php中找到以下代码 $smarty->display('goods.dwt', $cache_id); 改为下面的代码 switch ($goods['cat_id']){ ...
- 免费的WebService
天气预报Web服务,数据来源于中国气象局 Endpoint : http://www.webxml.com.cn/WebServices/WeatherWebService.asmx Disc ...
- T-SQL备忘(4):分页
set statistics io on set statistics time on --SQL Server 2012分页方式 select * from Production.Product o ...
- 成功BOSS的六大秘诀
1.信念力 一个没有坚定信念的人,是不可能成为伟大企业家的.如果你认为自己行,你就一定行:如果你都认为自己不行了,那你就注定不行.在成功这条道路上,要勇敢地自我肯定和鼓励,这样才能带来巨大的创造力并最 ...
- 网页元素定位神器之Xpath详解
摘要: 经常在工作中会使用到XPath的相关知识,但每次总会在一些关键的地方不记得或不太清楚,所以免不了每次总要查一些零碎的知识,感觉即很烦又浪费时间,所以对XPath归纳及总结一下. ... ...
- 查找指定目录下的文件 .xml
pre{ line-height:1; color:#9f1d66; background-color:#cfe4e4; font-size:16px;}.sysFunc{color:#5d57ff; ...
- MySQL_PHP学习笔记_2015_0923_MySQL如何开启事件
1. 查看事件状态>>>>>>>>>>>>>>>>>>>>>>> ...
- 安装linux操作系统--浪潮服务器
一直都是在虚拟机上进行安装linux操作系统,在服务器上安装的很少,也没有碰到过没找到驱动的情况,例如什么raid卡驱动,网卡驱动等异常情况的发生. 这次安装了两台服务器,浪潮的提供的服务器,硬盘是两 ...