< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.IdentityModel.Tokens.SecurityTokenHandlerConfiguration
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/IdentityModel/Tokens/SecurityTokenHandlerConfiguration.cs
Line coverage
75%
Covered lines: 40
Uncovered lines: 13
Coverable lines: 53
Total lines: 249
Line coverage: 75.4%
Branch coverage
25%
Covered branches: 4
Total branches: 16
Branch coverage: 25%
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%11100%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/IdentityModel/Tokens/SecurityTokenHandlerConfiguration.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.Cryptography.X509Certificates;
 6using CoreWCF.IdentityModel.Configuration;
 7using CoreWCF.IdentityModel.Selectors;
 8using CoreWCF.Security;
 9
 10namespace CoreWCF.IdentityModel.Tokens
 11{
 12    /// <summary>
 13    /// Configuration common to all SecurityTokenHandlers.
 14    /// </summary>
 15    public class SecurityTokenHandlerConfiguration
 16    {
 17        /// <summary>
 18        /// Gets a value indicating whether or not to detect replay tokens by default.
 19        /// </summary>
 20        public static readonly bool DefaultDetectReplayedTokens; // false
 21
 22        /// <summary>
 23        /// Gets the default issuer name registry.
 24        /// </summary>
 225        public static readonly IssuerNameRegistry DefaultIssuerNameRegistry = new ConfigurationBasedIssuerNameRegistry()
 26
 27        /// <summary>
 28        /// Gets the default issuer token resolver.
 29        /// </summary>
 230        public static readonly SecurityTokenResolver DefaultIssuerTokenResolver = CoreWCF.IdentityModel.Tokens.IssuerTok
 31
 32        /// <summary>
 33        /// Gets the default maximum clock skew.
 34        /// </summary>
 235        public static readonly TimeSpan DefaultMaxClockSkew = new TimeSpan(0, 5, 0); // 5 minutes
 36
 37        /// <summary>
 38        /// Gets a value indicating whether or not to save bootstrap tokens by default.
 39        /// </summary>
 40        public static readonly bool DefaultSaveBootstrapContext; // false;
 41
 42        /// <summary>
 43        /// Gets the default token replay cache expiration period.
 44        /// </summary>
 245        public static readonly TimeSpan DefaultTokenReplayCacheExpirationPeriod = TimeSpan.MaxValue;
 46
 47        // The below 3 defaults were moved from  IdentityConfiguration class as we can not have service configuration in
 48
 49        /// <summary>
 50        /// Gets the default X.509 certificate validation mode.
 51        /// </summary>
 252        public static readonly X509CertificateValidationMode DefaultCertificateValidationMode = IdentityConfiguration.De
 53
 54        /// <summary>
 55        /// Gets the default X.509 certificate revocation validation mode.
 56        /// </summary>
 257        public static readonly X509RevocationMode DefaultRevocationMode = IdentityConfiguration.DefaultRevocationMode;
 58
 59        /// <summary>
 60        /// Gets the default X.509 certificate trusted store location.
 61        /// </summary>
 262        public static readonly StoreLocation DefaultTrustedStoreLocation = IdentityConfiguration.DefaultTrustedStoreLoca
 1063        X509CertificateValidationMode certificateValidationMode = DefaultCertificateValidationMode;
 64
 65        /// <summary>
 66        /// Gets the default X.509 certificate validator instance.
 67        /// </summary>
 268        public static readonly X509CertificateValidator DefaultCertificateValidator = X509Util.CreateCertificateValidato
 1069        private AudienceRestriction _audienceRestriction = new AudienceRestriction();
 1070        private X509CertificateValidator _certificateValidator = DefaultCertificateValidator;
 1071        private IssuerNameRegistry _issuerNameRegistry = DefaultIssuerNameRegistry;
 1072        private SecurityTokenResolver _issuerTokenResolver = DefaultIssuerTokenResolver;
 1073        private TimeSpan _maxClockSkew = DefaultMaxClockSkew;
 1074        private SecurityTokenResolver _serviceTokenResolver = EmptySecurityTokenResolver.Instance;
 1075        private TimeSpan _tokenReplayCacheExpirationPeriod = DefaultTokenReplayCacheExpirationPeriod;
 1076        private IdentityModelCaches _caches = new IdentityModelCaches();
 77
 78        /// <summary>
 79        /// Creates an instance of <see cref="SecurityTokenHandlerConfiguration"/>
 80        /// </summary>
 1081        public SecurityTokenHandlerConfiguration()
 82        {
 1083        }
 84
 85        /// <summary>
 86        /// Gets or sets the AudienceRestriction.
 87        /// </summary>
 88        public AudienceRestriction AudienceRestriction
 89        {
 90            get
 91            {
 13892                return _audienceRestriction;
 93            }
 94
 95            set
 96            {
 097                _audienceRestriction = value ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(
 098            }
 99        }
 100
 101        /// <summary>
 102        /// Gets or sets the certificate validator used by handlers to validate issuer certificates
 103        /// </summary>
 104        public X509CertificateValidator CertificateValidator
 105        {
 106            get
 107            {
 30108                return _certificateValidator;
 109            }
 110
 111            set
 112            {
 4113                _certificateValidator = value ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof
 4114            }
 115        }
 116
 12117        public X509RevocationMode RevocationMode { get; set; } = DefaultRevocationMode;
 118
 119        /// <summary>
 120        /// Gets or sets the trusted store location used by handlers to validate issuer certificates
 121        /// </summary>
 10122        public StoreLocation TrustedStoreLocation { get; set; } = DefaultTrustedStoreLocation;
 123
 124        /// <summary>
 125        /// Gets or sets the certificate validation mode used by handlers to validate issuer certificates
 126        /// </summary>
 127        public X509CertificateValidationMode CertificateValidationMode
 128        {
 0129            get { return certificateValidationMode; }
 4130            set { certificateValidationMode = value; }
 131        }
 132
 133        /// <summary>
 134        /// Gets or sets a value indicating whether to detect replaying of tokens by handlers in this configuration.
 135        /// </summary>
 58136        public bool DetectReplayedTokens { get; set; } = DefaultDetectReplayedTokens;
 137
 138        /// <summary>
 139        /// Gets or sets the IssuerNameRegistry.
 140        /// </summary>
 141        public IssuerNameRegistry IssuerNameRegistry
 142        {
 143            get
 144            {
 32145                return _issuerNameRegistry;
 146            }
 147
 148            set
 149            {
 4150                _issuerNameRegistry = value ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(v
 4151            }
 152        }
 153
 154        /// <summary>
 155        /// Gets or sets the IssuerTokenResolver.
 156        /// </summary>
 157        public SecurityTokenResolver IssuerTokenResolver
 158        {
 159            get
 160            {
 50161                return _issuerTokenResolver;
 162            }
 163
 164            set
 165            {
 4166                _issuerTokenResolver = value ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(
 4167            }
 168        }
 169
 170        /// <summary>
 171        /// Gets or sets the maximum clock skew for handlers using this config.
 172        /// </summary>
 173        public TimeSpan MaxClockSkew
 174        {
 175            get
 176            {
 48177                return _maxClockSkew;
 178            }
 179
 180            set
 181            {
 2182                if (value < TimeSpan.Zero)
 183                {
 0184                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(SR.Format(SR.ID2070));
 185                }
 186
 2187                _maxClockSkew = value;
 2188            }
 189        }
 190
 191        /// <summary>
 192        /// Gets or sets a value indicating whether BootstrapContext is saved in the ClaimsIdentity and Sessions after t
 193        /// </summary>
 42194        public bool SaveBootstrapContext { get; set; } = DefaultSaveBootstrapContext;
 195
 196        /// <summary>
 197        /// Gets or sets the TokenResolver that resolves Service tokens.
 198        /// </summary>
 199        public SecurityTokenResolver ServiceTokenResolver
 200        {
 201            get
 202            {
 4203                return _serviceTokenResolver;
 204            }
 205
 206            set
 207            {
 0208                _serviceTokenResolver = value ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof
 0209            }
 210        }
 211
 212        /// <summary>
 213        /// Gets or sets the Caches that are used.
 214        /// </summary>
 215        public IdentityModelCaches Caches
 216        {
 217            get
 218            {
 2219                return _caches;
 220            }
 221
 222            set
 223            {
 0224                _caches = value ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(value));
 0225            }
 226        }
 227
 228        /// <summary>
 229        /// Gets or sets the expiration period for items placed in the TokenReplayCache.
 230        /// </summary>
 231        public TimeSpan TokenReplayCacheExpirationPeriod
 232        {
 233            get
 234            {
 0235                return _tokenReplayCacheExpirationPeriod;
 236            }
 237
 238            set
 239            {
 0240                if (value <= TimeSpan.Zero)
 241                {
 0242                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(nameof(value), SR.Format(SR.ID0016));
 243                }
 244
 0245                _tokenReplayCacheExpirationPeriod = value;
 0246            }
 247        }
 248    }
 249}