Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
NegotiationInfoClass.cs
Go to the documentation of this file.
2
3namespace System.Net;
4
5internal static class NegotiationInfoClass
6{
7 internal unsafe static string GetAuthenticationPackageName(SafeHandle safeHandle, int negotiationState)
8 {
9 if (safeHandle.IsInvalid)
10 {
11 if (System.Net.NetEventSource.Log.IsEnabled())
12 {
13 System.Net.NetEventSource.Info(null, $"Invalid handle:{safeHandle}", "GetAuthenticationPackageName");
14 }
15 return null;
16 }
17 bool success = false;
18 try
19 {
20 safeHandle.DangerousAddRef(ref success);
21 IntPtr intPtr = safeHandle.DangerousGetHandle();
22 if (System.Net.NetEventSource.Log.IsEnabled())
23 {
24 System.Net.NetEventSource.Info(null, $"packageInfo:{intPtr} negotiationState:{negotiationState:x}", "GetAuthenticationPackageName");
25 }
26 if (negotiationState == 0 || negotiationState == 1)
27 {
28 string text = Marshal.PtrToStringUni(((SecurityPackageInfo*)(void*)intPtr)->Name);
29 if (System.Net.NetEventSource.Log.IsEnabled())
30 {
31 System.Net.NetEventSource.Info(null, $"packageInfo:{intPtr} negotiationState:{negotiationState:x} name:{text}", "GetAuthenticationPackageName");
32 }
33 return string.Equals(text, "Kerberos", StringComparison.OrdinalIgnoreCase) ? "Kerberos" : (string.Equals(text, "NTLM", StringComparison.OrdinalIgnoreCase) ? "NTLM" : text);
34 }
35 }
36 finally
37 {
38 if (success)
39 {
40 safeHandle.DangerousRelease();
41 }
42 }
43 return null;
44 }
45}
static unsafe string GetAuthenticationPackageName(SafeHandle safeHandle, int negotiationState)
static readonly System.Net.NetEventSource Log
static void Info(object thisOrContextObject, FormattableString formattableString=null, [CallerMemberName] string memberName=null)
static unsafe? string PtrToStringUni(IntPtr ptr)
Definition Marshal.cs:652
void DangerousAddRef(ref bool success)
Definition SafeHandle.cs:76