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 ...
随机推荐
- (转载)ios关闭虚拟键盘的几种方法
在iOS应用开发中,有三类视图对象会打开虚拟键盘,进行输入操作,但如何关闭虚拟键盘,却没有提供自动化的方法.这个需要我们自己去实现.这三类视图对象分别是UITextField,UITextView和U ...
- hihoCoder #1181: 欧拉路·二 (输出路径)
题意: 给定一个图,要求打印出任一条欧拉路径(保证图肯定有欧拉路). 思路: 深搜的过程中删除遍历过的边,并在回溯时打印出来.在深搜时会形成多个环路,每个环都有一个或多个结点与其他环相扣,这样就可以产 ...
- android studio 加载第三方类库
以引入Xutil包为例 1. 将Xutil包导入到module的libs目录下 2. File->project structure 还有一种方法是在libs目录下右键点击Add as libr ...
- erl_0013 erlang 带参数模块 parameterized modules are no longer supported
code: -module(mod_test, [Name]). -export([show/0]). show() -> io:format("show:~p~n",[Na ...
- Android如何获取系统高度、标题栏和状态栏高度
在android应用中,有时需要计算个View的位置,导致需要计算状态栏高度,标题栏高度等信息.为以后方便,在此做个简单记录. 晒代码前先了解一下android屏幕区域的划分,如下图(该图引用自此文h ...
- MySQL多表连接
主要分3种:内连接,外连接,交叉连接 其 他:联合连接,自然连接 1.内联接 典型的联接运算,使用像 = 或 <> 之类的比较运算).包括相等联接和自然联接. 内联接使用比 ...
- AIX系统管理员--第一章笔记
IBM产品系列 x系类为PC服务器-- e-server x x表示x-architecture 可自由选择运行环境,windows.linux.unix等 p系类为 ...
- vim的保存误认为utf8问题
用vim改脚本改到一处写到'太原':w一下,再打开,,结果给乱码了...我默认sql是用cp936的,,,想到到和记录本的联通问题一样.... 可能会问我为什么不用utf8,,,,因为ms200 ...
- hdu 2476(第一道区间dp)
题意:就是给定两个字符串,第一个是初始串,第二个是目标串,问你把初始串变到目标串最少需要多少串! 分析:此题分两步,第一步是假设开始的初始串是空串,然后就进行区间dp,dp[i][j]代表把区间[i, ...
- 工具栏ToolStrip能触发焦点控件的Leave、Validating、DataError等事件以验证数据 z
public class ToolStripEx : ToolStrip { protected override void OnClick(EventArgs e) { base.OnClick(e ...