Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SSPIWrapper.cs
Go to the documentation of this file.
3
4namespace System.Net;
5
6internal static class SSPIWrapper
7{
9 {
10 if (secModule.SecurityPackages == null)
11 {
12 lock (secModule)
13 {
14 if (secModule.SecurityPackages == null)
15 {
16 int pkgnum = 0;
18 try
19 {
20 int num = secModule.EnumerateSecurityPackages(out pkgnum, out pkgArray);
21 if (System.Net.NetEventSource.Log.IsEnabled())
22 {
23 System.Net.NetEventSource.Info(null, $"arrayBase: {pkgArray}", "EnumerateSecurityPackages");
24 }
25 if (num != 0)
26 {
27 throw new Win32Exception(num);
28 }
30 for (int i = 0; i < pkgnum; i++)
31 {
32 array[i] = new System.Net.SecurityPackageInfoClass(pkgArray, i);
33 if (System.Net.NetEventSource.Log.IsEnabled())
34 {
35 System.Net.NetEventSource.Log.EnumerateSecurityPackages(array[i].Name);
36 }
37 }
38 secModule.SecurityPackages = array;
39 }
40 finally
41 {
42 pkgArray?.Dispose();
43 }
44 }
45 }
46 }
47 return secModule.SecurityPackages;
48 }
49
50 internal static System.Net.SecurityPackageInfoClass GetVerifyPackageInfo(System.Net.ISSPIInterface secModule, string packageName, bool throwIfMissing)
51 {
53 if (array != null)
54 {
55 for (int i = 0; i < array.Length; i++)
56 {
57 if (string.Equals(array[i].Name, packageName, StringComparison.OrdinalIgnoreCase))
58 {
59 return array[i];
60 }
61 }
62 }
63 if (System.Net.NetEventSource.Log.IsEnabled())
64 {
65 System.Net.NetEventSource.Log.SspiPackageNotFound(packageName);
66 }
67 if (throwIfMissing)
68 {
70 }
71 return null;
72 }
73
74 public static System.Net.Security.SafeFreeCredentials AcquireDefaultCredential(System.Net.ISSPIInterface secModule, string package, global::Interop.SspiCli.CredentialUse intent)
75 {
76 if (System.Net.NetEventSource.Log.IsEnabled())
77 {
78 System.Net.NetEventSource.Log.AcquireDefaultCredential(package, intent);
79 }
80 System.Net.Security.SafeFreeCredentials outCredential = null;
81 int num = secModule.AcquireDefaultCredential(package, intent, out outCredential);
82 if (num != 0)
83 {
84 if (System.Net.NetEventSource.Log.IsEnabled())
85 {
86 System.Net.NetEventSource.Error(null, System.SR.Format(System.SR.net_log_operation_failed_with_error, "AcquireDefaultCredential", $"0x{num:X}"), "AcquireDefaultCredential");
87 }
88 throw new Win32Exception(num);
89 }
90 return outCredential;
91 }
92
93 public static System.Net.Security.SafeFreeCredentials AcquireCredentialsHandle(System.Net.ISSPIInterface secModule, string package, global::Interop.SspiCli.CredentialUse intent, ref System.Net.Security.SafeSspiAuthDataHandle authdata)
94 {
95 if (System.Net.NetEventSource.Log.IsEnabled())
96 {
97 System.Net.NetEventSource.Log.AcquireCredentialsHandle(package, intent, authdata);
98 }
99 System.Net.Security.SafeFreeCredentials outCredential = null;
100 int num = secModule.AcquireCredentialsHandle(package, intent, ref authdata, out outCredential);
101 if (num != 0)
102 {
103 if (System.Net.NetEventSource.Log.IsEnabled())
104 {
105 System.Net.NetEventSource.Error(null, System.SR.Format(System.SR.net_log_operation_failed_with_error, "AcquireCredentialsHandle", $"0x{num:X}"), "AcquireCredentialsHandle");
106 }
107 throw new Win32Exception(num);
108 }
109 return outCredential;
110 }
111
112 internal static int InitializeSecurityContext(System.Net.ISSPIInterface secModule, ref System.Net.Security.SafeFreeCredentials credential, ref System.Net.Security.SafeDeleteSslContext context, string targetName, global::Interop.SspiCli.ContextFlags inFlags, global::Interop.SspiCli.Endianness datarep, System.Net.Security.InputSecurityBuffers inputBuffers, ref System.Net.Security.SecurityBuffer outputBuffer, ref global::Interop.SspiCli.ContextFlags outFlags)
113 {
114 if (System.Net.NetEventSource.Log.IsEnabled())
115 {
116 System.Net.NetEventSource.Log.InitializeSecurityContext(credential, context, targetName, inFlags);
117 }
118 int num = secModule.InitializeSecurityContext(ref credential, ref context, targetName, inFlags, datarep, inputBuffers, ref outputBuffer, ref outFlags);
119 if (System.Net.NetEventSource.Log.IsEnabled())
120 {
121 System.Net.NetEventSource.Log.SecurityContextInputBuffers("InitializeSecurityContext", inputBuffers.Count, outputBuffer.size, (global::Interop.SECURITY_STATUS)num);
122 }
123 return num;
124 }
125
126 internal static int AcceptSecurityContext(System.Net.ISSPIInterface secModule, System.Net.Security.SafeFreeCredentials credential, ref System.Net.Security.SafeDeleteSslContext context, global::Interop.SspiCli.ContextFlags inFlags, global::Interop.SspiCli.Endianness datarep, System.Net.Security.InputSecurityBuffers inputBuffers, ref System.Net.Security.SecurityBuffer outputBuffer, ref global::Interop.SspiCli.ContextFlags outFlags)
127 {
128 if (System.Net.NetEventSource.Log.IsEnabled())
129 {
130 System.Net.NetEventSource.Log.AcceptSecurityContext(credential, context, inFlags);
131 }
132 int num = secModule.AcceptSecurityContext(credential, ref context, inputBuffers, inFlags, datarep, ref outputBuffer, ref outFlags);
133 if (System.Net.NetEventSource.Log.IsEnabled())
134 {
135 System.Net.NetEventSource.Log.SecurityContextInputBuffers("AcceptSecurityContext", inputBuffers.Count, outputBuffer.size, (global::Interop.SECURITY_STATUS)num);
136 }
137 return num;
138 }
139
141 {
142 int num = secModule.CompleteAuthToken(ref context, in inputBuffer);
143 if (System.Net.NetEventSource.Log.IsEnabled())
144 {
145 System.Net.NetEventSource.Log.OperationReturnedSomething("CompleteAuthToken", (global::Interop.SECURITY_STATUS)num);
146 }
147 return num;
148 }
149}
static readonly System.Net.NetEventSource Log
static void Info(object thisOrContextObject, FormattableString formattableString=null, [CallerMemberName] string memberName=null)
static void Error(object thisOrContextObject, FormattableString formattableString, [CallerMemberName] string memberName=null)
static System.Net.Security.SafeFreeCredentials AcquireDefaultCredential(System.Net.ISSPIInterface secModule, string package, global::Interop.SspiCli.CredentialUse intent)
static System.Net.SecurityPackageInfoClass GetVerifyPackageInfo(System.Net.ISSPIInterface secModule, string packageName, bool throwIfMissing)
static int InitializeSecurityContext(System.Net.ISSPIInterface secModule, ref System.Net.Security.SafeFreeCredentials credential, ref System.Net.Security.SafeDeleteSslContext context, string targetName, global::Interop.SspiCli.ContextFlags inFlags, global::Interop.SspiCli.Endianness datarep, System.Net.Security.InputSecurityBuffers inputBuffers, ref System.Net.Security.SecurityBuffer outputBuffer, ref global::Interop.SspiCli.ContextFlags outFlags)
static int CompleteAuthToken(System.Net.ISSPIInterface secModule, ref System.Net.Security.SafeDeleteSslContext context, in System.Net.Security.SecurityBuffer inputBuffer)
static int AcceptSecurityContext(System.Net.ISSPIInterface secModule, System.Net.Security.SafeFreeCredentials credential, ref System.Net.Security.SafeDeleteSslContext context, global::Interop.SspiCli.ContextFlags inFlags, global::Interop.SspiCli.Endianness datarep, System.Net.Security.InputSecurityBuffers inputBuffers, ref System.Net.Security.SecurityBuffer outputBuffer, ref global::Interop.SspiCli.ContextFlags outFlags)
static System.Net.SecurityPackageInfoClass[] EnumerateSecurityPackages(System.Net.ISSPIInterface secModule)
Definition SSPIWrapper.cs:8
static System.Net.Security.SafeFreeCredentials AcquireCredentialsHandle(System.Net.ISSPIInterface secModule, string package, global::Interop.SspiCli.CredentialUse intent, ref System.Net.Security.SafeSspiAuthDataHandle authdata)
static unsafe int AcquireDefaultCredential(string package, global::Interop.SspiCli.CredentialUse intent, out System.Net.Security.SafeFreeCredentials outCredential)
static unsafe int AcquireCredentialsHandle(string package, global::Interop.SspiCli.CredentialUse intent, ref System.Net.Security.SafeSspiAuthDataHandle authdata, out System.Net.Security.SafeFreeCredentials outCredential)
static string net_securitypackagesupport
Definition SR.cs:156
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string net_log_operation_failed_with_error
Definition SR.cs:154
Definition SR.cs:7