aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Web/Tango.MachineService/Security/RefreshTokenEncoder.cs
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2019-02-24 00:57:14 +0200
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2019-02-24 00:57:14 +0200
commit0adea9eb464a3f2d5d73b2c8c26d32e0d1a3874b (patch)
treebb5e4055020aa4417e1f7703a611353ce44689d6 /Software/Visual_Studio/Web/Tango.MachineService/Security/RefreshTokenEncoder.cs
parent17612c08da93c75d4c941a643bc7602c18f351d8 (diff)
downloadTango-0adea9eb464a3f2d5d73b2c8c26d32e0d1a3874b.tar.gz
Tango-0adea9eb464a3f2d5d73b2c8c26d32e0d1a3874b.zip
Working on refresh tokens...
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