caauthwin.jsp
8.33 KB
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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
<%@ page import="com.engine.workflow.util.SecondAuthUtil" %>
<%@ page import="java.util.Map" %>
<%@ page import="com.alibaba.fastjson.JSONObject" %>
<%@ page import="weaver.hrm.User" %>
<%@ page import="weaver.hrm.HrmUserVarify" %>
<%@ page import="weaver.general.Util" %>
<%@ page import="java.util.Date" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>CA认证</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="author" content="Weaver E-Mobile Dev Group"/>
<meta name="description" content="Weaver E-mobile"/>
<meta name="keywords" content="weaver,e-mobile"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, minimum-scale=1.0"/>
<script type='text/javascript' src='/mobile/plugin/1/js/jquery-1.6.2.min_wev8.js'></script>
<link rel="stylesheet" href="/mobile/plugin/css/mobile_wev8.css" type="text/css">
<style type="text/css">
body *{
font-family: Microsoft YaHei;
font-size: 14px;
}
.cert_content {
padding: 10px 20px;
}
div.cert_title {
padding: 10px 0;
text-align: center;
font-size: 18px;
color: #2DB7F5;
}
table.cert_table {
width: 100%;
}
table.cert_table td {
height: 30px;
padding: 5px 0;
}
input[type='password'] {
width: 100%;
height: 30px;
border: 1px solid #dddddd;
}
input::-webkit-input-placeholder {
color: #999999;
}
.labeltd {
color: #999999;
}
.cert_footer {
width: 100%;
height: 34px;
position: fixed;
bottom: 0px;
background-color: #F2F2F2;
border-top: 1px solid #D8D8D8;
text-align: center;
padding: 6px 0;
}
.cert_btn {
vertical-align: top;
background-color: #007AFF;
border: 1px solid #007AFF;
border-radius: 3px;
min-width: 80px;
height: 34px;
text-align: center;
white-space: nowrap;
overflow: hidden;
color: #FFFFFF;
font-size: 16px;
line-height: 34px;
display: inline-block;
margin: 0 20px;
}
.disable {
border: 1px solid #d9d9d9;
background-color: #d9d9d9 !important;
}
.cert_error {
font-size: 18px;
color: #FF0000;
padding: 10px;
}
</style>
</head>
<%
User user = HrmUserVarify.getUser(request, response);
String authKey = Util.null2String(request.getParameter("authKey"));
Map<String, Object> dataMap = SecondAuthUtil.getAuthData(authKey, user);
int success = Util.getIntValue(Util.null2String(dataMap.get("success")), 0);
String message = Util.null2String(dataMap.get("message"));
boolean isShow = false;
if (success == 1) {
Map<String, Object> data = (Map<String, Object>) dataMap.get("data");
String requestName = Util.null2String(data.get("requestName"));
String requestMark = Util.null2String(data.get("requestMark"));
String sourcestr = Util.null2String(data.get("sourcestr"));
isShow = "1".equals(Util.null2String(data.get("isShow"))); //是否需要显示流程标题
%>
<body>
<div class="cert_content">
<div class="cert_title">CA证书验证</div>
<table class="cert_table">
<colgroup>
<col width="80px">
<col width="*">
</colgroup>
<tbody>
<%if (isShow) {%>
<tr>
<td class="labeltd">请求标题</td>
<td>
<%=requestName%>
</td>
</tr>
<tr>
<td class="labeltd">流程编号</td>
<td>
<%=requestMark%>
</td>
</tr>
<%}%>
<tr>
<td class="labeltd">所有者</td>
<td>
<span id="owner"></span>
</td>
</tr>
<tr>
<td class="labeltd">颁发时间</td>
<td>
<span id="startTime"></span>
</td>
</tr>
<tr>
<td class="labeltd">失效时间</td>
<td>
<span id="endTime"></span>
</td>
</tr>
<tr>
<td class="labeltd">加密算法</td>
<td>
<span id="signAlg"></span>
</td>
</tr>
<tr>
<td colspan="2">
<input type="password" placeholder="请输入证书密码" name="certPassword" id="certPassword">
</td>
</tr>
</tbody>
</table>
</div>
<div class="cert_footer">
<button class="cert_btn" onclick="backHome();">取消</button>
<button class="cert_btn" onclick="checkCAAuth();">确定</button>
</div>
<script type="text/javascript">
var _sourcestr = "<%=sourcestr%>";
var _supportCAAuth = false;
//客户端加载完成后会调用此方法
function supportCAAuth() {
_supportCAAuth = true;
//从客户端中获取证书的信息
try {
location = 'emobile:CAMethod:{"func":"getCACertInfo","params":{"callback":"getCAAuthInfo"}}';
} catch (e) {
}
}
//获取证书信息
function getCAAuthInfo(certinfo) {
if (!!certinfo) {
if (typeof certinfo == "string") {
certinfo = JSON.parse(certinfo);
}
var _owner = certinfo.owner; //所有者
var _startTime = certinfo.startTime; //开始时间
var _endTime = certinfo.endTime; //结束时间
var _signAlg = certinfo.signAlg; //加密算法
jQuery("#owner").html(_owner);
jQuery("#startTime").html(_startTime);
jQuery("#endTime").html(_endTime);
jQuery("#signAlg").html(_signAlg);
}
}
//CA认证
function checkCAAuth(btn) {
if (!_supportCAAuth) { //说明不支持CA证书
alert("对不起,您当前的客户端版本不支持CA证书验证");
return;
}
var certPassword = jQuery("#certPassword").val();
if (!certPassword) {
alert("请输入证书密码!");
return;
}
//第一步,调用客户端方法,验证密码,签名数据
location = 'emobile:CAMethod:{"func":"getSignValueWithPass","params":{"original":"' + _sourcestr + '","passWord":"' + certPassword + '","callback":"checkCAResult"}}';
//第二步,得到签名后的数据,然后存入数据库
//回调checkCAResult方法
}
//调用客户端方法CA验证后的回调方法
function checkCAResult(resultObj) {
if (typeof resultObj == "string") {
resultObj = JSON.parse(resultObj);
}
var signValue = resultObj.signValue;
if (!signValue) {
alert("数据签名失败,未获取到签名后的值");
return;
}
disableAllBtns();
var ajaxUrl = "/mobile/plugin/1/caauthajax.jsp?authKey=<%=authKey%>&signValue=" + signValue + "&t=<%=System.currentTimeMillis()%>";
jQuery.ajax({
method: "GET",
data: {},
url: ajaxUrl,
async: true,
dataType: "json",
contentType: "application/x-www-form-urlencoded;charset=UTF-8",
success: function (result) {
var success = result.success;
if (success == 1) {
backHome();
} else {
alert("认证失败!");
enableAllBtns();
}
}
});
}
function backHome() {
disableAllBtns();
location = "/home.do";
}
//所有的按钮置灰
function disableAllBtns() {
jQuery("button.cert_btn").addClass("disable").attr("disabled", "disabled");
}
//按钮置为可用
function enableAllBtns() {
jQuery("button.cert_btn").removeClass("disable").removeAttr("disabled");
}
</script>
<%
} else {
%>
<div class="cert_error">
<%=message%>
</div>
<%
}
%>
</body>
</html>