< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.IdentityModel.Tokens.SecurityTokenDescriptor
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/IdentityModel/SecurityTokenDescriptor.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 23
Coverable lines: 23
Total lines: 142
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
AddAuthenticationClaims(...)100%110%
AddAuthenticationClaims(...)100%110%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/IdentityModel/SecurityTokenDescriptor.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.Generic;
 6using System.Security.Claims;
 7using System.Xml;
 8using CoreWCF.IdentityModel.Claims;
 9using CoreWCF.IdentityModel.Protocols.WSTrust;
 10
 11namespace CoreWCF.IdentityModel.Tokens
 12{
 13    /// <summary>
 14    /// This is a place holder for all the attributes related to the issued token.
 15    /// </summary>
 16    public class SecurityTokenDescriptor
 17    {
 18        private string _appliesToAddress;
 19
 20        /// <summary>
 21        /// Gets or sets the address for the <see cref="RequestSecurityTokenResponse"/> AppliesTo property.
 22        /// </summary>
 23        /// <exception cref="InvalidOperationException">Thrown if not an absolute URI.</exception>
 24        public string AppliesToAddress
 25        {
 26            get
 27            {
 028                return _appliesToAddress;
 29            }
 30
 31            set
 32            {
 033                if (!string.IsNullOrEmpty(value))
 34                {
 35                    //if (!UriUtil.CanCreateValidUri(value, UriKind.Absolute))
 36                    //{
 37                    //    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.For
 38                    //}
 39                }
 40
 041                _appliesToAddress = value;
 042            }
 43        }
 44
 45        /// <summary>
 46        /// Gets or sets the address for the <see cref="RequestSecurityTokenResponse"/> ReplyToAddress property.
 47        /// </summary>
 048        public string ReplyToAddress { get; set; }
 49
 50        /// <summary>
 51        /// Gets or sets the credentials used to encrypt the token.
 52        /// </summary>
 053        public EncryptingCredentials EncryptingCredentials { get; set; }
 54
 55        /// <summary>
 56        /// Gets or sets the credentials used to sign the token.
 57        /// </summary>
 058        public SigningCredentials SigningCredentials { get; set; }
 59
 60        /// <summary>
 61        /// Gets or sets the SecurityKeyIdentifierClause when the token is attached
 62        /// to the message.
 63        /// </summary>
 064        public SecurityKeyIdentifierClause AttachedReference { get; set; }
 65
 66        /// <summary>
 67        /// Gets or sets the issuer name, which may be used inside the issued token as well.
 68        /// </summary>
 069        public string TokenIssuerName { get; set; }
 70
 71        /// <summary>
 72        /// Gets or sets the proof descriptor, which can be used to modify some fields inside
 73        /// the RSTR, such as requested proof token.
 74        /// </summary>
 75        //public ProofDescriptor Proof
 76        //{
 77        //    get { return this.proofDescriptor; }
 78        //    set { this.proofDescriptor = value; }
 79        //}
 80
 81        /// <summary>
 82        /// Gets the properties bag to extend the object.
 83        /// </summary>
 084        public Dictionary<string, object> Properties { get; } = new Dictionary<string, object>();
 85
 86        /// <summary>
 87        /// Gets or sets the issued security token.
 88        /// </summary>
 089        public SecurityToken Token { get; set; }
 90
 91        /// <summary>
 92        /// Gets or sets the token type of the issued token.
 93        /// </summary>
 094        public string TokenType { get; set; }
 95
 96        /// <summary>
 97        /// Gets or sets the unattached token reference to refer to the issued token when it is not
 98        /// attached to the message.
 99        /// </summary>
 0100        public SecurityKeyIdentifierClause UnattachedReference { get; set; }
 101
 102        /// <summary>
 103        /// Gets or sets the lifetime information for the issued token.
 104        /// </summary>
 0105        public Lifetime Lifetime { get; set; }
 106
 107        /// <summary>
 108        /// Gets or sets the OutputClaims to be included in the issued token.
 109        /// </summary>
 0110        public ClaimsIdentity Subject { get; set; }
 111
 112        /// <summary>
 113        /// Gets or sets the AuthenticationInformation.
 114        /// </summary>
 0115        public AuthenticationInformation AuthenticationInfo { get; set; }
 116
 117        /// <summary>
 118        /// Adds a <see cref="Claim"/> for the authentication type to the claim collection of
 119        /// the <see cref="SecurityTokenDescriptor"/>
 120        /// </summary>
 121        /// <param name="authType">The authentication type.</param>
 122        public void AddAuthenticationClaims(string authType)
 123        {
 0124            AddAuthenticationClaims(authType, DateTime.UtcNow);
 0125        }
 126
 127        /// <summary>
 128        /// Adds <see cref="Claim"/>s for the authentication type and the authentication instant
 129        /// to the claim collection of the <see cref="SecurityTokenDescriptor"/>
 130        /// </summary>
 131        /// <param name="authType">Specifies the authentication type</param>
 132        /// <param name="time">Specifies the authentication instant in UTC. If the input is not in UTC, it is converted 
 133        public void AddAuthenticationClaims(string authType, DateTime time)
 134        {
 0135            Subject.AddClaim(
 0136                new System.Security.Claims.Claim(System.Security.Claims.ClaimTypes.AuthenticationMethod, authType, Claim
 137
 0138            Subject.AddClaim(
 0139                new System.Security.Claims.Claim(System.Security.Claims.ClaimTypes.AuthenticationInstant, XmlConvert.ToS
 0140        }
 141    }
 142}