aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Web/Tango.MachineService/Security/RefreshTokenEncoder.cs
diff options
context:
space:
mode:
authorAvi Levkovich <avi@twine-s.com>2019-02-24 10:54:16 +0200
committerAvi Levkovich <avi@twine-s.com>2019-02-24 10:54:16 +0200
commit682018018e817ae15e9ab7f38a5d923b41c8cf9a (patch)
tree799bcb84d8c0443c3cd91b576c95c73c06fa4a42 /Software/Visual_Studio/Web/Tango.MachineService/Security/RefreshTokenEncoder.cs
parent9650a4bd82398bcece7fb054c79f73996cd2d664 (diff)
parent028ab0e5cc2699ceec3e04b1eeab5f56b9b38083 (diff)
downloadTango-682018018e817ae15e9ab7f38a5d923b41c8cf9a.tar.gz
Tango-682018018e817ae15e9ab7f38a5d923b41c8cf9a.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/Web/Tango.MachineService/Security/RefreshTokenEncoder.cs')
-rw-r--r--Software/Visual_Studio/Web/Tango.MachineService/Security/RefreshTokenEncoder.cs26
1 files changed, 26 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Security/RefreshTokenEncoder.cs b/Software/Visual_Studio/Web/Tango.MachineService/Security/RefreshTokenEncoder.cs
new file mode 100644
index 000000000..3948ae1c4
--- /dev/null
+++ b/Software/Visual_Studio/Web/Tango.MachineService/Security/RefreshTokenEncoder.cs
@@ -0,0 +1,26 @@
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using Tango.Core.Cryptography;
+
+namespace Tango.MachineService.Security
+{
+ public class RefreshTokenEncoder<T>
+ {
+ public String Encode(T obj)
+ {
+ String str = obj.ToJsonString();
+ Rfc2898Cryptographer crypt = new Rfc2898Cryptographer();
+ return crypt.Encrypt(str);
+ }
+
+ public T Decode(String token)
+ {
+ Rfc2898Cryptographer crypt = new Rfc2898Cryptographer();
+ String str = crypt.Decrypt(token);
+ return JsonConvert.DeserializeObject<T>(str);
+ }
+ }
+} \ No newline at end of file