< Summary

Line coverage
0%
Covered lines: 0
Uncovered lines: 71
Coverable lines: 71
Total lines: 108
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 8
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.cctor()0%220%
GetSecurityStatusPalFromNativeInt(...)100%110%
GetSecurityStatusPalFromInterop(...)0%440%
GetInteropFromSecurityStatusPal(...)0%220%

File(s)

https://raw.githubusercontent.com/dotnet/runtime/811a7eabb75c42db53440e8ba3f60c07511cfd1f/src/libraries/System.Net.Security/src/System/Net/SecurityStatusAdapterPal.Windows.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.Collections.Generic;
 5using System.ComponentModel;
 6using System.Diagnostics;
 7
 8namespace System.Net
 9{
 10    internal static class SecurityStatusAdapterPal
 11    {
 12        private const int StatusDictionarySize = 46;
 13
 14#if DEBUG
 15        static SecurityStatusAdapterPal()
 016        {
 017            Debug.Assert(s_statusDictionary.Count == StatusDictionarySize, $"Expected size {StatusDictionarySize}, got s
 018        }
 19#endif
 20
 021        private static readonly BidirectionalDictionary<Interop.SECURITY_STATUS, SecurityStatusPalErrorCode> s_statusDic
 022        {
 023            { Interop.SECURITY_STATUS.AlgorithmMismatch, SecurityStatusPalErrorCode.AlgorithmMismatch },
 024            { Interop.SECURITY_STATUS.ApplicationProtocolMismatch, SecurityStatusPalErrorCode.ApplicationProtocolMismatc
 025            { Interop.SECURITY_STATUS.BadBinding, SecurityStatusPalErrorCode.BadBinding },
 026            { Interop.SECURITY_STATUS.BufferNotEnough, SecurityStatusPalErrorCode.BufferNotEnough },
 027            { Interop.SECURITY_STATUS.CannotInstall, SecurityStatusPalErrorCode.CannotInstall },
 028            { Interop.SECURITY_STATUS.CannotPack, SecurityStatusPalErrorCode.CannotPack },
 029            { Interop.SECURITY_STATUS.CertExpired, SecurityStatusPalErrorCode.CertExpired },
 030            { Interop.SECURITY_STATUS.CertUnknown, SecurityStatusPalErrorCode.CertUnknown },
 031            { Interop.SECURITY_STATUS.CompAndContinue, SecurityStatusPalErrorCode.CompAndContinue },
 032            { Interop.SECURITY_STATUS.CompleteNeeded, SecurityStatusPalErrorCode.CompleteNeeded },
 033            { Interop.SECURITY_STATUS.ContextExpired, SecurityStatusPalErrorCode.ContextExpired },
 034            { Interop.SECURITY_STATUS.ContextExpiredError, SecurityStatusPalErrorCode.ContextExpiredError },
 035            { Interop.SECURITY_STATUS.ContinueNeeded, SecurityStatusPalErrorCode.ContinueNeeded },
 036            { Interop.SECURITY_STATUS.CredentialsNeeded, SecurityStatusPalErrorCode.CredentialsNeeded },
 037            { Interop.SECURITY_STATUS.DecryptFailure, SecurityStatusPalErrorCode.DecryptFailure },
 038            { Interop.SECURITY_STATUS.DowngradeDetected, SecurityStatusPalErrorCode.DowngradeDetected },
 039            { Interop.SECURITY_STATUS.IllegalMessage, SecurityStatusPalErrorCode.IllegalMessage },
 040            { Interop.SECURITY_STATUS.IncompleteCredentials, SecurityStatusPalErrorCode.IncompleteCredentials },
 041            { Interop.SECURITY_STATUS.IncompleteMessage, SecurityStatusPalErrorCode.IncompleteMessage },
 042            { Interop.SECURITY_STATUS.InternalError, SecurityStatusPalErrorCode.InternalError },
 043            { Interop.SECURITY_STATUS.InvalidHandle, SecurityStatusPalErrorCode.InvalidHandle },
 044            { Interop.SECURITY_STATUS.InvalidToken, SecurityStatusPalErrorCode.InvalidToken },
 045            { Interop.SECURITY_STATUS.LogonDenied, SecurityStatusPalErrorCode.LogonDenied },
 046            { Interop.SECURITY_STATUS.MessageAltered, SecurityStatusPalErrorCode.MessageAltered },
 047            { Interop.SECURITY_STATUS.MutualAuthFailed, SecurityStatusPalErrorCode.MutualAuthFailed },
 048            { Interop.SECURITY_STATUS.NoAuthenticatingAuthority, SecurityStatusPalErrorCode.NoAuthenticatingAuthority },
 049            { Interop.SECURITY_STATUS.NoImpersonation, SecurityStatusPalErrorCode.NoImpersonation },
 050            { Interop.SECURITY_STATUS.NoCredentials, SecurityStatusPalErrorCode.NoCredentials },
 051            { Interop.SECURITY_STATUS.NotOwner, SecurityStatusPalErrorCode.NotOwner },
 052            { Interop.SECURITY_STATUS.OK, SecurityStatusPalErrorCode.OK },
 053            { Interop.SECURITY_STATUS.OutOfMemory, SecurityStatusPalErrorCode.OutOfMemory },
 054            { Interop.SECURITY_STATUS.OutOfSequence, SecurityStatusPalErrorCode.OutOfSequence },
 055            { Interop.SECURITY_STATUS.PackageNotFound, SecurityStatusPalErrorCode.PackageNotFound },
 056            { Interop.SECURITY_STATUS.QopNotSupported, SecurityStatusPalErrorCode.QopNotSupported },
 057            { Interop.SECURITY_STATUS.Renegotiate, SecurityStatusPalErrorCode.Renegotiate },
 058            { Interop.SECURITY_STATUS.SecurityQosFailed, SecurityStatusPalErrorCode.SecurityQosFailed },
 059            { Interop.SECURITY_STATUS.SmartcardLogonRequired, SecurityStatusPalErrorCode.SmartcardLogonRequired },
 060            { Interop.SECURITY_STATUS.TargetUnknown, SecurityStatusPalErrorCode.TargetUnknown },
 061            { Interop.SECURITY_STATUS.TimeSkew, SecurityStatusPalErrorCode.TimeSkew },
 062            { Interop.SECURITY_STATUS.UnknownCredentials, SecurityStatusPalErrorCode.UnknownCredentials },
 063            { Interop.SECURITY_STATUS.UnsupportedPreauth, SecurityStatusPalErrorCode.UnsupportedPreauth },
 064            { Interop.SECURITY_STATUS.Unsupported, SecurityStatusPalErrorCode.Unsupported },
 065            { Interop.SECURITY_STATUS.UntrustedRoot, SecurityStatusPalErrorCode.UntrustedRoot },
 066            { Interop.SECURITY_STATUS.WrongPrincipal, SecurityStatusPalErrorCode.WrongPrincipal },
 067            { Interop.SECURITY_STATUS.NoRenegotiation, SecurityStatusPalErrorCode.NoRenegotiation },
 068            { Interop.SECURITY_STATUS.KeySetDoesNotExist, SecurityStatusPalErrorCode.KeySetDoesNotExist }
 069        };
 70
 71        internal static SecurityStatusPal GetSecurityStatusPalFromNativeInt(int win32SecurityStatus)
 072        {
 073            return GetSecurityStatusPalFromInterop((Interop.SECURITY_STATUS)win32SecurityStatus);
 074        }
 75
 76        internal static SecurityStatusPal GetSecurityStatusPalFromInterop(Interop.SECURITY_STATUS win32SecurityStatus, b
 077        {
 78            SecurityStatusPalErrorCode statusCode;
 79
 080            if (!s_statusDictionary.TryGetForward(win32SecurityStatus, out statusCode))
 081            {
 082                Debug.Fail("Unknown Interop.SecurityStatus value: " + win32SecurityStatus);
 83                throw new InternalException(win32SecurityStatus);
 84            }
 85
 086            if (attachException)
 087            {
 088                return new SecurityStatusPal(statusCode, new Win32Exception((int)win32SecurityStatus));
 89            }
 90            else
 091            {
 092                return new SecurityStatusPal(statusCode);
 93            }
 094        }
 95
 96        internal static Interop.SECURITY_STATUS GetInteropFromSecurityStatusPal(SecurityStatusPal status)
 097        {
 98            Interop.SECURITY_STATUS interopStatus;
 099            if (!s_statusDictionary.TryGetBackward(status.ErrorCode, out interopStatus))
 0100            {
 0101                Debug.Fail("Unknown SecurityStatus value: " + status);
 102                throw new InternalException(status.ErrorCode);
 103            }
 0104            return interopStatus;
 0105        }
 106    }
 107}
 108