< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Security.WindowsSspiNegotiation
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Security/WindowsSspiNegotiation.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 26
Coverable lines: 26
Total lines: 81
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 10
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%
Decrypt(...)100%110%
Dispose()0%220%
Encrypt(...)100%110%
GetOutgoingBlob(...)0%220%
GetRemoteIdentityName()0%440%
GetIdentity()0%220%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Security/WindowsSspiNegotiation.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.Authentication.ExtendedProtection;
 6using System.Security.Principal;
 7using CoreWCF.Security.NegotiateInternal;
 8
 9namespace CoreWCF.Security
 10{
 11    /// <summary>
 12    /// WindowsSspiNegotiation is re-write of
 13    /// https://referencesource.microsoft.com/#System.ServiceModel/System/ServiceModel/Security/WindowsSspiNegotiation.c
 14    /// With .net standard, many code moved to NTAuth/NegotiateStream..
 15    /// Using another layer of abstraction in NegotiateInternal.NegotiateInternalState to call most of the API using ref
 16    ///
 17    /// </summary>
 18    internal class WindowsSspiNegotiation : ISspiNegotiation
 19    {
 20        private readonly INegotiateInternalState _negotiateState;
 21
 022        public WindowsSspiNegotiation(INegotiateInternalState passedNegotiateState)
 23        {
 024            _negotiateState = passedNegotiateState;
 025        }
 26
 027        public bool IsCompleted { get; private set; }
 28
 029        public bool IsValidContext => _negotiateState.IsValidContext;
 30
 031        public string KeyEncryptionAlgorithm => SecurityAlgorithmStrings.WindowsSspiKeyWrap;
 32
 033        public byte[] Decrypt(byte[] encryptedData) => throw new NotImplementedException();
 34
 35        public void Dispose()
 36        {
 037            if (_negotiateState != null)
 38            {
 039                _negotiateState.Dispose();
 40            }
 041        }
 42
 043        public byte[] Encrypt(byte[] input) => _negotiateState.Encrypt(input);
 44
 45        public byte[] GetOutgoingBlob(byte[] incomingBlob, ChannelBinding channelbinding, ExtendedProtectionPolicy prote
 46        {
 047            _negotiateState.SetChannelBinding(channelbinding);
 048            _negotiateState.SetExtendedProtectionPolicy(protectionPolicy);
 049            byte[] outGoingBlob = _negotiateState.GetOutgoingBlob(incomingBlob, out BlobErrorType errorType, out Excepti
 050            if (errorType != BlobErrorType.None)
 51            {
 052                throw exception;
 53            }
 054            IsCompleted = _negotiateState.IsCompleted;
 055            return outGoingBlob;
 56        }
 57
 58        public string GetRemoteIdentityName()
 59        {
 060            if (IsValidContext)
 61            {
 062                IIdentity identity = _negotiateState.GetIdentity();
 063                if (identity != null)
 64                {
 065                    return identity.Name;
 66                }
 67            }
 068            return string.Empty;
 69        }
 70
 71        public IIdentity GetIdentity()
 72        {
 073            if (IsValidContext)
 74            {
 075                return _negotiateState.GetIdentity();
 76            }
 77
 078            return null;
 79        }
 80    }
 81}