[eglib] Prefer <langinfo.h> to <localcharset.h>
[mono.git] / mcs / class / System.ServiceModel / System.ServiceModel.Description / ClientCredentials.cs
1 //
2 // ClientCredentials.cs
3 //
4 // Author:
5 //      Atsushi Enomoto <atsushi@ximian.com>
6 //
7 // Copyright (C) 2005-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;
29 using System.Collections.Generic;
30 using System.ServiceModel.Channels;
31 using System.ServiceModel.Description;
32 using System.ServiceModel.Dispatcher;
33 using System.ServiceModel.Security;
34 #if !NET_2_1
35 using System.IdentityModel.Selectors;
36 using System.IdentityModel.Tokens;
37 using System.ServiceModel.Security.Tokens;
38 #endif
39
40 namespace System.ServiceModel.Description
41 {
42         public class ClientCredentials
43 #if NET_2_1
44                 : IEndpointBehavior
45 #else
46                 : SecurityCredentialsManager, IEndpointBehavior
47 #endif
48         {
49                 public ClientCredentials ()
50                 {
51                 }
52
53                 [MonoTODO]
54                 protected ClientCredentials (ClientCredentials source)
55                 {
56                         userpass = source.userpass.Clone ();
57 #if !NET_2_1
58                         issued_token = source.issued_token.Clone ();
59                         digest = source.digest.Clone ();
60                         initiator = source.initiator.Clone ();
61                         recipient = source.recipient.Clone ();
62                         windows = source.windows.Clone ();
63                         peer = source.peer.Clone ();
64                         support_interactive = source.support_interactive;
65 #endif
66                 }
67
68                 UserNamePasswordClientCredential userpass =
69                         new UserNamePasswordClientCredential ();
70 #if !NET_2_1
71                 IssuedTokenClientCredential issued_token =
72                         new IssuedTokenClientCredential ();
73                 HttpDigestClientCredential digest =
74                         new HttpDigestClientCredential ();
75                 X509CertificateInitiatorClientCredential initiator =
76                         new X509CertificateInitiatorClientCredential ();
77                 X509CertificateRecipientClientCredential recipient =
78                         new X509CertificateRecipientClientCredential ();
79                 WindowsClientCredential windows =
80                         new WindowsClientCredential ();
81                 PeerCredential peer = new PeerCredential ();
82                 bool support_interactive = true;
83
84                 public X509CertificateInitiatorClientCredential ClientCertificate {
85                         get { return initiator; }
86                 }
87
88                 public HttpDigestClientCredential HttpDigest {
89                         get { return digest; }
90                 }
91
92                 public IssuedTokenClientCredential IssuedToken {
93                         get { return issued_token; }
94                 }
95
96                 public PeerCredential Peer {
97                         get { return peer; }
98                 }
99
100                 public X509CertificateRecipientClientCredential ServiceCertificate {
101                         get { return recipient; }
102                 }
103
104                 public bool SupportInteractive {
105                         get { return support_interactive; }
106                         set { support_interactive = value; }
107                 }
108
109                 public WindowsClientCredential Windows {
110                         get { return windows; }
111                 }
112 #endif
113
114                 public UserNamePasswordClientCredential UserName {
115                         get { return userpass; }
116                 }
117
118                 public ClientCredentials Clone ()
119                 {
120                         ClientCredentials ret = CloneCore ();
121                         if (ret.GetType () != GetType ())
122                                 throw new NotImplementedException ("CloneCore() must be implemented to return an instance of the same type in this custom ClientCredentials type.");
123                         return ret;
124                 }
125
126                 protected virtual ClientCredentials CloneCore ()
127                 {
128                         return new ClientCredentials (this);
129                 }
130
131 #if !NET_2_1
132                 public override SecurityTokenManager CreateSecurityTokenManager ()
133                 {
134                         return new ClientCredentialsSecurityTokenManager (this);
135                 }
136
137                 [MonoTODO]
138                 protected virtual SecurityToken GetInfoCardSecurityToken (
139                         bool requiresInfoCard, CardSpacePolicyElement [] chain,
140                         SecurityTokenSerializer tokenSerializer)
141                 {
142                         throw new NotImplementedException ();
143                 }
144 #endif
145
146                 void IEndpointBehavior.ApplyDispatchBehavior (ServiceEndpoint endpoint,
147                         EndpointDispatcher dispatcher)
148                 {
149                         // documented as to have no effect.
150                 }
151
152                 void IEndpointBehavior.AddBindingParameters (ServiceEndpoint endpoint,
153                         BindingParameterCollection parameters)
154                 {
155                         parameters.Add (this);
156                 }
157
158                 [MonoTODO]
159                 public virtual void ApplyClientBehavior (
160                         ServiceEndpoint endpoint, ClientRuntime behavior)
161                 {
162                         if (endpoint == null)
163                                 throw new ArgumentNullException ("endpoint");
164                         if (behavior == null)
165                                 throw new ArgumentNullException ("behavior");
166
167                         // FIXME: apply to endpoint when there is not security binding element.
168                 }
169
170                 void IEndpointBehavior.Validate (ServiceEndpoint endpoint)
171                 {
172                         // documented as reserved for future use.
173                 }
174         }
175 }