< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Security.RequestSecurityTokenResponse
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Security/RequestSecurityTokenResponse.cs
Line coverage
42%
Covered lines: 103
Uncovered lines: 141
Coverable lines: 244
Total lines: 716
Line coverage: 42.2%
Branch coverage
31%
Covered branches: 33
Total branches: 106
Branch coverage: 31.1%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.cctor()100%11100%
.ctor()100%110%
.ctor(...)100%110%
.ctor(...)100%110%
.ctor(...)100%110%
.ctor(...)50%22100%
.ctor(...)0%440%
.ctor(...)100%110%
SetIssuerEntropy(...)50%4475%
SetIssuerEntropy(...)0%220%
GetIssuerEntropy()100%11100%
GetIssuerEntropy(...)50%2266.66%
SetLifetime(...)50%4475%
SetAppliesTo(...)0%660%
GetAppliesToQName(...)0%220%
GetAppliesTo()100%110%
GetAppliesTo(...)0%440%
SetBinaryNegotiation(...)0%440%
GetBinaryNegotiation()50%2266.66%
SetAuthenticator(...)0%440%
GetAuthenticator()50%4442.85%
OnWriteTo(...)50%2275%
WriteTo(...)66.66%6681.25%
CreateFrom(...)100%110%
CreateFrom(...)100%110%
CreateFrom(...)100%110%
OnWriteBodyContents(...)100%11100%
MakeReadOnly()100%22100%
GetIssuedToken(...)100%110%
GetIssuedToken(...)0%220%
GetIssuedToken(...)0%220%
OnWriteCustomAttributes(...)100%11100%
OnWriteCustomElements(...)100%11100%
OnMakeReadOnly()100%11100%
ComputeCombinedKey(...)50%8862.5%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Security/RequestSecurityTokenResponse.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.Collections.ObjectModel;
 7using System.IO;
 8using System.Runtime.Serialization;
 9using System.Security.Cryptography;
 10using System.Xml;
 11using CoreWCF.Channels;
 12using CoreWCF.Dispatcher;
 13using CoreWCF.IdentityModel;
 14using CoreWCF.IdentityModel.Policy;
 15using CoreWCF.IdentityModel.Selectors;
 16using CoreWCF.IdentityModel.Tokens;
 17using CoreWCF.Runtime;
 18using CoreWCF.Security.Tokens;
 19using Psha1DerivedKeyGenerator = CoreWCF.IdentityModel.Psha1DerivedKeyGenerator;
 20
 21namespace CoreWCF.Security
 22{
 23    internal class RequestSecurityTokenResponse : BodyWriter
 24    {
 225        private static readonly int s_minSaneKeySizeInBits = 8 * 8; // 8 Bytes.
 226        private static readonly int s_maxSaneKeySizeInBits = (16 * 1024) * 8; // 16 K
 27        private SecurityStandardsManager _standardsManager;
 28        private string _context;
 29        private int _keySize;
 30        private bool _computeKey;
 31        private string _tokenType;
 32        private SecurityKeyIdentifierClause _requestedAttachedReference;
 33        private SecurityKeyIdentifierClause _requestedUnattachedReference;
 34        private SecurityToken _issuedToken;
 35        private SecurityToken _proofToken;
 36        private SecurityToken _entropyToken;
 37        private BinaryNegotiation _negotiationData;
 38        private readonly XmlElement _rstrXml;
 39        private bool _isLifetimeSet;
 40        private byte[] _authenticator;
 41        private byte[] _cachedWriteBuffer;
 42        private int _cachedWriteBufferLength;
 43        private bool _isRequestedTokenClosed;
 44        private object _appliesTo;
 45        private XmlObjectSerializer _appliesToSerializer;
 46        private Type _appliesToType;
 47
 48        public RequestSecurityTokenResponse()
 049            : this(SecurityStandardsManager.DefaultInstance)
 50        {
 051        }
 52
 53        public RequestSecurityTokenResponse(MessageSecurityVersion messageSecurityVersion, SecurityTokenSerializer secur
 054            : this(SecurityUtils.CreateSecurityStandardsManager(messageSecurityVersion, securityTokenSerializer))
 55        {
 056        }
 57
 58        public RequestSecurityTokenResponse(XmlElement requestSecurityTokenResponseXml,
 59                                            string context,
 60                                            string tokenType,
 61                                            int keySize,
 62                                            SecurityKeyIdentifierClause requestedAttachedReference,
 63                                            SecurityKeyIdentifierClause requestedUnattachedReference,
 64                                            bool computeKey,
 65                                            DateTime validFrom,
 66                                            DateTime validTo,
 67                                            bool isRequestedTokenClosed)
 068            : this(SecurityStandardsManager.DefaultInstance,
 069                   requestSecurityTokenResponseXml,
 070                   context,
 071                   tokenType,
 072                   keySize,
 073                   requestedAttachedReference,
 074                   requestedUnattachedReference,
 075                   computeKey,
 076                   validFrom,
 077                   validTo,
 078                   isRequestedTokenClosed)
 79        {
 080        }
 81
 82        public RequestSecurityTokenResponse(MessageSecurityVersion messageSecurityVersion,
 83                                            SecurityTokenSerializer securityTokenSerializer,
 84                                            XmlElement requestSecurityTokenResponseXml,
 85                                            string context,
 86                                            string tokenType,
 87                                            int keySize,
 88                                            SecurityKeyIdentifierClause requestedAttachedReference,
 89                                            SecurityKeyIdentifierClause requestedUnattachedReference,
 90                                            bool computeKey,
 91                                            DateTime validFrom,
 92                                            DateTime validTo,
 93                                            bool isRequestedTokenClosed)
 094            : this(SecurityUtils.CreateSecurityStandardsManager(messageSecurityVersion, securityTokenSerializer),
 095                   requestSecurityTokenResponseXml,
 096                   context,
 097                   tokenType,
 098                   keySize,
 099                   requestedAttachedReference,
 0100                   requestedUnattachedReference,
 0101                   computeKey,
 0102                   validFrom,
 0103                   validTo,
 0104                   isRequestedTokenClosed)
 105        {
 0106        }
 107
 108        internal RequestSecurityTokenResponse(SecurityStandardsManager standardsManager)
 20109            : base(true)
 110        {
 20111            _standardsManager = standardsManager ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new Argume
 20112            ValidFrom = SecurityUtils.MinUtcDateTime;
 20113            ValidTo = SecurityUtils.MaxUtcDateTime;
 20114            _isRequestedTokenClosed = false;
 20115            _isLifetimeSet = false;
 20116            IsReceiver = false;
 20117            IsReadOnly = false;
 20118        }
 119
 120        internal RequestSecurityTokenResponse(SecurityStandardsManager standardsManager,
 121                                              XmlElement rstrXml,
 122                                              string context,
 123                                              string tokenType,
 124                                              int keySize,
 125                                              SecurityKeyIdentifierClause requestedAttachedReference,
 126                                              SecurityKeyIdentifierClause requestedUnattachedReference,
 127                                              bool computeKey,
 128                                              DateTime validFrom,
 129                                              DateTime validTo,
 130                                              bool isRequestedTokenClosed)
 0131            : base(true)
 132        {
 0133            _standardsManager = standardsManager ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new Argume
 0134            _rstrXml = rstrXml ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(rstrXml));
 0135            _context = context;
 0136            _tokenType = tokenType;
 0137            _keySize = keySize;
 0138            _requestedAttachedReference = requestedAttachedReference;
 0139            _requestedUnattachedReference = requestedUnattachedReference;
 0140            _computeKey = computeKey;
 0141            ValidFrom = validFrom.ToUniversalTime();
 0142            ValidTo = validTo.ToUniversalTime();
 0143            _isLifetimeSet = true;
 0144            _isRequestedTokenClosed = isRequestedTokenClosed;
 145            // this.issuedTokenBuffer = issuedTokenBuffer;
 0146            IsReceiver = true;
 0147            IsReadOnly = true;
 0148        }
 149
 150        public RequestSecurityTokenResponse(SecurityStandardsManager standardsManager,
 151            XmlElement rstrXml,
 152            string context,
 153            string tokenType, int keySize, SecurityKeyIdentifierClause requestedAttachedReference,
 154            SecurityKeyIdentifierClause requestedUnattachedReference, bool computeKey, DateTime validFrom, DateTime vali
 155            bool isRequestedTokenClosed, XmlBuffer issuedTokenBuffer) :
 0156            this(standardsManager, rstrXml, context, tokenType, keySize, requestedAttachedReference, requestedUnattached
 157        {
 0158            IssuedTokenBuffer = issuedTokenBuffer;
 0159        }
 160
 161        public string Context
 162        {
 163            get
 164            {
 20165                return _context;
 166            }
 167            set
 168            {
 20169                if (IsReadOnly)
 170                {
 0171                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.ObjectIsR
 172                }
 173
 20174                _context = value;
 20175            }
 176        }
 177
 178        public string TokenType
 179        {
 180            get
 181            {
 30182                return _tokenType;
 183            }
 184            set
 185            {
 10186                if (IsReadOnly)
 187                {
 0188                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.ObjectIsR
 189                }
 190
 10191                _tokenType = value;
 10192            }
 193        }
 194
 195        public SecurityKeyIdentifierClause RequestedAttachedReference
 196        {
 197            get
 198            {
 30199                return _requestedAttachedReference;
 200            }
 201            set
 202            {
 10203                if (IsReadOnly)
 204                {
 0205                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.ObjectIsR
 206                }
 207
 10208                _requestedAttachedReference = value;
 10209            }
 210        }
 211
 212        public SecurityKeyIdentifierClause RequestedUnattachedReference
 213        {
 214            get
 215            {
 30216                return _requestedUnattachedReference;
 217            }
 218            set
 219            {
 10220                if (IsReadOnly)
 221                {
 0222                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.ObjectIsR
 223                }
 224
 10225                _requestedUnattachedReference = value;
 10226            }
 227        }
 228
 40229        public DateTime ValidFrom { get; private set; }
 230
 40231        public DateTime ValidTo { get; private set; }
 232
 233        public bool ComputeKey
 234        {
 235            get
 236            {
 30237                return _computeKey;
 238            }
 239            set
 240            {
 10241                if (IsReadOnly)
 242                {
 0243                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.ObjectIsR
 244                }
 245
 10246                _computeKey = value;
 10247            }
 248        }
 249
 250        public int KeySize
 251        {
 252            get
 253            {
 30254                return _keySize;
 255            }
 256            set
 257            {
 10258                if (IsReadOnly)
 259                {
 0260                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.ObjectIsR
 261                }
 262
 10263                if (value < 0)
 264                {
 0265                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(val
 266                }
 267
 10268                _keySize = value;
 10269            }
 270        }
 271
 272        public bool IsRequestedTokenClosed
 273        {
 274            get
 275            {
 20276                return _isRequestedTokenClosed;
 277            }
 278            set
 279            {
 10280                if (IsReadOnly)
 281                {
 0282                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.ObjectIsR
 283                }
 284
 10285                _isRequestedTokenClosed = value;
 10286            }
 287        }
 288
 190289        public bool IsReadOnly { get; private set; }
 290
 20291        protected object ThisLock { get; } = new object();
 292
 200293        internal bool IsReceiver { get; }
 294
 295        internal SecurityStandardsManager StandardsManager
 296        {
 297            get
 298            {
 0299                return _standardsManager;
 300            }
 301            set
 302            {
 0303                if (IsReadOnly)
 304                {
 0305                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.ObjectIsR
 306                }
 307
 0308                _standardsManager = (value ?? SecurityStandardsManager.DefaultInstance);
 0309            }
 310        }
 311
 312        public SecurityToken EntropyToken
 313        {
 314            get
 315            {
 0316                if (IsReceiver)
 317                {
 0318                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR
 319                }
 0320                return _entropyToken;
 321            }
 322        }
 323
 324        public SecurityToken RequestedSecurityToken
 325        {
 326            get
 327            {
 40328                if (IsReceiver)
 329                {
 0330                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR
 331                }
 40332                return _issuedToken;
 333            }
 334            set
 335            {
 10336                if (IsReadOnly)
 337                {
 0338                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.ObjectIsR
 339                }
 340
 10341                _issuedToken = value;
 10342            }
 343        }
 344
 345        public SecurityToken RequestedProofToken
 346        {
 347            get
 348            {
 10349                if (IsReceiver)
 350                {
 0351                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR
 352                }
 10353                return _proofToken;
 354            }
 355            set
 356            {
 0357                if (IsReadOnly)
 358                {
 0359                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.ObjectIsR
 360                }
 361
 0362                _proofToken = value;
 0363            }
 364        }
 365
 366        public XmlElement RequestSecurityTokenResponseXml
 367        {
 368            get
 369            {
 0370                if (!IsReceiver)
 371                {
 0372                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR
 373                }
 0374                return _rstrXml;
 375            }
 376        }
 377
 378        internal object AppliesTo
 379        {
 380            get
 381            {
 20382                if (IsReceiver)
 383                {
 0384                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR
 385                }
 20386                return _appliesTo;
 387            }
 388        }
 389
 390        internal XmlObjectSerializer AppliesToSerializer
 391        {
 392            get
 393            {
 0394                if (IsReceiver)
 395                {
 0396                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR
 397                }
 0398                return _appliesToSerializer;
 399            }
 400        }
 401
 402        internal Type AppliesToType
 403        {
 404            get
 405            {
 0406                if (IsReceiver)
 407                {
 0408                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR
 409                }
 0410                return _appliesToType;
 411            }
 412        }
 413
 414        internal bool IsLifetimeSet
 415        {
 416            get
 417            {
 30418                if (IsReceiver)
 419                {
 0420                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR
 421                }
 30422                return _isLifetimeSet;
 423            }
 424        }
 425
 0426        internal CoreWCF.XmlBuffer IssuedTokenBuffer { get; }
 427
 428        public void SetIssuerEntropy(byte[] issuerEntropy)
 429        {
 10430            if (IsReadOnly)
 431            {
 0432                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.ObjectIsReadO
 433            }
 434
 10435            _entropyToken = (issuerEntropy != null) ? new NonceToken(issuerEntropy) : null;
 10436        }
 437
 438        internal void SetIssuerEntropy(WrappedKeySecurityToken issuerEntropy)
 439        {
 0440            if (IsReadOnly)
 441            {
 0442                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.ObjectIsReadO
 443            }
 444
 0445            _entropyToken = issuerEntropy;
 0446        }
 447
 448        public SecurityToken GetIssuerEntropy()
 449        {
 20450            return GetIssuerEntropy(null);
 451        }
 452
 453        internal SecurityToken GetIssuerEntropy(SecurityTokenResolver resolver)
 454        {
 20455            if (IsReceiver)
 456            {
 0457                return _standardsManager.TrustDriver.GetEntropy(this, resolver);
 458            }
 459            else
 460            {
 20461                return _entropyToken;
 462            }
 463        }
 464
 465        public void SetLifetime(DateTime validFrom, DateTime validTo)
 466        {
 10467            if (IsReadOnly)
 468            {
 0469                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.ObjectIsReadO
 470            }
 471
 10472            if (validFrom.ToUniversalTime() > validTo.ToUniversalTime())
 473            {
 0474                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(SR.EffectiveGreaterThanExpiration);
 475            }
 10476            ValidFrom = validFrom.ToUniversalTime();
 10477            ValidTo = validTo.ToUniversalTime();
 10478            _isLifetimeSet = true;
 10479        }
 480
 481        public void SetAppliesTo<T>(T appliesTo, XmlObjectSerializer serializer)
 482        {
 0483            if (IsReadOnly)
 484            {
 0485                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.ObjectIsReadO
 486            }
 487
 0488            if (appliesTo != null && serializer == null)
 489            {
 0490                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(serializer));
 491            }
 0492            _appliesTo = appliesTo;
 0493            _appliesToSerializer = serializer;
 0494            _appliesToType = typeof(T);
 0495        }
 496
 497        public void GetAppliesToQName(out string localName, out string namespaceUri)
 498        {
 0499            if (!IsReceiver)
 500            {
 0501                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.Ite
 502            }
 503
 0504            _standardsManager.TrustDriver.GetAppliesToQName(this, out localName, out namespaceUri);
 0505        }
 506
 507        public T GetAppliesTo<T>()
 508        {
 0509            return GetAppliesTo<T>(DataContractSerializerDefaults.CreateSerializer(typeof(T), DataContractSerializerDefa
 510        }
 511
 512        public T GetAppliesTo<T>(XmlObjectSerializer serializer)
 513        {
 0514            if (IsReceiver)
 515            {
 0516                if (serializer == null)
 517                {
 0518                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(serializer));
 519                }
 0520                return _standardsManager.TrustDriver.GetAppliesTo<T>(this, serializer);
 521            }
 522            else
 523            {
 0524                return (T)_appliesTo;
 525            }
 526        }
 527
 528        internal void SetBinaryNegotiation(BinaryNegotiation negotiation)
 529        {
 0530            if (IsReadOnly)
 531            {
 0532                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.ObjectIsReadO
 533            }
 534
 0535            _negotiationData = negotiation ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(ne
 0536        }
 537
 538        internal BinaryNegotiation GetBinaryNegotiation()
 539        {
 20540            if (IsReceiver)
 541            {
 0542                return _standardsManager.TrustDriver.GetBinaryNegotiation(this);
 543            }
 544            else
 545            {
 20546                return _negotiationData;
 547            }
 548        }
 549
 550        internal void SetAuthenticator(byte[] authenticator)
 551        {
 0552            if (authenticator == null)
 553            {
 0554                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(authenticator));
 555            }
 556
 0557            if (IsReadOnly)
 558            {
 0559                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.ObjectIsReadO
 560            }
 561
 0562            _authenticator = Fx.AllocateByteArray(authenticator.Length);
 0563            Buffer.BlockCopy(authenticator, 0, _authenticator, 0, authenticator.Length);
 0564        }
 565
 566        internal byte[] GetAuthenticator()
 567        {
 20568            if (IsReceiver)
 569            {
 0570                return _standardsManager.TrustDriver.GetAuthenticator(this);
 571            }
 572            else
 573            {
 20574                if (_authenticator == null)
 575                {
 20576                    return null;
 577                }
 578                else
 579                {
 0580                    byte[] result = Fx.AllocateByteArray(_authenticator.Length);
 0581                    Buffer.BlockCopy(_authenticator, 0, result, 0, _authenticator.Length);
 0582                    return result;
 583                }
 584            }
 585        }
 586
 587        private void OnWriteTo(XmlWriter w)
 588        {
 20589            if (IsReceiver)
 590            {
 0591                _rstrXml.WriteTo(w);
 592            }
 593            else
 594            {
 20595                _standardsManager.TrustDriver.WriteRequestSecurityTokenResponse(this, w);
 596            }
 20597        }
 598
 599        public void WriteTo(XmlWriter writer)
 600        {
 20601            if (writer == null)
 602            {
 0603                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(writer));
 604            }
 605
 20606            if (IsReadOnly)
 607            {
 608                // cache the serialized bytes to ensure repeatability
 20609                if (_cachedWriteBuffer == null)
 610                {
 20611                    MemoryStream stream = new MemoryStream();
 20612                    using (XmlDictionaryWriter binaryWriter = XmlDictionaryWriter.CreateBinaryWriter(stream, XD.Dictiona
 613                    {
 20614                        OnWriteTo(binaryWriter);
 20615                        binaryWriter.Flush();
 20616                        stream.Flush();
 20617                        stream.Seek(0, SeekOrigin.Begin);
 20618                        _cachedWriteBuffer = stream.GetBuffer();
 20619                        _cachedWriteBufferLength = (int)stream.Length;
 20620                    }
 621                }
 20622                writer.WriteNode(XmlDictionaryReader.CreateBinaryReader(_cachedWriteBuffer, 0, _cachedWriteBufferLength,
 623            }
 624            else
 625            {
 0626                OnWriteTo(writer);
 627            }
 0628        }
 629
 630        public static RequestSecurityTokenResponse CreateFrom(XmlReader reader)
 631        {
 0632            return CreateFrom(SecurityStandardsManager.DefaultInstance, reader);
 633        }
 634
 635        public static RequestSecurityTokenResponse CreateFrom(XmlReader reader, MessageSecurityVersion messageSecurityVe
 636        {
 0637            return CreateFrom(SecurityUtils.CreateSecurityStandardsManager(messageSecurityVersion, securityTokenSerializ
 638        }
 639
 640        internal static RequestSecurityTokenResponse CreateFrom(SecurityStandardsManager standardsManager, XmlReader rea
 641        {
 0642            return standardsManager.TrustDriver.CreateRequestSecurityTokenResponse(reader);
 643        }
 644
 645        protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
 646        {
 12647            WriteTo(writer);
 12648        }
 649
 650        public void MakeReadOnly()
 651        {
 20652            if (!IsReadOnly)
 653            {
 20654                IsReadOnly = true;
 20655                OnMakeReadOnly();
 656            }
 20657        }
 658
 659        public GenericXmlSecurityToken GetIssuedToken(SecurityTokenResolver resolver, IList<SecurityTokenAuthenticator> 
 660            ReadOnlyCollection<IAuthorizationPolicy> authorizationPolicies)
 661        {
 0662            return GetIssuedToken(resolver, allowedAuthenticators, keyEntropyMode, requestorEntropy, expectedTokenType, 
 663        }
 664
 665        public virtual GenericXmlSecurityToken GetIssuedToken(SecurityTokenResolver resolver, IList<SecurityTokenAuthent
 666            ReadOnlyCollection<IAuthorizationPolicy> authorizationPolicies, int defaultKeySize, bool isBearerKeyType)
 667        {
 0668            if (!IsReceiver)
 669            {
 0670                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.Ite
 671            }
 672
 0673            return _standardsManager.TrustDriver.GetIssuedToken(this, resolver, allowedAuthenticators, keyEntropyMode, r
 674        }
 675
 676        public virtual GenericXmlSecurityToken GetIssuedToken(string expectedTokenType, ReadOnlyCollection<IAuthorizatio
 677        {
 0678            if (!IsReceiver)
 679            {
 0680                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.Ite
 681            }
 682
 0683            return _standardsManager.TrustDriver.GetIssuedToken(this, expectedTokenType, authorizationPolicies, clientKe
 684        }
 685
 686        protected internal virtual void OnWriteCustomAttributes(XmlWriter writer)
 20687        { }
 688
 689        protected internal virtual void OnWriteCustomElements(XmlWriter writer)
 20690        { }
 691
 20692        protected virtual void OnMakeReadOnly() { }
 693
 694        public static byte[] ComputeCombinedKey(byte[] requestorEntropy, byte[] issuerEntropy, int keySizeInBits)
 695        {
 10696            if (requestorEntropy == null)
 697            {
 0698                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(requestorEntropy));
 699            }
 700
 10701            if (issuerEntropy == null)
 702            {
 0703                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(issuerEntropy));
 704            }
 705            // Do a sanity check here. We don't want to allow invalid keys or keys that are too
 706            // large.
 10707            if ((keySizeInBits < s_minSaneKeySizeInBits) || (keySizeInBits > s_maxSaneKeySizeInBits))
 708            {
 0709                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityNegotiationException(SR.Format(SR.
 710            }
 711
 10712            Psha1DerivedKeyGenerator generator = new Psha1DerivedKeyGenerator(requestorEntropy);
 10713            return generator.GenerateDerivedKey(Array.Empty<byte>(), issuerEntropy, keySizeInBits, 0);
 714        }
 715    }
 716}

Methods/Properties

.cctor()
.ctor()
.ctor(CoreWCF.MessageSecurityVersion,CoreWCF.IdentityModel.Selectors.SecurityTokenSerializer)
.ctor(System.Xml.XmlElement,System.String,System.String,System.Int32,CoreWCF.IdentityModel.SecurityKeyIdentifierClause,CoreWCF.IdentityModel.SecurityKeyIdentifierClause,System.Boolean,System.DateTime,System.DateTime,System.Boolean)
.ctor(CoreWCF.MessageSecurityVersion,CoreWCF.IdentityModel.Selectors.SecurityTokenSerializer,System.Xml.XmlElement,System.String,System.String,System.Int32,CoreWCF.IdentityModel.SecurityKeyIdentifierClause,CoreWCF.IdentityModel.SecurityKeyIdentifierClause,System.Boolean,System.DateTime,System.DateTime,System.Boolean)
.ctor(CoreWCF.Security.SecurityStandardsManager)
.ctor(CoreWCF.Security.SecurityStandardsManager,System.Xml.XmlElement,System.String,System.String,System.Int32,CoreWCF.IdentityModel.SecurityKeyIdentifierClause,CoreWCF.IdentityModel.SecurityKeyIdentifierClause,System.Boolean,System.DateTime,System.DateTime,System.Boolean)
.ctor(CoreWCF.Security.SecurityStandardsManager,System.Xml.XmlElement,System.String,System.String,System.Int32,CoreWCF.IdentityModel.SecurityKeyIdentifierClause,CoreWCF.IdentityModel.SecurityKeyIdentifierClause,System.Boolean,System.DateTime,System.DateTime,System.Boolean,CoreWCF.XmlBuffer)
Context()
Context(System.String)
TokenType()
TokenType(System.String)
RequestedAttachedReference()
RequestedAttachedReference(CoreWCF.IdentityModel.SecurityKeyIdentifierClause)
RequestedUnattachedReference()
RequestedUnattachedReference(CoreWCF.IdentityModel.SecurityKeyIdentifierClause)
ValidFrom()
ValidTo()
ComputeKey()
ComputeKey(System.Boolean)
KeySize()
KeySize(System.Int32)
IsRequestedTokenClosed()
IsRequestedTokenClosed(System.Boolean)
IsReadOnly()
ThisLock()
IsReceiver()
StandardsManager()
StandardsManager(CoreWCF.Security.SecurityStandardsManager)
EntropyToken()
RequestedSecurityToken()
RequestedSecurityToken(CoreWCF.IdentityModel.Tokens.SecurityToken)
RequestedProofToken()
RequestedProofToken(CoreWCF.IdentityModel.Tokens.SecurityToken)
RequestSecurityTokenResponseXml()
AppliesTo()
AppliesToSerializer()
AppliesToType()
IsLifetimeSet()
IssuedTokenBuffer()
SetIssuerEntropy(System.Byte[])
SetIssuerEntropy(CoreWCF.Security.Tokens.WrappedKeySecurityToken)
GetIssuerEntropy()
GetIssuerEntropy(CoreWCF.IdentityModel.Selectors.SecurityTokenResolver)
SetLifetime(System.DateTime,System.DateTime)
SetAppliesTo(T,System.Runtime.Serialization.XmlObjectSerializer)
GetAppliesToQName(System.String&,System.String&)
GetAppliesTo()
GetAppliesTo(System.Runtime.Serialization.XmlObjectSerializer)
SetBinaryNegotiation(CoreWCF.Security.BinaryNegotiation)
GetBinaryNegotiation()
SetAuthenticator(System.Byte[])
GetAuthenticator()
OnWriteTo(System.Xml.XmlWriter)
WriteTo(System.Xml.XmlWriter)
CreateFrom(System.Xml.XmlReader)
CreateFrom(System.Xml.XmlReader,CoreWCF.MessageSecurityVersion,CoreWCF.IdentityModel.Selectors.SecurityTokenSerializer)
CreateFrom(CoreWCF.Security.SecurityStandardsManager,System.Xml.XmlReader)
OnWriteBodyContents(System.Xml.XmlDictionaryWriter)
MakeReadOnly()
GetIssuedToken(CoreWCF.IdentityModel.Selectors.SecurityTokenResolver,System.Collections.Generic.IList`1<CoreWCF.IdentityModel.Selectors.SecurityTokenAuthenticator>,CoreWCF.Security.SecurityKeyEntropyMode,System.Byte[],System.String,System.Collections.ObjectModel.ReadOnlyCollection`1<CoreWCF.IdentityModel.Policy.IAuthorizationPolicy>)
GetIssuedToken(CoreWCF.IdentityModel.Selectors.SecurityTokenResolver,System.Collections.Generic.IList`1<CoreWCF.IdentityModel.Selectors.SecurityTokenAuthenticator>,CoreWCF.Security.SecurityKeyEntropyMode,System.Byte[],System.String,System.Collections.ObjectModel.ReadOnlyCollection`1<CoreWCF.IdentityModel.Policy.IAuthorizationPolicy>,System.Int32,System.Boolean)
GetIssuedToken(System.String,System.Collections.ObjectModel.ReadOnlyCollection`1<CoreWCF.IdentityModel.Policy.IAuthorizationPolicy>,System.Security.Cryptography.RSA)
OnWriteCustomAttributes(System.Xml.XmlWriter)
OnWriteCustomElements(System.Xml.XmlWriter)
OnMakeReadOnly()
ComputeCombinedKey(System.Byte[],System.Byte[],System.Int32)