Couple more 'bockbuild split' mixups
[mono.git] / mcs / class / System.ServiceModel / System.ServiceModel.Security.Tokens / IssuedSecurityTokenProvider.cs
1 //
2 // IssuedSecurityTokenProvider.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.Collections.ObjectModel;
30 using System.Xml;
31 using System.IdentityModel.Selectors;
32 using System.IdentityModel.Tokens;
33 using System.ServiceModel;
34 using System.ServiceModel.Channels;
35 using System.ServiceModel.Description;
36 using System.ServiceModel.Security;
37
38 namespace System.ServiceModel.Security.Tokens
39 {
40         public class IssuedSecurityTokenProvider : SecurityTokenProvider, ICommunicationObject
41         {
42                 public IssuedSecurityTokenProvider ()
43                 {
44                 }
45
46                 IssuedTokenCommunicationObject comm =
47                         new IssuedTokenCommunicationObject ();
48
49                 SecurityKeyEntropyMode entropy_mode =
50                         SecurityKeyEntropyMode.CombinedEntropy;
51                 TimeSpan max_cache_time = TimeSpan.MaxValue;
52                 MessageSecurityVersion version = MessageSecurityVersion.Default;
53                 int threshold = 60;
54                 IdentityVerifier verifier = IdentityVerifier.CreateDefault ();
55                 bool cache_issued_tokens = true;
56                 Collection<XmlElement> request_params =
57                         new Collection<XmlElement> ();
58
59                 CommunicationState state = CommunicationState.Created;
60
61                 internal IssuedTokenCommunicationObject Communication {
62                         get { return comm; }
63                 }
64
65                 public bool CacheIssuedTokens {
66                         get { return cache_issued_tokens; }
67                         set { cache_issued_tokens = value; }
68                 }
69
70                 public virtual TimeSpan DefaultCloseTimeout {
71                         get { return comm.DefaultCloseTimeout; }
72                 }
73
74                 public virtual TimeSpan DefaultOpenTimeout {
75                         get { return comm.DefaultOpenTimeout; }
76                 }
77
78                 public IdentityVerifier IdentityVerifier {
79                         get { return verifier; }
80                         set { verifier = value; }
81                 }
82
83                 public int IssuedTokenRenewalThresholdPercentage {
84                         get { return threshold; }
85                         set { threshold = value; }
86                 }
87
88                 public EndpointAddress IssuerAddress {
89                         get { return comm.IssuerAddress; }
90                         set { comm.IssuerAddress = value; }
91                 }
92
93                 public Binding IssuerBinding {
94                         get { return comm.IssuerBinding; }
95                         set { comm.IssuerBinding = value; }
96                 }
97
98                 public KeyedByTypeCollection<IEndpointBehavior> IssuerChannelBehaviors {
99                         get { return comm.IssuerChannelBehaviors; }
100                 }
101
102                 public SecurityKeyEntropyMode KeyEntropyMode {
103                         get { return entropy_mode; }
104                         set { entropy_mode = value; }
105                 }
106
107                 public TimeSpan MaxIssuedTokenCachingTime {
108                         get { return max_cache_time; }
109                         set { max_cache_time = value; }
110                 }
111
112                 public MessageSecurityVersion MessageSecurityVersion {
113                         get { return version; }
114                         set { version = value; }
115                 }
116
117                 public SecurityAlgorithmSuite SecurityAlgorithmSuite {
118                         get { return comm.SecurityAlgorithmSuite; }
119                         set { comm.SecurityAlgorithmSuite = value; }
120                 }
121
122                 public SecurityTokenSerializer SecurityTokenSerializer {
123                         get { return comm.SecurityTokenSerializer; }
124                         set { comm.SecurityTokenSerializer = value; }
125                 }
126
127                 public EndpointAddress TargetAddress {
128                         get { return comm.TargetAddress; }
129                         set { comm.TargetAddress = value; }
130                 }
131
132                 public Collection<XmlElement> TokenRequestParameters {
133                         get { return request_params; }
134                 }
135
136                 // SecurityTokenProvider
137
138                 [MonoTODO ("support it then")]
139                 public override bool SupportsTokenCancellation {
140                         get { return true; }
141                 }
142
143                 [MonoTODO]
144                 protected override SecurityToken GetTokenCore (TimeSpan timeout)
145                 {
146                         if (State != CommunicationState.Opened)
147                                 throw new InvalidOperationException ("Open the provider before issuing actual request to get token.");
148                         return comm.GetToken (timeout);
149                 }
150
151                 [MonoTODO]
152                 protected override IAsyncResult BeginGetTokenCore (
153                         TimeSpan timeout,
154                         AsyncCallback callback, object state)
155                 {
156                         throw new NotImplementedException ();
157                 }
158
159                 [MonoTODO]
160                 protected override SecurityToken EndGetTokenCore (IAsyncResult result)
161                 {
162                         throw new NotImplementedException ();
163                 }
164
165                 // ICommunicationObject
166
167                 public CommunicationState State {
168                         get { return comm.State; }
169                 }
170
171                 [MonoTODO]
172                 public void Abort ()
173                 {
174                         comm.Abort ();
175                 }
176
177                 public void Open ()
178                 {
179                         comm.Open ();
180                 }
181
182                 [MonoTODO]
183                 public void Open (TimeSpan timeout)
184                 {
185                         comm.Open (timeout);
186                 }
187
188                 public IAsyncResult BeginOpen (AsyncCallback callback, object state)
189                 {
190                         return comm.BeginOpen (callback, state);
191                 }
192
193                 [MonoTODO]
194                 public IAsyncResult BeginOpen (TimeSpan timeout, AsyncCallback callback, object state)
195                 {
196                         return comm.BeginOpen (timeout, callback, state);
197                 }
198
199                 [MonoTODO]
200                 public void EndOpen (IAsyncResult result)
201                 {
202                         comm.EndOpen (result);
203                 }
204
205                 public void Close ()
206                 {
207                         comm.Close ();
208                 }
209
210                 [MonoTODO]
211                 public void Close (TimeSpan timeout)
212                 {
213                         comm.Close (timeout);
214                 }
215
216                 public IAsyncResult BeginClose (AsyncCallback callback, object state)
217                 {
218                         return comm.BeginClose (callback, state);
219                 }
220
221                 [MonoTODO]
222                 public IAsyncResult BeginClose (TimeSpan timeout, AsyncCallback callback, object state)
223                 {
224                         return comm.BeginClose (timeout, callback, state);
225                 }
226
227                 [MonoTODO]
228                 public void EndClose (IAsyncResult result)
229                 {
230                         comm.EndClose (result);
231                 }
232
233                 public void Dispose ()
234                 {
235                         Close ();
236                 }
237
238                 public event EventHandler Opened {
239                         add { comm.Opened += value; }
240                         remove { comm.Opened -= value; }
241                 }
242                 public event EventHandler Opening {
243                         add { comm.Opening += value; }
244                         remove { comm.Opening -= value; }
245                 }
246                 public event EventHandler Closed {
247                         add { comm.Closed += value; }
248                         remove { comm.Closed -= value; }
249                 }
250                 public event EventHandler Closing {
251                         add { comm.Closing += value; }
252                         remove { comm.Closing -= value; }
253                 }
254                 public event EventHandler Faulted {
255                         add { comm.Faulted += value; }
256                         remove { comm.Faulted -= value; }
257                 }
258         }
259 }