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
package com.cy.report.utils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.cy.report.action.InitListener;
import com.cy.report.pojo.AppInfo;
import com.cy.report.pojo.User;
import com.cy.report.service.ServiceFactory;
public class AuthUtil {
public static boolean isManageReport(String metric) {
if (InitListener.manage_report.contains(metric)) {
return true;
}
return false;
}
/**
* 母账号查看的appkey,如果不是自己创建的,无权限.
*
* @param appkey
* @param user
* @return
*/
public static boolean verificationAuth(String appkey, User user) {
int dev_id = user.getId();
List<AppInfo> appList = ServiceFactory.getAppInfoService().getAppInfoByAppKey(appkey);
for (AppInfo info : appList) {
if (info.getDev_id().equals(String.valueOf(dev_id))) {
return true;
}
}
// AppInfo app = ServiceFactory.getAppInfoService().getAppInfoByAppKey(
// appkey);
// if (app.getDev_id().equals(String.valueOf(dev_id))) {
// return true;
// }
return false;
}
public static boolean verificationAuth(String appkey, int dev_id) {
// AppInfo app = ServiceFactory.getAppInfoService().getAppInfoByAppKey(
// appkey);
// if (app.getDev_id().equals(String.valueOf(dev_id))) {
// return true;
// }
List<AppInfo> appList = ServiceFactory.getAppInfoService().getAppInfoByAppKey(appkey);
for (AppInfo info : appList) {
if (info.getDev_id().equals(String.valueOf(dev_id))) {
return true;
}
}
return false;
}
/**
* 子账户用户权限列表中如果不包含这个游戏key,无权限.
* @param appkey
* @param user
* @return
*/
public static boolean verificationAuthSubAccount(String appkey, User user) {
Map<String, String> map = user.getAuthmap();
if (map == null) {
map = new HashMap<String, String>();
}
boolean auth = true;
if (map.containsKey(appkey)) {
auth = true;
} else {
auth = false;
}
return auth;
}
/**
* 检测该子账户用户是否具有该游戏、改功能的权限.功能包含报表和管理.
*
* @param appkey
* @param reportname
* @param user
* @return
*/
public static boolean verificationAuth(String appkey, String reportname,
User user) {
Map<String, String> map = user.getAuthmap();
if (map == null) {
map = new HashMap<String, String>();
}
boolean auth = true;
if (map.containsKey(appkey)) {
String channel_report = map.get(appkey);
String[] rs = reportname.split(",");
for (String r : rs) {
String check = r +"_r"+ ",";
if (channel_report.indexOf(check) == -1) {
auth = false;
break;
}
}
} else {
auth = false;
}
if(reportname.equals("getAppDownloadUrl") || reportname.equals("logtool")) {
auth = true;
}
return auth;
}
/**
* 检测该子账户用户是否具有该游戏、改渠道、改功能报表的权限.
*
* @param appkey
* @param channelname
* @param reportname
* @param user
* @return
*/
public static boolean verificationAuth(String appkey, String channelname,
String reportname, User user) {
Map<String, String> map = user.getAuthmap();
if (map == null) {
map = new HashMap<String, String>();
}
boolean auth = true;
if (map.containsKey(appkey)) {
String channel_report = map.get(appkey);
if (channel_report.indexOf("reyun_allchannel_-3_c,") == -1) {
if (!channelname.equals("")) {
String[] cns = channelname.split(",");
for (String cn : cns) {
String check = cn + "_c" + ",";
if (channel_report.indexOf(check) == -1) {
auth = false;
break;
}
}
}
}
String[] rs = reportname.split(",");
for (String r : rs) {
String check = r + "_r" + ",";
if (channel_report.indexOf(check) == -1) {
auth = false;
break;
}
}
} else {
auth = false;
}
return auth;
}
/**
* 判断用户是否是母账户.
* @param user
* @return
*/
public static boolean isOriginalUser(User user) {
if (!StringUtil.isEmpty(user.getIsoriginaluser()) && user.getIsoriginaluser().equals("1")) {
return true;
}
return false;
}
/**
* 判断用户是否是管理员账户.
* @param user
* @return
*/
public static boolean isManagerUser(User user) {
if (!StringUtil.isEmpty(user.getIsmanager()) && user.getIsmanager().equals("1")) {
return true;
}
return false;
}
}