< Summary

Line coverage
0%
Covered lines: 0
Uncovered lines: 30
Coverable lines: 30
Total lines: 57
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 18
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
GetAuthenticationPackageName(...)0%18180%

File(s)

https://raw.githubusercontent.com/dotnet/runtime/811a7eabb75c42db53440e8ba3f60c07511cfd1f/src/libraries/Common/src/Interop/Windows/SspiCli/NegotiationInfoClass.cs

#LineLine coverage
 1// Licensed to the .NET Foundation under one or more agreements.
 2// The .NET Foundation licenses this file to you under the MIT license.
 3
 4using System.Runtime.InteropServices;
 5
 6namespace System.Net
 7{
 8    // This class is used to determine if NTLM or
 9    // Kerberos are used in the context of a Negotiate handshake
 10    internal static partial class NegotiationInfoClass
 11    {
 12        internal static string? GetAuthenticationPackageName(SafeHandle safeHandle, int negotiationState)
 013        {
 014            if (safeHandle.IsInvalid)
 015            {
 016                if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(null, $"Invalid handle:{safeHandle}");
 017                return null;
 18            }
 19
 020            bool gotRef = false;
 21            try
 022            {
 023                safeHandle.DangerousAddRef(ref gotRef);
 024                IntPtr packageInfo = safeHandle.DangerousGetHandle();
 025                if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(null, $"packageInfo:{packageInfo} negotiationSta
 26
 027                if (negotiationState == Interop.SspiCli.SECPKG_NEGOTIATION_COMPLETE ||
 028                    negotiationState == Interop.SspiCli.SECPKG_NEGOTIATION_OPTIMISTIC)
 029                {
 30                    string? name;
 31                    unsafe
 032                    {
 033                        name = Marshal.PtrToStringUni(((SecurityPackageInfo*)packageInfo)->Name);
 034                    }
 35
 036                    if (NetEventSource.Log.IsEnabled()) NetEventSource.Info(null, $"packageInfo:{packageInfo} negotiatio
 37
 38                    // An optimization for future string comparisons.
 039                    return
 040                        string.Equals(name, Kerberos, StringComparison.OrdinalIgnoreCase) ? Kerberos :
 041                        string.Equals(name, NTLM, StringComparison.OrdinalIgnoreCase) ? NTLM :
 042                        name;
 43                }
 044            }
 45            finally
 046            {
 047                if (gotRef)
 048                {
 049                    safeHandle.DangerousRelease();
 050                }
 051            }
 52
 053            return null;
 054        }
 55    }
 56}
 57