You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

844 lines
35 KiB
Plaintext

2 years ago
<%--
Created by IntelliJ IDEA.
User: xvshanshan
Date: 2023/7/3
Time: 9:23
To change this template use File | Settings | File Templates.
--%>
<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="weaver.general.BaseBean" %>
<%@ page import="weaver.general.Util" %>
<%@ page import="com.alibaba.fastjson.JSONObject" %>
<%@ page import="com.alibaba.fastjson.JSONArray" %>
<%@ page import="java.util.regex.Pattern" %>
<%@ page import="java.util.regex.Matcher" %>
<%@ page import="java.io.*" %>
<%@ page import="weaver.hrm.User" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.*" %>
2 years ago
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
2 years ago
<%@ page import="org.apache.http.impl.client.CloseableHttpClient" %>
<%@ page import="org.apache.http.impl.client.HttpClients" %>
<%@ page import="org.apache.http.client.methods.HttpPost" %>
<%@ page import="com.alibaba.fastjson.JSON" %>
<%@ page import="org.apache.http.entity.StringEntity" %>
<%@ page import="org.apache.http.client.methods.CloseableHttpResponse" %>
<%@ page import="org.apache.http.HttpStatus" %>
<%@ page import="org.apache.http.HttpEntity" %>
<%@ page import="org.apache.http.util.EntityUtils" %>
<%@ page import="org.apache.http.client.ClientProtocolException" %>
<%@ page import="weaver.hrm.HrmUserVarify" %>
<%@ page import="java.net.URL" %>
<%@ page import="java.net.HttpURLConnection" %>
<%@ page import="org.apache.http.HttpException" %>
<%@ page import="org.apache.http.client.HttpClient" %>
<%@ page import="org.apache.commons.httpclient.methods.PostMethod" %>
<%@ page import="org.apache.commons.httpclient.params.HttpMethodParams" %>
<%@ page import="org.apache.http.NameValuePair" %>
<%@ page import="org.apache.http.message.BasicNameValuePair" %>
<%@ page import="org.apache.http.client.entity.UrlEncodedFormEntity" %>
<%@ page import="weaver.rsa.security.RSA" %>
<%@ page import="java.security.interfaces.RSAPublicKey" %>
<%@ page import="java.security.KeyFactory" %>
<%@ page import="java.security.spec.X509EncodedKeySpec" %>
<%@ page import="javax.crypto.Cipher" %>
<%@ page import="org.apache.commons.codec.binary.Base64" %>
<%@ page import="java.nio.charset.StandardCharsets" %>
<%@ page import="org.apache.http.impl.client.HttpClientBuilder" %>
<%@ page import="org.apache.http.client.methods.HttpGet" %>
<%@ page import="com.engine.common.util.ParamUtil" %>
<%@ page import="com.wbi.util.StringUtil" %>
2 years ago
<%@ page import="org.json.JSONException" %>
<%@ page import="java.time.format.DateTimeFormatter" %>
<%@ page import="java.time.LocalDateTime" %>
<%@ page import="java.time.temporal.ChronoUnit" %>
<%@ page import="okhttp3.*" %>
<%@ page import="javax.servlet.http.Cookie" %>
2 years ago
<%!
//获取分页sql
public static String getPaginationSql(String sql, String orderby, int pageNo, int pageSize) {
String execSql = "";
RecordSet rs = new RecordSet();
String dbType = rs.getDBType();
// String dbType = "oracle";
// String dbType = "sqlserver";
int firstResult = 0;
int endResult = 0;
// 返回分页sql
2 years ago
if ("oracle".equals(dbType)) { // rownum
2 years ago
firstResult = pageNo * pageSize + 1;
endResult = (pageNo - 1) * pageSize;
execSql = " select * from ( select tabUN2.*,rownum as my_rownum from ( select tableUN.*,rownum as r from ( " + sql
+ orderby + ") tableUN " + ") tabUN2 where r < " + firstResult + " ) where my_rownum > " + endResult;
2 years ago
} else if ("sqlserver".equals(dbType)) {
sql = "select *,row_number()OVER(" + orderby + ") as rn from (" + sql + ") newt";
2 years ago
execSql = "select * from ( " +
2 years ago
sql + ")fy " +
" where rn between (" + pageNo + "-1)*" + pageSize + "+1 and " + pageNo + "*" + pageSize + " ";
} else { // 使用 ROW_NUMBER OVER()分页
2 years ago
firstResult = pageNo * pageSize + 1;
endResult = (pageNo - 1) * pageSize;
execSql = " select * from ( select tabUN2.*,rownum as my_rownum from ( select tableUN.*,rownum as r from ( " + sql
2 years ago
+ orderby + ") tableUN ) tabUN2 where r < " + firstResult + " ) where my_rownum > " + endResult;
2 years ago
}
2 years ago
rs.writeLog("execSql---->" + execSql);
2 years ago
return execSql;
}
private boolean isEmpty(String str) {
2 years ago
if ("".equals(str) || "(null)".equals(str) || str == null) {
2 years ago
return true;
} else {
return false;
}
}
/**
* 获取指定类型的src值的集合
* @param htmlStr
* @param type 标签名称
* @return
* 简历
*/
public static Set<String> getSrcStr(String htmlStr, String type) {
Set<String> srcs = new HashSet<String>();
String src = "";
Pattern p_src;
Matcher m_src;
// String regEx_img = "<img.*src=(.*?)[^>]*?>"; //图片链接地址
2 years ago
String regEx_src = "<" + type + ".*src\\s*=\\s*(.*?)[^>]*?>";
2 years ago
p_src = Pattern.compile
(regEx_src, Pattern.CASE_INSENSITIVE);
m_src = p_src.matcher(htmlStr);
while (m_src.find()) {
// 得到<img />数据
src = m_src.group();
// 匹配<img>中的src数据
Matcher m = Pattern.compile("src\\s*=\\s*\"?(.*?)(\"|>|\\s+)").matcher(src);
while (m.find()) {
srcs.add(m.group(1));
}
}
return srcs;
}
2 years ago
public User getUser(int uid) {
2 years ago
User user = new User();
RecordSet rs = new RecordSet();
if (uid == 1)
rs.executeQuery("select * from hrmresourcemanager where id=?", uid);
else {
rs.executeQuery("select * from hrmresource where id=?", uid);
}
String userid = "";
if (rs.next()) {
userid = rs.getString("id");
user.setUid(rs.getInt("id"));
user.setLogintype("1");
user.setLoginid(rs.getString("loginid"));
user.setFirstname(rs.getString("firstname"));
user.setLastname(rs.getString("lastname"));
user.setAliasname(rs.getString("aliasname"));
user.setTitle(rs.getString("title"));
user.setTitlelocation(rs.getString("titlelocation"));
user.setSex(rs.getString("sex"));
String langid = rs.getString("systemlanguage");
user.setLanguage(Util.getIntValue(langid, 0));
user.setTelephone(rs.getString("telephone"));
user.setMobile(rs.getString("mobile"));
user.setMobilecall(rs.getString("mobilecall"));
user.setEmail(rs.getString("email"));
user.setCountryid(rs.getString("countryid"));
user.setLocationid(rs.getString("locationid"));
user.setResourcetype(rs.getString("resourcetype"));
user.setStartdate(rs.getString("startdate"));
user.setEnddate(rs.getString("enddate"));
user.setContractdate(rs.getString("contractdate"));
user.setJobtitle(rs.getString("jobtitle"));
user.setJobgroup(rs.getString("jobgroup"));
user.setJobactivity(rs.getString("jobactivity"));
user.setJoblevel(rs.getString("joblevel"));
user.setSeclevel(rs.getString("seclevel"));
2 years ago
user.setUserDepartment(Util.getIntValue(rs.getString("departmentid"), 0));
user.setUserSubCompany1(Util.getIntValue(rs.getString("subcompanyid1"), 0));
user.setUserSubCompany2(Util.getIntValue(rs.getString("subcompanyid2"), 0));
user.setUserSubCompany3(Util.getIntValue(rs.getString("subcompanyid3"), 0));
user.setUserSubCompany4(Util.getIntValue(rs.getString("subcompanyid4"), 0));
2 years ago
user.setManagerid(rs.getString("managerid"));
user.setAssistantid(rs.getString("assistantid"));
user.setPurchaselimit(rs.getString("purchaselimit"));
user.setCurrencyid(rs.getString("currencyid"));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String lastLoginDate = sdf.format(new Date());
user.setLastlogindate(lastLoginDate);
user.setLogintype("1");
user.setAccount(rs.getString("account"));
}
return user;
}
2 years ago
public String httpPostRequest(String param, String url, String token) {
2 years ago
BaseBean baseBean = new BaseBean();
JSONObject jsonObject = new JSONObject();
2 years ago
String responseBody = "";
2 years ago
try {
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(url);
JSONObject jsonString = JSON.parseObject(param);
//设置请求体参数
2 years ago
StringEntity entity = new StringEntity(param, "utf-8");
baseBean.writeLog("entity-param->" + param);
baseBean.writeLog("entity-->" + entity);
2 years ago
entity.setContentEncoding("utf-8");
2 years ago
baseBean.writeLog("entity-utf-8->" + entity);
2 years ago
httpPost.setEntity(entity);
//设置请求头部
httpPost.setHeader("Content-Type", "application/json");
2 years ago
if (token != null && !"".equals(token)) {
httpPost.setHeader("Authorization", token);
2 years ago
}
//执行请求,返回请求响应
CloseableHttpResponse response = httpClient.execute(httpPost);
//请求返回状态码
int statusCode = response.getStatusLine().getStatusCode();
2 years ago
baseBean.writeLog("statusCode状态码->" + statusCode);
2 years ago
//请求成功
if (statusCode == HttpStatus.SC_OK && statusCode <= HttpStatus.SC_TEMPORARY_REDIRECT) {
//取出响应体
HttpEntity entity2 = response.getEntity();
//从响应体中解析出token
responseBody = EntityUtils.toString(entity2, "utf-8");
// jsonObject = JSONObject.parseObject(responseBody);
2 years ago
baseBean.writeLog("responseBody->" + responseBody);
2 years ago
// baseBean.writeLog("jsonObject->"+jsonObject);
//token = jsonObject.getString("access_token");
} else {
//请求失败
throw new ClientProtocolException("请求失败,响应码为:" + statusCode);
}
} catch (Exception e) {
e.printStackTrace();
}
return responseBody;
}
/**
* 发送http get请求
*/
2 years ago
public static String httpGet(String url, Map<String, String> headers, String encode) {
2 years ago
BaseBean bb = new BaseBean();
2 years ago
if (encode == null) {
2 years ago
encode = "utf-8";
}
CloseableHttpResponse httpResponse = null;
CloseableHttpClient closeableHttpClient = null;
String content = null;
//since 4.3 不再使用 DefaultHttpClient
try {
closeableHttpClient = HttpClientBuilder.create().build();
HttpGet httpGet = new HttpGet(url);
//设置header
if (headers != null && headers.size() > 0) {
for (Map.Entry<String, String> entry : headers.entrySet()) {
2 years ago
httpGet.setHeader(entry.getKey(), entry.getValue());
2 years ago
}
}
2 years ago
bb.writeLog("url=" + url + "header=" + headers + "encode=" + encode);
2 years ago
httpResponse = closeableHttpClient.execute(httpGet);
HttpEntity entity = httpResponse.getEntity();
content = EntityUtils.toString(entity, encode);
} catch (Exception e) {
e.printStackTrace();
2 years ago
} finally {
2 years ago
try {
httpResponse.close();
} catch (IOException e) {
e.printStackTrace();
}
}
try { //关闭连接、释放资源
closeableHttpClient.close();
} catch (IOException e) {
e.printStackTrace();
}
return content;
}
/**
* 向指定 URL 发送POST方法的请求
*
* @param url 发送请求的 URL
* @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
* @return 所代表远程资源的响应结果
*/
public static String sendPost(String url, String param) {
BaseBean bb = new BaseBean();
String result = "";
PrintWriter out = null;
BufferedReader in = null;
HttpURLConnection connection = null;
try {
URL postUrl = new URL(url);
2 years ago
bb.writeLog("getUrl-->" + postUrl);
2 years ago
// 打开和URL之间的连接
connection = (HttpURLConnection) postUrl.openConnection();
// 在connect之前设置通用的请求属性
connection.setRequestProperty("accept", "*/*");
connection.setRequestProperty("connection", "Keep-Alive");
connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
connection.setRequestProperty("Charsert", "UTF-8");
connection.setConnectTimeout(15000);
connection.setReadTimeout(60000);
// 发送POST请求必须设置如下两行参数要放在http正文内
connection.setDoOutput(true);
connection.setDoInput(true);
// 默认是 GET方式
connection.setRequestMethod("POST");
// Post 请求不使用缓存
connection.setUseCaches(false);
// 配置本次连接的Content-typeform表单是"application/x-www-form-urlencoded"json是"application/json"等
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.connect();
// 参数要放在http正文内
//1.获取URLConnection对象对应的输出流
out = new PrintWriter(connection.getOutputStream());
//2.中文有乱码的需要将PrintWriter改为如下
//out=new OutputStreamWriter(conn.getOutputStream(),"UTF-8")
out.print(param);
out.flush();
//也可以使用DataOutputStream
// DataOutputStream dos=new DataOutputStream(httpConn.getOutputStream());
// dos.writeBytes(param);
// dos.flush();
// dos.close();
// 定义BufferedReader输入流来读取URL的响应
if (connection.getResponseCode() == 200) {
in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
}
} catch (Exception e) {
bb.writeLog("发送 POST 请求出现异常!" + e);
e.printStackTrace();
} finally {
try {
if (out != null) {
out.close();
}
if (in != null) {
in.close();
}
if (connection != null) {
//关闭连接
connection.disconnect();
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
return result;
}
/**
* 发送 http post 请求参数以form表单键值对的形式提交。
*/
2 years ago
public static String httpPostForm(String url, Map<String, String> params, Map<String, String> headers, String encode) {
2 years ago
BaseBean bb = new BaseBean();
2 years ago
if (encode == null) {
2 years ago
encode = "utf-8";
}
String content = null;
2 years ago
CloseableHttpResponse httpResponse = null;
2 years ago
CloseableHttpClient closeableHttpClient = null;
try {
closeableHttpClient = HttpClients.createDefault();
HttpPost httpost = new HttpPost(url);
//设置header
if (headers != null && headers.size() > 0) {
for (Map.Entry<String, String> entry : headers.entrySet()) {
2 years ago
httpost.setHeader(entry.getKey(), entry.getValue());
2 years ago
}
}
2 years ago
bb.writeLog("url=" + url + "header=" + headers + "encode=" + encode);
bb.writeLog("params=" + params);
2 years ago
//组织请求参数
2 years ago
List<NameValuePair> paramList = new ArrayList<NameValuePair>();
if (params != null && params.size() > 0) {
2 years ago
Set<String> keySet = params.keySet();
2 years ago
for (String key : keySet) {
2 years ago
paramList.add(new BasicNameValuePair(key, params.get(key)));
}
}
httpost.setEntity(new UrlEncodedFormEntity(paramList, encode));
httpResponse = closeableHttpClient.execute(httpost);
HttpEntity entity = httpResponse.getEntity();
content = EntityUtils.toString(entity, encode);
} catch (Exception e) {
e.printStackTrace();
2 years ago
} finally {
2 years ago
try {
httpResponse.close();
} catch (IOException e) {
e.printStackTrace();
}
}
try { //关闭连接、释放资源
closeableHttpClient.close();
} catch (IOException e) {
e.printStackTrace();
}
return content;
}
/**
* 公钥加密
*
* @param content 内容
* @param publicKey 公钥
* @return 加密后的密文
* @throws Exception 异常信息
*/
public static String encrypt(String content, String publicKey) throws Exception {
//base64编码的公钥
byte[] decoded = org.apache.commons.codec.binary.Base64.decodeBase64(publicKey);
RSAPublicKey pubKey = (RSAPublicKey) KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(decoded));
//RSA加密
Cipher cipher = Cipher.getInstance("RSA");
cipher.init(Cipher.ENCRYPT_MODE, pubKey);
return Base64.encodeBase64String(cipher.doFinal(content.getBytes(StandardCharsets.UTF_8)));
}
2 years ago
public static String getPublicKey(Map<String, String> MachInfo) {
2 years ago
BaseBean bb = new BaseBean();
2 years ago
String publicKey = "";
String API_KEY = Util.null2String(bb.getPropValue("tjbankEMobileSSO", "key"));
2 years ago
//请求获取publicKey接口
2 years ago
Map<String, String> headers = new HashMap<>();
String url = Util.null2String(bb.getPropValue("tjbankEMobileSSO", "publicKeyUrl"));
headers.put("API_KEY", API_KEY);
// headers.put("MACH_ID","123");
// headers.put("MACH_TYPE","0");
// headers.put("MACH_IP","127.0.0.1");
headers.put("MACH_ID", MachInfo.get("deviceId"));
headers.put("MACH_TYPE", MachInfo.get("clientType"));
headers.put("MACH_IP", MachInfo.get("param_ip"));
String msg = httpGet(url, headers, null);
bb.writeLog("===获取publickey返回值====" + msg);
2 years ago
try {
org.json.JSONObject resMsg = new org.json.JSONObject(msg);
2 years ago
bb.writeLog("===获取publickey返回值====" + resMsg);
if (resMsg.has("pubKey")) {
2 years ago
publicKey = Util.null2String(resMsg.get("pubKey").toString());
}
2 years ago
} catch (Exception e) {
2 years ago
e.getMessage();
}
return publicKey;
}
//获取TG
2 years ago
public static String getST(String tgt, String emobileUrl, Map<String, String> MachInfo) {
2 years ago
BaseBean bb = new BaseBean();
String ST = "";
String retMsg = "";
2 years ago
Map<String, String> params = new HashMap<>();//参数
Map<String, String> headers = new HashMap<>();//headers
String API_KEY = Util.null2String(bb.getPropValue("tjbankEMobileSSO", "key"));
2 years ago
//请求获取TG接口
2 years ago
String url = Util.null2String(bb.getPropValue("tjbankEMobileSSO", "stUrl"));
bb.writeLog("==获取TG==" + url);
2 years ago
//移动端首页地址
2 years ago
bb.writeLog("==移动端首页地址==" + emobileUrl);
2 years ago
//获取TGT
params = new HashMap<>();//参数
2 years ago
params.put("tgt", tgt);
params.put("service", emobileUrl);
bb.writeLog("==STparams==" + params);
2 years ago
headers = new HashMap<>();//headers
2 years ago
headers.put("API_KEY", API_KEY);
// headers.put("MACH_ID","123");
// headers.put("MACH_TYPE","0");
// headers.put("MACH_IP","127.0.0.1");
headers.put("MACH_ID", MachInfo.get("deviceId"));
headers.put("MACH_TYPE", MachInfo.get("clientType"));
headers.put("MACH_IP", MachInfo.get("param_ip"));
2 years ago
try {
2 years ago
retMsg = httpPostForm(url, params, headers, null);
bb.writeLog("===获取ST返回值====" + retMsg);
2 years ago
org.json.JSONObject resMsg = new org.json.JSONObject(retMsg);
2 years ago
bb.writeLog("===获取ST返回值resMsg====" + resMsg);
if (resMsg.has("ST")) {
2 years ago
ST = Util.null2String(resMsg.get("ST").toString());
}
2 years ago
bb.writeLog("===获取ST====" + ST);
} catch (Exception e) {
2 years ago
throw new RuntimeException(e);
}
return retMsg;
}
2 years ago
public static String getSysUrl(String sysid) {
2 years ago
RecordSet rs = new RecordSet();
String url = "-1";
//查询建模
2 years ago
rs.executeQuery("select * from uf_otherSysInfo where id = ?", sysid);
if (rs.next()) {
2 years ago
url = Util.null2String(rs.getString("xtdz"));
2 years ago
} else {
2 years ago
return "-1";
}
url = url.trim();
2 years ago
if (!StringUtil.isBlank(url)) {
2 years ago
//判断是否带?号
2 years ago
if (url.indexOf("?") == -1) {
url = url + "?";
} else {
url = url + "&";
2 years ago
}
2 years ago
}
;
2 years ago
return url;
}
2 years ago
public static String getsysSSOurl(String sysid) {
RecordSet rs = new RecordSet();
String url = "-1";
//查询建模
rs.executeQuery("select * from uf_otherSysInfo where id = ?", sysid);
if (rs.next()) {
url = Util.null2String(rs.getString("hqdddz"));
} else {
return "-1";
}
new BaseBean().writeLog("hqdddz====" + url);
url = url.trim();
// if (!StringUtil.isBlank(url)){
// //判断是否带?号
// if (url.indexOf("?") == -1){
// url = url+"?";
// }else{
// url = url+"&";
// }
// };
return url;
}
public static boolean isDifferenceGreaterThan(String timeStr2, int hours) {
// 定义日期时间格式
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
// 解析字符串为LocalDateTime对象
// LocalDateTime time1 = LocalDateTime.parse(timeStr1, formatter);
LocalDateTime now = LocalDateTime.now();
LocalDateTime time2 = LocalDateTime.parse(timeStr2, formatter);
// 计算两个时间的差值(以小时为单位)
// long hoursDifference = ChronoUnit.HOURS.between(time1, time2);
long hoursDifference = ChronoUnit.SECONDS.between(now, time2);
System.out.println(hoursDifference);
// 检查差值是否大于给定的小时数
return Math.abs(hoursDifference) > (long) hours * 60 * 60;
}
public String getEMToken() {
try {
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("http://10.200.1.69:9001/emp/api/gettoken?corpid=t963B4AC53420B211F7B01CC29004FB03&corpsecret=0a99c695-bf19-4989-af15-1aa284f98a92")
.get()
.build();
Response response = client.newCall(request).execute();
String responseStr = response.body().string();
JSONObject responseJson = JSONObject.parseObject(responseStr);
if ("0".equals(responseJson.get("errcode")+"")){
return responseJson.getString("access_token");
}else {
return responseJson.getString("errmsg");
}
} catch (Exception e) {
return e.getMessage();
}
}
public String EMExt(String access_token,String jsonStr) {
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType,jsonStr);
Request request = new Request.Builder()
.url("http://10.200.1.69:9001/emp/api/integrate/func/offline?access_token="+access_token)
.post(body)
.addHeader("content-type", "application/json")
.build();
try {
Response response = client.newCall(request).execute();
String responseStr = response.body().string();
JSONObject responseJson = JSONObject.parseObject(responseStr);
if ("0".equals(responseJson.get("errcode"))){
return responseJson.getString("errmsg");
}else {
return responseJson.getString("errmsg");
}
} catch (Exception e) {
e.printStackTrace();
return e.getMessage();
}
}
2 years ago
%>
<%
2 years ago
2 years ago
RecordSet rs = new RecordSet();
2 years ago
BaseBean bb = new BaseBean();
2 years ago
RSA rsa = new RSA();
2 years ago
Map<String, String> params = new HashMap<>();//参数
Map<String, String> headers = new HashMap<>();//headers
2 years ago
JSONArray array = new JSONArray();
List<String> decriptList = new ArrayList<>();
2 years ago
String ST = "";//获取ST
bb.writeLog("进入跳转异构系统jsp-->");
try {
new BaseBean().writeLog("header====>" + JSONObject.toJSONString(request));
new BaseBean().writeLog("header====>" + request.getHeader("User-Agent"));
} catch (Exception e) {
new BaseBean().writeLog("error===>" + e.getMessage());
}
2 years ago
Map<String, Object> paramsMap = ParamUtil.request2Map(request);
2 years ago
new BaseBean().writeLog("paramsMap===>" + JSONObject.toJSONString(paramsMap));
String deviceId = Util.null2String(paramsMap.get("deviceId"));
String clientType = Util.null2String(paramsMap.get("clientType"));
if ("2".equals(clientType)) {
clientType = "0";
} else if ("3".equals(clientType)) {
clientType = "1";
}
String param_ip = Util.null2String(paramsMap.get("param_ip"));
new BaseBean().writeLog("paramsMap===>" + paramsMap);
new BaseBean().writeLog("deviceId===>" + deviceId);
new BaseBean().writeLog("clientType===>" + clientType);
HashMap<String, String> MachInfo = new HashMap<>();
MachInfo.put("deviceId", deviceId.isEmpty() ? "123" : deviceId);
MachInfo.put("clientType", clientType.isEmpty() ? "1" : clientType);
MachInfo.put("param_ip", param_ip.isEmpty() ? "127.0.0.1" : param_ip);
2 years ago
String sysid = (String) paramsMap.get("sysid");
2 years ago
if (StringUtil.isBlank(sysid)) {
2 years ago
out.print("sysid为空");
return;
}
String sysUrl = getSysUrl(sysid);
2 years ago
if ("-1".equals(sysUrl)) {
2 years ago
out.print("系统url为空");
return;
}
String login_id = "";
String user_password = "";
User user = HrmUserVarify.getUser(request, response);
int uid = user.getUID();
2 years ago
bb.writeLog("uid-->" + uid);
2 years ago
rs.executeQuery("select id,loginid,password,createtime from EmobileLoginDetail where id=?", uid);
2 years ago
if (rs.next()) {
2 years ago
login_id = Util.null2String(rs.getString("loginid"));
user_password = Util.null2String(rs.getString("password"));
}
2 years ago
bb.writeLog("login_id-->" + login_id);
bb.writeLog("user_password-->" + user_password);
2 years ago
//获取session
session = request.getSession(true);
String certified_token = Util.null2String(session.getAttribute("certified_token"));
2 years ago
String certified_token_expires = Util.null2String(session.getAttribute("certified_token_expires"));
bb.writeLog("获取sessionTGT==" + certified_token);
2 years ago
//获取cookie
Cookie[] cookies = request.getCookies();
2 years ago
bb.writeLog("获取cookies==" + cookies);
2 years ago
String idd = "";
2 years ago
if (cookies != null) {
for (Cookie cookie : cookies) {
bb.writeLog("获取cookiesName==" + cookie.getName());
if (cookie.getName().equals("loginidweaver")) {
2 years ago
idd = cookie.getValue();
2 years ago
bb.writeLog("获取idd==" + idd);
2 years ago
}
}
}
//查询人员工号
RecordSet recordSet = new RecordSet();
String requestURI = request.getRequestURI();
2 years ago
bb.writeLog("请求路径=" + requestURI);
2 years ago
Map<String, Object> useridMap = ParamUtil.request2Map(request);
2 years ago
bb.writeLog("人员id=" + useridMap.get("userid"));
2 years ago
recordSet.executeQuery("select WORKCODE from HRMRESOURCE where id=?", Util.null2String(useridMap.get("userid")));
String workcode = "";
2 years ago
if (recordSet.next()) {
2 years ago
workcode = Util.null2String(recordSet.getString("WORKCODE"));
}
2 years ago
bb.writeLog("人员workcode=" + useridMap.get("workcode"));
2 years ago
//查询
2 years ago
String API_KEY = Util.null2String(bb.getPropValue("tjbankEMobileSSO", "key"));//publicKey
String url = Util.null2String(bb.getPropValue("tjbankEMobileSSO", "stUrl"));//获取ST的url
// String cockpitUrl = Util.null2String(bb.getPropValue("tjbankEMobileSSO","cockpitUrl"));
String cockpitUrl = getsysSSOurl(sysid);
String tgturl = Util.null2String(bb.getPropValue("tjbankEMobileSSO", "tgtUrl"));//请求获取TGT地址
2 years ago
//获取ST带着下游系统
2 years ago
if (!isEmpty(certified_token) && !isDifferenceGreaterThan(certified_token_expires, 4)) {
bb.writeLog("TGT未失效");
String responseInfo = getST(certified_token, cockpitUrl, MachInfo);
bb.writeLog("进入responseInfo-->" + responseInfo);
if (isEmpty(responseInfo)) {
2 years ago
out.print("单点系统接口返回值为null");
return;
2 years ago
} else {
2 years ago
org.json.JSONObject stMsg = new org.json.JSONObject(responseInfo);
2 years ago
if (stMsg.has("ST")) {
2 years ago
ST = Util.null2String(stMsg.get("ST").toString());
2 years ago
} else {
2 years ago
out.print(Util.null2String(stMsg.getString("message")));
return;
}
String loginUrl = "";
// String remuseUrl = bb.getPropValue("tjbkremuse", "hbUrl");
String remuseUrl = sysUrl;
boolean isEm = Util.null2String(request.getHeader("user-agent")).indexOf("E-Mobile") > -1;
2 years ago
if (isEm == true) {
loginUrl = remuseUrl + "ticket=" + ST;
2 years ago
}
//loginUrl = "https://www.baidu.com/";
2 years ago
bb.writeLog("loginUrl-->" + loginUrl);
out.print("跳转路径-->" + loginUrl);
//out.print(loginUrl);
2 years ago
response.sendRedirect(loginUrl);
// request.getRequestDispatcher("loginUrl").forward(request,response);
// return;
}
2 years ago
} else {
bb.writeLog("TGT已失效");
String TGT = "";
String passWord = "";
String retMsg = "";
2 years ago
decriptList.add(login_id);
decriptList.add(user_password);
List<String> resultList = rsa.decryptList(request, decriptList);
String loginId = resultList.get(0);
String userPassword = resultList.get(1);
2 years ago
String publicKey = getPublicKey(MachInfo);
2 years ago
passWord = encrypt(user_password, publicKey);
params = new HashMap<>();//参数
2 years ago
params.put("username", loginId);
params.put("password", passWord);
bb.writeLog("==STparams==" + params);
2 years ago
headers = new HashMap<>();//headers
2 years ago
headers.put("API_KEY", API_KEY);
headers.put("MACH_ID", MachInfo.get("deviceId"));
headers.put("MACH_TYPE", MachInfo.get("clientType"));
headers.put("MACH_IP", MachInfo.get("param_ip"));
2 years ago
2 years ago
retMsg = httpPostForm(tgturl, params, headers, null);
bb.writeLog("===获取TGT返回值retMsg====" + retMsg);
2 years ago
org.json.JSONObject resMsg = new org.json.JSONObject(retMsg);
2 years ago
bb.writeLog("===获取TGT返回值====" + resMsg);
if (resMsg.has("TGT")) {
2 years ago
TGT = Util.null2String(resMsg.get("TGT").toString());
2 years ago
}else{
//密码不正确,执行强制退出
if ("2002".equals(resMsg.get("errorCode")+"")){
out.print("<h3 style='font-size: 20px;'>您的单点系统密码已修改,请重新登录,将在3秒后退出</h3>");
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
JSONObject postBody = new JSONObject();
postBody.put("sysid","84df78883322432f90eb599899365c7b");
postBody.put("userids",user.getUID());
postBody.put("offline_type","1");
postBody.put("client_type","1,2,3");
String errmsg = EMExt(getEMToken(), postBody.toJSONString());
}
});
thread.start();
return;
}else{
out.print(resMsg.get("message"));
return;
}
2 years ago
}
2 years ago
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date now = new Date();
Date expiresDate = new Date(now.getTime() + (4 * 60 * 60 * 1000));
request.getSession(true).setAttribute("certified_token_expires", sdf.format(expiresDate));//记录toekn失效日期时间
request.getSession(true).setAttribute("certified_token", TGT);//记录toekn
String responseInfo = getST(TGT, cockpitUrl, MachInfo);
if (isEmpty(responseInfo)) {
2 years ago
out.print("单点系统接口返回值为null");
return;
2 years ago
} else {
2 years ago
org.json.JSONObject stMsg = new org.json.JSONObject(responseInfo);
2 years ago
if (stMsg.has("ST")) {
2 years ago
ST = Util.null2String(stMsg.get("ST").toString());
2 years ago
} else {
bb.writeLog(stMsg);
2 years ago
out.print(Util.null2String(stMsg.getString("message")));
return;
}
String loginUrl = "";
// String remuseUrl = bb.getPropValue("tjbkremuse", "hbUrl");
String remuseUrl = sysUrl;
boolean isEm = Util.null2String(request.getHeader("user-agent")).indexOf("E-Mobile") > -1;
2 years ago
if (isEm == true) {
loginUrl = remuseUrl + "ticket=" + ST;
2 years ago
}
2 years ago
bb.writeLog("loginUrl-->" + loginUrl);
//out.print(loginUrl);
2 years ago
response.sendRedirect(loginUrl);
2 years ago
}
2 years ago
}
%>
 <script type="text/javascript">
<%--<%=httpPostRequest%>;--%>
// alert("00000");
// next();
//   function next(){
// alert("2222");
// console.log("111111111");
<%--console.log("http://10.16.103.18:9900/coremail/main.jsp?sid="+<%=sid%>);--%>
<%--console.log("sid="+<%=sid%>);--%>
<%--window.location.href= "http://10.16.103.18:9900/coremail/main.jsp?sid="+<%=sid%>;--%>
//   window.location.href= "https://www.baidu.com/";
<%--   }--%>
 </script>