2009-08-17 Atsushi Enomoto <atsushi@ximian.com>
[mono.git] / mcs / class / System.ServiceModel / System.ServiceModel.Security.Tokens / ServiceModelSecurityTokenRequirement.cs
1 //
2 // ServiceModelSecurityTokenRequirement.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 using System.Collections.Generic;
29 using System.IdentityModel.Selectors;
30 using System.IdentityModel.Tokens;
31 using System.ServiceModel.Channels;
32 using System.ServiceModel.Security;
33 using System.Text;
34
35 namespace System.ServiceModel.Security.Tokens
36 {
37         public abstract class ServiceModelSecurityTokenRequirement :
38                 SecurityTokenRequirement
39         {
40                 protected ServiceModelSecurityTokenRequirement ()
41                 {
42                 }
43
44                 protected const string Namespace = "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement";
45
46                 public static string AuditLogLocationProperty {
47                         get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/AuditLogLocation"; }
48                 }
49
50                 public static string ChannelParametersCollectionProperty {
51                         get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/ChannelParametersCollection"; }
52                 }
53
54                 public static string DuplexClientLocalAddressProperty {
55                         get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/DuplexClientLocalAddress"; }
56                 }
57
58                 public static string EndpointFilterTableProperty {
59                         get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/EndpointFilterTable"; }
60                 }
61
62                 public static string HttpAuthenticationSchemeProperty {
63                         get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/HttpAuthenticationScheme"; }
64                 }
65
66                 public static string IsInitiatorProperty {
67                         get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/IsInitiator"; }
68                 }
69
70                 public static string IsOutOfBandTokenProperty {
71                         get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/IsOutOfBandToken"; }
72                 }
73
74                 public static string IssuedSecurityTokenParametersProperty {
75                         get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/IssuedSecurityTokenParameters"; }
76                 }
77
78                 public static string IssuerAddressProperty {
79                         get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/IssuerAddress"; }
80                 }
81
82                 public static string IssuerBindingContextProperty {
83                         get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/IssuerBindingContext"; }
84                 }
85
86                 public static string IssuerBindingProperty {
87                         get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/IssuerBinding"; }
88                 }
89
90                 public static string ListenUriProperty {
91                         get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/ListenUri"; }
92                 }
93
94                 public static string MessageAuthenticationAuditLevelProperty {
95                         get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/MessageAuthenticationAuditLevel"; }
96                 }
97
98                 public static string MessageDirectionProperty {
99                         get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/MessageDirection"; }
100                 }
101
102                 public static string MessageSecurityVersionProperty {
103                         get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/MessageSecurityVersion"; }
104                 }
105
106                 public static string PrivacyNoticeUriProperty {
107                         get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/PrivacyNoticeUri"; }
108                 }
109
110                 public static string PrivacyNoticeVersionProperty {
111                         get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/PrivacyNoticeVersion"; }
112                 }
113
114                 public static string SecureConversationSecurityBindingElementProperty {
115                         get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/SecureConversationSecurityBindingElement"; }
116                 }
117
118                 public static string SecurityAlgorithmSuiteProperty {
119                         get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/SecurityAlgorithmSuite"; }
120                 }
121
122                 public static string SecurityBindingElementProperty {
123                         get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/SecurityBindingElement"; }
124                 }
125
126                 public static string SupportingTokenAttachmentModeProperty {
127                         get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/SupportingTokenAttachmentMode"; }
128                 }
129
130                 public static string SupportSecurityContextCancellationProperty {
131                         get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/SupportSecurityContextCancellation"; }
132                 }
133
134                 public static string SuppressAuditFailureProperty {
135                         get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/SuppressAuditFailure"; }
136                 }
137
138                 public static string TargetAddressProperty {
139                         get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/TargetAddress"; }
140                 }
141
142                 public static string TransportSchemeProperty {
143                         get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/TransportScheme"; }
144                 }
145
146                 public static string ViaProperty {
147                         get { return "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement/Via"; }
148                 }
149
150                 public bool IsInitiator {
151                         get {
152                                 bool ret;
153                                 if (TryGetProperty<bool> (IsInitiatorProperty, out ret))
154                                         return ret;
155                                 return false;
156                         }
157                 }
158
159                 public EndpointAddress IssuerAddress {
160                         get {
161                                 EndpointAddress ret;
162                                 TryGetProperty<EndpointAddress> (IssuerAddressProperty, out ret);
163                                 return ret;
164                         }
165                         set { Properties [IssuerAddressProperty] = value; }
166                 }
167
168                 public Binding IssuerBinding {
169                         get {
170                                 Binding ret;
171                                 TryGetProperty<Binding> (IssuerBindingProperty, out ret);
172                                 return ret;
173                         }
174                         set { Properties [IssuerBindingProperty] = value; }
175                 }
176
177                 public SecurityTokenVersion MessageSecurityVersion {
178                         get {
179                                 SecurityTokenVersion ret;
180                                 TryGetProperty<SecurityTokenVersion> (MessageSecurityVersionProperty, out ret);
181                                 return ret;
182                         }
183                         set { Properties [MessageSecurityVersionProperty] = value; }
184                 }
185
186                 public SecurityBindingElement SecureConversationSecurityBindingElement {
187                         get {
188                                 SecurityBindingElement ret;
189                                 TryGetProperty<SecurityBindingElement> (SecureConversationSecurityBindingElementProperty, out ret);
190                                 return ret;
191                         }
192                         set { Properties [SecureConversationSecurityBindingElementProperty] = value; }
193                 }
194
195                 public SecurityAlgorithmSuite SecurityAlgorithmSuite {
196                         get {
197                                 SecurityAlgorithmSuite ret;
198                                 TryGetProperty<SecurityAlgorithmSuite> (SecurityAlgorithmSuiteProperty, out ret);
199                                 return ret;
200                         }
201                         set { Properties [SecurityAlgorithmSuiteProperty] = value; }
202                 }
203
204                 public SecurityBindingElement SecurityBindingElement {
205                         get {
206                                 SecurityBindingElement ret;
207                                 TryGetProperty<SecurityBindingElement> (SecurityBindingElementProperty, out ret);
208                                 return ret;
209                         }
210                         set { Properties [SecurityBindingElementProperty] = value; }
211                 }
212
213                 public string TransportScheme {
214                         get {
215                                 string ret;
216                                 TryGetProperty<string> (TransportSchemeProperty, out ret);
217                                 return ret;
218                         }
219                         set { Properties [TransportSchemeProperty] = value; }
220                 }
221
222                 internal string Dump ()
223                 {
224                         StringBuilder sb = new StringBuilder ();
225                         sb.Append (GetType ()).Append (":");
226                         foreach (KeyValuePair<string, object> p in Properties)
227                                 sb.Append ("\n------------\n")
228                                   .Append ("URI: ")
229                                   .Append (p.Key)
230                                   .Append ("\nValue: ")
231                                   .Append (p.Value);
232                         return sb.ToString ();
233                 }
234         }
235 }