< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Security.Tokens.WindowsSidIdentity
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Security/Tokens/WindowsSidIdentity.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 21
Coverable lines: 21
Total lines: 67
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 14
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(...)0%220%
.ctor(...)0%660%
Equals(...)0%440%
GetHashCode()100%110%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Security/Tokens/WindowsSidIdentity.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.Principal;
 5
 6namespace CoreWCF.Security.Tokens
 7{
 8    internal class WindowsSidIdentity : IIdentity
 9    {
 10        private string _name;
 11
 012        public WindowsSidIdentity(SecurityIdentifier sid)
 13        {
 014            SecurityIdentifier = sid ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(sid));
 015            AuthenticationType = string.Empty;
 016        }
 17
 018        public WindowsSidIdentity(SecurityIdentifier sid, string name, string authenticationType)
 19        {
 020            SecurityIdentifier = sid ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(sid));
 021            _name = name ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(name));
 022            AuthenticationType = authenticationType ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(
 023        }
 24
 025        public SecurityIdentifier SecurityIdentifier { get; }
 26
 027        public string AuthenticationType { get; }
 28
 29        public bool IsAuthenticated
 30        {
 031            get { return true; }
 32        }
 33
 34        public string Name
 35        {
 36            get
 37            {
 038                if (_name == null)
 39                {
 040                    _name = ((NTAccount)SecurityIdentifier.Translate(typeof(NTAccount))).Value;
 41                }
 42
 043                return _name;
 44            }
 45        }
 46
 47        public override bool Equals(object obj)
 48        {
 049            if (ReferenceEquals(this, obj))
 50            {
 051                return true;
 52            }
 53
 054            if (!(obj is WindowsSidIdentity sidIdentity))
 55            {
 056                return false;
 57            }
 58
 059            return SecurityIdentifier == sidIdentity.SecurityIdentifier;
 60        }
 61
 62        public override int GetHashCode()
 63        {
 064            return SecurityIdentifier.GetHashCode();
 65        }
 66    }
 67}