< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Security.WSSecurityPolicy12
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Security/WSSecurityPolicy12.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 87
Coverable lines: 87
Total lines: 204
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 48
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Security/WSSecurityPolicy12.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.Collections.ObjectModel;
 5using System.Net;
 6using System.Xml;
 7using CoreWCF.Channels;
 8using CoreWCF.Description;
 9using CoreWCF.Runtime;
 10using CoreWCF.Security.Tokens;
 11
 12namespace CoreWCF.Security
 13{
 14    internal class WSSecurityPolicy12 : WSSecurityPolicy
 15    {
 16        public const string WsspNamespace = @"http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702";
 17        public const string SignedEncryptedSupportingTokensName = "SignedEncryptedSupportingTokens";
 18        public const string RequireImpliedDerivedKeysName = "RequireImpliedDerivedKeys";
 19        public const string RequireExplicitDerivedKeysName = "RequireExplicitDerivedKeys";
 20
 21        public override string WsspNamespaceUri
 22        {
 023            get { return WsspNamespace; }
 24        }
 25
 26        public override bool IsSecurityVersionSupported(MessageSecurityVersion version)
 27        {
 028            return version == MessageSecurityVersion.WSSecurity10WSTrust13WSSecureConversation13WSSecurityPolicy12BasicS
 029                version == MessageSecurityVersion.WSSecurity11WSTrust13WSSecureConversation13WSSecurityPolicy12 ||
 030                version == MessageSecurityVersion.WSSecurity11WSTrust13WSSecureConversation13WSSecurityPolicy12BasicSecu
 31        }
 32
 33        public override TrustDriver TrustDriver
 34        {
 35            get
 36            {
 037                return new WSTrustDec2005.DriverDec2005(new SecurityStandardsManager(MessageSecurityVersion.WSSecurity11
 38            }
 39        }
 40
 41        public override Collection<XmlElement> CreateWsspSupportingTokensAssertion(MetadataExporter exporter, Collection
 42        {
 043            Collection<XmlElement> supportingTokenAssertions = new Collection<XmlElement>();
 44
 45            // Signed Supporting Tokens
 046            XmlElement supportingTokenAssertion = CreateWsspSignedSupportingTokensAssertion(exporter, signed, optionalSi
 047            if (supportingTokenAssertion != null)
 048                supportingTokenAssertions.Add(supportingTokenAssertion);
 49
 50            // Signed Encrypted Supporting Tokens
 051            supportingTokenAssertion = CreateWsspSignedEncryptedSupportingTokensAssertion(exporter, signedEncrypted, opt
 052            if (supportingTokenAssertion != null)
 053                supportingTokenAssertions.Add(supportingTokenAssertion);
 54
 55            // Endorsing Supporting Tokens.
 056            supportingTokenAssertion = CreateWsspEndorsingSupportingTokensAssertion(exporter, endorsing, optionalEndorsi
 057            if (supportingTokenAssertion != null)
 058                supportingTokenAssertions.Add(supportingTokenAssertion);
 59
 60            // Signed Endorsing Supporting Tokens.
 061            supportingTokenAssertion = CreateWsspSignedEndorsingSupportingTokensAssertion(exporter, signedEndorsing, opt
 062            if (supportingTokenAssertion != null)
 063                supportingTokenAssertions.Add(supportingTokenAssertion);
 64
 065            return supportingTokenAssertions;
 66        }
 67
 68        public override XmlElement CreateWsspSpnegoContextTokenAssertion(MetadataExporter exporter, SspiSecurityTokenPar
 69        {
 070            XmlElement result = CreateWsspAssertion(SpnegoContextTokenName);
 071            SetIncludeTokenValue(result, parameters.InclusionMode);
 072            result.AppendChild(
 073                CreateWspPolicyWrapper(
 074                    exporter,
 075                    CreateWsspRequireDerivedKeysAssertion(parameters.RequireDerivedKeys),
 076                    // Always emit <sp:MustNotSendCancel/> for spnego and sslnego
 077                    CreateWsspMustNotSendCancelAssertion(false),
 078                    CreateWsspMustNotSendAmendAssertion(),
 079                    CreateWsspMustNotSendRenewAssertion()
 080            ));
 081            return result;
 82        }
 83
 84        public override XmlElement CreateMsspSslContextTokenAssertion(MetadataExporter exporter, SslSecurityTokenParamet
 85        {
 086            XmlElement result = CreateMsspAssertion(SslContextTokenName);
 087            SetIncludeTokenValue(result, parameters.InclusionMode);
 088            result.AppendChild(
 089                CreateWspPolicyWrapper(
 090                    exporter,
 091                    CreateWsspRequireDerivedKeysAssertion(parameters.RequireDerivedKeys),
 092                    // Always emit <sp:MustNotSendCancel/> for spnego and sslnego
 093                    CreateWsspMustNotSendCancelAssertion(false),
 094                    CreateMsspRequireClientCertificateAssertion(parameters.RequireClientCertificate),
 095                    CreateWsspMustNotSendAmendAssertion(),
 096                    CreateWsspMustNotSendRenewAssertion()
 097            ));
 098            return result;
 99        }
 100
 101        public override XmlElement CreateWsspSecureConversationTokenAssertion(MetadataExporter exporter, SecureConversat
 102        {
 0103            XmlElement result = CreateWsspAssertion(SecureConversationTokenName);
 0104            SetIncludeTokenValue(result, parameters.InclusionMode);
 0105            result.AppendChild(
 0106                CreateWspPolicyWrapper(
 0107                    exporter,
 0108                    CreateWsspRequireDerivedKeysAssertion(parameters.RequireDerivedKeys),
 0109                    CreateWsspMustNotSendCancelAssertion(parameters.RequireCancellation),
 0110                    CreateWsspBootstrapPolicyAssertion(exporter, parameters.BootstrapSecurityBindingElement),
 0111                    CreateWsspMustNotSendAmendAssertion(),
 0112                    (!parameters.RequireCancellation || !parameters.CanRenewSession) ? CreateWsspMustNotSendRenewAsserti
 0113            ));
 0114            return result;
 115        }
 116
 117        XmlElement CreateWsspMustNotSendAmendAssertion()
 118        {
 0119            XmlElement result = CreateWsspAssertion(MustNotSendAmendName);
 0120            return result;
 121        }
 122
 123        XmlElement CreateWsspMustNotSendRenewAssertion()
 124        {
 0125            XmlElement result = CreateWsspAssertion(MustNotSendRenewName);
 0126            return result;
 127        }
 128
 129        XmlElement CreateWsspSignedSupportingTokensAssertion(MetadataExporter exporter, Collection<SecurityTokenParamete
 130        {
 131            XmlElement result;
 132
 0133            if ((signed == null || signed.Count == 0)
 0134                && (optionalSigned == null || optionalSigned.Count == 0))
 135            {
 0136                result = null;
 137            }
 138            else
 139            {
 0140                XmlElement policy = CreateWspPolicyWrapper(exporter);
 141
 0142                if (signed != null)
 143                {
 0144                    foreach (SecurityTokenParameters p in signed)
 145                    {
 0146                        policy.AppendChild(CreateTokenAssertion(exporter, p));
 147                    }
 148                }
 0149                if (optionalSigned != null)
 150                {
 0151                    foreach (SecurityTokenParameters p in optionalSigned)
 152                    {
 0153                        policy.AppendChild(CreateTokenAssertion(exporter, p, true));
 154                    }
 155                }
 156
 0157                result = CreateWsspAssertion(SignedSupportingTokensName);
 0158                result.AppendChild(policy);
 159            }
 160
 0161            return result;
 162        }
 163
 164        XmlElement CreateWsspSignedEncryptedSupportingTokensAssertion(MetadataExporter exporter, Collection<SecurityToke
 165        {
 166            XmlElement result;
 167
 0168            if ((signedEncrypted == null || signedEncrypted.Count == 0)
 0169                && (optionalSignedEncrypted == null || optionalSignedEncrypted.Count == 0))
 170            {
 0171                result = null;
 172            }
 173            else
 174            {
 0175                XmlElement policy = CreateWspPolicyWrapper(exporter);
 176
 0177                if (signedEncrypted != null)
 178                {
 0179                    foreach (SecurityTokenParameters p in signedEncrypted)
 180                    {
 0181                        policy.AppendChild(CreateTokenAssertion(exporter, p));
 182                    }
 183                }
 0184                if (optionalSignedEncrypted != null)
 185                {
 0186                    foreach (SecurityTokenParameters p in optionalSignedEncrypted)
 187                    {
 0188                        policy.AppendChild(CreateTokenAssertion(exporter, p, true));
 189                    }
 190                }
 191
 0192                result = CreateWsspAssertion(SignedEncryptedSupportingTokensName);
 0193                result.AppendChild(policy);
 194            }
 195
 0196            return result;
 197        }
 198
 199        public override XmlElement CreateWsspTrustAssertion(MetadataExporter exporter, SecurityKeyEntropyMode keyEntropy
 200        {
 0201            return CreateWsspTrustAssertion(Trust13Name, exporter, keyEntropyMode);
 202        }
 203    }
 204}

Methods/Properties

WsspNamespaceUri()
IsSecurityVersionSupported(CoreWCF.MessageSecurityVersion)
TrustDriver()
CreateWsspSupportingTokensAssertion(CoreWCF.Description.MetadataExporter,System.Collections.ObjectModel.Collection`1<CoreWCF.Security.Tokens.SecurityTokenParameters>,System.Collections.ObjectModel.Collection`1<CoreWCF.Security.Tokens.SecurityTokenParameters>,System.Collections.ObjectModel.Collection`1<CoreWCF.Security.Tokens.SecurityTokenParameters>,System.Collections.ObjectModel.Collection`1<CoreWCF.Security.Tokens.SecurityTokenParameters>,System.Collections.ObjectModel.Collection`1<CoreWCF.Security.Tokens.SecurityTokenParameters>,System.Collections.ObjectModel.Collection`1<CoreWCF.Security.Tokens.SecurityTokenParameters>,System.Collections.ObjectModel.Collection`1<CoreWCF.Security.Tokens.SecurityTokenParameters>,System.Collections.ObjectModel.Collection`1<CoreWCF.Security.Tokens.SecurityTokenParameters>,CoreWCF.Channels.AddressingVersion)
CreateWsspSpnegoContextTokenAssertion(CoreWCF.Description.MetadataExporter,CoreWCF.Security.Tokens.SspiSecurityTokenParameters)
CreateMsspSslContextTokenAssertion(CoreWCF.Description.MetadataExporter,CoreWCF.Security.Tokens.SslSecurityTokenParameters)
CreateWsspSecureConversationTokenAssertion(CoreWCF.Description.MetadataExporter,CoreWCF.Security.Tokens.SecureConversationSecurityTokenParameters)
CreateWsspMustNotSendAmendAssertion()
CreateWsspMustNotSendRenewAssertion()
CreateWsspSignedSupportingTokensAssertion(CoreWCF.Description.MetadataExporter,System.Collections.ObjectModel.Collection`1<CoreWCF.Security.Tokens.SecurityTokenParameters>,System.Collections.ObjectModel.Collection`1<CoreWCF.Security.Tokens.SecurityTokenParameters>)
CreateWsspSignedEncryptedSupportingTokensAssertion(CoreWCF.Description.MetadataExporter,System.Collections.ObjectModel.Collection`1<CoreWCF.Security.Tokens.SecurityTokenParameters>,System.Collections.ObjectModel.Collection`1<CoreWCF.Security.Tokens.SecurityTokenParameters>)
CreateWsspTrustAssertion(CoreWCF.Description.MetadataExporter,CoreWCF.Security.SecurityKeyEntropyMode)