< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Security.Tokens.SslSecurityTokenParameters
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Security/Tokens/SslSecurityTokenParameters.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 42
Coverable lines: 42
Total lines: 117
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 10
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()100%110%
.ctor(...)100%110%
.ctor(...)100%110%
CloneCore()100%110%
CreateKeyIdentifierClause(...)0%220%
InitializeSecurityTokenRequirement(...)0%440%
ToString()100%110%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Security/Tokens/SslSecurityTokenParameters.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 SslSecurityTokenParameters : SecurityTokenParameters
 15    {
 16        internal const bool defaultRequireClientCertificate = false;
 17        internal const bool defaultRequireCancellation = false;
 18        private BindingContext _issuerBindingContext;
 19
 20        protected SslSecurityTokenParameters(SslSecurityTokenParameters other)
 021            : base(other)
 22        {
 023            RequireClientCertificate = other.RequireClientCertificate;
 024            RequireCancellation = other.RequireCancellation;
 025            if (other._issuerBindingContext != null)
 26            {
 027                _issuerBindingContext = other._issuerBindingContext.Clone();
 28            }
 029        }
 30
 31        public SslSecurityTokenParameters()
 032            : this(defaultRequireClientCertificate)
 33        {
 34            // empty
 035        }
 36
 37        public SslSecurityTokenParameters(bool requireClientCertificate)
 038            : this(requireClientCertificate, defaultRequireCancellation)
 39        {
 40            // empty
 041        }
 42
 43        public SslSecurityTokenParameters(bool requireClientCertificate, bool requireCancellation)
 044            : base()
 45        {
 046            RequireClientCertificate = requireClientCertificate;
 047            RequireCancellation = requireCancellation;
 048        }
 49
 050        protected internal override bool HasAsymmetricKey { get { return false; } }
 51
 052        public bool RequireCancellation { get; set; } = defaultRequireCancellation;
 53
 054        public bool RequireClientCertificate { get; set; }
 55
 56        internal BindingContext IssuerBindingContext
 57        {
 58            get
 59            {
 060                return _issuerBindingContext;
 61            }
 62            set
 63            {
 064                if (value != null)
 65                {
 066                    value = value.Clone();
 67                }
 068                _issuerBindingContext = value;
 069            }
 70        }
 71
 072        protected internal override bool SupportsClientAuthentication { get { return RequireClientCertificate; } }
 073        protected internal override bool SupportsServerAuthentication { get { return true; } }
 074        protected internal override bool SupportsClientWindowsIdentity { get { return RequireClientCertificate; } }
 75
 76        protected override SecurityTokenParameters CloneCore()
 77        {
 078            return new SslSecurityTokenParameters(this);
 79        }
 80
 81        protected internal override SecurityKeyIdentifierClause CreateKeyIdentifierClause(SecurityToken token, SecurityT
 82        {
 083            if (token is GenericXmlSecurityToken)
 84            {
 085                return CreateGenericXmlTokenKeyIdentifierClause(token, referenceStyle);
 86            }
 87            else
 88            {
 089                return CreateKeyIdentifierClause<SecurityContextKeyIdentifierClause, LocalIdKeyIdentifierClause>(token, 
 90            }
 91        }
 92
 93        protected internal override void InitializeSecurityTokenRequirement(SecurityTokenRequirement requirement)
 94        {
 095            requirement.TokenType = (RequireClientCertificate) ? ServiceModelSecurityTokenTypes.MutualSslnego : ServiceM
 096            requirement.RequireCryptographicToken = true;
 097            requirement.KeyType = SecurityKeyType.SymmetricKey;
 098            requirement.Properties[ServiceModelSecurityTokenRequirement.SupportSecurityContextCancellationProperty] = Re
 099            if (IssuerBindingContext != null)
 100            {
 0101                requirement.Properties[ServiceModelSecurityTokenRequirement.IssuerBindingContextProperty] = IssuerBindin
 102            }
 0103            requirement.Properties[ServiceModelSecurityTokenRequirement.IssuedSecurityTokenParametersProperty] = Clone()
 0104        }
 105
 106        public override string ToString()
 107        {
 0108            StringBuilder sb = new StringBuilder();
 0109            sb.AppendLine(base.ToString());
 110
 0111            sb.AppendLine(string.Format(CultureInfo.InvariantCulture, "RequireCancellation: {0}", RequireCancellation.To
 0112            sb.Append(string.Format(CultureInfo.InvariantCulture, "RequireClientCertificate: {0}", RequireClientCertific
 113
 0114            return sb.ToString();
 115        }
 116    }
 117}