tokenGain.jsp
2.56 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
<%--
Created by IntelliJ IDEA.
User: zhaiyaqi
Date: 2020/3/15
Time: 7:34 PM
To change this template use File | Settings | File Templates.
--%>
<%@ page import="com.alibaba.fastjson.JSONObject" %>
<%@ page import="org.apache.commons.logging.Log" %>
<%@ page import="org.apache.commons.logging.LogFactory" %>
<%@ page import="weaver.hrm.HrmUserVarify" %>
<%@ page import="weaver.hrm.User" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.List" %>
<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="com.cntytz.HttpUtils" %>
<%@ page import="org.springframework.web.servlet.ModelAndView" %>
<%@ page import="org.springframework.web.servlet.view.RedirectView" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
response.setContentType("application/json;charset=utf-8");
out.clear();
writeLog("【start token gain interfince ==========】:");
JSONObject result = new JSONObject(true);
User user = HrmUserVarify.getUser(request,response);
String url = request.getParameter("url");
JSONObject json = new JSONObject();
String loginid ="";
writeLog("user=========================" + JSONObject.toJSONString(user));
try {
loginid = user.getLoginid();
String tokenGainurl = "https://ty.cntytz.com/uasSign/sign/authentication";
writeLog("json =============url " + url);
json.put("url",url);
json.put("userLoginName",loginid);
writeLog("json =============url " + JSONObject.toJSONString(json));
JSONObject jsonObject = HttpUtils.doPost(tokenGainurl, json);
writeLog("===================="+jsonObject);
String tokenUrl = jsonObject.get("url").toString();
writeLog("====================tokenUrl="+tokenUrl);
String token = tokenUrl.substring(tokenUrl.indexOf("=")+1,tokenUrl.length());
writeLog("====================token="+token);
writeLog("====================url="+url);
writeLog("====================url+token="+url+token);
response.sendRedirect(url+token);
} catch (Exception e) {
result.put("code", -1);
result.put("message", "接口处理异常"+e.getMessage());
out.print("用户信息不完善,请联系管理员进一步完善,谢谢");
return;
}
out.print(result.toJSONString());
%>
<%!
private void writeLog(Object o) {
Log var3 = LogFactory.getLog(this.getClass().getName());
if(o instanceof Exception) {
var3.info(this.getClass().getName(), (Exception)o);
} else {
var3.info(o);
}
}
%>