< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.IdentityModel.Tokens.EncryptingCredentials
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/IdentityModel/EncryptingCredentials.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 28
Coverable lines: 28
Total lines: 123
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()100%110%
.ctor(...)0%660%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/IdentityModel/EncryptingCredentials.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;
 5
 6namespace CoreWCF.IdentityModel.Tokens
 7{
 8    /// <summary>
 9    /// This class defines the encrypting credentials which can be used to
 10    /// encrypt the proof key. It is very similar to SigningCredentials class defined
 11    /// in System.IdentityModel.dll
 12    /// </summary>
 13    public class EncryptingCredentials
 14    {
 15        private string _algorithm;
 16        private SecurityKey _key;
 17        private SecurityKeyIdentifier _keyIdentifier;
 18
 19        /// <summary>
 20        /// Constructor for easy subclassing.
 21        /// </summary>
 022        public EncryptingCredentials()
 23        {
 024        }
 25
 26        /// <summary>
 27        /// Constructs an EncryptingCredentials with a security key, a security key identifier and
 28        /// the encryption algorithm.
 29        /// </summary>
 30        /// <param name="key">A security key for encryption.</param>
 31        /// <param name="keyIdentifier">A security key identifier for the encryption key.</param>
 32        /// <param name="algorithm">The encryption algorithm.</param>
 33        /// <exception cref="ArgumentNullException">When key is null.</exception>
 34        /// <exception cref="ArgumentNullException">When key identifier is null.</exception>
 35        /// <exception cref="ArgumentNullException">When algorithm is null.</exception>
 036        public EncryptingCredentials(SecurityKey key, SecurityKeyIdentifier keyIdentifier, string algorithm)
 37        {
 038            if (key == null)
 39            {
 040                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(key));
 41            }
 42
 043            if (keyIdentifier == null)
 44            {
 045                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(keyIdentifier));
 46            }
 47
 048            if (string.IsNullOrEmpty(algorithm))
 49            {
 050                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(algorithm));
 51            }
 52
 53            //
 54            // It is possible that keyIdentifier is pointing to a token which
 55            // is not capable of doing the given algorithm, we have no way verify
 56            // that at this level.
 57            //
 058            _algorithm = algorithm;
 059            _key = key;
 060            _keyIdentifier = keyIdentifier;
 061        }
 62
 63        /// <summary>
 64        /// Gets or sets the encryption algorithm.
 65        /// </summary>
 66        public string Algorithm
 67        {
 68            get
 69            {
 070                return _algorithm;
 71            }
 72            set
 73            {
 074                if (string.IsNullOrEmpty(value))
 75                {
 076                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(value));
 77                }
 78
 079                _algorithm = value;
 080            }
 81        }
 82
 83        /// <summary>
 84        /// Gets or sets the encryption key material.
 85        /// </summary>
 86        public SecurityKey SecurityKey
 87        {
 88            get
 89            {
 090                return _key;
 91            }
 92            set
 93            {
 094                if (value == null)
 95                {
 096                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(value));
 97                }
 98
 099                _key = value;
 0100            }
 101        }
 102
 103        /// <summary>
 104        /// Gets or sets the SecurityKeyIdentifier that identifies the encrypting credential.
 105        /// </summary>
 106        public SecurityKeyIdentifier SecurityKeyIdentifier
 107        {
 108            get
 109            {
 0110                return _keyIdentifier;
 111            }
 112            set
 113            {
 0114                if (value == null)
 115                {
 0116                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(value));
 117                }
 118
 0119                _keyIdentifier = value;
 0120            }
 121        }
 122    }
 123}