< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.IdentityModel.Tokens.X509WindowsSecurityToken
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/IdentityModel/Tokens/X509WindowsSecurityToken.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 25
Coverable lines: 25
Total lines: 76
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 6
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)100%110%
.ctor(...)100%110%
.ctor(...)100%110%
.ctor(...)100%110%
.ctor(...)0%440%
Dispose()0%220%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/IdentityModel/Tokens/X509WindowsSecurityToken.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.Security.Cryptography.X509Certificates;
 5using System.Security.Principal;
 6using CoreWCF.Security;
 7
 8namespace CoreWCF.IdentityModel.Tokens
 9{
 10    internal class X509WindowsSecurityToken : X509SecurityToken
 11    {
 12        private WindowsIdentity _windowsIdentity;
 13        private bool _disposed = false;
 14
 15        public X509WindowsSecurityToken(X509Certificate2 certificate, WindowsIdentity windowsIdentity)
 016            : this(certificate, windowsIdentity, null, true)
 17        {
 018        }
 19
 20        public X509WindowsSecurityToken(X509Certificate2 certificate, WindowsIdentity windowsIdentity, string id)
 021            : this(certificate, windowsIdentity, null, id, true)
 22        {
 023        }
 24
 25        public X509WindowsSecurityToken(X509Certificate2 certificate, WindowsIdentity windowsIdentity, string authentica
 026            : this(certificate, windowsIdentity, authenticationType, id, true)
 27        {
 028        }
 29
 30        internal X509WindowsSecurityToken(X509Certificate2 certificate, WindowsIdentity windowsIdentity, string authenti
 031            : this(certificate, windowsIdentity, authenticationType, SecurityUniqueId.Create().Value, clone)
 32        {
 033        }
 34
 35        internal X509WindowsSecurityToken(X509Certificate2 certificate, WindowsIdentity windowsIdentity, string authenti
 036            : base(certificate, id, clone)
 37        {
 038            if (windowsIdentity == null)
 39            {
 040                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(windowsIdentity));
 41            }
 42
 043            AuthenticationType = authenticationType;
 044            _windowsIdentity = clone ? SecurityUtils.CloneWindowsIdentityIfNecessary(windowsIdentity, authenticationType
 045        }
 46
 47
 48        public WindowsIdentity WindowsIdentity
 49        {
 50            get
 51            {
 052                ThrowIfDisposed();
 053                return _windowsIdentity;
 54            }
 55        }
 56
 057        public string AuthenticationType { get; }
 58
 59        public override void Dispose()
 60        {
 61            try
 62            {
 063                if (!_disposed)
 64                {
 065                    _disposed = true;
 066                    _windowsIdentity.Dispose();
 067                    _windowsIdentity = null;
 68                }
 069            }
 70            finally
 71            {
 072                base.Dispose();
 073            }
 074        }
 75    }
 76}