ThreadLocalClient小应用
今天遇到hibernate.find就会进行权限配置,如果某处想要跳过权限配置,则可以如下
ThreadLocalClient.get().envParamMap.put(DataAuthority.IS_APPLY_AUTHORITY, false);
所有ThreadLocalClient都在下面配置
package com.huatek.framework.security; import java.io.Serializable;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set; import com.huatek.framework.entity.FwAccount;
import com.huatek.framework.entity.FwActionCnt;
import com.huatek.framework.entity.FwGroup;
import com.huatek.framework.entity.FwSrcAction; public class ClientInfoBean implements Serializable { /**
*
*/
private static final long serialVersionUID = 8810206692236045600L; private String actionURL; private String actionMethod; private String contextPath; private String serverHost; private int serverPort; private Calendar accessCalendar; private String actionId; private String hostIp; private int hostPort; private Long menuId; private boolean isLogged; private String requestMethod; public Map<String,Object> envParamMap = new HashMap<String,Object>(); public String getRequestMethod() {
return requestMethod;
} public void setRequestMethod(String requestMethod) {
this.requestMethod = requestMethod;
} public Long getMenuId() {
return menuId;
} public void setMenuId(Long menuId) {
this.menuId = menuId;
} private Long operationGroupId; private List<FwGroup> permitGroup; private List<FwSrcAction> permitAction; public List<FwSrcAction> getPermitAction() {
return permitAction;
} public void setPermitAction(List<FwSrcAction> permitAction) {
this.permitAction = permitAction;
} public List<FwGroup> getPermitGroup() {
return permitGroup;
} public void setPermitGroup(List<FwGroup> permitGroup) {
this.permitGroup = permitGroup;
} public Long getOperationGroupId() {
return operationGroupId;
} public void setOperationGroupId(Long operationGroupId) {
this.operationGroupId = operationGroupId;
} private FwAccount operator; private Set<FwActionCnt> auditContents; public Set<FwActionCnt> getAuditContents() {
return auditContents;
} public void setAuditContents(Set<FwActionCnt> auditContents) {
this.auditContents = auditContents;
} private String actualActionPath; public String getActualActionPath() {
return actualActionPath;
} public void setActualActionPath(String actualActionPath) {
this.actualActionPath = actualActionPath;
} public FwAccount getOperator() {
return operator;
} public void setOperator(FwAccount operator) {
this.operator = operator;
} private FwSrcAction srcAction; public FwSrcAction getSrcAction() {
return srcAction;
} public void setSrcAction(FwSrcAction srcAction) {
this.srcAction = srcAction;
} public int getHostPort() {
return hostPort;
} public void setHostPort(int hostPort) {
this.hostPort = hostPort;
} public Calendar getAccessCalendar() {
return accessCalendar;
} public void setAccessCalendar(Calendar accessCalendar) {
this.accessCalendar = accessCalendar;
} public String getActionId() {
return actionId;
} public void setActionId(String actionId) {
this.actionId = actionId;
} public String getActionURL() {
return actionURL;
} public void setActionURL(String actionName) {
this.actionURL = actionName;
} public String getHostIp() {
return hostIp;
} public void setHostIp(String hostIp) {
this.hostIp = hostIp;
} public String toString() { /*SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-DD hh:mm:ss");*/
Date time = accessCalendar.getInstance().getTime();
if(time==null){
time = new Date();
}
return "actionURL=" + this.actionURL + "\n" + "accessCalendar="
+ time + "\n"
+ "actionId=" + this.actionId + "\n"
+ "hostIp=" + this.hostIp;
} public String getActionMethod() {
return actionMethod;
} public void setActionMethod(String actionMethod) {
this.actionMethod = actionMethod;
} public String getContextPath() {
return contextPath;
} public void setContextPath(String contextPath) {
this.contextPath = contextPath;
} public int getServerPort() {
return serverPort;
} public void setServerPort(int serverPort) {
this.serverPort = serverPort;
} public String getServerHost() {
return serverHost;
} public void setServerHost(String serverHost) {
this.serverHost = serverHost;
} public boolean isLogged() {
return isLogged;
} public void setLogged(boolean isLogged) {
this.isLogged = isLogged;
} }
根据下面判断当前的账户是否要继续
if(ThreadLocalClient.get().envParamMap.get(DataAuthority.IS_APPLY_AUTHORITY)!=null&&
ThreadLocalClient.get().envParamMap.get(DataAuthority.IS_APPLY_AUTHORITY).equals(false)){
return hsql;
}
if (ThreadLocalClient.get() == null || ThreadLocalClient.get().getOperator()==null
|| ThreadLocalClient.get().getOperator().getId().longValue() == Constant.OPS_ADMIN
.longValue()) {
return hsql;
}
ThreadLocalClient小应用的更多相关文章
- 【小程序分享篇 二 】web在线踢人小程序,维持用户只能在一个台电脑持登录状态
最近离职了, 突然记起来还一个小功能没做, 想想也挺简单,留下代码和思路给同事做个参考. 换工作心里挺忐忑, 对未来也充满了憧憬与担忧.(虽然已是老人, 换了N次工作了,但每次心里都和忐忑). 写写代 ...
- 【小程序分享篇 一 】开发了个JAVA小程序, 用于清除内存卡或者U盘里的垃圾文件非常有用
有一种场景, 手机内存卡空间被用光了,但又不知道哪个文件占用了太大,一个个文件夹去找又太麻烦,所以我开发了个小程序把手机所有文件(包括路径下所有层次子文件夹下的文件)进行一个排序,这样你就可以找出哪个 ...
- jQuery实践-网页版2048小游戏
▓▓▓▓▓▓ 大致介绍 看了一个实现网页版2048小游戏的视频,觉得能做出自己以前喜欢玩的小游戏很有意思便自己动手试了试,真正的验证了这句话-不要以为你以为的就是你以为的,看视频时觉得看懂了,会写了, ...
- 微信小程序开发心得
微信小程序也已出来有一段时间了,最近写了几款微信小程序项目,今天来说说感受. 首先开发一款微信小程序,最主要的就是针对于公司来运营的,因为,在申请appid(微信小程序ID号)时候,需要填写相关的公司 ...
- 前端网络、JavaScript优化以及开发小技巧
一.网络优化 YSlow有23条规则,中文可以参考这里.这几十条规则最主要是在做消除或减少不必要的网络延迟,将需要传输的数据压缩至最少. 1)合并压缩CSS.JavaScript.图片,静态资源CDN ...
- 微信应用号(小程序)开发IDE配置(第一篇)
2016年9月22日凌晨,微信宣布“小程序”问世,当然只是开始内测了,微信公众平台对200个服务号发送了小程序内测邀请.那么什么是“小程序”呢,来看微信之父怎么说 看完之后,相信大家大概都有些明白了吧 ...
- Chrome出了个小bug:论如何在Chrome下劫持原生只读对象
Chrome出了个小bug:论如何在Chrome下劫持原生只读对象 概述 众所周知,虽然JavaScript是个很灵活的语言,浏览器里很多原生的方法都可以随意覆盖或者重写,比如alert.但是为了保证 ...
- TODO:小程序开发过程之体验者
TODO:小程序开发过程之体验者 1. 小程序开发过程,先下载开发者并安装开发者工具,现在腾讯开放测试了,普通用户也可以登录开发者工具,如图普通用户登录为调试类型,但是只能建立无AppID的项目 如果 ...
- TODO:即将开发的第一个小程序
TODO:即将开发的第一个小程序 微信小程序是一种全新的连接用户与服务的方式,它可以在微信内被便捷地获取和传播,同时具有出色的使用体验.个人理解小程序是寄宿在微信平台上的一个前端框架,具有跨平台功能, ...
随机推荐
- B. Hierarchy
http://codeforces.com/problemset/problem/17/B 用邻接矩阵建图后, 设cost[v]表示去到顶点v的最小值. 很多个人去顶点v的话,就选最小的那个就OK 然 ...
- css制作三分圆形
效果图展示: 原理很简单,主要运用transform这个样式,通过斜切和旋转达成 html: css: 怎样,是不是很简单
- SVN上传文件过程中出现错误“不知道这样的主机”
在虚拟机中安装完成VisualSVN Server,并且在本地客户端也安装好了TortoiseSVN,在上传文件到服务器的过程中出现错误“不知道这样的主机”,如下图: 地址https://admin- ...
- 绘制surfaceView 基础类
public class SurfaceViewTempalte extends SurfaceView implements Callback, Runnable { private Surface ...
- [windows]设置使用空白密码进行远程登录
前提:系统用户设置了空白密码 方法1步骤: 开始菜单--〉运行--〉输入:gpedit.msc--> 计算机配置--〉Windows设置--〉安全设置--〉本地策略--〉安全选项:帐户:使用空白 ...
- [Rational Rose 2007]解决启动报”解决无法启动此程序因为丢失suite objects.dll“的问题
问题根源1:不是丢失suite objects.dll文件,而是环境变量配置错误或无配置 假如安装目录如:C:\Program Files\Rational 需要配置环境变量的路径为:C:\Progr ...
- apache下设置域名多站点访问及禁止apache访问80端口
apache下设置域名多站点访问 当前系统:macOS High Sierra 域名访问配置指定端口后,不同域名只能配置不同的端口 apache配置目录: sudo vim /etc/apache2/ ...
- SqlServer表和excel数据批量复制方法
SqlServer表和excel数据批量复制方法 一.SqlServer表数据复制到excel方法: 1.新建查询,用sql语句把表数据读出来 2.然后,选择数据,右键“复制”(如果需要表字段名称,则 ...
- ycsb模板介绍
#对应的mongodb uri参数等mongodb.url=mongodb://127.0.0.1:27010/test_1 #对应的mongo数据库名称mongodb.database=test_1 ...
- cgi_and_fastcgi
CGI 来自维基百科 In computing, Common Gateway Interface (CGI) offers a standard protocol for web servers t ...