< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Security.Tokens.SecureConversationSecurityTokenParameters
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Security/Tokens/SecureConversationSecurityTokenParameters.cs
Line coverage
71%
Covered lines: 47
Uncovered lines: 19
Coverable lines: 66
Total lines: 172
Line coverage: 71.2%
Branch coverage
60%
Covered branches: 12
Total branches: 20
Branch coverage: 60%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

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

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Security/Tokens/SecureConversationSecurityTokenParameters.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 SecureConversationSecurityTokenParameters : SecurityTokenParameters
 15    {
 16        internal const bool defaultRequireCancellation = true;
 17        internal const bool defaultCanRenewSession = true;
 18        private BindingContext _issuerBindingContext;
 19
 20        protected SecureConversationSecurityTokenParameters(SecureConversationSecurityTokenParameters other)
 53921            : base(other)
 22        {
 53923            RequireCancellation = other.RequireCancellation;
 53924            CanRenewSession = other.CanRenewSession;
 53925            if (other.BootstrapSecurityBindingElement != null)
 26            {
 53927                BootstrapSecurityBindingElement = (SecurityBindingElement)other.BootstrapSecurityBindingElement.Clone();
 28            }
 29
 53930            if (other.BootstrapProtectionRequirements != null)
 31            {
 53932                BootstrapProtectionRequirements = new ChannelProtectionRequirements(other.BootstrapProtectionRequirement
 33            }
 34
 53935            if (other._issuerBindingContext != null)
 36            {
 2237                _issuerBindingContext = other._issuerBindingContext.Clone();
 38            }
 53939        }
 40
 41        public SecureConversationSecurityTokenParameters()
 042            : this(null, defaultRequireCancellation, null)
 43        {
 44            // empty
 045        }
 46
 47        public SecureConversationSecurityTokenParameters(SecurityBindingElement bootstrapSecurityBindingElement)
 048            : this(bootstrapSecurityBindingElement, defaultRequireCancellation, null)
 49        {
 50            // empty
 051        }
 52
 53        public SecureConversationSecurityTokenParameters(SecurityBindingElement bootstrapSecurityBindingElement, bool re
 054            : this(bootstrapSecurityBindingElement, requireCancellation, true)
 55        {
 56            // empty
 057        }
 58
 59        public SecureConversationSecurityTokenParameters(SecurityBindingElement bootstrapSecurityBindingElement, bool re
 060            : this(bootstrapSecurityBindingElement, requireCancellation, canRenewSession, null)
 61        {
 62            // empty
 063        }
 64
 65        public SecureConversationSecurityTokenParameters(SecurityBindingElement bootstrapSecurityBindingElement, bool re
 12366            : this(bootstrapSecurityBindingElement, requireCancellation, defaultCanRenewSession, null)
 67        {
 68            // empty
 12369        }
 70
 71        public SecureConversationSecurityTokenParameters(SecurityBindingElement bootstrapSecurityBindingElement, bool re
 12372            : base()
 73        {
 12374            BootstrapSecurityBindingElement = bootstrapSecurityBindingElement;
 12375            CanRenewSession = canRenewSession;
 12376            if (bootstrapProtectionRequirements != null)
 77            {
 078                BootstrapProtectionRequirements = new ChannelProtectionRequirements(bootstrapProtectionRequirements);
 79            }
 80            else
 81            {
 12382                BootstrapProtectionRequirements = new ChannelProtectionRequirements();
 12383                BootstrapProtectionRequirements.IncomingEncryptionParts.AddParts(new MessagePartSpecification(true));
 12384                BootstrapProtectionRequirements.IncomingSignatureParts.AddParts(new MessagePartSpecification(true));
 12385                BootstrapProtectionRequirements.OutgoingEncryptionParts.AddParts(new MessagePartSpecification(true));
 12386                BootstrapProtectionRequirements.OutgoingSignatureParts.AddParts(new MessagePartSpecification(true));
 87            }
 12388            RequireCancellation = requireCancellation;
 12389        }
 90
 1091        protected internal override bool HasAsymmetricKey => false;
 92
 191793        public SecurityBindingElement BootstrapSecurityBindingElement { get; set; }
 94
 157095        public ChannelProtectionRequirements BootstrapProtectionRequirements { get; }
 96
 97        internal BindingContext IssuerBindingContext
 98        {
 99            get
 100            {
 22101                return _issuerBindingContext;
 102            }
 103            set
 104            {
 44105                if (value != null)
 106                {
 44107                    value = value.Clone();
 108                }
 44109                _issuerBindingContext = value;
 44110            }
 111        }
 112
 124113        private ISecurityCapabilities BootstrapSecurityCapabilities => BootstrapSecurityBindingElement.GetIndividualProp
 114
 1254115        public bool RequireCancellation { get; set; }
 116
 1908117        public bool CanRenewSession { get; set; } = defaultCanRenewSession;
 118
 31119        protected internal override bool SupportsClientAuthentication => BootstrapSecurityCapabilities == null ? false :
 120
 0121        protected internal override bool SupportsServerAuthentication => BootstrapSecurityCapabilities == null ? false :
 122
 31123        protected internal override bool SupportsClientWindowsIdentity => BootstrapSecurityCapabilities == null ? false 
 124
 125        protected override SecurityTokenParameters CloneCore()
 126        {
 539127            return new SecureConversationSecurityTokenParameters(this);
 128        }
 129
 130        protected internal override SecurityKeyIdentifierClause CreateKeyIdentifierClause(SecurityToken token, SecurityT
 131        {
 30132            if (token is GenericXmlSecurityToken)
 133            {
 0134                return CreateGenericXmlTokenKeyIdentifierClause(token, referenceStyle);
 135            }
 136            else
 137            {
 30138                return CreateKeyIdentifierClause<SecurityContextKeyIdentifierClause, LocalIdKeyIdentifierClause>(token, 
 139            }
 140        }
 141
 142        protected internal override void InitializeSecurityTokenRequirement(SecurityTokenRequirement requirement)
 143        {
 22144            requirement.TokenType = ServiceModelSecurityTokenTypes.SecureConversation;
 22145            requirement.KeyType = SecurityKeyType.SymmetricKey;
 22146            requirement.RequireCryptographicToken = true;
 22147            requirement.Properties[ServiceModelSecurityTokenRequirement.SupportSecurityContextCancellationProperty] = Re
 22148            requirement.Properties[ServiceModelSecurityTokenRequirement.SecureConversationSecurityBindingElementProperty
 22149            requirement.Properties[ServiceModelSecurityTokenRequirement.IssuerBindingContextProperty] = IssuerBindingCon
 22150            requirement.Properties[ServiceModelSecurityTokenRequirement.IssuedSecurityTokenParametersProperty] = Clone()
 22151        }
 152
 153        public override string ToString()
 154        {
 0155            StringBuilder sb = new StringBuilder();
 0156            sb.AppendLine(base.ToString());
 157
 0158            sb.AppendLine(string.Format(CultureInfo.InvariantCulture, "RequireCancellation: {0}", RequireCancellation.To
 0159            if (BootstrapSecurityBindingElement == null)
 160            {
 0161                sb.AppendLine(string.Format(CultureInfo.InvariantCulture, "BootstrapSecurityBindingElement: null"));
 162            }
 163            else
 164            {
 0165                sb.AppendLine(string.Format(CultureInfo.InvariantCulture, "BootstrapSecurityBindingElement:"));
 0166                sb.AppendLine("  " + BootstrapSecurityBindingElement.ToString().Trim().Replace("\n", "\n  "));
 167            }
 168
 0169            return sb.ToString().Trim();
 170        }
 171    }
 172}