< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Security.WSTrustFeb2005
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Security/WSTrustFeb2005.cs
Line coverage
40%
Covered lines: 29
Uncovered lines: 42
Coverable lines: 71
Total lines: 226
Line coverage: 40.8%
Branch coverage
30%
Covered branches: 16
Total branches: 52
Branch coverage: 30.7%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)100%11100%
.ctor(...)100%11100%
ProcessUnknownRequestParameters(...)100%110%
ReadReferences(...)0%22220%
ReadRequestedTokenClosed(...)0%880%
ReadTargets(...)83.33%121290%
WriteReferences(...)100%44100%
WriteRequestedTokenClosed(...)100%22100%
WriteTargets(...)0%440%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Security/WSTrustFeb2005.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.Collections.ObjectModel;
 6using System.Xml;
 7using CoreWCF.IdentityModel;
 8using CoreWCF.Security.Tokens;
 9
 10namespace CoreWCF.Security
 11{
 12    internal class WSTrustFeb2005 : WSTrust
 13    {
 14        public WSTrustFeb2005(WSSecurityTokenSerializer tokenSerializer)
 13215            : base(tokenSerializer)
 16        {
 13217        }
 18
 19        public override TrustDictionary SerializerDictionary
 20        {
 17221            get { return XD.TrustFeb2005Dictionary; }
 22        }
 23
 24        public class DriverFeb2005 : Driver
 25        {
 26            public DriverFeb2005(SecurityStandardsManager standardsManager)
 13127                : base(standardsManager)
 28            {
 13129            }
 30
 31            public override TrustDictionary DriverDictionary
 32            {
 33                get
 34                {
 49835                    return XD.TrustFeb2005Dictionary;
 36                }
 37            }
 38
 39            public override XmlDictionaryString RequestSecurityTokenResponseFinalAction
 40            {
 41                get
 42                {
 043                    return XD.TrustFeb2005Dictionary.RequestSecurityTokenIssuanceResponse;
 44                }
 45            }
 46
 47            public override bool IsSessionSupported
 48            {
 49                get
 50                {
 2251                    return true;
 52                }
 53            }
 54
 55            public override bool IsIssuedTokensSupported
 56            {
 57                get
 58                {
 059                    return true;
 60                }
 61            }
 62
 63            public override string IssuedTokensHeaderName
 64            {
 65                get
 66                {
 067                    return DriverDictionary.IssuedTokensHeader.Value;
 68                }
 69            }
 70
 71            public override string IssuedTokensHeaderNamespace
 72            {
 73                get
 74                {
 075                    return DriverDictionary.Namespace.Value;
 76                }
 77            }
 78
 79            public override string RequestTypeRenew
 80            {
 81                get
 82                {
 083                    return DriverDictionary.RequestTypeRenew.Value;
 84                }
 85            }
 86
 87            public override string RequestTypeClose
 88            {
 89                get
 90                {
 1091                    return DriverDictionary.RequestTypeClose.Value;
 92                }
 93            }
 94
 95            public override Collection<XmlElement> ProcessUnknownRequestParameters(Collection<XmlElement> unknownRequest
 96            {
 097                throw new NotImplementedException();
 98            }
 99
 100            protected override void ReadReferences(XmlElement rstrXml, out SecurityKeyIdentifierClause requestedAttached
 101                    out SecurityKeyIdentifierClause requestedUnattachedReference)
 102            {
 0103                XmlElement issuedTokenXml = null;
 0104                requestedAttachedReference = null;
 0105                requestedUnattachedReference = null;
 0106                for (int i = 0; i < rstrXml.ChildNodes.Count; ++i)
 107                {
 0108                    if (rstrXml.ChildNodes[i] is XmlElement child)
 109                    {
 0110                        if (child.LocalName == DriverDictionary.RequestedSecurityToken.Value && child.NamespaceURI == Dr
 111                        {
 0112                            issuedTokenXml = XmlHelper.GetChildElement(child);
 113                        }
 0114                        else if (child.LocalName == DriverDictionary.RequestedAttachedReference.Value && child.Namespace
 115                        {
 0116                            requestedAttachedReference = GetKeyIdentifierXmlReferenceClause(XmlHelper.GetChildElement(ch
 117                        }
 0118                        else if (child.LocalName == DriverDictionary.RequestedUnattachedReference.Value && child.Namespa
 119                        {
 0120                            requestedUnattachedReference = GetKeyIdentifierXmlReferenceClause(XmlHelper.GetChildElement(
 121                        }
 122                    }
 123                }
 124
 125                try
 126                {
 0127                    if (issuedTokenXml != null)
 128                    {
 0129                        if (requestedAttachedReference == null)
 130                        {
 0131                            StandardsManager.TryCreateKeyIdentifierClauseFromTokenXml(issuedTokenXml, SecurityTokenRefer
 132                        }
 0133                        if (requestedUnattachedReference == null)
 134                        {
 0135                            StandardsManager.TryCreateKeyIdentifierClauseFromTokenXml(issuedTokenXml, SecurityTokenRefer
 136                        }
 137                    }
 0138                }
 0139                catch (XmlException)
 140                {
 0141                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.Format(SR.TrustDriverI
 142                }
 0143            }
 144
 145            protected override bool ReadRequestedTokenClosed(XmlElement rstrXml)
 146            {
 0147                for (int i = 0; i < rstrXml.ChildNodes.Count; ++i)
 148                {
 0149                    XmlElement child = (rstrXml.ChildNodes[i] as XmlElement);
 0150                    if (child != null)
 151                    {
 0152                        if (child.LocalName == DriverDictionary.RequestedTokenClosed.Value && child.NamespaceURI == Driv
 153                        {
 0154                            return true;
 155                        }
 156                    }
 157                }
 0158                return false;
 159            }
 160
 161            protected override void ReadTargets(XmlElement rstXml, out SecurityKeyIdentifierClause renewTarget, out Secu
 162            {
 20163                renewTarget = null;
 20164                closeTarget = null;
 165
 160166                for (int i = 0; i < rstXml.ChildNodes.Count; ++i)
 167                {
 60168                    XmlElement child = (rstXml.ChildNodes[i] as XmlElement);
 60169                    if (child != null)
 170                    {
 60171                        if (child.LocalName == DriverDictionary.RenewTarget.Value && child.NamespaceURI == DriverDiction
 172                        {
 0173                            renewTarget = StandardsManager.SecurityTokenSerializer.ReadKeyIdentifierClause(new XmlNodeRe
 174                        }
 60175                        else if (child.LocalName == DriverDictionary.CloseTarget.Value && child.NamespaceURI == DriverDi
 176                        {
 10177                            closeTarget = StandardsManager.SecurityTokenSerializer.ReadKeyIdentifierClause(new XmlNodeRe
 178                        }
 179                    }
 180                }
 20181            }
 182
 183            protected override void WriteReferences(RequestSecurityTokenResponse rstr, XmlDictionaryWriter writer)
 184            {
 20185                if (rstr.RequestedAttachedReference != null)
 186                {
 10187                    writer.WriteStartElement(DriverDictionary.Prefix.Value, DriverDictionary.RequestedAttachedReference,
 10188                    StandardsManager.SecurityTokenSerializer.WriteKeyIdentifierClause(writer, rstr.RequestedAttachedRefe
 10189                    writer.WriteEndElement();
 190                }
 191
 20192                if (rstr.RequestedUnattachedReference != null)
 193                {
 10194                    writer.WriteStartElement(DriverDictionary.Prefix.Value, DriverDictionary.RequestedUnattachedReferenc
 10195                    StandardsManager.SecurityTokenSerializer.WriteKeyIdentifierClause(writer, rstr.RequestedUnattachedRe
 10196                    writer.WriteEndElement();
 197                }
 20198            }
 199
 200            protected override void WriteRequestedTokenClosed(RequestSecurityTokenResponse rstr, XmlDictionaryWriter wri
 201            {
 20202                if (rstr.IsRequestedTokenClosed)
 203                {
 10204                    writer.WriteElementString(DriverDictionary.RequestedTokenClosed, DriverDictionary.Namespace, string.
 205                }
 20206            }
 207
 208            protected override void WriteTargets(RequestSecurityToken rst, XmlDictionaryWriter writer)
 209            {
 0210                if (rst.RenewTarget != null)
 211                {
 0212                    writer.WriteStartElement(DriverDictionary.Prefix.Value, DriverDictionary.RenewTarget, DriverDictiona
 0213                    StandardsManager.SecurityTokenSerializer.WriteKeyIdentifierClause(writer, rst.RenewTarget);
 0214                    writer.WriteEndElement();
 215                }
 216
 0217                if (rst.CloseTarget != null)
 218                {
 0219                    writer.WriteStartElement(DriverDictionary.Prefix.Value, DriverDictionary.CloseTarget, DriverDictiona
 0220                    StandardsManager.SecurityTokenSerializer.WriteKeyIdentifierClause(writer, rst.CloseTarget);
 0221                    writer.WriteEndElement();
 222                }
 0223            }
 224        }
 225    }
 226}