systemUrlGet.jsp
4.15 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
<%--
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="org.apache.http.HttpResponse" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="com.cntytz.HttpUtils" %>
<%@ page import="java.util.Map" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
response.setContentType("application/json;charset=utf-8");
out.clear();
writeLog("【sysytem=========================22222222222222】:");
writeLog("【sysytem=========================22222222222222】:");
writeLog("【sysytem=========================22222222222222】:");
JSONObject result = new JSONObject(true);
String sysytem = request.getParameter("sysytem");
String userName = request.getParameter("userName");
String password = request.getParameter("password");
JSONObject json = new JSONObject();
writeLog("sysytem========================="+sysytem);
writeLog("userName========================="+userName);
writeLog("password========================="+password);
try {
Map<String, String> headers = new HashMap<>();
Map<String, String> querys = new HashMap<String, String>();
Map<String, String> bodys = new HashMap<String, String>();
String host = "";
String path = "";
String redirectUrl = "";
String errorUrl ="";
//jira
if ("jira".equals(sysytem)){
bodys.put("os_username",userName);
bodys.put("os_password",password);
bodys.put("os_destination","");
bodys.put("user_role","");
bodys.put("atl_token","");
bodys.put("login","登录");
host = "https://jira.cntytz.com";
path = "/login.jsp";
redirectUrl = host+path+"?"+"os_username="+userName+"&os_password="+password+"&os_destination=&user_role=&atl_token=&login=登录";
errorUrl ="https://os.cntytz.com/spa/integration/static4engine/engine.html#/main/integration/accountSetting/confluence";
}
writeLog("confluence=========================");
//confluence
if ("confluence".equals(sysytem)){
bodys.put("os_username",userName);
bodys.put("os_password",password);
bodys.put("login","登录");
bodys.put("os_destination","");
bodys.put("permissionViolation","true");
host = "https://confluence.cntytz.com";
// host = "https://192.168.150.212:8090";
path = "/dologin.action";
redirectUrl = host+path+"?"+"os_username="+userName+"&os_password="+password+"&&login=登录&permissionViolation=true&os_destination=";
errorUrl ="https://os.cntytz.com/spa/integration/static4engine/engine.html#/main/integration/accountSetting/confluence";
}
writeLog("https========================="+redirectUrl);
writeLog("host========================="+host);
writeLog("path========================="+path);
writeLog("querys========================="+JSONObject.toJSONString(bodys));
HttpResponse res = HttpUtils.doPost(host, path, "POST", headers, querys, bodys);
writeLog("res========================="+res);
org.apache.http.HeaderElement element = res.getHeaders("X-Seraph-LoginReason")[0].getElements()[0];
writeLog("element========================="+element);
if ("OK".equals(element)){
response.sendRedirect(redirectUrl);
}else{
response.sendRedirect(errorUrl);
}
} catch (Exception e) {
result.put("code", -1);
result.put("message", "接口处理异常"+e.getMessage());
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);
}
}
%>