Update Reference Sources to .NET Framework 4.6.1
[mono.git] / mcs / class / referencesource / System.ServiceModel / System / ServiceModel / Security / TrustDriver.cs
1 //------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation.  All rights reserved.
3 //------------------------------------------------------------
4
5 namespace System.ServiceModel.Security
6 {
7     using System;
8     using System.ServiceModel.Channels;
9     using System.ServiceModel;
10     using System.ServiceModel.Description;
11     using System.Collections.Generic;
12     using System.Collections.ObjectModel;
13     using System.Diagnostics;
14     using System.Runtime.Serialization;
15     using System.IdentityModel.Claims;
16     using System.IdentityModel.Policy;
17     using System.IdentityModel.Selectors;
18     using System.IdentityModel.Tokens;
19     using System.Security.Principal;
20     using System.Security.Cryptography;
21     using System.ServiceModel.Security.Tokens;
22
23     using System.Xml;
24
25     abstract class TrustDriver
26     {
27         // issued tokens control        
28         public virtual bool IsIssuedTokensSupported
29         {
30             get
31             {
32                 return false;
33             }
34         }
35
36         // issued tokens feature        
37         public virtual string IssuedTokensHeaderName
38         {
39             get
40             {
41                 // PreSharp Bug: Property get methods should not throw exceptions.
42 #pragma warning suppress 56503
43                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.TrustDriverVersionDoesNotSupportIssuedTokens)));
44             }
45         }
46
47         // issued tokens feature        
48         public virtual string IssuedTokensHeaderNamespace
49         {
50             get
51             {
52                 // PreSharp Bug: Property get methods should not throw exceptions.
53 #pragma warning suppress 56503
54                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.TrustDriverVersionDoesNotSupportIssuedTokens)));
55             }
56         }
57
58         // session control
59         public virtual bool IsSessionSupported
60         {
61             get
62             {
63                 return false;
64             }
65         }
66
67         public abstract XmlDictionaryString RequestSecurityTokenAction { get; }
68
69         public abstract XmlDictionaryString RequestSecurityTokenResponseAction { get; }
70
71         public abstract XmlDictionaryString RequestSecurityTokenResponseFinalAction { get; }
72
73         // session feature
74         public virtual string RequestTypeClose
75         {
76             get
77             {
78                 // PreSharp Bug: Property get methods should not throw exceptions.
79 #pragma warning suppress 56503
80                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.TrustDriverVersionDoesNotSupportSession)));
81             }
82         }
83
84         public abstract string RequestTypeIssue { get; }
85
86         // session feature
87         public virtual string RequestTypeRenew
88         {
89             get
90             {
91                 // PreSharp Bug: Property get methods should not throw exceptions.
92 #pragma warning suppress 56503
93                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.TrustDriverVersionDoesNotSupportSession)));
94             }
95         }
96
97         public abstract string ComputedKeyAlgorithm { get; }
98
99         public abstract SecurityStandardsManager StandardsManager { get; }
100
101         public abstract XmlDictionaryString Namespace { get; }
102
103         // RST specific method
104         public abstract RequestSecurityToken CreateRequestSecurityToken(XmlReader reader);
105
106         // RSTR specific method
107         public abstract RequestSecurityTokenResponse CreateRequestSecurityTokenResponse(XmlReader reader);
108
109         // RSTRC specific method
110         public abstract RequestSecurityTokenResponseCollection CreateRequestSecurityTokenResponseCollection(XmlReader xmlReader);
111
112         public abstract bool IsAtRequestSecurityTokenResponse(XmlReader reader);
113
114         public abstract bool IsAtRequestSecurityTokenResponseCollection(XmlReader reader);
115
116         public abstract bool IsRequestedSecurityTokenElement(string name, string nameSpace);
117
118         public abstract bool IsRequestedProofTokenElement(string name, string nameSpace);
119
120         public abstract T GetAppliesTo<T>(RequestSecurityToken rst, XmlObjectSerializer serializer);
121
122         public abstract T GetAppliesTo<T>(RequestSecurityTokenResponse rstr, XmlObjectSerializer serializer);
123
124         public abstract void GetAppliesToQName(RequestSecurityToken rst, out string localName, out string namespaceUri);
125
126         public abstract void GetAppliesToQName(RequestSecurityTokenResponse rstr, out string localName, out string namespaceUri);
127
128         public abstract bool IsAppliesTo(string localName, string namespaceUri);
129
130         // RSTR specific method
131         public abstract byte[] GetAuthenticator(RequestSecurityTokenResponse rstr);
132
133         // RST specific method
134         public abstract BinaryNegotiation GetBinaryNegotiation(RequestSecurityToken rst);
135
136         // RSTR specific method
137         public abstract BinaryNegotiation GetBinaryNegotiation(RequestSecurityTokenResponse rstr);
138
139         // RST specific method
140         public abstract SecurityToken GetEntropy(RequestSecurityToken rst, SecurityTokenResolver resolver);
141
142         // RSTR specific method
143         public abstract SecurityToken GetEntropy(RequestSecurityTokenResponse rstr, SecurityTokenResolver resolver);
144
145         // RSTR specific method
146         public abstract GenericXmlSecurityToken GetIssuedToken(RequestSecurityTokenResponse rstr, SecurityTokenResolver resolver, IList<SecurityTokenAuthenticator> allowedAuthenticators, SecurityKeyEntropyMode keyEntropyMode, byte[] requestorEntropy,
147             string expectedTokenType, ReadOnlyCollection<IAuthorizationPolicy> authorizationPolicies, int defaultKeySize, bool isBearerKeyType);
148
149         public abstract GenericXmlSecurityToken GetIssuedToken(RequestSecurityTokenResponse rstr, string expectedTokenType, ReadOnlyCollection<IAuthorizationPolicy> authorizationPolicies, RSA clientKey);
150
151         public abstract void OnRSTRorRSTRCMissingException();
152
153         // RST specific method
154         public abstract void WriteRequestSecurityToken(RequestSecurityToken rst, XmlWriter w);
155
156         // RSTR specific method
157         public abstract void WriteRequestSecurityTokenResponse(RequestSecurityTokenResponse rstr, XmlWriter w);
158
159         // RSTR Collection method
160         public abstract void WriteRequestSecurityTokenResponseCollection(RequestSecurityTokenResponseCollection rstrCollection, XmlWriter writer);
161
162         // Federation proxy creation
163         public abstract IChannelFactory<IRequestChannel> CreateFederationProxy(EndpointAddress address, Binding binding, KeyedByTypeCollection<IEndpointBehavior> channelBehaviors);
164         public abstract XmlElement CreateKeySizeElement(int keySize);
165         public abstract XmlElement CreateKeyTypeElement(SecurityKeyType keyType);
166         public abstract XmlElement CreateTokenTypeElement(string tokenTypeUri);
167         public abstract XmlElement CreateRequiredClaimsElement(IEnumerable<XmlElement> claimsList);
168         public abstract XmlElement CreateUseKeyElement(SecurityKeyIdentifier keyIdentifier, SecurityStandardsManager standardsManager);
169         public abstract XmlElement CreateSignWithElement(string signatureAlgorithm);
170         public abstract XmlElement CreateEncryptWithElement(string encryptionAlgorithm);
171         public abstract XmlElement CreateEncryptionAlgorithmElement(string encryptionAlgorithm);
172         public abstract XmlElement CreateCanonicalizationAlgorithmElement(string canonicalicationAlgorithm);
173         public abstract XmlElement CreateComputedKeyAlgorithmElement(string computedKeyAlgorithm);
174         public abstract Collection<XmlElement> ProcessUnknownRequestParameters(Collection<XmlElement> unknownRequestParameters, Collection<XmlElement> originalRequestParameters);
175         public abstract bool TryParseKeySizeElement(XmlElement element, out int keySize);
176         public abstract bool TryParseKeyTypeElement(XmlElement element, out SecurityKeyType keyType);
177         public abstract bool TryParseTokenTypeElement(XmlElement element, out string tokenType);
178         public abstract bool TryParseRequiredClaimsElement(XmlElement element, out Collection<XmlElement> requiredClaims);
179         // helper methods for the parsing standard binding elements
180         internal virtual bool IsSignWithElement(XmlElement element, out string signatureAlgorithm) { signatureAlgorithm = null; return false; }
181         internal virtual bool IsEncryptWithElement(XmlElement element, out string encryptWithAlgorithm) { encryptWithAlgorithm = null; return false; }
182         internal virtual bool IsEncryptionAlgorithmElement(XmlElement element, out string encryptionAlgorithm) { encryptionAlgorithm = null; return false; }
183         internal virtual bool IsCanonicalizationAlgorithmElement(XmlElement element, out string canonicalizationAlgorithm) { canonicalizationAlgorithm = null; return false; }
184         internal virtual bool IsKeyWrapAlgorithmElement(XmlElement element, out string keyWrapAlgorithm) { keyWrapAlgorithm = null; return false; }
185     }
186 }