| | | 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 | | |
| | | 4 | | using System.Threading.Tasks; |
| | | 5 | | using System.Xml; |
| | | 6 | | |
| | | 7 | | namespace CoreWCF.Security |
| | | 8 | | { |
| | | 9 | | internal sealed class StrictModeSecurityHeaderElementInferenceEngine : SecurityHeaderElementInferenceEngine |
| | | 10 | | { |
| | 4 | 11 | | private StrictModeSecurityHeaderElementInferenceEngine() { } |
| | | 12 | | |
| | 90 | 13 | | internal static StrictModeSecurityHeaderElementInferenceEngine Instance { get; } = new StrictModeSecurityHeaderE |
| | | 14 | | |
| | 88 | 15 | | public override ValueTask ExecuteProcessingPassesAsync(ReceiveSecurityHeader securityHeader, XmlDictionaryReader |
| | | 16 | | |
| | | 17 | | public override void MarkElements(ReceiveSecurityHeaderElementManager elementManager, bool messageSecurityMode) |
| | | 18 | | { |
| | 0 | 19 | | bool primarySignatureFound = false; |
| | 0 | 20 | | for (int position = 0; position < elementManager.Count; position++) |
| | | 21 | | { |
| | 0 | 22 | | elementManager.GetElementEntry(position, out ReceiveSecurityHeaderEntry entry); |
| | 0 | 23 | | if (entry.elementCategory == ReceiveSecurityHeaderElementCategory.Signature) |
| | | 24 | | { |
| | 0 | 25 | | if (!messageSecurityMode || primarySignatureFound) |
| | | 26 | | { |
| | 0 | 27 | | elementManager.SetBindingMode(position, ReceiveSecurityHeaderBindingModes.Endorsing); |
| | | 28 | | } |
| | | 29 | | else |
| | | 30 | | { |
| | 0 | 31 | | elementManager.SetBindingMode(position, ReceiveSecurityHeaderBindingModes.Primary); |
| | 0 | 32 | | primarySignatureFound = true; |
| | | 33 | | } |
| | | 34 | | } |
| | | 35 | | } |
| | 0 | 36 | | } |
| | | 37 | | } |
| | | 38 | | } |