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 ...
随机推荐
- BZOJ 1103 大都市
dfs序+BIT. #include<iostream> #include<cstdio> #include<cstring> #include<algori ...
- 【C#学习笔记】改变字体
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- HttpWebRequest模拟c#网站登录
用户名 密码 模拟登录asp.net开发的网站 关心两个问题:通过控件属性获取数据.响应事件. 上面是一个普通的asp.net表单.输入用户名.密码后,点击按钮将会进入各自绑定的后台函数,而不仅仅是 ...
- marginCollapse之兄弟关系的DIV
废话不说,直接上图 基本代码如下: 效果图如下: 给两个div分别加marginBottom和marginTop看一下效果 实际效果如下: 我们可以看出两个div之间的距离并不是50+50,而是只显示 ...
- yii 打印sql
$query = TableModel::find()->where([‘xxx’=>xxx]); var_dump($query->prepare(\Yii::$app->d ...
- 深入了解 Oracle Flex ASM 及其优点
简介 Oracle Real Application Cluster (RAC) 是 Oracle 解决方案中的一个著名产品,用于保持业务数据的高可用性.Oracle RAC 允许在所有集群节点之间共 ...
- Oracle 安装 检查操作系统版本 必须是 5.0 5.1 的解决办法
打开 oraparam.ini文件 添加红色部分 Windows=5.1,5.2,6.1 最下面添加 [Windows-6.1-required]#Minimum display colours fo ...
- Linux makefile教程之函数七[转]
使用函数 ———— 在Makefile中可以使用函数来处理变量,从而让我们的命令或是规则更为的灵活和具有智能.make所支持的函数也不算很多,不过已经足够我们的操作了.函数调用后,函数的返回值可以当做 ...
- Effective java笔记8--序列化
对象的序列化(object serialization)API,它提供了一个框架,用来将对象编码成一个字节流,以及从字节流编码中重新构建对象. 一.谨慎地实现Serializable 要想使一 ...
- Android 最火框架XUtils之注解机制详解
http://blog.csdn.net/rain_butterfly/article/details/37931031