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.
54 lines
1.2 KiB
54 lines
1.2 KiB
using Entity;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Net.Http;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace EasyBL.WEBAPP
|
|
{
|
|
public static class SETokenUtil
|
|
{
|
|
|
|
public static SEToken GetToken(HttpRequestMessage message) {
|
|
|
|
SEToken seToken = new SEToken();
|
|
|
|
IEnumerable<string> headerValues;
|
|
if (message.Headers.TryGetValues("authtoken", out headerValues))
|
|
{
|
|
var token = headerValues.FirstOrDefault();
|
|
|
|
seToken = Decrypt(token);
|
|
|
|
}
|
|
|
|
return seToken;
|
|
|
|
}
|
|
|
|
public static SEToken Decrypt(string data) {
|
|
|
|
SEToken seToken = new SEToken();
|
|
|
|
if (!string.IsNullOrEmpty(data)) {
|
|
|
|
var authtoken = EasyNet.SecurityUtil.Decrypt(data);
|
|
var saAuthtoken = authtoken.Split(',');
|
|
|
|
seToken.OrgID = saAuthtoken[0].Split(':')[1];
|
|
seToken.Email = saAuthtoken[1].Split(':')[1];
|
|
seToken.MemberID = saAuthtoken[1].Split(':')[1];
|
|
seToken.SignToken = saAuthtoken[2].Split(':')[1];
|
|
|
|
}
|
|
|
|
return seToken;
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|