-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIAppSettingsHelper.cs
More file actions
108 lines (88 loc) · 3.11 KB
/
IAppSettingsHelper.cs
File metadata and controls
108 lines (88 loc) · 3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
using System;
using System.Collections.Generic;
using System.Security.AccessControl;
using System.Security.Principal;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;
namespace OktaDemo
{
public interface IAppSettingsHelper
{
string GetBaseUrl();
void WriteSessionTokenInRegistry(string sessionToken);
void WriteOfflineMFA_AttemptCount(int offlineMFA_AttemptCount, string username);
string GetContactInfoText();
bool GetOfflineEnrollPromptValue(string username);
}
public class RegistryAppSettingsHelper : IAppSettingsHelper
{
private readonly SecurityHelper securityHelper;
public RegistryAppSettingsHelper(SecurityHelper securityHelper)
{
this.securityHelper = securityHelper;
}
public string GetBaseUrl()
{
string baseUrl = "https://tecnics-dev.oktapreview.com";
if (baseUrl != null)
{
return baseUrl;
}
else
{
throw new Exception("Base Url is not set in registry.");
}
}
public string GetContactInfoText()
{
throw new NotImplementedException();
}
public bool GetOfflineEnrollPromptValue(string username)
{
throw new NotImplementedException();
}
public void WriteOfflineMFA_AttemptCount(int offlineMFA_AttemptCount, string username)
{
throw new NotImplementedException();
}
public void WriteSessionTokenInRegistry(string sessionToken)
{
throw new NotImplementedException();
}
}
public class SignOnPolicyRegistryHelper
{
public void AssignDeviceTokenIfNotAssigned(string username)
{
this.AssignDeviceToken(username);
}
/*
public bool IsDeviceTokenAssigned(string username)
{
string registryPath = string.Format(Constants.USERS_REGISTRY_PATH_IN_SIGNON_POLICY + "\\" + username);
Tuple<bool, object> deviceToken = RegistryUtils.FindValueAtPath(Constants.DEVICE_TOKEN, registryPath);
return deviceToken.Item1;
}*/
public string GetAssignedDeviceToken(string username)
{
string deviceToken = CreateDeviceToken();
return deviceToken;
}
public string CreateDeviceToken()
{
return this.CreateGuidForDeviceToken();
}
public string CreateGuidForDeviceToken()
{
Guid guid = Guid.NewGuid();
return guid.ToString("N").ToUpper().Substring(0, 31);
}
public void AssignDeviceToken(string username)
{
string deviceToken = this.CreateDeviceToken();
//string registryPath = string.Format(Constants.USERS_REGISTRY_PATH_IN_SIGNON_POLICY + "\\" + username);
// RegistryUtils.WriteCredToRegistry(deviceToken, registryPath, Constants.DEVICE_TOKEN);
}
}
}