< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Security.Tokens.ProviderBackedSecurityToken
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Security/Tokens/ProviderBackedSecurityToken.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 23
Coverable lines: 23
Total lines: 143
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 12
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)0%220%
ResolveSecurityToken()100%110%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Security/Tokens/ProviderBackedSecurityToken.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.Security.Authentication.ExtendedProtection;
 6using CoreWCF.IdentityModel.Selectors;
 7using CoreWCF.IdentityModel.Tokens;
 8
 9namespace CoreWCF.Security.Tokens
 10{
 11    /// <summary>
 12    /// The ProviderBackedSecurityToken was added for the ChannelBindingToken work for Win7.
 13    /// It is used to delay the resolution of a token until it is needed.
 14    /// For the CBT, this delay is necessary as the CBT is not available until SecurityAppliedMessage.OnWriteMessage is 
 15    /// The CBT binds a token to the
 16    /// </summary>
 17    internal class ProviderBackedSecurityToken : SecurityToken
 18    {
 19        // Double-checked locking pattern requires volatile for read/write synchronization
 20#pragma warning disable CS0649 // The field is never assigned to
 21        private readonly SecurityToken _securityToken;
 22#pragma warning restore CS0649 // The field is never assigned to
 23        private TimeSpan _timeout;
 24        private ChannelBinding _channelBinding;
 25        private readonly object _lock;
 26
 27        /// <summary>
 28        /// Constructor to create an instance of this class.
 29        /// </summary>
 30        /// <param name="securityToken">SecurityToken that represents the SecurityTokenElement element.</param>
 031        public ProviderBackedSecurityToken(SecurityTokenProvider tokenProvider, TimeSpan timeout)
 32        {
 033            _lock = new object();
 034            TokenProvider = tokenProvider ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullE
 035            _timeout = timeout;
 036        }
 37
 038        public SecurityTokenProvider TokenProvider { get; }
 39
 40        public ChannelBinding ChannelBinding
 41        {
 042            set { _channelBinding = value; }
 43        }
 44
 45        private void ResolveSecurityToken()
 46        {
 047            throw new NotImplementedException();
 48            //TODO
 49            //if ( _securityToken == null )
 50            //{
 51            //    lock ( _lock )
 52            //    {
 53            //        if ( _securityToken == null )
 54            //        {
 55
 56            //            ClientCredentialsSecurityTokenManager.KerberosSecurityTokenProviderWrapper kerbTokenProvider =
 57            //                                            as ClientCredentialsSecurityTokenManager.KerberosSecurityToken
 58            //            if (kerbTokenProvider != null)
 59            //            {
 60            //                _securityToken = kerbTokenProvider.GetToken((new TimeoutHelper(_timeout)).RemainingTime(),
 61            //            }
 62            //            else
 63            //            {
 64            //                _securityToken = _tokenProvider.GetToken((new TimeoutHelper(_timeout)).RemainingTime());
 65            //            }
 66            //        }
 67            //    }
 68            //}
 69
 70            //if ( _securityToken == null )
 71            //{
 72            //    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new SecurityTokenException( SR.Format( SR.S
 73            //}
 74
 75            //return;
 76        }
 77
 78        public SecurityToken Token
 79        {
 80            get
 81            {
 082                if (_securityToken == null)
 83                {
 084                    ResolveSecurityToken();
 85                }
 86
 087                return _securityToken;
 88            }
 89        }
 90
 91        public override string Id
 92        {
 93            get
 94            {
 095                if (_securityToken == null)
 96                {
 097                    ResolveSecurityToken();
 98                }
 99
 0100                return _securityToken.Id;
 101            }
 102        }
 103
 104        public override System.Collections.ObjectModel.ReadOnlyCollection<SecurityKey> SecurityKeys
 105        {
 106            get
 107            {
 0108                if (_securityToken == null)
 109                {
 0110                    ResolveSecurityToken();
 111                }
 112
 0113                return _securityToken.SecurityKeys;
 114            }
 115        }
 116
 117        public override DateTime ValidFrom
 118        {
 119            get
 120            {
 0121                if (_securityToken == null)
 122                {
 0123                    ResolveSecurityToken();
 124                }
 125
 0126                return _securityToken.ValidFrom;
 127            }
 128        }
 129
 130        public override DateTime ValidTo
 131        {
 132            get
 133            {
 0134                if (_securityToken == null)
 135                {
 0136                    ResolveSecurityToken();
 137                }
 138
 0139                return _securityToken.ValidTo;
 140            }
 141        }
 142    }
 143}