今天遇到hibernate.find就会进行权限配置,如果某处想要跳过权限配置,则可以如下
1 |
ThreadLocalClient.get().envParamMap.put(DataAuthority.IS_APPLY_AUTHORITY, false ); |
所有ThreadLocalClient都在下面配置
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233 |
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; <span style= "color: rgb(255, 0, 0);" > public
Map<String,Object> envParamMap = new
HashMap<String,Object>();</span> 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; } } |
根据下面判断当前的账户是否要继续
1
2
3
4
5
6
7
8
9 |
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小应用,布布扣,bubuko.com
原文:http://www.cnblogs.com/kyxyes/p/3690030.html