You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
2.0 KiB
51 lines
2.0 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using QMFrameWork.ServiceInterface;
|
|
using QMFrameWork.ServiceLibrary;
|
|
using QMAPP.Entity.Sys;
|
|
using QMAPP.BLL.Sys;
|
|
|
|
namespace QMFrameWork.ServiceLibrary
|
|
{
|
|
/// <summary>
|
|
/// 服务校验管理
|
|
/// </summary>
|
|
public class AuthorizationManager
|
|
{
|
|
/// <summary>
|
|
/// 服务静态密码
|
|
/// </summary>
|
|
public static string ServiceCredential { get; set; }
|
|
|
|
public void IsAuthorization(ServiceRequest request)
|
|
{
|
|
if (string.IsNullOrEmpty(request.UserCredential.CredentialID) == true)
|
|
throw new Exception("登录超时,请重新登录。");
|
|
|
|
ServiceSession session = SessionManager.GetSession(request.UserCredential.CredentialID);
|
|
if (session == null)
|
|
{
|
|
//应用二次登录
|
|
LoginInfo login = null;
|
|
if (string.IsNullOrEmpty(request.UserCredential.UserName) == false && string.IsNullOrEmpty(request.UserCredential.PassWord) == false)
|
|
{
|
|
string passWord = QMFrameWork.Common.Encrypt.DESEncrypt.Decrypt(request.UserCredential.PassWord);
|
|
login = new LoginBLL().IsLogin(new LoginInfo { LoginUserID = request.UserCredential.UserName, PassWord = passWord });
|
|
}
|
|
|
|
if (login != null)
|
|
{
|
|
request.UserCredential.UserName = login.UserName;
|
|
SessionManager.Add(request.UserCredential.CredentialID, new ServiceSession { SessionID = request.UserCredential.CredentialID, UserCredential = request.UserCredential, UserLogin = login }, new TimeSpan(0, 240, 0));
|
|
}
|
|
else
|
|
{
|
|
if (request.UserCredential.CredentialID != ServiceCredential)
|
|
throw new Exception("服务凭据不正确。");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|