< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Security.Tokens.SspiSecurityTokenParameters
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Security/Tokens/SspiSecurityTokenParameters.cs
Line coverage
72%
Covered lines: 26
Uncovered lines: 10
Coverable lines: 36
Total lines: 106
Line coverage: 72.2%
Branch coverage
75%
Covered branches: 6
Total branches: 8
Branch coverage: 75%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)100%22100%
.ctor()100%110%
.ctor(...)100%11100%
CloneCore()100%11100%
CreateKeyIdentifierClause(...)0%220%
InitializeSecurityTokenRequirement(...)100%22100%
ToString()100%110%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Security/Tokens/SspiSecurityTokenParameters.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;
 5using System.Globalization;
 6using System.Text;
 7using CoreWCF.Channels;
 8using CoreWCF.IdentityModel;
 9using CoreWCF.IdentityModel.Selectors;
 10using CoreWCF.IdentityModel.Tokens;
 11
 12namespace CoreWCF.Security.Tokens
 13{
 14    public class SspiSecurityTokenParameters : SecurityTokenParameters
 15    {
 16        internal const bool defaultRequireCancellation = false;
 17        private BindingContext _issuerBindingContext;
 18
 19        protected SspiSecurityTokenParameters(SspiSecurityTokenParameters other)
 3120            : base(other)
 21        {
 3122            RequireCancellation = other.RequireCancellation;
 3123            if (other._issuerBindingContext != null)
 24            {
 125                _issuerBindingContext = other._issuerBindingContext.Clone();
 26            }
 3127        }
 28
 29
 30        public SspiSecurityTokenParameters()
 031            : this(defaultRequireCancellation)
 32        {
 33            // empty
 034        }
 35
 36        public SspiSecurityTokenParameters(bool requireCancellation)
 237            : base()
 38        {
 239            RequireCancellation = requireCancellation;
 240        }
 41
 242        protected internal override bool HasAsymmetricKey { get { return false; } }
 43
 6644        public bool RequireCancellation { get; set; } = defaultRequireCancellation;
 45
 46        internal BindingContext IssuerBindingContext
 47        {
 48            get
 49            {
 250                return _issuerBindingContext;
 51            }
 52            set
 53            {
 154                if (value != null)
 55                {
 156                    value = value.Clone();
 57                }
 158                _issuerBindingContext = value;
 159            }
 60        }
 61
 1062        protected internal override bool SupportsClientAuthentication { get { return true; } }
 063        protected internal override bool SupportsServerAuthentication { get { return true; } }
 1064        protected internal override bool SupportsClientWindowsIdentity { get { return true; } }
 65
 66        protected override SecurityTokenParameters CloneCore()
 67        {
 3168            return new SspiSecurityTokenParameters(this);
 69        }
 70
 71        protected internal override SecurityKeyIdentifierClause CreateKeyIdentifierClause(SecurityToken token, SecurityT
 72        {
 073            if (token is GenericXmlSecurityToken)
 74            {
 075                return CreateGenericXmlTokenKeyIdentifierClause(token, referenceStyle);
 76            }
 77            else
 78            {
 079                return CreateKeyIdentifierClause<SecurityContextKeyIdentifierClause, LocalIdKeyIdentifierClause>(token, 
 80            }
 81        }
 82
 83        protected internal override void InitializeSecurityTokenRequirement(SecurityTokenRequirement requirement)
 84        {
 185            requirement.TokenType = ServiceModelSecurityTokenTypes.Spnego;
 186            requirement.RequireCryptographicToken = true;
 187            requirement.KeyType = SecurityKeyType.SymmetricKey;
 188            requirement.Properties[ServiceModelSecurityTokenRequirement.SupportSecurityContextCancellationProperty] = Re
 189            if (IssuerBindingContext != null)
 90            {
 191                requirement.Properties[ServiceModelSecurityTokenRequirement.IssuerBindingContextProperty] = IssuerBindin
 92            }
 193            requirement.Properties[ServiceModelSecurityTokenRequirement.IssuedSecurityTokenParametersProperty] = Clone()
 194        }
 95
 96        public override string ToString()
 97        {
 098            StringBuilder sb = new StringBuilder();
 099            sb.AppendLine(base.ToString());
 100
 0101            sb.Append(string.Format(CultureInfo.InvariantCulture, "RequireCancellation: {0}", RequireCancellation.ToStri
 102
 0103            return sb.ToString();
 104        }
 105    }
 106}