aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.Shared/Updates/GetUpdatesAndPackagesRequest.cs
blob: f8cadc49d80d5292bc7f5ec9f458884cb614f7a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tango.PPC.Shared.Updates
{
    public class GetUpdatesAndPackagesRequest
    {

    }
}
icrosoft.WindowsAzure.Storage.Table; using System; using System.Collections.Generic; using System.Linq; using System.Security.Authentication; using System.Web; namespace Tango.MachineService.Security { public class TokenManager { private CloudTable GetTokensTable() { CloudStorageAccount storageAccount = CloudStorageAccount.Parse(MachineServiceConfig.STORAGE_ACCOUNT); var client = storageAccount.CreateCloudTableClient(); var table = client.GetTableReference("Tokens"); table.CreateIfNotExists(); return table; } public void AddToken(String token, String identity, DateTime expiration) { var table = GetTokensTable(); table.Execute(TableOperation.InsertOrReplace(new TokenEntity() { PartitionKey = MachineServiceConfig.REFRESH_TOKENS_TABLE_PARTITION, RowKey = Guid.NewGuid().ToString(), AccessToken = token, Identity = identity, Expiration = expiration, })); } public void UpdateToken(String oldToken, String newToken, DateTime expiration) { var table = GetTokensTable(); var existingToken = table.CreateQuery<TokenEntity>().AsQueryable().Where(x => x.AccessToken == oldToken).ToList().FirstOrDefault(); if (existingToken == null) { throw new AuthenticationException("Invalid token."); } existingToken.AccessToken = newToken; existingToken.Expiration = expiration; table.Execute(TableOperation.InsertOrMerge(existingToken)); } } }