Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit baca839

Browse files
committed
First commit
0 parents  commit baca839

109 files changed

Lines changed: 32190 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto
3+
4+
# Custom for Visual Studio
5+
*.cs diff=csharp
6+
*.sln merge=union
7+
*.csproj merge=union
8+
*.vbproj merge=union
9+
*.fsproj merge=union
10+
*.dbproj merge=union
11+
12+
# Standard to msysgit
13+
*.doc diff=astextplain
14+
*.DOC diff=astextplain
15+
*.docx diff=astextplain
16+
*.DOCX diff=astextplain
17+
*.dot diff=astextplain
18+
*.DOT diff=astextplain
19+
*.pdf diff=astextplain
20+
*.PDF diff=astextplain
21+
*.rtf diff=astextplain
22+
*.RTF diff=astextplain

.gitignore

Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
## Ignore Visual Studio temporary files, build results, and
2+
## files generated by popular Visual Studio add-ons.
3+
4+
# User-specific files
5+
*.suo
6+
*.user
7+
*.sln.docstates
8+
9+
# Build results
10+
[Dd]ebug/
11+
[Dd]ebugPublic/
12+
[Rr]elease/
13+
x64/
14+
build/
15+
bld/
16+
[Bb]in/
17+
[Oo]bj/
18+
19+
# MSTest test Results
20+
[Tt]est[Rr]esult*/
21+
[Bb]uild[Ll]og.*
22+
23+
#NUNIT
24+
*.VisualState.xml
25+
TestResult.xml
26+
27+
# Build Results of an ATL Project
28+
[Dd]ebugPS/
29+
[Rr]eleasePS/
30+
dlldata.c
31+
32+
*_i.c
33+
*_p.c
34+
*_i.h
35+
*.ilk
36+
*.meta
37+
*.obj
38+
*.pch
39+
*.pdb
40+
*.pgc
41+
*.pgd
42+
*.rsp
43+
*.sbr
44+
*.tlb
45+
*.tli
46+
*.tlh
47+
*.tmp
48+
*.tmp_proj
49+
*.log
50+
*.vspscc
51+
*.vssscc
52+
.builds
53+
*.pidb
54+
*.svclog
55+
*.scc
56+
57+
# Chutzpah Test files
58+
_Chutzpah*
59+
60+
# Visual C++ cache files
61+
ipch/
62+
*.aps
63+
*.ncb
64+
*.opensdf
65+
*.sdf
66+
*.cachefile
67+
68+
# Visual Studio profiler
69+
*.psess
70+
*.vsp
71+
*.vspx
72+
73+
# TFS 2012 Local Workspace
74+
$tf/
75+
76+
# Guidance Automation Toolkit
77+
*.gpState
78+
79+
# ReSharper is a .NET coding add-in
80+
_ReSharper*/
81+
*.[Rr]e[Ss]harper
82+
*.DotSettings.user
83+
84+
# JustCode is a .NET coding addin-in
85+
.JustCode
86+
87+
# TeamCity is a build add-in
88+
_TeamCity*
89+
90+
# DotCover is a Code Coverage Tool
91+
*.dotCover
92+
93+
# NCrunch
94+
*.ncrunch*
95+
_NCrunch_*
96+
.*crunch*.local.xml
97+
98+
# MightyMoose
99+
*.mm.*
100+
AutoTest.Net/
101+
102+
# Web workbench (sass)
103+
.sass-cache/
104+
105+
# Installshield output folder
106+
[Ee]xpress/
107+
108+
# DocProject is a documentation generator add-in
109+
DocProject/buildhelp/
110+
DocProject/Help/*.HxT
111+
DocProject/Help/*.HxC
112+
DocProject/Help/*.hhc
113+
DocProject/Help/*.hhk
114+
DocProject/Help/*.hhp
115+
DocProject/Help/Html2
116+
DocProject/Help/html
117+
118+
# Click-Once directory
119+
publish/
120+
121+
# Publish Web Output
122+
*.[Pp]ublish.xml
123+
*.azurePubxml
124+
125+
# NuGet Packages Directory
126+
packages/
127+
## TODO: If the tool you use requires repositories.config uncomment the next line
128+
#!packages/repositories.config
129+
130+
# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
131+
# This line needs to be after the ignore of the build folder (and the packages folder if the line above has been uncommented)
132+
!packages/build/
133+
134+
# Windows Azure Build Output
135+
csx/
136+
*.build.csdef
137+
138+
# Windows Store app package directory
139+
AppPackages/
140+
141+
# Others
142+
sql/
143+
*.Cache
144+
ClientBin/
145+
[Ss]tyle[Cc]op.*
146+
~$*
147+
*~
148+
*.dbmdl
149+
*.dbproj.schemaview
150+
*.pfx
151+
*.publishsettings
152+
node_modules/
153+
154+
# RIA/Silverlight projects
155+
Generated_Code/
156+
157+
# Backup & report files from converting an old project file to a newer
158+
# Visual Studio version. Backup files are not needed, because we have git ;-)
159+
_UpgradeReport_Files/
160+
Backup*/
161+
UpgradeLog*.XML
162+
UpgradeLog*.htm
163+
164+
# SQL Server files
165+
*.mdf
166+
*.ldf
167+
168+
# Business Intelligence projects
169+
*.rdl.data
170+
*.bim.layout
171+
*.bim_*.settings
172+
173+
# Microsoft Fakes
174+
FakesAssemblies/
175+
176+
# =========================
177+
# Operating System Files
178+
# =========================
179+
180+
# OSX
181+
# =========================
182+
183+
.DS_Store
184+
.AppleDouble
185+
.LSOverride
186+
187+
# Icon must ends with two \r.
188+
Icon
189+
190+
# Thumbnails
191+
._*
192+
193+
# Files that might appear on external disk
194+
.Spotlight-V100
195+
.Trashes
196+
197+
# Windows
198+
# =========================
199+
200+
# Windows image file caches
201+
Thumbs.db
202+
ehthumbs.db
203+
204+
# Folder config file
205+
Desktop.ini
206+
207+
# Recycle Bin used on file shares
208+
$RECYCLE.BIN/
209+
210+
# Windows Installer files
211+
*.cab
212+
*.msi
213+
*.msm
214+
*.msp

