< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.IdentityModel.Tokens.EncryptedSecurityToken
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/IdentityModel/Tokens/EncryptedSecurityToken.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 14
Coverable lines: 14
Total lines: 94
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 4
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%440%
CanCreateKeyIdentifierClause()100%110%
CreateKeyIdentifierClause()100%110%
MatchesKeyIdentifierClause(...)100%110%
ResolveKeyIdentifierClause(...)100%110%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/IdentityModel/Tokens/EncryptedSecurityToken.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.ObjectModel;
 6
 7namespace CoreWCF.IdentityModel.Tokens
 8{
 9    /// <summary>
 10    /// A pseudo-token which handles encryption for a token which
 11    /// does not natively support it.
 12    /// </summary>
 13    /// <remarks>
 14    /// For example, a SamlSecurityToken has no notion of how to encrypt
 15    /// itself, so to issue an encrypted SAML11 assertion, wrap a
 16    /// SamlSecurityToken with an EncryptedSecurityToken and provide
 17    /// appropriate EncryptingCredentials.
 18    /// </remarks>
 19    public class EncryptedSecurityToken : SecurityToken
 20    {
 21        /// <summary>
 22        /// Creates an instance of EncryptedSecurityToken.
 23        /// </summary>
 24        /// <param name="token">The <see cref="SecurityToken"/> to encrypt.</param>
 25        /// <param name="encryptingCredentials">The <see cref="EncryptingCredentials"/> to use for encryption.</param>
 026        public EncryptedSecurityToken(SecurityToken token, EncryptingCredentials encryptingCredentials)
 27        {
 028            EncryptingCredentials = encryptingCredentials ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumen
 029            Token = token ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(token));
 030        }
 31
 32        /// <summary>
 33        /// Inherited from <see cref="SecurityToken"/>.
 34        /// </summary>
 35        public override bool CanCreateKeyIdentifierClause<T>()
 36        {
 037            return Token.CanCreateKeyIdentifierClause<T>();
 38        }
 39
 40        /// <summary>
 41        /// Inherited from <see cref="SecurityToken"/>.
 42        /// </summary>
 43        public override T CreateKeyIdentifierClause<T>()
 44        {
 045            return Token.CreateKeyIdentifierClause<T>();
 46        }
 47
 48        /// <summary>
 49        /// Gets the <see cref="EncryptingCredentials"/> to use for encryption.
 50        /// </summary>
 051        public EncryptingCredentials EncryptingCredentials { get; }
 52
 53        /// <summary>
 54        /// Gets a unique identifier of the security token.
 55        /// </summary>
 056        public override string Id => Token.Id;
 57
 58        /// <summary>
 59        /// Inherited from <see cref="SecurityToken"/>.
 60        /// </summary>
 61        public override bool MatchesKeyIdentifierClause(SecurityKeyIdentifierClause keyIdentifierClause)
 62        {
 063            return Token.MatchesKeyIdentifierClause(keyIdentifierClause);
 64        }
 65
 66        /// <summary>
 67        /// Inherited from <see cref="SecurityToken"/>.
 68        /// </summary>
 69        public override SecurityKey ResolveKeyIdentifierClause(SecurityKeyIdentifierClause keyIdentifierClause)
 70        {
 071            return Token.ResolveKeyIdentifierClause(keyIdentifierClause);
 72        }
 73
 74        /// <summary>
 75        /// Inherited from <see cref="SecurityToken"/>.
 76        /// </summary>
 077        public override ReadOnlyCollection<SecurityKey> SecurityKeys => Token.SecurityKeys;
 78
 79        /// <summary>
 80        /// Gets the encrypted <see cref="SecurityToken"/>.
 81        /// </summary>
 082        public SecurityToken Token { get; }
 83
 84        /// <summary>
 85        /// Gets the first instant in time at which this security token is valid.
 86        /// </summary>
 087        public override DateTime ValidFrom => Token.ValidFrom;
 88
 89        /// <summary>
 90        /// Gets the last instant in time at which this security token is valid.
 91        /// </summary>
 092        public override DateTime ValidTo => Token.ValidTo;
 93    }
 94}