11
This commit is contained in:
@@ -1181,6 +1181,7 @@
|
|||||||
<Content Include="HSSE\Hazard\SetToolTipTime.aspx" />
|
<Content Include="HSSE\Hazard\SetToolTipTime.aspx" />
|
||||||
<Content Include="HSSE\Hazard\ShowEnvironmentalItem.aspx" />
|
<Content Include="HSSE\Hazard\ShowEnvironmentalItem.aspx" />
|
||||||
<Content Include="HSSE\Hazard\ShowHazardList.aspx" />
|
<Content Include="HSSE\Hazard\ShowHazardList.aspx" />
|
||||||
|
<Content Include="HSSE\Hazard\ToHazard.aspx" />
|
||||||
<Content Include="HSSE\HiddenInspection\CheckStatisticsAnalysis.aspx" />
|
<Content Include="HSSE\HiddenInspection\CheckStatisticsAnalysis.aspx" />
|
||||||
<Content Include="HSSE\HiddenInspection\CheckStatisticsAnalysisProject.aspx" />
|
<Content Include="HSSE\HiddenInspection\CheckStatisticsAnalysisProject.aspx" />
|
||||||
<Content Include="HSSE\HiddenInspection\HiddenRectificationAdd.aspx" />
|
<Content Include="HSSE\HiddenInspection\HiddenRectificationAdd.aspx" />
|
||||||
@@ -12768,6 +12769,13 @@
|
|||||||
<Compile Include="HSSE\Hazard\ShowHazardList.aspx.designer.cs">
|
<Compile Include="HSSE\Hazard\ShowHazardList.aspx.designer.cs">
|
||||||
<DependentUpon>ShowHazardList.aspx</DependentUpon>
|
<DependentUpon>ShowHazardList.aspx</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="HSSE\Hazard\ToHazard.aspx.cs">
|
||||||
|
<DependentUpon>ToHazard.aspx</DependentUpon>
|
||||||
|
<SubType>ASPXCodeBehind</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="HSSE\Hazard\ToHazard.aspx.designer.cs">
|
||||||
|
<DependentUpon>ToHazard.aspx</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="HSSE\HiddenInspection\CheckStatisticsAnalysis.aspx.cs">
|
<Compile Include="HSSE\HiddenInspection\CheckStatisticsAnalysis.aspx.cs">
|
||||||
<DependentUpon>CheckStatisticsAnalysis.aspx</DependentUpon>
|
<DependentUpon>CheckStatisticsAnalysis.aspx</DependentUpon>
|
||||||
<SubType>ASPXCodeBehind</SubType>
|
<SubType>ASPXCodeBehind</SubType>
|
||||||
@@ -20498,7 +20506,7 @@
|
|||||||
</FlavorProperties>
|
</FlavorProperties>
|
||||||
</VisualStudio>
|
</VisualStudio>
|
||||||
</ProjectExtensions>
|
</ProjectExtensions>
|
||||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v18.0\WebApplications\Microsoft.WebApplication.targets" />
|
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v17.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
<Target Name="BeforeBuild">
|
<Target Name="BeforeBuild">
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ToHazard.aspx.cs" Inherits="FineUIPro.Web.HSSE.Hazard.ToHazard" %>
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<head runat="server">
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||||
|
<title></title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<form id="form1" runat="server">
|
||||||
|
<div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
function openNewTab() {
|
||||||
|
window.open('<%=url%>', '_blank');
|
||||||
|
}
|
||||||
|
openNewTab()
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,131 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Text;
|
||||||
|
using System.Web;
|
||||||
|
using System.Web.UI;
|
||||||
|
using System.Web.UI.WebControls;
|
||||||
|
|
||||||
|
namespace FineUIPro.Web.HSSE.Hazard
|
||||||
|
{
|
||||||
|
public partial class ToHazard : PageBase
|
||||||
|
{
|
||||||
|
|
||||||
|
public string url
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return (string)ViewState["url"];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
ViewState["url"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protected void Page_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
url = BuildRedirectUrl(CurrUser.Account);
|
||||||
|
}// 密钥(与Java完全一致)
|
||||||
|
private const string SECRET_B64 = "y3KXl9sle7+WUpwyVajCyx8LyQdZSwUUgVS69FDvuR8=";
|
||||||
|
// 登录接口地址
|
||||||
|
private const string API_LOGIN = "https://hse-ai.cwcec.com/api/auth/unified-login";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 构建统一登录跳转URL(C#版,与Java逻辑完全一致)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="username">用户名</param>
|
||||||
|
/// <returns>加密签名字符串</returns>
|
||||||
|
public static string BuildRedirectUrl(string username)
|
||||||
|
{
|
||||||
|
// 1. Base64 解码密钥
|
||||||
|
byte[] key = Convert.FromBase64String(SECRET_B64);
|
||||||
|
|
||||||
|
// 2. 生成时间戳(秒)、随机nonce
|
||||||
|
long ts = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
|
||||||
|
string nonce = Guid.NewGuid().ToString("N"); // 去掉横杠,与Java一致
|
||||||
|
|
||||||
|
// 3. 构建JSON明文
|
||||||
|
string json = $"{{\"username\":\"{username}\",\"timestamp\":{ts},\"nonce\":\"{nonce}\"}}";
|
||||||
|
|
||||||
|
// 4. AES-CBC-PKCS7 加密(Hutool默认:随机IV,输出 = IV + 密文)
|
||||||
|
string data = AesCbcEncrypt(json, key);
|
||||||
|
|
||||||
|
// 5. 构建签名原文 + HMACSHA256 签名
|
||||||
|
string signPayload = $"data={data}×tamp={ts}&nonce={nonce}";
|
||||||
|
string sign = HmacSha256Sign(signPayload, key);
|
||||||
|
|
||||||
|
// 6. 构建有序参数(LinkedHashMap 对应 SortedDictionary / 手动有序)
|
||||||
|
var queryParams = new Dictionary<string, string>
|
||||||
|
{
|
||||||
|
{ "data", data },
|
||||||
|
{ "timestamp", ts.ToString() },
|
||||||
|
{ "nonce", nonce },
|
||||||
|
{ "sign", sign }
|
||||||
|
};
|
||||||
|
|
||||||
|
// 7. 拼接URL(URL编码)
|
||||||
|
StringBuilder sb = new StringBuilder(API_LOGIN).Append('?');
|
||||||
|
foreach (var kvp in queryParams)
|
||||||
|
{
|
||||||
|
sb.Append(HttpUtility.UrlEncode(kvp.Key))
|
||||||
|
.Append('=')
|
||||||
|
.Append(HttpUtility.UrlEncode(kvp.Value))
|
||||||
|
.Append('&');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 去掉最后一个 &
|
||||||
|
if (sb.Length > 0) sb.Length--;
|
||||||
|
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 核心加密工具方法(与Java Hutool完全对齐)
|
||||||
|
/// <summary>
|
||||||
|
/// AES-CBC-PKCS7 加密
|
||||||
|
/// 输出格式:IV(16字节) + 密文 → Base64(和Hutool AES.encrypt 行为一致)
|
||||||
|
/// </summary>
|
||||||
|
private static string AesCbcEncrypt(string plainText, byte[] key)
|
||||||
|
{
|
||||||
|
using (Aes aes = Aes.Create())
|
||||||
|
{
|
||||||
|
aes.Key = key;
|
||||||
|
aes.Mode = CipherMode.CBC;
|
||||||
|
aes.Padding = PaddingMode.PKCS7; // 与Java PKCS5Padding 通用兼容
|
||||||
|
aes.GenerateIV(); // 自动生成随机16字节IV(和Java一致)
|
||||||
|
|
||||||
|
using (var encryptor = aes.CreateEncryptor(aes.Key, aes.IV))
|
||||||
|
using (var ms = new System.IO.MemoryStream())
|
||||||
|
{
|
||||||
|
// 先写入IV(Hutool默认格式:IV + 密文)
|
||||||
|
ms.Write(aes.IV, 0, aes.IV.Length);
|
||||||
|
|
||||||
|
using (var cs = new CryptoStream(ms, encryptor, CryptoStreamMode.Write))
|
||||||
|
using (var sw = new System.IO.StreamWriter(cs, Encoding.UTF8))
|
||||||
|
{
|
||||||
|
sw.Write(plainText);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 输出:IV + 密文 → Base64
|
||||||
|
return Convert.ToBase64String(ms.ToArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// HMACSHA256 签名(小写十六进制)
|
||||||
|
/// </summary>
|
||||||
|
private static string HmacSha256Sign(string payload, byte[] key)
|
||||||
|
{
|
||||||
|
using (var hmac = new HMACSHA256(key))
|
||||||
|
{
|
||||||
|
byte[] payloadBytes = Encoding.UTF8.GetBytes(payload);
|
||||||
|
byte[] hashBytes = hmac.ComputeHash(payloadBytes);
|
||||||
|
|
||||||
|
// 转小写十六进制(与Java digestHex一致)
|
||||||
|
return BitConverter.ToString(hashBytes).Replace("-", "").ToLower();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <自动生成>
|
||||||
|
// 此代码由工具生成。
|
||||||
|
//
|
||||||
|
// 对此文件的更改可能导致不正确的行为,如果
|
||||||
|
// 重新生成代码,则所做更改将丢失。
|
||||||
|
// </自动生成>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace FineUIPro.Web.HSSE.Hazard
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
public partial class ToHazard
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// form1 控件。
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// 自动生成的字段。
|
||||||
|
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
|
||||||
|
/// </remarks>
|
||||||
|
protected global::System.Web.UI.HtmlControls.HtmlForm form1;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user