aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Web/Tango.MachineService/Security/RefreshTokenEntity.cs
blob: 2788799aab9e732036e21861daff21ab36c4ad83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .g
using Microsoft.WindowsAzure.Storage.Table;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tango.MachineService.Security
{
    public class RefreshTokenEntity<T> : TableEntity where T : class
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="RefreshTokenEntity"/> class.
        /// </summary>
        public RefreshTokenEntity()
        {

        }


        public RefreshTokenEntity(String identity, String accessToken, String refreshToken, DateTime expiration, T obj)
        {
            PartitionKey = MachineServiceConfig.REFRESH_TOKENS_TABLE_PARTITION;

            Identity = identity;
            AccessToken = accessToken;
            RefreshToken = refreshToken;
            Expiration = expiration;

            RefreshTokenEncoder<T> encoder = new RefreshTokenEncoder<T>();
            Object = encoder.Encode(obj);
        }

        [IgnoreProperty]
        public String RefreshToken
        {
            get { return RowKey; }
            set { RowKey = value; }
        }

        public String Identity { get; set; }

        public String AccessToken { get; set; }

        public DateTime Expiration { get; set; }

        public String Object { get; set; }

        public T GetObject()
        {
            RefreshTokenEncoder<T> encoder = new RefreshTokenEncoder<T>();
            return encoder.Decode(RefreshToken);
        }
    }
}