123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.AspNetCore.Http;
- using Microsoft.Extensions.Logging;
- using Microsoft.Extensions.Options;
- using System.Web;
- using MySystem.MainModels;
- using LitJson;
- using Library;
- using Microsoft.IdentityModel.Tokens;
- using System.Text;
- using System.Security.Claims;
- using System.IdentityModel.Tokens.Jwt;
- namespace MySystem.Areas.Api.Controllers
- {
- [Area("Api")]
- [Route("Api/[controller]/[action]")]
- public class SystemSetController : BaseController
- {
- public SystemSetController(IHttpContextAccessor accessor, ILogger<BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
- {
- }
- #region 验证获取jwt的token
- public JsonResult AppCheck(string value)
- {
- value = DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- string uuid = data["uuid"].ToString();
- string salt = data["salt"].ToString();
- string u = function.MD5_16(uuid + salt);
- Dictionary<string, object> Obj = new Dictionary<string, object>();
- //生成jwt令牌
- Obj.Add("Token", PublicFunction.AppToken(u, JwtSecret, JwtIss, "consumer"));
- return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
- }
- #endregion
- #region 检查签名是否合法,合法返回1,不合法返回提示信息
- /// <summary>
- /// 检查签名是否合法,合法返回1,不合法返回提示信息
- /// </summary>
- /// <param name="value">请求的参数(json字符串)</param>
- /// <param name="signField">要签名的字段</param>
- /// <returns></returns>
- private string CheckSign(string value, string[] signField)
- {
- JsonData json = JsonMapper.ToObject(value);
- Dictionary<string, string> dic = new Dictionary<string, string>();
- for (int i = 0; i < signField.Length; i++)
- {
- dic.Add(signField[i], json[signField[i]].ToString());
- }
- string sign = json["sign"].ToString(); //客户端签名字符串
- return new Sign().sign(dic, sign);
- }
- #endregion
- }
- }
|