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.
90 lines
3.1 KiB
Plaintext
90 lines
3.1 KiB
Plaintext
|
|
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
|
|
<%@ page import="weaver.hrm.User" %>
|
|
<%@ page import="weaver.general.BaseBean" %>
|
|
<%@ page import="weaver.hrm.HrmUserVarify" %>
|
|
<%@ page import="org.apache.commons.lang3.StringUtils" %>
|
|
<%@ page import="java.nio.charset.StandardCharsets" %>
|
|
<%@ page import="javax.crypto.spec.SecretKeySpec" %>
|
|
<%@ page import="javax.xml.bind.DatatypeConverter" %>
|
|
<%@ page import="java.security.NoSuchAlgorithmException" %>
|
|
<%@ page import="java.security.InvalidKeyException" %>
|
|
<%@ page import="javax.crypto.*" %>
|
|
<jsp:useBean id="ResourceComInfo" class="weaver.hrm.resource.ResourceComInfo" scope="page"/>
|
|
|
|
<%
|
|
BaseBean bb = new BaseBean();
|
|
String host = "https://mip.beta.myspacex.cn/yczg/fw/OA_SSO_Login";
|
|
String secretKey = "httpsoanjycjtcom";
|
|
|
|
String msg = "" ;
|
|
String jumpUrl = "" ;
|
|
User user = HrmUserVarify.getUser (request,response);
|
|
try{
|
|
if(user !=null){
|
|
String userid = user.getUID()+"";
|
|
String workcode = ResourceComInfo.getWorkcode(userid);
|
|
if(StringUtils.isNotBlank(workcode) && StringUtils.isNotBlank(secretKey)){
|
|
String token = encryptAES(secretKey,workcode);
|
|
jumpUrl = host+"?Token="+token ;
|
|
}else{
|
|
msg = "获取当前用户工号为空";
|
|
}
|
|
}else{
|
|
msg = "获取当前用户为空";
|
|
}
|
|
|
|
}catch (Exception e){
|
|
|
|
}
|
|
|
|
if(StringUtils.isNotBlank(jumpUrl)){
|
|
response.sendRedirect(jumpUrl);
|
|
}
|
|
|
|
%>
|
|
|
|
<script type="text/javascript" src="<%=weaver.general.GCONST.getContextPath()%>/cloudstore/resource/pc/jquery/jquery.min.js"></script>
|
|
<script>
|
|
|
|
// window.location.href=viewUrl+"&returnUrl="+window.encodeURIComponent(returnUrl);
|
|
jQuery(document).ready(function () {
|
|
var msg = "<%=msg %>";
|
|
var jumpUrl = "<%=jumpUrl %>";
|
|
if(jumpUrl =="" && msg !=""){
|
|
alert(msg);
|
|
}
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
<%!
|
|
/**
|
|
* AES加密字符串
|
|
* @return 加密后内容
|
|
*/
|
|
public String encryptAES(String password,String data) {
|
|
String ALGORITHM = "AES";
|
|
String encrtptData = "" ;
|
|
try {
|
|
byte[] keyBytes = password.getBytes(StandardCharsets.UTF_8); // 生成随机的16字节密钥
|
|
SecretKey secretKey = new SecretKeySpec(keyBytes, ALGORITHM); // 创建SecretKey对象
|
|
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
|
|
cipher.init(Cipher.ENCRYPT_MODE, secretKey); // 初始化加密器
|
|
byte[] encryptedBytes = cipher.doFinal(data.getBytes());
|
|
encrtptData = DatatypeConverter.printHexBinary(encryptedBytes);
|
|
} catch (NoSuchAlgorithmException e) {
|
|
e.printStackTrace();
|
|
} catch (NoSuchPaddingException e) {
|
|
e.printStackTrace();
|
|
}catch (InvalidKeyException e) {
|
|
e.printStackTrace();
|
|
} catch (IllegalBlockSizeException e) {
|
|
e.printStackTrace();
|
|
} catch (BadPaddingException e) {
|
|
e.printStackTrace();
|
|
}
|
|
return encrtptData ;
|
|
}
|
|
%> |