< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Channels.LocalServiceSecuritySettings
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Channels/LocalServiceSecuritySettings.cs
Line coverage
70%
Covered lines: 95
Uncovered lines: 40
Coverable lines: 135
Total lines: 340
Line coverage: 70.3%
Branch coverage
50%
Covered branches: 20
Total branches: 40
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)100%11100%
.ctor()100%11100%
Clone()100%11100%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Channels/LocalServiceSecuritySettings.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 CoreWCF.Runtime;
 6using CoreWCF.Security;
 7
 8namespace CoreWCF.Channels
 9{
 10    public sealed class LocalServiceSecuritySettings
 11    {
 12        //Move these to NegotiationTokenAuthenticator
 13        internal const string defaultServerMaxNegotiationLifetimeString = "00:01:00";
 14        internal const string defaultServerIssuedTokenLifetimeString = "10:00:00";
 15        internal const string defaultServerIssuedTransitionTokenLifetimeString = "00:15:00";
 16        internal const int defaultServerMaxActiveNegotiations = 128;
 17        private int _replayCacheSize;
 18        private TimeSpan _replayWindow;
 19        private TimeSpan _maxClockSkew;
 20        private TimeSpan _issuedCookieLifetime;
 21        private int _maxStatefulNegotiations;
 22        private TimeSpan _negotiationTimeout;
 23        private int _maxCachedCookies;
 24        private int _maxPendingSessions;
 25        private TimeSpan _inactivityTimeout;
 26        private TimeSpan _sessionKeyRenewalInterval;
 27        private TimeSpan _sessionKeyRolloverInterval;
 28        private TimeSpan _timestampValidityDuration;
 29
 139230        private LocalServiceSecuritySettings(LocalServiceSecuritySettings other)
 31        {
 139232            DetectReplays = other.DetectReplays;
 139233            _replayCacheSize = other._replayCacheSize;
 139234            _replayWindow = other._replayWindow;
 139235            _maxClockSkew = other._maxClockSkew;
 139236            _issuedCookieLifetime = other._issuedCookieLifetime;
 139237            _maxStatefulNegotiations = other._maxStatefulNegotiations;
 139238            _negotiationTimeout = other._negotiationTimeout;
 139239            _maxPendingSessions = other._maxPendingSessions;
 139240            _inactivityTimeout = other._inactivityTimeout;
 139241            _sessionKeyRenewalInterval = other._sessionKeyRenewalInterval;
 139242            _sessionKeyRolloverInterval = other._sessionKeyRolloverInterval;
 139243            ReconnectTransportOnFailure = other.ReconnectTransportOnFailure;
 139244            _timestampValidityDuration = other._timestampValidityDuration;
 139245            _maxCachedCookies = other._maxCachedCookies;
 139246            NonceCache = other.NonceCache;
 139247        }
 48
 363649        public bool DetectReplays { get; set; }
 50
 51        public int ReplayCacheSize
 52        {
 53            get
 54            {
 5555                return _replayCacheSize;
 56            }
 57            set
 58            {
 37359                if (value < 0)
 60                {
 061                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(val
 062                                                    SRCommon.ValueMustBeNonNegative));
 63                }
 37364                _replayCacheSize = value;
 37365            }
 66        }
 67
 68        public TimeSpan ReplayWindow
 69        {
 70            get
 71            {
 5572                return _replayWindow;
 73            }
 74            set
 75            {
 37376                if (value < TimeSpan.Zero)
 77                {
 078                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(val
 079                        SR.Format(SRCommon.SFxTimeoutOutOfRange0)));
 80                }
 81
 37382                if (TimeoutHelper.IsTooLarge(value))
 83                {
 084                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(val
 085                        SRCommon.SFxTimeoutOutOfRangeTooBig));
 86                }
 87
 37388                _replayWindow = value;
 37389            }
 90        }
 91
 92        public TimeSpan MaxClockSkew
 93        {
 94            get
 95            {
 5596                return _maxClockSkew;
 97            }
 98            set
 99            {
 374100                if (value < TimeSpan.Zero)
 101                {
 0102                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(val
 0103                        SR.Format(SRCommon.SFxTimeoutOutOfRange0)));
 104                }
 105
 374106                if (TimeoutHelper.IsTooLarge(value))
 107                {
 0108                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(val
 0109                        SRCommon.SFxTimeoutOutOfRangeTooBig));
 110                }
 111
 374112                _maxClockSkew = value;
 374113            }
 114        }
 115
 3156116        public NonceCache NonceCache { get; set; } = null;
 117
 118        public TimeSpan IssuedCookieLifetime
 119        {
 120            get
 121            {
 1122                return _issuedCookieLifetime;
 123            }
 124            set
 125            {
 495126                if (value < TimeSpan.Zero)
 127                {
 0128                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(val
 0129                        SR.Format(SRCommon.SFxTimeoutOutOfRange0)));
 130                }
 131
 495132                if (TimeoutHelper.IsTooLarge(value))
 133                {
 0134                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(val
 0135                        SRCommon.SFxTimeoutOutOfRangeTooBig));
 136                }
 137
 495138                _issuedCookieLifetime = value;
 495139            }
 140        }
 141
 142        public int MaxStatefulNegotiations
 143        {
 144            get
 145            {
 24146                return _maxStatefulNegotiations;
 147            }
 148            set
 149            {
 373150                if (value < 0)
 151                {
 0152                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(val
 0153                                                    SRCommon.ValueMustBeNonNegative));
 154                }
 373155                _maxStatefulNegotiations = value;
 373156            }
 157        }
 158
 159        public TimeSpan NegotiationTimeout
 160        {
 161            get
 162            {
 23163                return _negotiationTimeout;
 164            }
 165            set
 166            {
 745167                if (value < TimeSpan.Zero)
 168                {
 0169                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(val
 0170                        SR.Format(SRCommon.SFxTimeoutOutOfRange0)));
 171                }
 172
 745173                if (TimeoutHelper.IsTooLarge(value))
 174                {
 0175                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(val
 0176                        SRCommon.SFxTimeoutOutOfRangeTooBig));
 177                }
 178
 745179                _negotiationTimeout = value;
 745180            }
 181        }
 182
 183        public int MaxPendingSessions
 184        {
 185            get
 186            {
 22187                return _maxPendingSessions;
 188            }
 189            set
 190            {
 1191                if (value < 0)
 192                {
 0193                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(val
 0194                                                    SRCommon.ValueMustBeNonNegative));
 195                }
 1196                _maxPendingSessions = value;
 1197            }
 198        }
 199
 200        public TimeSpan InactivityTimeout
 201        {
 202            get
 203            {
 22204                return _inactivityTimeout;
 205            }
 206            set
 207            {
 5208                if (value < TimeSpan.Zero)
 209                {
 0210                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(val
 0211                        SR.Format(SRCommon.SFxTimeoutOutOfRange0)));
 212                }
 213
 5214                if (TimeoutHelper.IsTooLarge(value))
 215                {
 0216                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(val
 0217                        SRCommon.SFxTimeoutOutOfRangeTooBig));
 218                }
 219
 5220                _inactivityTimeout = value;
 5221            }
 222        }
 223
 224        public TimeSpan SessionKeyRenewalInterval
 225        {
 226            get
 227            {
 44228                return _sessionKeyRenewalInterval;
 229            }
 230            set
 231            {
 1232                if (value < TimeSpan.Zero)
 233                {
 0234                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(val
 0235                        SR.Format(SRCommon.SFxTimeoutOutOfRange0)));
 236                }
 237
 1238                if (TimeoutHelper.IsTooLarge(value))
 239                {
 0240                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(val
 0241                        SRCommon.SFxTimeoutOutOfRangeTooBig));
 242                }
 243
 1244                _sessionKeyRenewalInterval = value;
 1245            }
 246        }
 247
 248        public TimeSpan SessionKeyRolloverInterval
 249        {
 250            get
 251            {
 22252                return _sessionKeyRolloverInterval;
 253            }
 254            set
 255            {
 1256                if (value < TimeSpan.Zero)
 257                {
 0258                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(val
 0259                        SR.Format(SRCommon.SFxTimeoutOutOfRange0)));
 260                }
 261
 1262                if (TimeoutHelper.IsTooLarge(value))
 263                {
 0264                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(val
 0265                        SRCommon.SFxTimeoutOutOfRangeTooBig));
 266                }
 267
 1268                _sessionKeyRolloverInterval = value;
 1269            }
 270        }
 271
 3353272        public bool ReconnectTransportOnFailure { get; set; }
 273
 274        public TimeSpan TimestampValidityDuration
 275        {
 276            get
 277            {
 55278                return _timestampValidityDuration;
 279            }
 280            set
 281            {
 373282                if (value < TimeSpan.Zero)
 283                {
 0284                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(val
 0285                        SR.Format(SRCommon.SFxTimeoutOutOfRange0)));
 286                }
 287
 373288                if (TimeoutHelper.IsTooLarge(value))
 289                {
 0290                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(val
 0291                        SRCommon.SFxTimeoutOutOfRangeTooBig));
 292                }
 293
 373294                _timestampValidityDuration = value;
 373295            }
 296        }
 297
 298        public int MaxCachedCookies
 299        {
 300            get
 301            {
 1302                return _maxCachedCookies;
 303            }
 304            set
 305            {
 1306                if (value < 0)
 307                {
 0308                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(val
 0309                                                    SRCommon.ValueMustBeNonNegative));
 310                }
 1311                _maxCachedCookies = value;
 1312            }
 313        }
 314
 372315        public LocalServiceSecuritySettings()
 316        {
 372317            DetectReplays = SecurityProtocolFactory.defaultDetectReplays;
 372318            ReplayCacheSize = SecurityProtocolFactory.defaultMaxCachedNonces;
 372319            ReplayWindow = SecurityProtocolFactory.defaultReplayWindow;
 372320            MaxClockSkew = SecurityProtocolFactory.defaultMaxClockSkew;
 372321            NegotiationTimeout = TimeSpan.FromMinutes(1);
 372322            IssuedCookieLifetime = TimeSpan.FromHours(10);
 372323            MaxStatefulNegotiations = 128; //NegotiationTokenAuthenticator<NegotiationTokenAuthenticatorState>.defaultSe
 372324            NegotiationTimeout = TimeSpan.FromMinutes(1);// NegotiationTokenAuthenticator<NegotiationTokenAuthenticatorS
 372325            _maxPendingSessions = SecuritySessionServerSettings.DefaultMaximumPendingSessions;
 372326            _inactivityTimeout = SecuritySessionServerSettings.s_defaultInactivityTimeout;
 372327            _sessionKeyRenewalInterval = SecuritySessionServerSettings.s_defaultKeyRenewalInterval;
 372328            _sessionKeyRolloverInterval = SecuritySessionServerSettings.s_defaultKeyRolloverInterval;
 372329            ReconnectTransportOnFailure = SecuritySessionServerSettings.DefaultTolerateTransportFailures;
 372330            TimestampValidityDuration = SecurityProtocolFactory.defaultTimestampValidityDuration;
 372331            _maxCachedCookies = 1000; // NegotiationTokenAuthenticator<NegotiationTokenAuthenticatorState>.defaultServer
 372332            NonceCache = null;
 372333        }
 334
 335        public LocalServiceSecuritySettings Clone()
 336        {
 1392337            return new LocalServiceSecuritySettings(this);
 338        }
 339    }
 340}