2 // LocalClientSecuritySettingsElement.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 sealed class LocalClientSecuritySettingsElement
58 : ConfigurationElement
60 static ConfigurationPropertyCollection properties;
61 static ConfigurationProperty cache_cookies;
62 static ConfigurationProperty cookie_renewal_threshold_percentage;
63 static ConfigurationProperty detect_replays;
64 static ConfigurationProperty max_clock_skew;
65 static ConfigurationProperty max_cookie_caching_time;
66 static ConfigurationProperty reconnect_transport_on_failure;
67 static ConfigurationProperty replay_cache_size;
68 static ConfigurationProperty replay_window;
69 static ConfigurationProperty session_key_renewal_interval;
70 static ConfigurationProperty session_key_rollover_interval;
71 static ConfigurationProperty timestamp_validity_duration;
73 static LocalClientSecuritySettingsElement ()
75 cache_cookies = new ConfigurationProperty ("cacheCookies", typeof (bool), true, null, null, ConfigurationPropertyOptions.None);
77 cookie_renewal_threshold_percentage = new ConfigurationProperty ("cookieRenewalThresholdPercentage", typeof (int), 60, null, new IntegerValidator (0, 100, false), ConfigurationPropertyOptions.None);
79 detect_replays = new ConfigurationProperty ("detectReplays", typeof (bool), true, null, null, ConfigurationPropertyOptions.None);
81 max_clock_skew = new ConfigurationProperty ("maxClockSkew", typeof (TimeSpan), "00:05:00", new TimeSpanConverter (), null, ConfigurationPropertyOptions.None);
83 max_cookie_caching_time = new ConfigurationProperty ("maxCookieCachingTime", typeof (TimeSpan), "10675199.02:48:05.4775807", new TimeSpanConverter (), null, ConfigurationPropertyOptions.None);
85 reconnect_transport_on_failure = new ConfigurationProperty ("reconnectTransportOnFailure", typeof (bool), true, null, null, ConfigurationPropertyOptions.None);
87 replay_cache_size = new ConfigurationProperty ("replayCacheSize", typeof (int), 900000, null, new IntegerValidator (1, int.MaxValue, false), ConfigurationPropertyOptions.None);
89 replay_window = new ConfigurationProperty ("replayWindow", typeof (TimeSpan), "00:05:00", new TimeSpanConverter (), null, ConfigurationPropertyOptions.None);
91 session_key_renewal_interval = new ConfigurationProperty ("sessionKeyRenewalInterval", typeof (TimeSpan), "10:00:00", new TimeSpanConverter (), null, ConfigurationPropertyOptions.None);
93 session_key_rollover_interval = new ConfigurationProperty ("sessionKeyRolloverInterval", typeof (TimeSpan), "00:05:00", new TimeSpanConverter (), null, ConfigurationPropertyOptions.None);
95 timestamp_validity_duration = new ConfigurationProperty ("timestampValidityDuration", typeof (TimeSpan), "00:05:00", new TimeSpanConverter (), null, ConfigurationPropertyOptions.None);
97 properties = new ConfigurationPropertyCollection ();
99 properties.Add (cache_cookies);
100 properties.Add (cookie_renewal_threshold_percentage);
101 properties.Add (detect_replays);
102 properties.Add (max_clock_skew);
103 properties.Add (max_cookie_caching_time);
104 properties.Add (reconnect_transport_on_failure);
105 properties.Add (replay_cache_size);
106 properties.Add (replay_window);
107 properties.Add (session_key_renewal_interval);
108 properties.Add (session_key_rollover_interval);
109 properties.Add (timestamp_validity_duration);
112 public LocalClientSecuritySettingsElement ()
119 [ConfigurationProperty ("cacheCookies",
120 Options = ConfigurationPropertyOptions.None,
121 DefaultValue = true)]
122 public bool CacheCookies {
123 get { return (bool) base ["cacheCookies"]; }
124 set { base ["cacheCookies"] = value; }
127 [IntegerValidator ( MinValue = 0,
129 ExcludeRange = false)]
130 [ConfigurationProperty ("cookieRenewalThresholdPercentage",
131 Options = ConfigurationPropertyOptions.None,
132 DefaultValue = "60")]
133 public int CookieRenewalThresholdPercentage {
134 get { return (int) base ["cookieRenewalThresholdPercentage"]; }
135 set { base ["cookieRenewalThresholdPercentage"] = value; }
138 [ConfigurationProperty ("detectReplays",
139 Options = ConfigurationPropertyOptions.None,
140 DefaultValue = true)]
141 public bool DetectReplays {
142 get { return (bool) base ["detectReplays"]; }
143 set { base ["detectReplays"] = value; }
146 [ConfigurationProperty ("maxClockSkew",
147 Options = ConfigurationPropertyOptions.None,
148 DefaultValue = "00:05:00")]
149 [TypeConverter (typeof (TimeSpanConverter))]
150 public TimeSpan MaxClockSkew {
151 get { return (TimeSpan) base ["maxClockSkew"]; }
152 set { base ["maxClockSkew"] = value; }
155 [ConfigurationProperty ("maxCookieCachingTime",
156 Options = ConfigurationPropertyOptions.None,
157 DefaultValue = "10675199.02:48:05.4775807")]
158 [TypeConverter (typeof (TimeSpanConverter))]
159 public TimeSpan MaxCookieCachingTime {
160 get { return (TimeSpan) base ["maxCookieCachingTime"]; }
161 set { base ["maxCookieCachingTime"] = value; }
164 protected override ConfigurationPropertyCollection Properties {
165 get { return properties; }
168 [ConfigurationProperty ("reconnectTransportOnFailure",
169 Options = ConfigurationPropertyOptions.None,
170 DefaultValue = true)]
171 public bool ReconnectTransportOnFailure {
172 get { return (bool) base ["reconnectTransportOnFailure"]; }
173 set { base ["reconnectTransportOnFailure"] = value; }
176 [ConfigurationProperty ("replayCacheSize",
177 Options = ConfigurationPropertyOptions.None,
178 DefaultValue = "900000")]
179 [IntegerValidator ( MinValue = 1,
180 MaxValue = int.MaxValue,
181 ExcludeRange = false)]
182 public int ReplayCacheSize {
183 get { return (int) base ["replayCacheSize"]; }
184 set { base ["replayCacheSize"] = value; }
187 [ConfigurationProperty ("replayWindow",
188 Options = ConfigurationPropertyOptions.None,
189 DefaultValue = "00:05:00")]
190 [TypeConverter (typeof (TimeSpanConverter))]
191 public TimeSpan ReplayWindow {
192 get { return (TimeSpan) base ["replayWindow"]; }
193 set { base ["replayWindow"] = value; }
196 [ConfigurationProperty ("sessionKeyRenewalInterval",
197 Options = ConfigurationPropertyOptions.None,
198 DefaultValue = "10:00:00")]
199 [TypeConverter (typeof (TimeSpanConverter))]
200 public TimeSpan SessionKeyRenewalInterval {
201 get { return (TimeSpan) base ["sessionKeyRenewalInterval"]; }
202 set { base ["sessionKeyRenewalInterval"] = value; }
205 [ConfigurationProperty ("sessionKeyRolloverInterval",
206 Options = ConfigurationPropertyOptions.None,
207 DefaultValue = "00:05:00")]
208 [TypeConverter (typeof (TimeSpanConverter))]
209 public TimeSpan SessionKeyRolloverInterval {
210 get { return (TimeSpan) base ["sessionKeyRolloverInterval"]; }
211 set { base ["sessionKeyRolloverInterval"] = value; }
214 [ConfigurationProperty ("timestampValidityDuration",
215 Options = ConfigurationPropertyOptions.None,
216 DefaultValue = "00:05:00")]
217 [TypeConverter (typeof (TimeSpanConverter))]
218 public TimeSpan TimestampValidityDuration {
219 get { return (TimeSpan) base ["timestampValidityDuration"]; }
220 set { base ["timestampValidityDuration"] = value; }