DeviceManager/TsSFCDeviceSvc/App_Code/SFCAuthorize.cs
2024-11-09 12:25:57 +08:00

59 lines
1.7 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using NLog;
using System;
using System.Text;
using System.Web;
using System.Web.Services.Protocols;
namespace TsSFCDeviceSvc.App_Code
{
public class SFCAuthorize : SoapHeader
{
private static readonly Logger log = LogManager.GetCurrentClassLogger();
public string Password;
public string Username;
public string GUID;
/// <summary>
/// SAP环境0测试环境/1正式环境
/// </summary>
public UInt16 SapSetting;
public string Version;
public string MacAddress;
public bool ValidUser(string inUsername, string inPassword)
{
//Utility.SapSetting = SapSetting;
if (inPassword == null) throw new ArgumentNullException("inPassword");
string conpass = "";
if (inUsername.Length == 0) return false;
string ip = HttpContext.Current.Request.UserHostAddress;
byte[] password = Encoding.Unicode.GetBytes(Username);
Array.Reverse(password);
string pass64 = Convert.ToBase64String(password);
if (pass64.Length < 10) pass64 += "YeT+=fue";
conpass = pass64;
if (conpass == Password)
{
return true;
}
//log.WriteLog("ValidUser", "密码验证未通过,有可能有非法用户在尝试登录:" + ip);
log.Error("ValidUser", "パスワードの検証が失敗し、ログインしようとする違法ユーザがあるかもしれません:" + ip);
return false;
}
public string token;
public SFCAuthorize()
{
}
}
}