< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.IdentityModel.Tokens.WSSecurityJan2004
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/IdentityModel/Tokens/WSSecurityJan2004.cs
Line coverage
54%
Covered lines: 122
Uncovered lines: 102
Coverable lines: 224
Total lines: 579
Line coverage: 54.4%
Branch coverage
52%
Covered branches: 37
Total branches: 70
Branch coverage: 52.8%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)100%11100%
PopulateKeyIdentifierClauseEntries(...)100%11100%
PopulateJan2004StrEntries(...)100%11100%
PopulateStrEntries(...)100%11100%
PopulateJan2004TokenEntries(...)100%11100%
PopulateTokenEntries(...)100%11100%
.cctor()100%110%
.ctor(...)100%11100%
.ctor(...)0%440%
SupportsTokenTypeUri(...)100%44100%
GetTokenTypesCore()100%11100%
GetTokenTypesCore()100%11100%
GetTokenTypesCore()100%11100%
.ctor()100%11100%
GetTokenTypesCore()100%11100%
.ctor(...)100%11100%
ReadTokenType(...)100%110%
ReadKeyIdentifierClauseCore(...)78.57%141487.5%
SupportsCore(...)75%4475%
WriteKeyIdentifierClauseCore(...)0%440%
.ctor(...)100%11100%
CanReadClause(...)50%2275%
GetTokenType(...)100%110%
ReadClause(...)25%8853.84%
SupportsCore(...)100%11100%
WriteContent(...)0%880%
.ctor(...)100%11100%
CreateClause(...)100%11100%
GetTokenTypeUri()100%110%
.ctor(...)100%11100%
GetTokenType(...)100%11100%
GetLocalTokenTypeUri(...)100%11100%
GetTokenTypeUri()100%110%
CanReadClause(...)100%88100%
ReadClause(...)75%4472.72%
SupportsCore(...)100%11100%
WriteContent(...)100%44100%
GetTokenType(...)100%110%
CanReadClause(...)100%11100%
GetTokenTypeUri()100%110%
ReadClause(...)100%110%
SupportsCore(...)100%11100%
WriteContent(...)100%110%
.cctor()100%110%
.ctor()100%110%
ExtractId(...)0%440%
WriteIdAttribute(...)0%220%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/IdentityModel/Tokens/WSSecurityJan2004.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.Generic;
 6using System.Globalization;
 7using System.Text;
 8using System.Xml;
 9using CoreWCF.IdentityModel.Selectors;
 10using CoreWCF.Security;
 11using CoreWCF.Security.Tokens;
 12using HexBinary = CoreWCF.Security.SoapHexBinary;
 13using KeyIdentifierClauseEntry = CoreWCF.IdentityModel.Selectors.SecurityTokenSerializer.KeyIdentifierClauseEntry;
 14using StrEntry = CoreWCF.IdentityModel.Selectors.SecurityTokenSerializer.StrEntry;
 15using TokenEntry = CoreWCF.IdentityModel.Selectors.SecurityTokenSerializer.TokenEntry;
 16
 17namespace CoreWCF.IdentityModel.Tokens
 18{
 19    internal class WSSecurityJan2004 : SecurityTokenSerializer.SerializerEntries
 20    {
 13421        public WSSecurityJan2004(KeyInfoSerializer securityTokenSerializer)
 22        {
 13423            SecurityTokenSerializer = securityTokenSerializer;
 13424        }
 25
 92626        public KeyInfoSerializer SecurityTokenSerializer { get; }
 27
 28        public override void PopulateKeyIdentifierClauseEntries(IList<KeyIdentifierClauseEntry> clauseEntries)
 29        {
 630            List<StrEntry> strEntries = new List<StrEntry>();
 631            SecurityTokenSerializer.PopulateStrEntries(strEntries);
 632            SecurityTokenReferenceJan2004ClauseEntry strClause = new SecurityTokenReferenceJan2004ClauseEntry(SecurityTo
 633            clauseEntries.Add(strClause);
 634        }
 35
 36        protected void PopulateJan2004StrEntries(IList<StrEntry> strEntries)
 37        {
 13438            strEntries.Add(new LocalReferenceStrEntry(SecurityTokenSerializer.EmitBspRequiredAttributes, SecurityTokenSe
 13439            strEntries.Add(new X509SkiStrEntry(SecurityTokenSerializer.EmitBspRequiredAttributes));
 13440            strEntries.Add(new X509IssuerSerialStrEntry());
 13441        }
 42
 43        public override void PopulateStrEntries(IList<StrEntry> strEntries)
 44        {
 645            PopulateJan2004StrEntries(strEntries);
 646        }
 47
 48        protected void PopulateJan2004TokenEntries(IList<TokenEntry> tokenEntryList)
 49        {
 13450            tokenEntryList.Add(new GenericXmlTokenEntry());
 13451            tokenEntryList.Add(new UserNamePasswordTokenEntry());
 13452            tokenEntryList.Add(new X509TokenEntry());
 13453        }
 54
 55        public override void PopulateTokenEntries(IList<TokenEntry> tokenEntryList)
 56        {
 657            PopulateJan2004TokenEntries(tokenEntryList);
 658        }
 59
 60        internal abstract class BinaryTokenEntry : TokenEntry
 61        {
 062            internal static readonly XmlDictionaryString ElementName = CoreWCF.XD.SecurityJan2004Dictionary.BinarySecuri
 063            internal static readonly XmlDictionaryString EncodingTypeAttribute = CoreWCF.XD.SecurityJan2004Dictionary.En
 64            internal const string EncodingTypeAttributeString = SecurityJan2004Strings.EncodingType;
 65            internal const string EncodingTypeValueBase64Binary = SecurityJan2004Strings.EncodingTypeValueBase64Binary;
 66            internal const string EncodingTypeValueHexBinary = SecurityJan2004Strings.EncodingTypeValueHexBinary;
 067            internal static readonly XmlDictionaryString ValueTypeAttribute = CoreWCF.XD.SecurityJan2004Dictionary.Value
 68
 69            private readonly string[] _valueTypeUris = null;
 70
 13471            protected BinaryTokenEntry(string valueTypeUri)
 72            {
 13473                _valueTypeUris = new string[1];
 13474                _valueTypeUris[0] = valueTypeUri;
 13475            }
 76
 077            protected BinaryTokenEntry(string[] valueTypeUris)
 78            {
 079                if (valueTypeUris == null)
 80                {
 081                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(valueTypeUris));
 82                }
 83
 084                _valueTypeUris = new string[valueTypeUris.GetLength(0)];
 085                for (int i = 0; i < _valueTypeUris.GetLength(0); ++i)
 86                {
 087                    _valueTypeUris[i] = valueTypeUris[i];
 88                }
 089            }
 90
 091            protected override XmlDictionaryString LocalName { get { return ElementName; } }
 092            protected override XmlDictionaryString NamespaceUri { get { return CoreWCF.XD.SecurityJan2004Dictionary.Name
 093            public override string TokenTypeUri { get { return _valueTypeUris[0]; } }
 094            protected override string ValueTypeUri { get { return _valueTypeUris[0]; } }
 95            public override bool SupportsTokenTypeUri(string tokenTypeUri)
 96            {
 7097                for (int i = 0; i < _valueTypeUris.GetLength(0); ++i)
 98                {
 1999                    if (_valueTypeUris[i] == tokenTypeUri)
 100                    {
 3101                        return true;
 102                    }
 103                }
 104
 16105                return false;
 106            }
 107        }
 108
 109        private class GenericXmlTokenEntry : TokenEntry
 110        {
 0111            protected override XmlDictionaryString LocalName { get { return null; } }
 0112            protected override XmlDictionaryString NamespaceUri { get { return null; } }
 8113            protected override Type[] GetTokenTypesCore() { return new Type[] { typeof(GenericXmlSecurityToken) }; }
 19114            public override string TokenTypeUri { get { return null; } }
 0115            protected override string ValueTypeUri { get { return null; } }
 116        }
 117
 118        private class UserNamePasswordTokenEntry : TokenEntry
 119        {
 0120            protected override XmlDictionaryString LocalName { get { return CoreWCF.XD.SecurityJan2004Dictionary.UserNam
 0121            protected override XmlDictionaryString NamespaceUri { get { return CoreWCF.XD.SecurityJan2004Dictionary.Name
 8122            protected override Type[] GetTokenTypesCore() { return new Type[] { typeof(UserNameSecurityToken) }; }
 19123            public override string TokenTypeUri { get { return SecurityJan2004Strings.UPTokenType; } }
 0124            protected override string ValueTypeUri { get { return null; } }
 125        }
 126
 127        //class KerberosTokenEntry : BinaryTokenEntry
 128        //{
 129        //    public KerberosTokenEntry()
 130        //        : base(new string[] { SecurityJan2004Strings.KerberosTokenTypeGSS, SecurityJan2004Strings.KerberosToke
 131        //    {
 132        //    }
 133
 134        //    protected override Type[] GetTokenTypesCore() { return new Type[] { typeof(KerberosReceiverSecurityToken),
 135        //}
 136
 137        //protected class SamlTokenEntry : TokenEntry
 138        //{
 139        //    protected override XmlDictionaryString LocalName { get { return XD.SecurityJan2004Dictionary.SamlAssertion
 140        //    protected override XmlDictionaryString NamespaceUri { get { return XD.SecurityJan2004Dictionary.SamlUri; }
 141        //    protected override Type[] GetTokenTypesCore() { return new Type[] { typeof(SamlSecurityToken) }; }
 142        //    public override string TokenTypeUri { get { return null; } }
 143        //    protected override string ValueTypeUri { get { return null; } }
 144        //}
 145        protected class WrappedKeyTokenEntry : TokenEntry
 146        {
 0147            protected override XmlDictionaryString LocalName { get { return EncryptedKey.ElementName; } }
 0148            protected override XmlDictionaryString NamespaceUri { get { return CoreWCF.XD.XmlEncryptionDictionary.Namesp
 8149            protected override Type[] GetTokenTypesCore() { return new Type[] { typeof(WrappedKeySecurityToken) }; }
 0150            public override string TokenTypeUri { get { return null; } }
 0151            protected override string ValueTypeUri { get { return null; } }
 152        }
 153        protected class X509TokenEntry : BinaryTokenEntry
 154        {
 155            internal const string ValueTypeAbsoluteUri = SecurityJan2004Strings.X509TokenType;
 156
 157            public X509TokenEntry()
 134158                : base(ValueTypeAbsoluteUri)
 159            {
 134160            }
 161
 11162            protected override Type[] GetTokenTypesCore() { return new Type[] { typeof(X509SecurityToken) }; }
 163        }
 164
 165        protected class SecurityTokenReferenceJan2004ClauseEntry : KeyIdentifierClauseEntry
 166        {
 167            private const int DefaultDerivedKeyLength = 32;
 168
 134169            public SecurityTokenReferenceJan2004ClauseEntry(bool emitBspRequiredAttributes, IList<StrEntry> strEntries)
 170            {
 134171                EmitBspRequiredAttributes = emitBspRequiredAttributes;
 134172                StrEntries = strEntries;
 134173            }
 20174            protected bool EmitBspRequiredAttributes { get; }
 573175            protected IList<StrEntry> StrEntries { get; }
 176
 177            protected override XmlDictionaryString LocalName
 178            {
 179                get
 180                {
 45181                    return CoreWCF.XD.SecurityJan2004Dictionary.SecurityTokenReference;
 182                }
 183            }
 184
 185            protected override XmlDictionaryString NamespaceUri
 186            {
 187                get
 188                {
 123189                    return CoreWCF.XD.SecurityJan2004Dictionary.Namespace;
 190                }
 191            }
 192
 193            protected virtual string ReadTokenType(XmlDictionaryReader reader)
 194            {
 0195                return null;
 196            }
 197
 198            public override SecurityKeyIdentifierClause ReadKeyIdentifierClauseCore(XmlDictionaryReader reader)
 199            {
 39200                byte[] nonce = null;
 39201                int length = 0;
 39202                if (reader.IsStartElement(CoreWCF.XD.SecurityJan2004Dictionary.SecurityTokenReference, NamespaceUri))
 203                {
 39204                    string nonceString = reader.GetAttribute(CoreWCF.XD.SecureConversationFeb2005Dictionary.Nonce, CoreW
 39205                    if (nonceString != null)
 206                    {
 0207                        nonce = Convert.FromBase64String(nonceString);
 208                    }
 209
 39210                    string lengthString = reader.GetAttribute(CoreWCF.XD.SecureConversationFeb2005Dictionary.Length, Cor
 39211                    if (lengthString != null)
 212                    {
 0213                        length = Convert.ToInt32(lengthString, CultureInfo.InvariantCulture);
 214                    }
 215                    else
 216                    {
 39217                        length = DefaultDerivedKeyLength;
 218                    }
 219                }
 39220                string tokenType = ReadTokenType(reader);
 39221                string strId = reader.GetAttribute(CoreWCF.XD.UtilityDictionary.IdAttribute, CoreWCF.XD.UtilityDictionar
 39222                reader.ReadStartElement(CoreWCF.XD.SecurityJan2004Dictionary.SecurityTokenReference, NamespaceUri);
 39223                SecurityKeyIdentifierClause clause = null;
 214224                for (int i = 0; i < StrEntries.Count; ++i)
 225                {
 107226                    if (StrEntries[i].CanReadClause(reader, tokenType))
 227                    {
 39228                        clause = StrEntries[i].ReadClause(reader, nonce, length, tokenType);
 39229                        break;
 230                    }
 231                }
 232
 39233                if (clause == null)
 234                {
 0235                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.Format(SR.CannotReadKe
 236                }
 237
 39238                if (!string.IsNullOrEmpty(strId))
 239                {
 1240                    clause.Id = strId;
 241                }
 242
 39243                reader.ReadEndElement();
 39244                return clause;
 245            }
 246
 247            public override bool SupportsCore(SecurityKeyIdentifierClause keyIdentifierClause)
 248            {
 140249                for (int i = 0; i < StrEntries.Count; ++i)
 250                {
 70251                    if (StrEntries[i].SupportsCore(keyIdentifierClause))
 252                    {
 20253                        return true;
 254                    }
 255                }
 0256                return false;
 257            }
 258
 259            public override void WriteKeyIdentifierClauseCore(XmlDictionaryWriter writer, SecurityKeyIdentifierClause ke
 260            {
 0261                for (int i = 0; i < StrEntries.Count; ++i)
 262                {
 0263                    if (StrEntries[i].SupportsCore(keyIdentifierClause))
 264                    {
 0265                        writer.WriteStartElement(CoreWCF.XD.SecurityJan2004Dictionary.Prefix.Value, CoreWCF.XD.SecurityJ
 0266                        StrEntries[i].WriteContent(writer, keyIdentifierClause);
 0267                        writer.WriteEndElement();
 0268                        return;
 269                    }
 270                }
 271
 0272                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.Sta
 273            }
 274        }
 275
 276        protected abstract class KeyIdentifierStrEntry : StrEntry
 277        {
 278            protected const string EncodingTypeValueBase64Binary = SecurityJan2004Strings.EncodingTypeValueBase64Binary;
 279            protected const string EncodingTypeValueHexBinary = SecurityJan2004Strings.EncodingTypeValueHexBinary;
 280            protected const string EncodingTypeValueText = SecurityJan2004Strings.EncodingTypeValueText;
 281
 282            protected abstract Type ClauseType { get; }
 0283            protected virtual string DefaultEncodingType { get { return EncodingTypeValueBase64Binary; } }
 284            public abstract Type TokenType { get; }
 285            protected abstract string ValueTypeUri { get; }
 0286            protected bool EmitBspRequiredAttributes { get; }
 287
 390288            protected KeyIdentifierStrEntry(bool emitBspRequiredAttributes)
 289            {
 390290                EmitBspRequiredAttributes = emitBspRequiredAttributes;
 390291            }
 292
 293            public override bool CanReadClause(XmlDictionaryReader reader, string tokenType)
 294            {
 44295                if (reader.IsStartElement(CoreWCF.XD.SecurityJan2004Dictionary.KeyIdentifier, CoreWCF.XD.SecurityJan2004
 296                {
 14297                    string valueType = reader.GetAttribute(CoreWCF.XD.SecurityJan2004Dictionary.ValueType, null);
 14298                    return (ValueTypeUri == valueType);
 299                }
 30300                return false;
 301            }
 302
 303            protected abstract SecurityKeyIdentifierClause CreateClause(byte[] bytes, byte[] derivationNonce, int deriva
 304
 305            public override Type GetTokenType(SecurityKeyIdentifierClause clause)
 306            {
 0307                return TokenType;
 308            }
 309
 310            public override SecurityKeyIdentifierClause ReadClause(XmlDictionaryReader reader, byte[] derivationNonce, i
 311            {
 6312                string encodingType = reader.GetAttribute(CoreWCF.XD.SecurityJan2004Dictionary.EncodingType, null);
 6313                if (encodingType == null)
 314                {
 0315                    encodingType = DefaultEncodingType;
 316                }
 317
 6318                reader.ReadStartElement();
 319
 320                byte[] bytes;
 6321                if (encodingType == EncodingTypeValueBase64Binary)
 322                {
 6323                    bytes = reader.ReadContentAsBase64();
 324                }
 0325                else if (encodingType == EncodingTypeValueHexBinary)
 326                {
 0327                    bytes = HexBinary.Parse(reader.ReadContentAsString()).Value;
 328                }
 0329                else if (encodingType == EncodingTypeValueText)
 330                {
 0331                    bytes = new UTF8Encoding().GetBytes(reader.ReadContentAsString());
 332                }
 333                else
 334                {
 0335                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new Exception("UnknownEncodingInKeyIdentif
 336                }
 337
 6338                reader.ReadEndElement();
 339
 6340                return CreateClause(bytes, derivationNonce, derivationLength);
 341            }
 342
 343            public override bool SupportsCore(SecurityKeyIdentifierClause clause)
 344            {
 60345                return ClauseType.IsAssignableFrom(clause.GetType());
 346            }
 347
 348            public override void WriteContent(XmlDictionaryWriter writer, SecurityKeyIdentifierClause clause)
 349            {
 0350                writer.WriteStartElement(CoreWCF.XD.SecurityJan2004Dictionary.Prefix.Value, CoreWCF.XD.SecurityJan2004Di
 0351                writer.WriteAttributeString(CoreWCF.XD.SecurityJan2004Dictionary.ValueType, null, ValueTypeUri);
 0352                if (EmitBspRequiredAttributes)
 353                {
 354                    // Emit the encodingType attribute.
 0355                    writer.WriteAttributeString(CoreWCF.XD.SecurityJan2004Dictionary.EncodingType, null, DefaultEncoding
 356                }
 0357                string encoding = DefaultEncodingType;
 0358                BinaryKeyIdentifierClause binaryClause = clause as BinaryKeyIdentifierClause;
 359
 0360                byte[] keyIdentifier = binaryClause.GetBuffer();
 0361                if (encoding == EncodingTypeValueBase64Binary)
 362                {
 0363                    writer.WriteBase64(keyIdentifier, 0, keyIdentifier.Length);
 364                }
 0365                else if (encoding == EncodingTypeValueHexBinary)
 366                {
 0367                    writer.WriteBinHex(keyIdentifier, 0, keyIdentifier.Length);
 368                }
 0369                else if (encoding == EncodingTypeValueText)
 370                {
 0371                    writer.WriteString(new UTF8Encoding().GetString(keyIdentifier, 0, keyIdentifier.Length));
 372                }
 0373                writer.WriteEndElement();
 0374            }
 375        }
 376
 377        protected class X509SkiStrEntry : KeyIdentifierStrEntry
 378        {
 20379            protected override Type ClauseType { get { return typeof(X509SubjectKeyIdentifierClause); } }
 0380            public override Type TokenType { get { return typeof(X509SecurityToken); } }
 6381            protected override string ValueTypeUri { get { return SecurityJan2004Strings.X509SKIValueType; } }
 382
 383            public X509SkiStrEntry(bool emitBspRequiredAttributes)
 134384                : base(emitBspRequiredAttributes)
 385            {
 134386            }
 387
 388            protected override SecurityKeyIdentifierClause CreateClause(byte[] bytes, byte[] derivationNonce, int deriva
 389            {
 2390                return new X509SubjectKeyIdentifierClause(bytes);
 391            }
 392            public override string GetTokenTypeUri()
 393            {
 0394                return SecurityJan2004Strings.X509TokenType;
 395            }
 396        }
 397
 398        protected class LocalReferenceStrEntry : StrEntry
 399        {
 400            private readonly bool _emitBspRequiredAttributes;
 401            private readonly KeyInfoSerializer _tokenSerializer;
 402
 134403            public LocalReferenceStrEntry(bool emitBspRequiredAttributes, KeyInfoSerializer tokenSerializer)
 404            {
 134405                _emitBspRequiredAttributes = emitBspRequiredAttributes;
 134406                _tokenSerializer = tokenSerializer;
 134407            }
 408
 409            public override Type GetTokenType(SecurityKeyIdentifierClause clause)
 410            {
 16411                LocalIdKeyIdentifierClause localClause = clause as LocalIdKeyIdentifierClause;
 16412                return localClause.OwnerType;
 413            }
 414
 415            public string GetLocalTokenTypeUri(SecurityKeyIdentifierClause clause)
 416            {
 16417                Type tokenType = GetTokenType(clause);
 16418                return _tokenSerializer.GetTokenTypeUri(tokenType);
 419            }
 420            public override string GetTokenTypeUri()
 421            {
 0422                return null;
 423            }
 424
 425            public override bool CanReadClause(XmlDictionaryReader reader, string tokenType)
 426            {
 39427                if (reader.IsStartElement(CoreWCF.XD.SecurityJan2004Dictionary.Reference, CoreWCF.XD.SecurityJan2004Dict
 428                {
 33429                    string uri = reader.GetAttribute(CoreWCF.XD.SecurityJan2004Dictionary.URI, null);
 33430                    if (uri != null && uri.Length > 0 && uri[0] == '#')
 431                    {
 23432                        return true;
 433                    }
 434                }
 16435                return false;
 436            }
 437
 438            public override SecurityKeyIdentifierClause ReadClause(XmlDictionaryReader reader, byte[] derivationNonce, i
 439            {
 23440                string uri = reader.GetAttribute(CoreWCF.XD.SecurityJan2004Dictionary.URI, null);
 23441                string tokenTypeUri = reader.GetAttribute(CoreWCF.XD.SecurityJan2004Dictionary.ValueType, null);
 23442                Type[] tokenTypes = null;
 23443                if (tokenTypeUri != null)
 444                {
 19445                    tokenTypes = _tokenSerializer.GetTokenTypes(tokenTypeUri);
 446                }
 23447                SecurityKeyIdentifierClause clause = new LocalIdKeyIdentifierClause(uri.Substring(1), derivationNonce, d
 23448                if (reader.IsEmptyElement)
 449                {
 23450                    reader.Read();
 451                }
 452                else
 453                {
 0454                    reader.ReadStartElement();
 0455                    reader.ReadEndElement();
 456                }
 0457                return clause;
 458            }
 459
 460            public override bool SupportsCore(SecurityKeyIdentifierClause clause)
 461            {
 40462                return clause is LocalIdKeyIdentifierClause;
 463            }
 464
 465            public override void WriteContent(XmlDictionaryWriter writer, SecurityKeyIdentifierClause clause)
 466            {
 10467                LocalIdKeyIdentifierClause localIdClause = clause as LocalIdKeyIdentifierClause;
 10468                writer.WriteStartElement(CoreWCF.XD.SecurityJan2004Dictionary.Prefix.Value, CoreWCF.XD.SecurityJan2004Di
 10469                if (_emitBspRequiredAttributes)
 470                {
 8471                    string tokenTypeUri = GetLocalTokenTypeUri(localIdClause);
 8472                    if (tokenTypeUri != null)
 473                    {
 8474                        writer.WriteAttributeString(CoreWCF.XD.SecurityJan2004Dictionary.ValueType, null, tokenTypeUri);
 475                    }
 476                }
 10477                writer.WriteAttributeString(CoreWCF.XD.SecurityJan2004Dictionary.URI, null, "#" + localIdClause.LocalId)
 10478                writer.WriteEndElement();
 10479            }
 480        }
 481
 482        protected class X509IssuerSerialStrEntry : StrEntry
 483        {
 484            public override Type GetTokenType(SecurityKeyIdentifierClause clause)
 485            {
 0486                return typeof(X509SecurityToken);
 487            }
 488
 489            public override bool CanReadClause(XmlDictionaryReader reader, string tokenType)
 490            {
 14491                return reader.IsStartElement(CoreWCF.XD.XmlSignatureDictionary.X509Data, CoreWCF.XD.XmlSignatureDictiona
 492            }
 493            public override string GetTokenTypeUri()
 494            {
 0495                return SecurityJan2004Strings.X509TokenType;
 496            }
 497
 498            public override SecurityKeyIdentifierClause ReadClause(XmlDictionaryReader reader, byte[] derivationNonce, i
 499            {
 0500                reader.ReadStartElement(CoreWCF.XD.XmlSignatureDictionary.X509Data, CoreWCF.XD.XmlSignatureDictionary.Na
 0501                reader.ReadStartElement(CoreWCF.XD.XmlSignatureDictionary.X509IssuerSerial, CoreWCF.XD.XmlSignatureDicti
 0502                reader.ReadStartElement(CoreWCF.XD.XmlSignatureDictionary.X509IssuerName, CoreWCF.XD.XmlSignatureDiction
 0503                string issuerName = reader.ReadContentAsString();
 0504                reader.ReadEndElement();
 0505                reader.ReadStartElement(CoreWCF.XD.XmlSignatureDictionary.X509SerialNumber, CoreWCF.XD.XmlSignatureDicti
 0506                string serialNumber = reader.ReadContentAsString();
 0507                reader.ReadEndElement();
 0508                reader.ReadEndElement();
 0509                reader.ReadEndElement();
 510
 0511                return new X509IssuerSerialKeyIdentifierClause(issuerName, serialNumber);
 512            }
 513
 514            public override bool SupportsCore(SecurityKeyIdentifierClause clause)
 515            {
 20516                return clause is X509IssuerSerialKeyIdentifierClause;
 517            }
 518
 519            public override void WriteContent(XmlDictionaryWriter writer, SecurityKeyIdentifierClause clause)
 520            {
 0521                X509IssuerSerialKeyIdentifierClause issuerClause = clause as X509IssuerSerialKeyIdentifierClause;
 0522                writer.WriteStartElement(CoreWCF.XD.XmlSignatureDictionary.Prefix.Value, CoreWCF.XD.XmlSignatureDictiona
 0523                writer.WriteStartElement(CoreWCF.XD.XmlSignatureDictionary.Prefix.Value, CoreWCF.XD.XmlSignatureDictiona
 0524                writer.WriteElementString(CoreWCF.XD.XmlSignatureDictionary.Prefix.Value, CoreWCF.XD.XmlSignatureDiction
 0525                writer.WriteElementString(CoreWCF.XD.XmlSignatureDictionary.Prefix.Value, CoreWCF.XD.XmlSignatureDiction
 0526                writer.WriteEndElement();
 0527                writer.WriteEndElement();
 0528            }
 529        }
 530
 531        public class IdManager : SignatureTargetIdManager
 532        {
 0533            internal static readonly XmlDictionaryString ElementName = CoreWCF.XD.XmlEncryptionDictionary.EncryptedData;
 534
 0535            private IdManager()
 536            {
 0537            }
 538
 539            public override string DefaultIdNamespacePrefix
 540            {
 0541                get { return UtilityStrings.Prefix; }
 542            }
 543
 544            public override string DefaultIdNamespaceUri
 545            {
 0546                get { return UtilityStrings.Namespace; }
 547            }
 548
 0549            internal static IdManager Instance { get; } = new IdManager();
 550
 551            public override string ExtractId(XmlDictionaryReader reader)
 552            {
 0553                if (reader == null)
 554                {
 0555                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(reader));
 556                }
 557
 0558                if (reader.IsStartElement(ElementName, CoreWCF.XD.XmlEncryptionDictionary.Namespace))
 559                {
 0560                    return reader.GetAttribute(CoreWCF.XD.XmlEncryptionDictionary.Id, null);
 561                }
 562                else
 563                {
 0564                    return reader.GetAttribute(CoreWCF.XD.UtilityDictionary.IdAttribute, CoreWCF.XD.UtilityDictionary.Na
 565                }
 566            }
 567
 568            public override void WriteIdAttribute(XmlDictionaryWriter writer, string id)
 569            {
 0570                if (writer == null)
 571                {
 0572                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(writer));
 573                }
 574
 0575                writer.WriteAttributeString(CoreWCF.XD.UtilityDictionary.Prefix.Value, CoreWCF.XD.UtilityDictionary.IdAt
 0576            }
 577        }
 578    }
 579}

Methods/Properties

.ctor(CoreWCF.IdentityModel.Tokens.KeyInfoSerializer)
SecurityTokenSerializer()
PopulateKeyIdentifierClauseEntries(System.Collections.Generic.IList`1<CoreWCF.IdentityModel.Selectors.SecurityTokenSerializer/KeyIdentifierClauseEntry>)
PopulateJan2004StrEntries(System.Collections.Generic.IList`1<CoreWCF.IdentityModel.Selectors.SecurityTokenSerializer/StrEntry>)
PopulateStrEntries(System.Collections.Generic.IList`1<CoreWCF.IdentityModel.Selectors.SecurityTokenSerializer/StrEntry>)
PopulateJan2004TokenEntries(System.Collections.Generic.IList`1<CoreWCF.IdentityModel.Selectors.SecurityTokenSerializer/TokenEntry>)
PopulateTokenEntries(System.Collections.Generic.IList`1<CoreWCF.IdentityModel.Selectors.SecurityTokenSerializer/TokenEntry>)
.cctor()
.ctor(System.String)
.ctor(System.String[])
LocalName()
NamespaceUri()
TokenTypeUri()
ValueTypeUri()
SupportsTokenTypeUri(System.String)
LocalName()
NamespaceUri()
GetTokenTypesCore()
TokenTypeUri()
ValueTypeUri()
LocalName()
NamespaceUri()
GetTokenTypesCore()
TokenTypeUri()
ValueTypeUri()
LocalName()
NamespaceUri()
GetTokenTypesCore()
TokenTypeUri()
ValueTypeUri()
.ctor()
GetTokenTypesCore()
.ctor(System.Boolean,System.Collections.Generic.IList`1<CoreWCF.IdentityModel.Selectors.SecurityTokenSerializer/StrEntry>)
EmitBspRequiredAttributes()
StrEntries()
LocalName()
NamespaceUri()
ReadTokenType(System.Xml.XmlDictionaryReader)
ReadKeyIdentifierClauseCore(System.Xml.XmlDictionaryReader)
SupportsCore(CoreWCF.IdentityModel.SecurityKeyIdentifierClause)
WriteKeyIdentifierClauseCore(System.Xml.XmlDictionaryWriter,CoreWCF.IdentityModel.SecurityKeyIdentifierClause)
DefaultEncodingType()
EmitBspRequiredAttributes()
.ctor(System.Boolean)
CanReadClause(System.Xml.XmlDictionaryReader,System.String)
GetTokenType(CoreWCF.IdentityModel.SecurityKeyIdentifierClause)
ReadClause(System.Xml.XmlDictionaryReader,System.Byte[],System.Int32,System.String)
SupportsCore(CoreWCF.IdentityModel.SecurityKeyIdentifierClause)
WriteContent(System.Xml.XmlDictionaryWriter,CoreWCF.IdentityModel.SecurityKeyIdentifierClause)
ClauseType()
TokenType()
ValueTypeUri()
.ctor(System.Boolean)
CreateClause(System.Byte[],System.Byte[],System.Int32)
GetTokenTypeUri()
.ctor(System.Boolean,CoreWCF.IdentityModel.Tokens.KeyInfoSerializer)
GetTokenType(CoreWCF.IdentityModel.SecurityKeyIdentifierClause)
GetLocalTokenTypeUri(CoreWCF.IdentityModel.SecurityKeyIdentifierClause)
GetTokenTypeUri()
CanReadClause(System.Xml.XmlDictionaryReader,System.String)
ReadClause(System.Xml.XmlDictionaryReader,System.Byte[],System.Int32,System.String)
SupportsCore(CoreWCF.IdentityModel.SecurityKeyIdentifierClause)
WriteContent(System.Xml.XmlDictionaryWriter,CoreWCF.IdentityModel.SecurityKeyIdentifierClause)
GetTokenType(CoreWCF.IdentityModel.SecurityKeyIdentifierClause)
CanReadClause(System.Xml.XmlDictionaryReader,System.String)
GetTokenTypeUri()
ReadClause(System.Xml.XmlDictionaryReader,System.Byte[],System.Int32,System.String)
SupportsCore(CoreWCF.IdentityModel.SecurityKeyIdentifierClause)
WriteContent(System.Xml.XmlDictionaryWriter,CoreWCF.IdentityModel.SecurityKeyIdentifierClause)
.cctor()
.ctor()
DefaultIdNamespacePrefix()
DefaultIdNamespaceUri()
Instance()
ExtractId(System.Xml.XmlDictionaryReader)
WriteIdAttribute(System.Xml.XmlDictionaryWriter,System.String)