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.

132 lines
4.9 KiB
Plaintext

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ page import="weaver.general.Util,weaver.conn.RecordSet" %>
<%@ page import="weaver.hrm.HrmUserVarify" %>
<%@ page import="weaver.hrm.User" %>
<%@ page import="javax.crypto.*" %>
<%@ page import="org.apache.commons.lang3.StringUtils" %>
<%@ page import="javax.crypto.spec.DESKeySpec" %>
<%@ page import="java.security.Key" %>
<%@ page import="javax.crypto.spec.IvParameterSpec" %>
<%@ page import="java.util.Base64" %>
<%@ page import="java.net.URLEncoder" %>
<jsp:useBean id="ResourceComInfo" class="weaver.hrm.resource.ResourceComInfo" scope="page"/>
<%
String erphost = "http://cs.njycjt.com:9060";
String IV_PARAMETER = "njy(cjt(";
String password = IV_PARAMETER ;
/**
* 密钥算法
*/
String ALGORITHM = "DES";
/**
* 加密/解密算法-工作模式-填充模式
*/
String CIPHER_ALGORITHM = "DES/CBC/PKCS5Padding";
/**
* 默认编码
*/
String CHARSET = "UTF-8";
User user = HrmUserVarify.getUser (request,response);
RecordSet rs = new RecordSet();
String pcurlsrc = "";
String userid = user.getUID()+"";
String workcode = ResourceComInfo.getWorkcode(userid);
String tododataid = request.getParameter("tododataid");
String isremark = request.getParameter("isremark");
if( "0".equals(isremark) || "8".equals(isremark)){
rs.executeQuery("select * from ofs_todo_data where id = ?",tododataid);
rs.next();
pcurlsrc = Util.null2String(rs.getString("pcurlsrc"));
}else{
rs.executeQuery("select * from ofs_done_data where id = ?",tododataid);
rs.next();
pcurlsrc = Util.null2String(rs.getString("pcurlsrc"));
}
String encryptUser = encrypt(password,workcode,CHARSET,ALGORITHM,CIPHER_ALGORITHM,IV_PARAMETER);
long currentTimeMillis = System.currentTimeMillis();
long currentTimeSeconds = currentTimeMillis / 1000;
String encryptTime = encrypt(password,Util.null2String(currentTimeSeconds),CHARSET,ALGORITHM,CIPHER_ALGORITHM,IV_PARAMETER);
String encodeTime = URLEncoder.encode(encryptTime,"UTF-8");
String encodeUser = "" ;
if(user !=null){
if(StringUtils.isNotBlank(password) && password.length()>=8){
if(StringUtils.isNotBlank(workcode)){
encodeUser = URLEncoder.encode(encryptUser,"UTF-8");
}
}
}
if(StringUtils.isNotBlank(pcurlsrc)){
if(pcurlsrc.contains("#")) {
String[] split = pcurlsrc.split("#");
if(split[0].contains("?")){
pcurlsrc = split[0] + "&UserCode=" + encodeUser +"&iat="+ encodeTime + "#" + split[1];
}else{
pcurlsrc = split[0] + "?UserCode=" + encodeUser +"&iat="+ encodeTime + "#" + split[1];
}
}else if(pcurlsrc.contains("?")){
pcurlsrc = pcurlsrc + "&UserCode=" + encodeUser +"&iat="+ encodeTime ;
}else{
pcurlsrc = pcurlsrc + "?UserCode=" + encodeUser +"&iat="+ encodeTime ;
}
response.sendRedirect(pcurlsrc);
}
// if(StringUtils.isNotBlank(token)){
// if(pcurlsrc.contains("#")) {
// String[] split = pcurlsrc.split("#");
// if(split[0].contains("?")){
// pcurlsrc = split[0] + "&Token=" + token + "#" + split[1];
// }else{
// pcurlsrc = split[0] + "?Token=" + token + "#" + split[1];
// }
// }else if(pcurlsrc.contains("?")){
// pcurlsrc = pcurlsrc + "&Token=" + token ;
// }else{
// pcurlsrc = pcurlsrc + "?Token=" + token ;
// }
// }
%>
<%!
/**
* DES加密字符串
*
* @param password 加密密码长度不能够小于8位
* @param data 待加密字符串
* @return 加密后内容
*/
public String encrypt(String password, String data,String CHARSET,String ALGORITHM,String CIPHER_ALGORITHM,String IV_PARAMETER) {
String encrtptData = "" ;
if (StringUtils.isNotBlank(data)){
try {
DESKeySpec dks = new DESKeySpec(password.getBytes(CHARSET));
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(ALGORITHM);
Key secretKey = keyFactory.generateSecret(dks);
Cipher cipher = Cipher.getInstance(CIPHER_ALGORITHM);
IvParameterSpec iv = new IvParameterSpec(IV_PARAMETER.getBytes(CHARSET));
cipher.init(Cipher.ENCRYPT_MODE, secretKey, iv);
byte[] bytes = cipher.doFinal(data.getBytes(CHARSET));
//JDK1.8及以上可直接使用Base64JDK1.7及以下可以使用BASE64Encoder
//Android平台可以使用android.util.Base64
encrtptData = new String(Base64.getEncoder().encode(bytes));
} catch (Exception e) {
e.printStackTrace();
}
}
return encrtptData ;
}
%>