| | | 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; |
| | | 5 | | using System.Collections.Generic; |
| | | 6 | | using System.Configuration; |
| | | 7 | | using CoreWCF.Channels; |
| | | 8 | | using CoreWCF.Security.Tokens; |
| | | 9 | | |
| | | 10 | | namespace CoreWCF.Configuration |
| | | 11 | | { |
| | | 12 | | public sealed class SecurityElement : SecurityElementBase |
| | | 13 | | { |
| | 3 | 14 | | public SecurityElement() |
| | | 15 | | { |
| | 3 | 16 | | SecureConversationBootstrap.IsSecurityElementBootstrap = true; // Tell the bootstrap it's potentially okay t |
| | 3 | 17 | | } |
| | | 18 | | |
| | | 19 | | [ConfigurationProperty(ConfigurationStrings.SecureConversationBootstrap)] |
| | | 20 | | public SecurityElementBase SecureConversationBootstrap |
| | | 21 | | { |
| | 6 | 22 | | get { return (SecurityElementBase)base[ConfigurationStrings.SecureConversationBootstrap]; } |
| | | 23 | | } |
| | | 24 | | |
| | | 25 | | public override void CopyFrom(ServiceModelExtensionElement from) |
| | | 26 | | { |
| | 0 | 27 | | base.CopyFrom(from); |
| | | 28 | | |
| | 0 | 29 | | SecurityElement source = (SecurityElement)from; |
| | | 30 | | |
| | 0 | 31 | | if (PropertyValueOrigin.Default != source.ElementInformation.Properties[ConfigurationStrings.SecureConversat |
| | 0 | 32 | | SecureConversationBootstrap.CopyFrom(source.SecureConversationBootstrap); |
| | 0 | 33 | | } |
| | | 34 | | |
| | | 35 | | protected internal override BindingElement CreateBindingElement(bool createTemplateOnly) |
| | | 36 | | { |
| | | 37 | | SecurityBindingElement result; |
| | 3 | 38 | | if (AuthenticationMode == AuthenticationMode.SecureConversation) |
| | | 39 | | { |
| | 1 | 40 | | if (SecureConversationBootstrap == null) |
| | 0 | 41 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR |
| | 1 | 42 | | if (SecureConversationBootstrap.AuthenticationMode == AuthenticationMode.SecureConversation) |
| | 0 | 43 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR |
| | 1 | 44 | | SecurityBindingElement bootstrapSecurity = (SecurityBindingElement)SecureConversationBootstrap.CreateBin |
| | 1 | 45 | | result = SecurityBindingElement.CreateSecureConversationBindingElement(bootstrapSecurity, RequireSecurit |
| | | 46 | | } |
| | | 47 | | else |
| | | 48 | | { |
| | 2 | 49 | | result = (SecurityBindingElement)base.CreateBindingElement(createTemplateOnly); |
| | | 50 | | } |
| | | 51 | | |
| | 1 | 52 | | ApplyConfiguration(result); |
| | | 53 | | |
| | 1 | 54 | | return result; |
| | | 55 | | } |
| | | 56 | | |
| | | 57 | | protected override void AddBindingTemplates(Dictionary<AuthenticationMode, SecurityBindingElement> bindingTempla |
| | | 58 | | { |
| | 0 | 59 | | base.AddBindingTemplates(bindingTemplates); |
| | 0 | 60 | | AddBindingTemplate(bindingTemplates, AuthenticationMode.SecureConversation); |
| | 0 | 61 | | } |
| | | 62 | | |
| | | 63 | | private void InitializeSecureConversationParameters(SecureConversationSecurityTokenParameters sc, bool initializ |
| | | 64 | | { |
| | 0 | 65 | | SetPropertyValueIfNotDefaultValue(ConfigurationStrings.RequireSecurityContextCancellation, sc.RequireCancell |
| | 0 | 66 | | CanRenewSecurityContextToken = sc.CanRenewSession; // can't use default value optimization here because Appl |
| | 0 | 67 | | if (sc.BootstrapSecurityBindingElement != null) |
| | | 68 | | { |
| | 0 | 69 | | SecureConversationBootstrap.InitializeFrom(sc.BootstrapSecurityBindingElement, initializeNestedBindings) |
| | | 70 | | } |
| | 0 | 71 | | } |
| | | 72 | | |
| | | 73 | | protected override void InitializeNestedTokenParameterSettings(SecurityTokenParameters sp, bool initializeNested |
| | | 74 | | { |
| | 0 | 75 | | if (sp is SecureConversationSecurityTokenParameters) |
| | 0 | 76 | | InitializeSecureConversationParameters((SecureConversationSecurityTokenParameters)sp, initializeNestedBi |
| | | 77 | | else |
| | 0 | 78 | | base.InitializeNestedTokenParameterSettings(sp, initializeNestedBindings); |
| | 0 | 79 | | } |
| | | 80 | | } |
| | | 81 | | } |