Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
NetworkCredential.cs
Go to the documentation of this file.
4
5namespace System.Net;
6
8{
9 private string _domain;
10
11 private string _userName = string.Empty;
12
13 private object _password;
14
15 public string UserName
16 {
17 get
18 {
19 return _userName;
20 }
21 [param: AllowNull]
22 set
23 {
24 _userName = value ?? string.Empty;
25 }
26 }
27
28 public string Password
29 {
30 get
31 {
32 if (_password is SecureString sstr)
33 {
34 return MarshalToString(sstr);
35 }
36 return ((string)_password) ?? string.Empty;
37 }
38 [param: AllowNull]
39 set
40 {
41 SecureString secureString = _password as SecureString;
43 secureString?.Dispose();
44 }
45 }
46
47 [CLSCompliant(false)]
49 {
50 get
51 {
52 if (_password is string str)
53 {
55 }
56 if (!(_password is SecureString secureString))
57 {
58 return new SecureString();
59 }
60 return secureString.Copy();
61 }
62 [param: AllowNull]
63 set
64 {
65 SecureString secureString = _password as SecureString;
66 _password = value?.Copy();
67 secureString?.Dispose();
68 }
69 }
70
71 public string Domain
72 {
73 get
74 {
75 return _domain;
76 }
77 [MemberNotNull("_domain")]
78 [param: AllowNull]
79 set
80 {
81 _domain = value ?? string.Empty;
82 }
83 }
84
87 {
88 }
89
90 public NetworkCredential(string? userName, string? password)
91 : this(userName, password, string.Empty)
92 {
93 }
94
95 public NetworkCredential(string? userName, string? password, string? domain)
96 {
97 UserName = userName;
98 Password = password;
99 Domain = domain;
100 }
101
102 [CLSCompliant(false)]
103 public NetworkCredential(string? userName, SecureString? password)
104 : this(userName, password, string.Empty)
105 {
106 }
107
108 [CLSCompliant(false)]
109 public NetworkCredential(string? userName, SecureString? password, string? domain)
110 {
111 UserName = userName;
112 SecurePassword = password;
113 Domain = domain;
114 }
115
116 public NetworkCredential GetCredential(Uri? uri, string? authenticationType)
117 {
118 return this;
119 }
120
121 public NetworkCredential GetCredential(string? host, int port, string? authenticationType)
122 {
123 return this;
124 }
125
126 private string MarshalToString(SecureString sstr)
127 {
128 if (sstr == null || sstr.Length == 0)
129 {
130 return string.Empty;
131 }
132 IntPtr intPtr = IntPtr.Zero;
133 string empty = string.Empty;
134 try
135 {
137 return Marshal.PtrToStringUni(intPtr);
138 }
139 finally
140 {
141 if (intPtr != IntPtr.Zero)
142 {
144 }
145 }
146 }
147
149 {
150 if (string.IsNullOrEmpty(str))
151 {
152 return new SecureString();
153 }
154 fixed (char* value = str)
155 {
156 return new SecureString(value, str.Length);
157 }
158 }
159}
NetworkCredential(string? userName, string? password)
NetworkCredential(string? userName, string? password, string? domain)
NetworkCredential GetCredential(string? host, int port, string? authenticationType)
NetworkCredential GetCredential(Uri? uri, string? authenticationType)
unsafe SecureString MarshalToSecureString(string str)
NetworkCredential(string? userName, SecureString? password, string? domain)
NetworkCredential(string? userName, SecureString? password)
string MarshalToString(SecureString sstr)
static unsafe void ZeroFreeGlobalAllocUnicode(IntPtr s)
Definition Marshal.cs:1522
static IntPtr SecureStringToGlobalAllocUnicode(SecureString s)
Definition Marshal.cs:1284
static unsafe? string PtrToStringUni(IntPtr ptr)
Definition Marshal.cs:652
static readonly IntPtr Zero
Definition IntPtr.cs:18