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

  1. using Entity;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Net.Http;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace EasyBL.WEBAPP
  9. {
  10. public static class SETokenUtil
  11. {
  12. public static SEToken GetToken(HttpRequestMessage message) {
  13. SEToken seToken = new SEToken();
  14. IEnumerable<string> headerValues;
  15. if (message.Headers.TryGetValues("authtoken", out headerValues))
  16. {
  17. var token = headerValues.FirstOrDefault();
  18. seToken = Decrypt(token);
  19. }
  20. return seToken;
  21. }
  22. public static SEToken Decrypt(string data) {
  23. SEToken seToken = new SEToken();
  24. if (!string.IsNullOrEmpty(data)) {
  25. var authtoken = EasyNet.SecurityUtil.Decrypt(data);
  26. var saAuthtoken = authtoken.Split(',');
  27. seToken.OrgID = saAuthtoken[0].Split(':')[1];
  28. seToken.Email = saAuthtoken[1].Split(':')[1];
  29. seToken.MemberID = saAuthtoken[1].Split(':')[1];
  30. seToken.SignToken = saAuthtoken[2].Split(':')[1];
  31. }
  32. return seToken;
  33. }
  34. }
  35. }