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:即将开发的第一个小程序 微信小程序是一种全新的连接用户与服务的方式,它可以在微信内被便捷地获取和传播,同时具有出色的使用体验.个人理解小程序是寄宿在微信平台上的一个前端框架,具有跨平台功能, ...
随机推荐
- Java编程基础-字符串
在Java语言中,字符串数据实际上由String类所实现的.Java字符串类分为两类:一类是在程序中不会被改变长度的不变字符串:另一类是在程序中会被改变长度的可变字符串.Java环境为了存储和维护这两 ...
- openssl 安装配置
Openssl是个为网络通信提供安全及数据完整性的一种安全协议,囊括了主要的密码算法.常用的密钥和证书封装管理功能以及SSL协议,并提供了丰富的应用程序供测试或其它目的使用.首先下载Openssl包: ...
- uvm_void 寂静的空宇
空也是一种存在. ——<三体> 文件: $UVM_HOME/src/base/uvm_misc.svh virtual class uvm_void; endclass 在静寂 ...
- JS 字符串 时间 数字函数操作 事件
字符串 操作 var s="abcdefg" s.tolowerCase() 转小写 s.toupperCase() 转大写 s.substring(2,5) 索引下 ...
- NSString+TimeCategory
NSString+TimeCategory.h //------------------------------------------------ #import <foundation fo ...
- 虚拟机ubuntu16.0 安装 mysql 主机配置访问
在bantu服务器中安装如下命令 sudo apt-get install mysql-server sudo apt-get install mysql-client安装成功之后 进入配置文件 ...
- libxml2.dylb 导致<libxml/tree.h> 老是找不到头文件
添加了libxml2.dylb的framework ,结果还是引用不了<libxml/tree.h>, 老是提示找不到头文件. 这个问题其实比较容易解决,但是XCode的版本问题确实让开 ...
- redis分布式共享锁模拟抢单的实现
本篇内容主要讲解的是redis分布式锁,并结合模拟抢单的场景来使用,内容节点如下: jedis的nx生成锁 如何删除锁 模拟抢单动作 1.jedis的nx生成锁 对于分布式锁的生成通常需要注意如下几个 ...
- websphere7.0异常:SRVE0255E: 尚未定义要处理 /wcm 的 Web 组/虚拟主机
websphere7.0错误:SRVE0255E: 尚未定义要处理 /wcm 的 Web 组/虚拟主机. SRVE0255E: 尚未定义要处理 /wcm 的 Web 组/虚拟主机.SRVE0255E: ...
- react native 在window 7上配置开发环境-Andorid
参照官方配置:https://facebook.github.io/react-native/docs/getting-started.html 因为在配置的过程中遇到很多问题,在此记录一下. 1.j ...