2 // SecurityElementBase.cs
5 // Atsushi Enomoto <atsushi@ximian.com>
7 // Copyright (C) 2006 Novell, Inc. http://www.novell.com
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 using System
.Collections
;
31 using System
.Collections
.Generic
;
32 using System
.Collections
.ObjectModel
;
33 using System
.ComponentModel
;
34 using System
.Configuration
;
36 using System
.Net
.Security
;
37 using System
.Reflection
;
38 using System
.Security
.Cryptography
.X509Certificates
;
39 using System
.Security
.Principal
;
40 using System
.IdentityModel
.Claims
;
41 using System
.IdentityModel
.Policy
;
42 using System
.IdentityModel
.Tokens
;
43 using System
.ServiceModel
;
44 using System
.ServiceModel
.Channels
;
45 using System
.ServiceModel
.Description
;
46 using System
.ServiceModel
.Diagnostics
;
47 using System
.ServiceModel
.Dispatcher
;
48 using System
.ServiceModel
.MsmqIntegration
;
49 using System
.ServiceModel
.PeerResolvers
;
50 using System
.ServiceModel
.Security
;
51 using System
.Runtime
.Serialization
;
55 namespace System
.ServiceModel
.Configuration
57 public class SecurityElementBase
58 : BindingElementExtensionElement
60 ConfigurationPropertyCollection _properties
;
62 public SecurityElementBase () {
68 [ConfigurationProperty ("allowSerializedSigningTokenOnReply",
69 Options
= ConfigurationPropertyOptions
.None
,
70 DefaultValue
= false)]
71 public bool AllowSerializedSigningTokenOnReply
{
72 get { return (bool) base ["allowSerializedSigningTokenOnReply"]; }
73 set { base ["allowSerializedSigningTokenOnReply"] = value; }
76 [ConfigurationProperty ("authenticationMode",
77 Options
= ConfigurationPropertyOptions
.None
,
78 DefaultValue
= "SspiNegotiated")]
79 public AuthenticationMode AuthenticationMode
{
80 get { return (AuthenticationMode) base ["authenticationMode"]; }
81 set { base ["authenticationMode"] = value; }
84 public override Type BindingElementType
{
85 get { return typeof (SecurityBindingElement); }
88 [ConfigurationProperty ("defaultAlgorithmSuite",
89 Options
= ConfigurationPropertyOptions
.None
,
90 DefaultValue
= "Default")]
91 [TypeConverter (typeof (SecurityAlgorithmSuiteConverter
))]
92 public SecurityAlgorithmSuite DefaultAlgorithmSuite
{
93 get { return (SecurityAlgorithmSuite) base ["defaultAlgorithmSuite"]; }
94 set { base ["defaultAlgorithmSuite"] = value; }
97 [ConfigurationProperty ("includeTimestamp",
98 Options
= ConfigurationPropertyOptions
.None
,
100 public bool IncludeTimestamp
{
101 get { return (bool) base ["includeTimestamp"]; }
102 set { base ["includeTimestamp"] = value; }
105 [ConfigurationProperty ("issuedTokenParameters",
106 Options
= ConfigurationPropertyOptions
.None
)]
107 public IssuedTokenParametersElement IssuedTokenParameters
{
108 get { return (IssuedTokenParametersElement) base ["issuedTokenParameters"]; }
111 [ConfigurationProperty ("keyEntropyMode",
112 Options
= ConfigurationPropertyOptions
.None
,
113 DefaultValue
= "CombinedEntropy")]
114 public SecurityKeyEntropyMode KeyEntropyMode
{
115 get { return (SecurityKeyEntropyMode) base ["keyEntropyMode"]; }
116 set { base ["keyEntropyMode"] = value; }
119 [ConfigurationProperty ("localClientSettings",
120 Options
= ConfigurationPropertyOptions
.None
)]
121 public LocalClientSecuritySettingsElement LocalClientSettings
{
122 get { return (LocalClientSecuritySettingsElement) base ["localClientSettings"]; }
125 [ConfigurationProperty ("localServiceSettings",
126 Options
= ConfigurationPropertyOptions
.None
)]
127 public LocalServiceSecuritySettingsElement LocalServiceSettings
{
128 get { return (LocalServiceSecuritySettingsElement) base ["localServiceSettings"]; }
131 [ConfigurationProperty ("messageProtectionOrder",
132 Options
= ConfigurationPropertyOptions
.None
,
133 DefaultValue
= "SignBeforeEncryptAndEncryptSignature")]
134 public MessageProtectionOrder MessageProtectionOrder
{
135 get { return (MessageProtectionOrder) base ["messageProtectionOrder"]; }
136 set { base ["messageProtectionOrder"] = value; }
139 [ConfigurationProperty ("messageSecurityVersion",
140 Options
= ConfigurationPropertyOptions
.None
,
141 DefaultValue
= "Default")]
142 [TypeConverter (typeof (MessageSecurityVersionConverter
))]
143 public MessageSecurityVersion MessageSecurityVersion
{
144 get { return (MessageSecurityVersion) base ["messageSecurityVersion"]; }
145 set { base ["messageSecurityVersion"] = value; }
148 protected override ConfigurationPropertyCollection Properties
{
150 if (_properties
== null) {
152 _properties
= new ConfigurationPropertyCollection ();
153 _properties
.Add (new ConfigurationProperty ("allowSerializedSigningTokenOnReply", typeof (bool), "false", new BooleanConverter (), null, ConfigurationPropertyOptions
.None
));
154 _properties
.Add (new ConfigurationProperty ("authenticationMode", typeof (AuthenticationMode
), "SspiNegotiated", null, null, ConfigurationPropertyOptions
.None
));
155 _properties
.Add (new ConfigurationProperty ("defaultAlgorithmSuite", typeof (SecurityAlgorithmSuite
), "Default", new SecurityAlgorithmSuiteConverter (), null, ConfigurationPropertyOptions
.None
));
156 _properties
.Add (new ConfigurationProperty ("includeTimestamp", typeof (bool), "true", new BooleanConverter (), null, ConfigurationPropertyOptions
.None
));
157 _properties
.Add (new ConfigurationProperty ("issuedTokenParameters", typeof (IssuedTokenParametersElement
), null, null, null, ConfigurationPropertyOptions
.None
));
158 _properties
.Add (new ConfigurationProperty ("keyEntropyMode", typeof (SecurityKeyEntropyMode
), "CombinedEntropy", null, null, ConfigurationPropertyOptions
.None
));
159 _properties
.Add (new ConfigurationProperty ("localClientSettings", typeof (LocalClientSecuritySettingsElement
), null, null, null, ConfigurationPropertyOptions
.None
));
160 _properties
.Add (new ConfigurationProperty ("localServiceSettings", typeof (LocalServiceSecuritySettingsElement
), null, null, null, ConfigurationPropertyOptions
.None
));
161 _properties
.Add (new ConfigurationProperty ("messageProtectionOrder", typeof (MessageProtectionOrder
), "SignBeforeEncryptAndEncryptSignature", null, null, ConfigurationPropertyOptions
.None
));
162 _properties
.Add (new ConfigurationProperty ("messageSecurityVersion", typeof (MessageSecurityVersion
), "Default", new MessageSecurityVersionConverter (), null, ConfigurationPropertyOptions
.None
));
163 _properties
.Add (new ConfigurationProperty ("requireDerivedKeys", typeof (bool), "true", new BooleanConverter (), null, ConfigurationPropertyOptions
.None
));
164 _properties
.Add (new ConfigurationProperty ("requireSecurityContextCancellation", typeof (bool), "true", new BooleanConverter (), null, ConfigurationPropertyOptions
.None
));
165 _properties
.Add (new ConfigurationProperty ("requireSignatureConfirmation", typeof (bool), "false", new BooleanConverter (), null, ConfigurationPropertyOptions
.None
));
166 _properties
.Add (new ConfigurationProperty ("securityHeaderLayout", typeof (SecurityHeaderLayout
), "Strict", null, null, ConfigurationPropertyOptions
.None
));
172 [ConfigurationProperty ("requireDerivedKeys",
173 Options
= ConfigurationPropertyOptions
.None
,
174 DefaultValue
= true)]
175 public bool RequireDerivedKeys
{
176 get { return (bool) base ["requireDerivedKeys"]; }
177 set { base ["requireDerivedKeys"] = value; }
180 [ConfigurationProperty ("requireSecurityContextCancellation",
181 Options
= ConfigurationPropertyOptions
.None
,
182 DefaultValue
= true)]
183 public bool RequireSecurityContextCancellation
{
184 get { return (bool) base ["requireSecurityContextCancellation"]; }
185 set { base ["requireSecurityContextCancellation"] = value; }
188 [ConfigurationProperty ("requireSignatureConfirmation",
189 Options
= ConfigurationPropertyOptions
.None
,
190 DefaultValue
= false)]
191 public bool RequireSignatureConfirmation
{
192 get { return (bool) base ["requireSignatureConfirmation"]; }
193 set { base ["requireSignatureConfirmation"] = value; }
196 [ConfigurationProperty ("securityHeaderLayout",
197 Options
= ConfigurationPropertyOptions
.None
,
198 DefaultValue
= "Strict")]
199 public SecurityHeaderLayout SecurityHeaderLayout
{
200 get { return (SecurityHeaderLayout) base ["securityHeaderLayout"]; }
201 set { base ["securityHeaderLayout"] = value; }
206 protected internal override BindingElement
CreateBindingElement () {
207 throw new NotImplementedException ();