NativeClient-Headless-DotNet.sln

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 2013
4+
VisualStudioVersion = 12.0.30501.0
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TodoListService", "TodoListService\TodoListService.csproj", "{047CDEF7-D5BA-4B1E-9748-910B610CCA51}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TodoListClient", "TodoListClient\TodoListClient.csproj", "{42FDCB9B-1B01-40DA-9F34-1182A31AAA56}"
9+
EndProject
10+
Global
11+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
Debug|Any CPU = Debug|Any CPU
13+
Release|Any CPU = Release|Any CPU
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{047CDEF7-D5BA-4B1E-9748-910B610CCA51}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17+
{047CDEF7-D5BA-4B1E-9748-910B610CCA51}.Debug|Any CPU.Build.0 = Debug|Any CPU
18+
{047CDEF7-D5BA-4B1E-9748-910B610CCA51}.Release|Any CPU.ActiveCfg = Release|Any CPU
19+
{047CDEF7-D5BA-4B1E-9748-910B610CCA51}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{42FDCB9B-1B01-40DA-9F34-1182A31AAA56}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{42FDCB9B-1B01-40DA-9F34-1182A31AAA56}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{42FDCB9B-1B01-40DA-9F34-1182A31AAA56}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{42FDCB9B-1B01-40DA-9F34-1182A31AAA56}.Release|Any CPU.Build.0 = Release|Any CPU
24+
EndGlobalSection
25+
GlobalSection(SolutionProperties) = preSolution
26+
HideSolutionNode = FALSE
27+
EndGlobalSection
28+
EndGlobal

