1 //
2 // X509ClientCertificateAuthenticationElement.cs
3 //
4 // Author:
5 //	Atsushi Enomoto <atsushi@ximian.com>
6 //
7 // Copyright (C) 2006 Novell, Inc.  http://www.novell.com
8 //
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:
16 //
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 //
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.
27 //
28 
29 using System;
30 using System.Collections;
31 using System.Collections.Generic;
32 using System.Collections.ObjectModel;
33 using System.ComponentModel;
34 using System.Configuration;
35 using System.Net;
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;
52 using System.Text;
53 using System.Xml;
54 
55 namespace System.ServiceModel.Configuration
56 {
57 	[MonoTODO]
58 	public sealed partial class X509ClientCertificateAuthenticationElement
59 		 : ConfigurationElement
60 	{
61 		// Static Fields
62 		static ConfigurationPropertyCollection properties;
63 		static ConfigurationProperty certificate_validation_mode;
64 		static ConfigurationProperty custom_certificate_validator_type;
65 		static ConfigurationProperty include_windows_groups;
66 		static ConfigurationProperty map_client_certificate_to_windows_account;
67 		static ConfigurationProperty revocation_mode;
68 		static ConfigurationProperty trusted_store_location;
69 
X509ClientCertificateAuthenticationElement()70 		static X509ClientCertificateAuthenticationElement ()
71 		{
72 			properties = new ConfigurationPropertyCollection ();
73 			certificate_validation_mode = new ConfigurationProperty ("certificateValidationMode",
74 				typeof (X509CertificateValidationMode), "ChainTrust", null/* FIXME: get converter for X509CertificateValidationMode*/, null,
75 				ConfigurationPropertyOptions.None);
76 
77 			custom_certificate_validator_type = new ConfigurationProperty ("customCertificateValidatorType",
78 				typeof (string), "", new StringConverter (), null,
79 				ConfigurationPropertyOptions.None);
80 
81 			include_windows_groups = new ConfigurationProperty ("includeWindowsGroups",
82 				typeof (bool), "true", new BooleanConverter (), null,
83 				ConfigurationPropertyOptions.None);
84 
85 			map_client_certificate_to_windows_account = new ConfigurationProperty ("mapClientCertificateToWindowsAccount",
86 				typeof (bool), "false", new BooleanConverter (), null,
87 				ConfigurationPropertyOptions.None);
88 
89 			revocation_mode = new ConfigurationProperty ("revocationMode",
90 				typeof (X509RevocationMode), "Online", null/* FIXME: get converter for X509RevocationMode*/, null,
91 				ConfigurationPropertyOptions.None);
92 
93 			trusted_store_location = new ConfigurationProperty ("trustedStoreLocation",
94 				typeof (StoreLocation), "LocalMachine", null/* FIXME: get converter for StoreLocation*/, null,
95 				ConfigurationPropertyOptions.None);
96 
97 			properties.Add (certificate_validation_mode);
98 			properties.Add (custom_certificate_validator_type);
99 			properties.Add (include_windows_groups);
100 			properties.Add (map_client_certificate_to_windows_account);
101 			properties.Add (revocation_mode);
102 			properties.Add (trusted_store_location);
103 		}
104 
X509ClientCertificateAuthenticationElement()105 		public X509ClientCertificateAuthenticationElement ()
106 		{
107 		}
108 
109 
110 		// Properties
111 
112 		[ConfigurationProperty ("certificateValidationMode",
113 			 DefaultValue = "ChainTrust",
114 			 Options = ConfigurationPropertyOptions.None)]
115 		public X509CertificateValidationMode CertificateValidationMode {
116 			get { return (X509CertificateValidationMode) base [certificate_validation_mode]; }
117 			set { base [certificate_validation_mode] = value; }
118 		}
119 
120 		[ConfigurationProperty ("customCertificateValidatorType",
121 			 DefaultValue = "",
122 			 Options = ConfigurationPropertyOptions.None)]
123 		[StringValidator ( MinLength = 0,
124 			MaxLength = int.MaxValue,
125 			 InvalidCharacters = null)]
126 		public string CustomCertificateValidatorType {
127 			get { return (string) base [custom_certificate_validator_type]; }
128 			set { base [custom_certificate_validator_type] = value; }
129 		}
130 
131 		[ConfigurationProperty ("includeWindowsGroups",
132 			DefaultValue = true,
133 			 Options = ConfigurationPropertyOptions.None)]
134 		public bool IncludeWindowsGroups {
135 			get { return (bool) base [include_windows_groups]; }
136 			set { base [include_windows_groups] = value; }
137 		}
138 
139 		[ConfigurationProperty ("mapClientCertificateToWindowsAccount",
140 			DefaultValue = false,
141 			 Options = ConfigurationPropertyOptions.None)]
142 		public bool MapClientCertificateToWindowsAccount {
143 			get { return (bool) base [map_client_certificate_to_windows_account]; }
144 			set { base [map_client_certificate_to_windows_account] = value; }
145 		}
146 
147 		protected override ConfigurationPropertyCollection Properties {
148 			get { return properties; }
149 		}
150 
151 		[ConfigurationProperty ("revocationMode",
152 			 DefaultValue = "Online",
153 			 Options = ConfigurationPropertyOptions.None)]
154 		public X509RevocationMode RevocationMode {
155 			get { return (X509RevocationMode) base [revocation_mode]; }
156 			set { base [revocation_mode] = value; }
157 		}
158 
159 		[ConfigurationProperty ("trustedStoreLocation",
160 			 DefaultValue = "LocalMachine",
161 			 Options = ConfigurationPropertyOptions.None)]
162 		public StoreLocation TrustedStoreLocation {
163 			get { return (StoreLocation) base [trusted_store_location]; }
164 			set { base [trusted_store_location] = value; }
165 		}
166 
167 
168 	}
169 
170 }
171