@@ -51,11 +51,12 @@ http://数字化智慧校园部署地址 / 测试用户名:thirdtest密码:1 | |||
接上一步,在跳转到应用时会在应用地址上携带参数:appkey=" xxxx"&name="xxxx"&no="xxxx"&type=0&a="xxx",appkey 是DES 密钥的 32位MD5(自行判断正确性,错误即非法请求。),name和no代表用户姓名和编号,都为DES加密后字符,type是类型,0为老师,1为学生。DES 密钥为约定项,自行配置在系统参数里。解密后得到用户信息自行在系统里配置该用户的登录认证及权限。 | |||
登录跳转的身份认证 | |||
数校登录页如果携带returnUrl参数,在登录后会自动跳转returnUrl,跳转时也会携带参数:appkey=" xxxx"&name="xxxx"&no="xxxx"&type=0&a="xxx",验证方法同上。 | |||
数校登录页如果携带returnUrl参数,在登录后会自动跳转returnUrl,跳转时也会携带参数:appkey=" xxxx"&name="xxxx"&no="xxxx"&type=0&m="xxx"&t="xxx",验证方法同上。 | |||
第三方应用在跳转数据登录页时需要传参returnUrl和appid参数。 | |||
退出 | |||
如果在非数校系统退出时,调用接口同步退出。 | |||
请求地址:http:// 数字化智慧校园部署地址/SSOSystem/out?appid=APPID& &appkey=APPKEY&a=xxx | |||
请求地址:http:// 数字化智慧校园部署地址/SSOSystem/out?appid=APPID& &appkey=APPKEY&m=xxx&t=xxx | |||
参数说明 | |||
参数 | |||
是否必须 | |||
@@ -63,7 +64,10 @@ http://数字化智慧校园部署地址 / 测试用户名:thirdtest密码:1 | |||
appid | |||
是 | |||
应用唯一标识 | |||
a | |||
m | |||
是 | |||
跳转时携带 | |||
t | |||
是 | |||
跳转时携带 | |||
appkey | |||
@@ -79,7 +83,7 @@ DES密钥MD5值 | |||
获取用户登录状态 | |||
如果在非数校系统中用户状态无法确定,可调用接口获取是否在线状态。 | |||
请求地址:http:// 数字化智慧校园部署地址/SSOSystem/userstat?appid=APPID& &appkey=APPKEY&a=xxx | |||
请求地址:http:// 数字化智慧校园部署地址/SSOSystem/userstat?appid=APPID& &appkey=APPKEY&m=xxx&t=xxx | |||
参数说明 | |||
参数 | |||
是否必须 | |||
@@ -87,7 +91,10 @@ DES密钥MD5值 | |||
appid | |||
是 | |||
应用唯一标识 | |||
a | |||
m | |||
是 | |||
跳转时携带 | |||
t | |||
是 | |||
跳转时携带 | |||
appkey | |||
@@ -111,6 +111,23 @@ namespace Learun.Application.Web.Areas.Permission.Controllers | |||
perm_FunctionVisitIBLL.SaveEntity(keyValue,entity); | |||
return Success("保存成功!"); | |||
} | |||
/// <summary> | |||
/// 退出实体数据 | |||
/// <param name="keyValue">主键</param> | |||
/// <summary> | |||
/// <returns></returns> | |||
[HttpPost] | |||
[AjaxOnly] | |||
public ActionResult DoOutHandle(string keyValue) | |||
{ | |||
var result = perm_FunctionVisitIBLL.DoOutHandle(keyValue); | |||
if (!result) | |||
{ | |||
return Fail("操作失败!"); | |||
} | |||
return Success("操作成功!"); | |||
} | |||
#endregion | |||
} | |||
@@ -17,7 +17,7 @@ | |||
</div> | |||
<div class="col-xs-12 lr-form-item" data-table="Perm_Function"> | |||
<div class="lr-form-item-title">退出地址<font face="宋体">*</font></div> | |||
<input id="FInterfaceUrl" type="text" class="form-control" isvalid="yes" checkexpession="NotNull" /> | |||
<input id="FOutUrl" type="text" class="form-control" isvalid="yes" checkexpession="NotNull" /> | |||
</div> | |||
<div class="col-xs-12 lr-form-item" data-table="Perm_Function" style="display: none;" id="divFId"> | |||
<div class="lr-form-item-title">appid</div> | |||
@@ -25,7 +25,7 @@ | |||
</div> | |||
<div class="col-xs-12 lr-form-item" data-table="Perm_Function"> | |||
<div class="lr-form-item-title">应用私钥<font face="宋体">*</font></div> | |||
<input id="FSecret" type="text" class="form-control" isvalid="yes" checkexpession="NotNull" /> | |||
<input id="FSecret" type="text" class="form-control" isvalid="yes" checkexpession="MinLenStr" length="8"/> | |||
</div> | |||
<div class="col-xs-6 lr-form-item" data-table="Perm_Function"> | |||
<div class="lr-form-item-title">排序<font face="宋体">*</font></div> | |||
@@ -31,6 +31,9 @@ | |||
<a id="lr_edit" class="btn btn-default"><i class="fa fa-pencil-square-o"></i> 修改</a> | |||
<a id="lr_delete" class="btn btn-default"><i class="fa fa-trash-o"></i> 删除</a> | |||
</div> | |||
<div class=" btn-group btn-group-sm"> | |||
<a id="lr_outhandle" class="btn btn-default"><i class="fa fa-pencil-square-o"></i> 退出</a> | |||
</div> | |||
</div> | |||
</div> | |||
<div class="lr-layout-body" id="gridtable"></div> | |||
@@ -62,10 +62,34 @@ var bootstrap = function ($, learun) { | |||
}); | |||
} | |||
}); | |||
// 退出 | |||
$('#lr_outhandle').on('click', function () { | |||
var keyValue = $('#gridtable').jfGridValue('PVId'); | |||
if (learun.checkrow(keyValue)) { | |||
var PIsLoginSuccess = $('#gridtable').jfGridValue('PIsLoginSuccess'); | |||
if (PIsLoginSuccess != true && PIsLoginSuccess != "true") { | |||
learun.alert.warning("此应用无法退出!"); | |||
return false; | |||
} | |||
var IsOut = $('#gridtable').jfGridValue('IsOut'); | |||
if (IsOut == true || IsOut == "true") { | |||
learun.alert.warning("此应用已退出!"); | |||
return false; | |||
} | |||
learun.layerConfirm('是否确认退出该项!', function (res) { | |||
if (res) { | |||
learun.postForm(top.$.rootUrl + '/Permission/Perm_FunctionVisit/DoOutHandle', { keyValue: keyValue }, function () { | |||
refreshGirdData(); | |||
}); | |||
} | |||
}); | |||
} | |||
}); | |||
}, | |||
// 初始化列表 | |||
initGird: function () { | |||
$('#gridtable').lrAuthorizeJfGrid({ | |||
$('#gridtable').jfGrid({ | |||
url: top.$.rootUrl + '/Permission/Perm_FunctionVisit/GetPageList', | |||
headData: [ | |||
{ label: "系统名称", name: "FName", width: 200, align: "left" }, | |||
@@ -76,11 +100,18 @@ var bootstrap = function ($, learun) { | |||
} | |||
}, | |||
{ label: "用户名称", name: "PUName", width: 100, align: "left" }, | |||
{ label: "访问情况", name: "PContent", width: 200, align: "left" }, | |||
{ label: "访问情况", name: "PContent", width: 400, align: "left" }, | |||
{ | |||
label: "是否退出", name: "IsOut", width: 70, align: "center", formatter: function (cellvalue) { | |||
return cellvalue == true ? "<i class=\"fa fa-toggle-on\"></i>" : "<i class=\"fa fa-toggle-off\"></i>"; | |||
} | |||
}, | |||
{ label: "退出日期", name: "OutDate", width: 150, align: "left" }, | |||
], | |||
mainId: 'PVId', | |||
isPage: true, | |||
rows: 100 | |||
rows: 100, | |||
sidx: 'PDate desc', | |||
}); | |||
page.search(); | |||
}, | |||
@@ -59,6 +59,102 @@ namespace Learun.Application.Web.Controllers | |||
private MealCardRunTabIBLL mealCardRunTabIBLL = new MealCardRunTabBLL(); | |||
private Sys_UpdateRecordIBLL sys_UpdateRecordIBLL = new Sys_UpdateRecordBLL(); | |||
#region 统一身份认证3.0 | |||
/// <summary> | |||
/// 退出 | |||
/// </summary> | |||
/// <returns></returns> | |||
[ActionName("out")] | |||
public ActionResult outApplication() | |||
{ | |||
string appid = Request.QueryString["appid"]; | |||
string appkey = Request.QueryString["appkey"]; | |||
string m = Request.QueryString["m"]; | |||
string t = Request.QueryString["t"]; | |||
if (string.IsNullOrEmpty(appid)) | |||
{ | |||
return Fail("参数:appid不能为空"); | |||
} | |||
if (string.IsNullOrEmpty(appkey)) | |||
{ | |||
return Fail("参数:appkey不能为空"); | |||
} | |||
if (string.IsNullOrEmpty(m)) | |||
{ | |||
return Fail("参数:m不能为空"); | |||
} | |||
if (string.IsNullOrEmpty(t)) | |||
{ | |||
return Fail("参数:t不能为空"); | |||
} | |||
var application = perm_FunctionIBLL.GetPerm_FunctionEntity(appid); | |||
if (application != null) | |||
{ | |||
if (Md5Helper.Encrypt(application.FSecret, 32) == appkey) | |||
{ | |||
OperatorHelper.Instance.EmptyCurrent(DESEncrypt.Decrypt(t), DESEncrypt.Decrypt(m)); | |||
return SuccessString("true"); | |||
} | |||
else | |||
{ | |||
return Fail("appkey错误"); | |||
} | |||
} | |||
else | |||
return Fail("未授权的appid"); | |||
} | |||
/// <summary> | |||
/// 获取用户登录状态 | |||
/// </summary> | |||
/// <returns></returns> | |||
public ActionResult userstat() | |||
{ | |||
string appid = Request.QueryString["appid"]; | |||
string appkey = Request.QueryString["appkey"]; | |||
string m = Request.QueryString["m"]; | |||
string t = Request.QueryString["t"]; | |||
if (string.IsNullOrEmpty(appid)) | |||
{ | |||
return Fail("参数:appid不能为空"); | |||
} | |||
if (string.IsNullOrEmpty(appkey)) | |||
{ | |||
return Fail("参数:appkey不能为空"); | |||
} | |||
if (string.IsNullOrEmpty(m)) | |||
{ | |||
return Fail("参数:m不能为空"); | |||
} | |||
if (string.IsNullOrEmpty(t)) | |||
{ | |||
return Fail("参数:t不能为空"); | |||
} | |||
var application = perm_FunctionIBLL.GetPerm_FunctionEntity(appid); | |||
if (application != null) | |||
{ | |||
if (Md5Helper.Encrypt(application.FSecret, 32) == appkey) | |||
{ | |||
OperatorResult res = OperatorHelper.Instance.IsOnLine(DESEncrypt.Decrypt(t), DESEncrypt.Decrypt(m)); | |||
if (res.stateCode == 1) | |||
{ | |||
return SuccessString("true"); | |||
} | |||
else | |||
{ | |||
return Fail("登录无效"); | |||
} | |||
} | |||
else | |||
{ | |||
return Fail("appkey错误"); | |||
} | |||
} | |||
else | |||
return Fail("未授权的appid"); | |||
} | |||
#endregion | |||
#region 统一身份认证2.0 | |||
/// <summary> | |||
/// 获取统一认证用户信息 | |||
@@ -1362,7 +1458,7 @@ namespace Learun.Application.Web.Controllers | |||
ViewBag.ReceiveFileListStr = JsonConvert.SerializeObject(ViewBag.ReceiveFileList); | |||
//公告 | |||
List<NewsEntity> outnewslist = new List<NewsEntity>(); | |||
var newsList = newsIBLL.GetList("",""); | |||
var newsList = newsIBLL.GetList("", ""); | |||
foreach (var newsitemEntity in newsList) | |||
{ | |||
if (!string.IsNullOrEmpty(newsitemEntity.F_SendPostId)) | |||
@@ -150,7 +150,7 @@ | |||
} | |||
} | |||
var r = { code: true, msg: '' }; | |||
if (checkexpession == 'LenNum' || checkexpession == 'LenNumOrNull' || checkexpession == 'LenStr' || checkexpession == 'LenStrOrNull') { | |||
if (checkexpession == 'LenNum' || checkexpession == 'LenNumOrNull' || checkexpession == 'LenStr' || checkexpession == 'LenStrOrNull' || checkexpession == 'MinLenStr') { | |||
var len = $this.attr("length"); | |||
r = checkfn(value, len); | |||
} else { | |||
@@ -202,6 +202,15 @@ | |||
res.msg = '必须小于等于' + n + '位字符或空'; | |||
} | |||
return res; | |||
}, | |||
isMinLenStr: function (obj, n) {//验证是否大于等于n位数的字符串 nchar | |||
var res = { code: true, msg: '' }; | |||
obj = $.trim(obj); | |||
if (!learun.validator.isNotNull(obj).code || obj.length < n) { | |||
res.code = false; | |||
res.msg = '必须大于等于' + n + '位字符'; | |||
} | |||
return res; | |||
} | |||
}; | |||
@@ -88,7 +88,7 @@ | |||
// value = $this.val(); | |||
//} | |||
var r = { code: true, msg: '' }; | |||
if (checkexpession == 'LenNum' || checkexpession == 'LenNumOrNull' || checkexpession == 'LenStr' || checkexpession == 'LenStrOrNull') { | |||
if (checkexpession == 'LenNum' || checkexpession == 'LenNumOrNull' || checkexpession == 'LenStr' || checkexpession == 'LenStrOrNull' || checkexpession == 'MinLenStr') { | |||
var len = $this.attr("length"); | |||
r = checkfn(value, len); | |||
} else { | |||
@@ -180,7 +180,7 @@ namespace Learun.Application.WebApi | |||
ReqParameter req = this.Bind<ReqParameter>(); | |||
loginMark = req.loginMark; | |||
token = req.token; | |||
if (path == "/learun/adms/user/login" || path == "/" || path == "/bgimg" || path == "/learun/adms/user/img" || path == "/learun/adms/desktop/img"||path== "/learun/adms/user/imgfordc"||path== "/learun/adms/annexes/down" || path == "/learun/adms/StampPersonal/img") | |||
if (path == "/learun/adms/user/login" || path == "/" || path == "/bgimg" || path == "/learun/adms/user/img" || path == "/learun/adms/desktop/img"||path== "/learun/adms/user/imgfordc"||path== "/learun/adms/annexes/down" || path == "/learun/adms/StampPersonal/img" || path == "/quanjiang/sso/out" || path == "/quanjiang/sso/userstat") | |||
{// 登录接口,默认页面接口不做权限验证处理 | |||
return null; | |||
} | |||
@@ -13,6 +13,7 @@ using Learun.Application.TwoDevelopment.Permission; | |||
using System; | |||
using Learun.Cache.Factory; | |||
using Learun.Cache.Base; | |||
using Learun.Util.Operat; | |||
namespace Learun.Application.WebApi.Modules | |||
{ | |||
@@ -35,8 +36,107 @@ namespace Learun.Application.WebApi.Modules | |||
Get["first"] = First; | |||
Post["first"] = FirstPost; | |||
Get["authorize"] = Authorize; | |||
Get["/out"] = outApplication; | |||
Get["/userstat"] = userstat; | |||
} | |||
#region 统一身份认证3.0 | |||
/// <summary> | |||
/// 退出 | |||
/// </summary> | |||
/// <param name="_"></param> | |||
/// <returns></returns> | |||
public Response outApplication(dynamic _) | |||
{ | |||
string appid = Request.Query["appid"]; | |||
string appkey = Request.Query["appkey"]; | |||
string m = Request.Query["m"]; | |||
string t = Request.Query["t"]; | |||
if (string.IsNullOrEmpty(appid)) | |||
{ | |||
return Fail("参数:appid不能为空"); | |||
} | |||
if (string.IsNullOrEmpty(appkey)) | |||
{ | |||
return Fail("参数:appkey不能为空"); | |||
} | |||
if (string.IsNullOrEmpty(m)) | |||
{ | |||
return Fail("参数:m不能为空"); | |||
} | |||
if (string.IsNullOrEmpty(t)) | |||
{ | |||
return Fail("参数:t不能为空"); | |||
} | |||
var application = perm_FunctionIBLL.GetPerm_FunctionEntity(appid); | |||
if (application != null) | |||
{ | |||
if (Md5Helper.Encrypt(application.FSecret, 32) == appkey) | |||
{ | |||
OperatorHelper.Instance.EmptyCurrent(DESEncrypt.Decrypt(t), DESEncrypt.Decrypt(m)); | |||
return SuccessString("true"); | |||
} | |||
else | |||
{ | |||
return Fail("appkey错误"); | |||
} | |||
} | |||
else | |||
return Fail("未授权的appid"); | |||
} | |||
/// <summary> | |||
/// 获取用户登录状态 | |||
/// </summary> | |||
/// <param name="_"></param> | |||
/// <returns></returns> | |||
public Response userstat(dynamic _) | |||
{ | |||
string appid = Request.Query["appid"]; | |||
string appkey = Request.Query["appkey"]; | |||
string m = Request.Query["m"]; | |||
string t = Request.Query["t"]; | |||
if (string.IsNullOrEmpty(appid)) | |||
{ | |||
return Fail("参数:appid不能为空"); | |||
} | |||
if (string.IsNullOrEmpty(appkey)) | |||
{ | |||
return Fail("参数:appkey不能为空"); | |||
} | |||
if (string.IsNullOrEmpty(m)) | |||
{ | |||
return Fail("参数:m不能为空"); | |||
} | |||
if (string.IsNullOrEmpty(t)) | |||
{ | |||
return Fail("参数:t不能为空"); | |||
} | |||
var application = perm_FunctionIBLL.GetPerm_FunctionEntity(appid); | |||
if (application != null) | |||
{ | |||
if (Md5Helper.Encrypt(application.FSecret, 32) == appkey) | |||
{ | |||
OperatorResult res = OperatorHelper.Instance.IsOnLine(DESEncrypt.Decrypt(t), DESEncrypt.Decrypt(m)); | |||
if (res.stateCode == 1) | |||
{ | |||
return SuccessString("true"); | |||
} | |||
else | |||
{ | |||
return Fail("登录无效"); | |||
} | |||
} | |||
else | |||
{ | |||
return Fail("appkey错误"); | |||
} | |||
} | |||
else | |||
return Fail("未授权的appid"); | |||
} | |||
#endregion | |||
/// <summary> | |||
/// 统一身份认证2.0 | |||
/// </summary> | |||
@@ -71,6 +71,12 @@ namespace Learun.Application.TwoDevelopment.Permission | |||
/// </summary> | |||
[Column("FENABLED")] | |||
public bool? FEnabled { get; set; } | |||
/// <summary> | |||
/// 退出地址 | |||
/// </summary> | |||
[Column("FOutUrl")] | |||
public string FOutUrl { get; set; } | |||
#endregion | |||
@@ -118,6 +118,30 @@ namespace Learun.Application.TwoDevelopment.Permission | |||
} | |||
} | |||
/// <summary> | |||
/// 退出实体数据 | |||
/// <param name="keyValue">主键</param> | |||
/// <summary> | |||
/// <returns></returns> | |||
public bool DoOutHandle(string keyValue) | |||
{ | |||
try | |||
{ | |||
return perm_FunctionVisitService.DoOutHandle(keyValue); | |||
} | |||
catch (Exception ex) | |||
{ | |||
if (ex is ExceptionEx) | |||
{ | |||
throw; | |||
} | |||
else | |||
{ | |||
throw ExceptionEx.ThrowBusinessException(ex); | |||
} | |||
} | |||
} | |||
#endregion | |||
} | |||
@@ -44,9 +44,26 @@ namespace Learun.Application.TwoDevelopment.Permission | |||
/// </summary> | |||
[Column("PCONTENT")] | |||
public string PContent { get; set; } | |||
/// <summary> | |||
/// 是否登录成功 | |||
/// </summary> | |||
[Column("PISLOGINSUCCESS")] | |||
public bool PIsLoginSuccess { get; set; } | |||
public bool? PIsLoginSuccess { get; set; } | |||
/// <summary> | |||
/// 用户编号 | |||
/// </summary> | |||
[Column("PUNO")] | |||
public string PUNo { get; set; } | |||
/// <summary> | |||
/// 是否退出第三方应用 | |||
/// </summary> | |||
[Column("ISOUT")] | |||
public bool? IsOut { get; set; } | |||
/// <summary> | |||
/// 退出时间 | |||
/// </summary> | |||
[Column("OUTDATE")] | |||
public DateTime? OutDate { get; set; } | |||
#endregion | |||
#region 扩展操作 | |||
@@ -43,6 +43,12 @@ namespace Learun.Application.TwoDevelopment.Permission | |||
/// <summary> | |||
/// <returns></returns> | |||
void SaveEntity(string keyValue, Perm_FunctionVisitEntity entity); | |||
/// <summary> | |||
/// 退出实体数据 | |||
/// <param name="keyValue">主键</param> | |||
/// <summary> | |||
/// <returns></returns> | |||
bool DoOutHandle(string keyValue); | |||
#endregion | |||
} | |||
@@ -3,7 +3,11 @@ using Learun.DataBase.Repository; | |||
using Learun.Util; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Configuration; | |||
using System.Data; | |||
using System.IO; | |||
using System.Net; | |||
using System.Net.Http; | |||
using System.Text; | |||
namespace Learun.Application.TwoDevelopment.Permission | |||
@@ -43,7 +47,7 @@ namespace Learun.Application.TwoDevelopment.Permission | |||
dp.Add("PUName", "%" + queryParam["PUName"].ToString() + "%", DbType.String); | |||
strSql.Append(" AND a.PUName Like @PUName "); | |||
} | |||
return this.BaseRepository().FindList<Perm_FunctionVisitEntity>(strSql.ToString(),dp, pagination); | |||
return this.BaseRepository().FindList<Perm_FunctionVisitEntity>(strSql.ToString(), dp, pagination); | |||
} | |||
catch (Exception ex) | |||
{ | |||
@@ -95,7 +99,7 @@ namespace Learun.Application.TwoDevelopment.Permission | |||
{ | |||
try | |||
{ | |||
this.BaseRepository().Delete<Perm_FunctionVisitEntity>(t=>t.PVId == keyValue); | |||
this.BaseRepository().Delete<Perm_FunctionVisitEntity>(t => t.PVId == keyValue); | |||
} | |||
catch (Exception ex) | |||
{ | |||
@@ -143,6 +147,66 @@ namespace Learun.Application.TwoDevelopment.Permission | |||
} | |||
} | |||
/// <summary> | |||
/// 退出实体数据 | |||
/// <param name="keyValue">主键</param> | |||
/// <summary> | |||
/// <returns></returns> | |||
public bool DoOutHandle(string keyValue) | |||
{ | |||
try | |||
{ | |||
var entity = this.BaseRepository().FindEntity<Perm_FunctionVisitEntity>(keyValue); | |||
if (entity != null && entity.PIsLoginSuccess == true && entity.IsOut != true) | |||
{ | |||
var functionEntity = this.BaseRepository().FindEntity<Perm_FunctionEntity>(entity.Fid); | |||
if (functionEntity != null && !string.IsNullOrEmpty(functionEntity.FOutUrl)) | |||
{ | |||
string outUrl = functionEntity.FOutUrl; | |||
if (outUrl.Contains("?")) | |||
{ | |||
outUrl = string.Format("{0}&no={1}", functionEntity.FOutUrl, DESEncrypt.Encrypt(entity.PUNo ?? " ", DESEncrypt.Decrypt(functionEntity.FSecret, ConfigurationManager.AppSettings["SSOPublicSecret"]), false)); | |||
} | |||
else | |||
{ | |||
outUrl = string.Format("{0}?no={1}", functionEntity.FOutUrl, DESEncrypt.Encrypt(entity.PUNo ?? " ", DESEncrypt.Decrypt(functionEntity.FSecret, ConfigurationManager.AppSettings["SSOPublicSecret"]), false)); | |||
} | |||
try | |||
{ | |||
HttpWebRequest webrequest = (HttpWebRequest)WebRequest.Create(outUrl); | |||
HttpWebResponse response = (HttpWebResponse)webrequest.GetResponse(); | |||
using (StreamReader streamReader = new StreamReader(response.GetResponseStream())) | |||
{ | |||
string responseData = streamReader.ReadToEnd(); | |||
if (!string.IsNullOrEmpty(responseData)) | |||
{ | |||
this.BaseRepository().ExecuteBySql($"update Perm_FunctionVisit set IsOut=1,OutDate='{DateTime.Now}' where PVId='{entity.PVId}' "); | |||
return true; | |||
} | |||
} | |||
} | |||
catch (Exception) | |||
{ | |||
return false; | |||
} | |||
} | |||
} | |||
return false; | |||
} | |||
catch (Exception ex) | |||
{ | |||
if (ex is ExceptionEx) | |||
{ | |||
throw; | |||
} | |||
else | |||
{ | |||
throw ExceptionEx.ThrowServiceException(ex); | |||
} | |||
} | |||
} | |||
#endregion | |||
} | |||
@@ -33,8 +33,8 @@ namespace Learun.Util | |||
/// <returns></returns> | |||
public static string Encrypt(string Text, string sKey, bool md5 = true) | |||
{ | |||
var key = sKey; | |||
var iv = sKey; | |||
var key = sKey.Substring(0, 8); | |||
var iv = sKey.Substring(0, 8); | |||
if (md5) | |||
{ | |||
key = Md5Helper.Hash(sKey).ToUpper().Substring(0, 8); | |||
@@ -84,8 +84,8 @@ namespace Learun.Util | |||
/// <returns></returns> | |||
public static string Decrypt(string Text, string sKey, bool md5 = true) | |||
{ | |||
var key = sKey; | |||
var iv = sKey; | |||
var key = sKey.Substring(0, 8); | |||
var iv = sKey.Substring(0, 8); | |||
if (md5) | |||
{ | |||
key = Md5Helper.Hash(sKey).ToUpper().Substring(0, 8); | |||