TodoListClient/App.config

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
5+
</startup>
6+
<appSettings>
7+
<add key="ida:AADInstance" value="https://login.windows.net/{0}" />
8+
<add key="ida:Tenant" value="developertenant.onmicrosoft.com" />
9+
<add key="ida:ClientId" value="83a417dd-2860-41ec-a4d0-178d4064d5f0" />
10+
<add key="ida:RedirectUri" value="http://BasicTodoListClient" />
11+
<add key="todo:TodoListResourceId" value="https://developertenant.onmicrosoft.com/BasicTodoService" />
12+
<add key="todo:TodoListBaseAddress" value="https://localhost:44321" />
13+
<!-- <add key="ida:AADInstance" value="https://login.windows.net/{0}" />
14+
<add key="ida:Tenant" value="[Enter tenant name, e.g. contoso.onmicrosoft.com]" />
15+
<add key="ida:ClientId" value="[Enter client ID as obtained from Azure Portal, e.g. 82692da5-a86f-44c9-9d53-2f88d52b478b]" />
16+
<add key="ida:RedirectUri" value="[Enter redirect URI as entered in Azure Portal, e.g. http://TodoListClient]" />
17+
<add key="todo:TodoListResourceId" value="[Enter App ID URI of TodoListService, e.g. https://contoso.onmicrosoft.com/TodoListService]" />
18+
<add key="todo:TodoListBaseAddress" value="https://localhost:44321" />-->
19+
</appSettings>
20+
</configuration>

TodoListClient/FileCache.cs

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Security.Cryptography;
7+
using Microsoft.IdentityModel.Clients.ActiveDirectory;
8+
using System.IO;
9+
10+
namespace TodoListClient
11+
{
12+
class FileCache : TokenCache
13+
{
14+
public string CacheFilePath;
15+
private static readonly object FileLock = new object();
16+
17+
// Initializes the cache against a local file.
18+
// If the file is already present, it loads its content in the ADAL cache
19+
public FileCache(string filePath = @".\TokenCache.dat")
20+
{
21+
CacheFilePath = filePath;
22+
this.AfterAccess = AfterAccessNotification;
23+
this.BeforeAccess = BeforeAccessNotification;
24+
lock (FileLock)
25+
{
26+
this.Deserialize(File.Exists(CacheFilePath) ? ProtectedData.Unprotect(File.ReadAllBytes(CacheFilePath), null, DataProtectionScope.CurrentUser) : null);
27+
}
28+
}
29+
30+
// Empties the persistent store.
31+
public override void Clear()
32+
{
33+
base.Clear();
34+
File.Delete(CacheFilePath);
35+
}
36+
37+
// Triggered right before ADAL needs to access the cache.
38+
// Reload the cache from the persistent store in case it changed since the last access.
39+
void BeforeAccessNotification(TokenCacheNotificationArgs args)
40+
{
41+
lock (FileLock)
42+
{
43+
this.Deserialize(File.Exists(CacheFilePath) ? ProtectedData.Unprotect(File.ReadAllBytes(CacheFilePath), null, DataProtectionScope.CurrentUser) : null);
44+
}
45+
}
46+
47+
// Triggered right after ADAL accessed the cache.
48+
void AfterAccessNotification(TokenCacheNotificationArgs args)
49+
{
50+
// if the access operation resulted in a cache update
51+
if (this.HasStateChanged)
52+
{
53+
lock (FileLock)
54+
{
55+
// reflect changes in the persistent store
56+
File.WriteAllBytes(CacheFilePath, ProtectedData.Protect(this.Serialize(), null, DataProtectionScope.CurrentUser));
57+
// once the write operation took place, restore the HasStateChanged bit to false
58+
this.HasStateChanged = false;
59+
}
60+
}
61+
}
62+
}
63+
}

0 commit comments

Comments
 (0)