2008-11-01 Marek Habersack <mhabersack@novell.com>
[mono.git] / mcs / class / System.ServiceModel / System.ServiceModel.Security.Tokens / SecurityTokenParameters.cs
1 //
2 // SecurityTokenParameters.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.IdentityModel.Selectors;
29 using System.IdentityModel.Tokens;
30 using System.ServiceModel.Channels;
31 using System.ServiceModel.Security;
32
33 namespace System.ServiceModel.Security.Tokens
34 {
35         public abstract class SecurityTokenParameters
36         {
37                 protected SecurityTokenParameters ()
38                 {
39                 }
40
41                 protected SecurityTokenParameters (SecurityTokenParameters source)
42                 {
43                 }
44
45                 SecurityTokenInclusionMode inclusion_mode;
46                 SecurityTokenReferenceStyle reference_style;
47                 bool require_derived_keys = true;
48                 BindingContext issuer_binding_context;
49
50                 public SecurityTokenInclusionMode InclusionMode {
51                         get { return inclusion_mode; }
52                         set { inclusion_mode = value; }
53                 }
54
55                 public SecurityTokenReferenceStyle ReferenceStyle {
56                         get { return reference_style; }
57                         set { reference_style = value; }
58                 }
59
60                 public bool RequireDerivedKeys {
61                         get { return require_derived_keys; }
62                         set { require_derived_keys = value; }
63                 }
64
65                 public SecurityTokenParameters Clone ()
66                 {
67                         return CloneCore ();
68                 }
69
70                 [MonoTODO]
71                 public override string ToString ()
72                 {
73                         return base.ToString ();
74                 }
75
76                 protected abstract bool HasAsymmetricKey { get; }
77
78                 protected abstract bool SupportsClientAuthentication { get; }
79
80                 protected abstract bool SupportsClientWindowsIdentity { get; }
81
82                 protected abstract bool SupportsServerAuthentication { get; }
83
84                 internal bool InternalHasAsymmetricKey {
85                         get { return HasAsymmetricKey; }
86                 }
87
88                 internal bool InternalSupportsClientAuthentication {
89                         get { return SupportsClientAuthentication; }
90                 }
91
92                 internal bool InternalSupportsClientWindowsIdentity {
93                         get { return SupportsClientWindowsIdentity; }
94                 }
95
96                 internal bool InternalSupportsServerAuthentication {
97                         get { return SupportsServerAuthentication; }
98                 }
99
100                 protected abstract SecurityTokenParameters CloneCore ();
101
102                 protected abstract SecurityKeyIdentifierClause CreateKeyIdentifierClause (
103                         SecurityToken token, SecurityTokenReferenceStyle referenceStyle);
104
105                 // internalized call to CreateKeyIdentifierClause()
106                 internal SecurityKeyIdentifierClause CallCreateKeyIdentifierClause (
107                         SecurityToken token, SecurityTokenReferenceStyle referenceStyle)
108                 {
109                         return CreateKeyIdentifierClause (token, referenceStyle);
110                 }
111
112                 protected abstract void InitializeSecurityTokenRequirement (SecurityTokenRequirement requirement);
113
114                 internal BindingContext IssuerBindingContext {
115                         set { issuer_binding_context = value; }
116                 }
117
118                 internal void CallInitializeSecurityTokenRequirement (SecurityTokenRequirement requirement)
119                 {
120                         if (issuer_binding_context != null)
121                                 requirement.Properties [ServiceModelSecurityTokenRequirement.IssuerBindingContextProperty] = issuer_binding_context;
122                         InitializeSecurityTokenRequirement (requirement);
123                 }
124
125                 [MonoTODO]
126                 protected virtual bool MatchesKeyIdentifierClause (
127                         SecurityToken token,
128                         SecurityKeyIdentifierClause keyIdentifierClause,
129                         SecurityTokenReferenceStyle referenceStyle)
130                 {
131                         throw new NotImplementedException ();
132                 }
133         }
134 }