/
SecurityToken.xml
524 lines (464 loc) · 40.3 KB
/
SecurityToken.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
<Type Name="SecurityToken" FullName="System.IdentityModel.Tokens.SecurityToken">
<TypeSignature Language="C#" Value="public abstract class SecurityToken" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi abstract beforefieldinit SecurityToken extends System.Object" />
<TypeSignature Language="DocId" Value="T:System.IdentityModel.Tokens.SecurityToken" />
<TypeSignature Language="VB.NET" Value="Public MustInherit Class SecurityToken" />
<TypeSignature Language="F#" Value="type SecurityToken = class" />
<TypeSignature Language="C++ CLI" Value="public ref class SecurityToken abstract" />
<AssemblyInfo>
<AssemblyName>System.IdentityModel</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.ServiceModel.Primitives</AssemblyName>
<AssemblyVersion>4.7.0.0</AssemblyVersion>
<AssemblyVersion>4.9.0.0</AssemblyVersion>
<AssemblyVersion>4.10.0.0</AssemblyVersion>
<AssemblyVersion>4.10.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>6.2.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Private.ServiceModel</AssemblyName>
<AssemblyVersion>4.10.3.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Object</BaseTypeName>
</Base>
<Interfaces />
<Docs>
<summary>Represents a base class used to implement all security tokens.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use a security token to provide authentication credentials or to protect a message.
A security token can be used to provide authentication credentials, cryptographic key material, or, in the case of a security token issued by a security token service (STS), a collection of claims about a subject. All security tokens derive from the <xref:System.IdentityModel.Tokens.SecurityToken> class.
Beginning with .NET 4.5, Windows Identity Foundation (WIF) has been fully integrated into the .NET Framework and the classes exposed by WIF are the preferred method of handling security tokens in your code. In WIF, security tokens are serialized and deserialized to and from their XML representation and are validated by using classes derived from the <xref:System.IdentityModel.Tokens.SecurityTokenHandler> base class. Validating a token involves not just ensuring that the token is valid, but also returning a <xref:System.Security.Claims.ClaimsIdentity> instance from the token that can be used in making authentication and authorization decisions. The <xref:System.Security.Claims.ClaimsIdentity> is constructed by the token handler's implementation of the <xref:System.IdentityModel.Tokens.SecurityTokenHandler.ValidateToken%2A> method from the claims contained in the token as well as from claims that are intrinsic to the token type itself.
WIF ships with support for the following types of security tokens:
- <xref:System.IdentityModel.Tokens.Saml2SecurityToken>: Represents a security token that is based upon a SAML 2.0 Assertion. This token type is typically issued by a security token service in response to a WS-Trust or WS-Federation security token request (RST).
- <xref:System.IdentityModel.Tokens.SamlSecurityToken>: Represents a security token that is based upon a SAML 1.1 Assertion. This token type is typically issued by a security token service in response to a WS-Trust or WS-Federation security token request (RST).
- <xref:System.IdentityModel.Tokens.KerberosRequestorSecurityToken> and <xref:System.IdentityModel.Tokens.KerberosReceiverSecurityToken>: Represents a security token that is based upon a Kerberos ticket that is received or sent in a SOAP message
- <xref:System.IdentityModel.Tokens.RsaSecurityToken>: Represents a security token that is based upon key that is created using the RSA algorithm.
- <xref:System.IdentityModel.Tokens.SessionSecurityToken>: Represents a security token that contains information about a session.
- <xref:System.IdentityModel.Tokens.UserNameSecurityToken>: Represents a security token that is based on a username and password.
- <xref:System.IdentityModel.Tokens.WindowsSecurityToken>: Represents a security token that is based on the identity of a Windows domain or user account.
- <xref:System.IdentityModel.Tokens.X509SecurityToken>: Represents a security token that is based on an X.509 certificate.
- <xref:System.IdentityModel.Tokens.X509WindowsSecurityToken>: Represents a security token that is based upon an X.509 certificate that is mapped to a Windows domain user or local computer user account.
Two other security token classes, <xref:System.IdentityModel.Tokens.GenericXmlSecurityToken> and <xref:System.IdentityModel.Tokens.EncryptedSecurityToken>, can be used to help handle general cases.
Broadly speaking security tokens fall into three major categories:
- Tokens that carry or reference cryptographic key material. For example the <xref:System.IdentityModel.Tokens.RsaSecurityToken> and <xref:System.IdentityModel.Tokens.X509SecurityToken> types are often used for this purpose.
- Tokens that represent credentials for users that have already been authenticated. For example, the <xref:System.IdentityModel.Tokens.UserNameSecurityToken>, <xref:System.IdentityModel.Tokens.WindowsSecurityToken>, and, in the case of a user authenticated using a certificate, the <xref:System.IdentityModel.Tokens.X509SecurityToken> types.
- Tokens that are issued by a security token service (STS) in response to a security token request using either the WS-Trust or WS-Federation protocol. These are typically returned in a `wst:RequestSecurityTokenResponse` XML fragment. The <xref:System.IdentityModel.Tokens.Saml2SecurityToken> and <xref:System.IdentityModel.Tokens.SamlSecurityToken> types are most often used to represent these tokens.
A special token type, the <xref:System.IdentityModel.Tokens.SessionSecurityToken>, contains information necessary to recreate a principal when using sessions in active or passive scenarios.
To add functionality to existing token types you can derive from the specific type and its associated token handler to support any new elements that you add to the token. To add support for new token types, you can derive directly from the <xref:System.IdentityModel.Tokens.SecurityToken> class. When you do this, you will also need to create a token handler class by deriving from the <xref:System.IdentityModel.Tokens.SecurityTokenHandler> class. Depending on how your token is to be used, you may also need to create a custom token resolver by deriving from the <xref:System.IdentityModel.Tokens.IssuerTokenResolver> class as well as one or more custom key identifier clause types by deriving from the <xref:System.IdentityModel.Tokens.SecurityKeyIdentifierClause> class.
## Examples
The code examples that are used in the <xref:System.IdentityModel.Tokens.SecurityToken> topics are taken from the `Custom Token` sample. This sample provides custom classes that enable processing of Simple Web Tokens (SWT). It includes an implementation of a `SimpleWebToken` class and a `SimpleWebTokenHandler` class, as well as other classes that support SWT tokens. For information about this sample and other samples available for WIF and about where to download them, see [WIF Code Sample Index](/previous-versions/dotnet/framework/windows-identity-foundation/wif-code-sample-index). The following code shows the implementation of the `SimpleWebToken` class. This class extends <xref:System.IdentityModel.Tokens.SecurityToken>.
:::code language="csharp" source="~/snippets/csharp/System.IdentityModel.Tokens/SecurityToken/Overview/simplewebtokenconstants.cs" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.IdentityModel.Tokens/SecurityToken/Overview/simplewebtoken.cs" id="Snippet2":::
]]></format>
</remarks>
<block subset="none" type="overrides">
<para>You must override the <see cref="P:System.IdentityModel.Tokens.SecurityToken.Id" />, <see cref="P:System.IdentityModel.Tokens.SecurityToken.SecurityKeys" />, <see cref="P:System.IdentityModel.Tokens.SecurityToken.ValidFrom" />, and <see cref="P:System.IdentityModel.Tokens.SecurityToken.ValidTo" /> properties. The <see cref="M:System.IdentityModel.Tokens.SecurityToken.CanCreateKeyIdentifierClause``1" />, <see cref="M:System.IdentityModel.Tokens.SecurityToken.CreateKeyIdentifierClause``1" />, <see cref="M:System.IdentityModel.Tokens.SecurityToken.MatchesKeyIdentifierClause(System.IdentityModel.Tokens.SecurityKeyIdentifierClause)" />, and <see cref="M:System.IdentityModel.Tokens.SecurityToken.ResolveKeyIdentifierClause(System.IdentityModel.Tokens.SecurityKeyIdentifierClause)" /> methods all support key identifiers of type <see cref="T:System.IdentityModel.Tokens.LocalIdKeyIdentifierClause" />. You must override these methods to support other key identifier types in your derived class.</para>
</block>
<altmember cref="T:System.IdentityModel.Tokens.SecurityTokenHandler" />
<altmember cref="T:System.IdentityModel.Tokens.SecurityKeyIdentifierClause" />
<altmember cref="T:System.IdentityModel.Tokens.IssuerTokenResolver" />
<altmember cref="T:System.IdentityModel.Tokens.LocalIdKeyIdentifierClause" />
</Docs>
<Members>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="protected SecurityToken ();" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig specialname rtspecialname instance void .ctor() cil managed" />
<MemberSignature Language="DocId" Value="M:System.IdentityModel.Tokens.SecurityToken.#ctor" />
<MemberSignature Language="VB.NET" Value="Protected Sub New ()" />
<MemberSignature Language="C++ CLI" Value="protected:
 SecurityToken();" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.IdentityModel</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.ServiceModel.Primitives</AssemblyName>
<AssemblyVersion>4.7.0.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Private.ServiceModel</AssemblyName>
<AssemblyVersion>4.10.3.0</AssemblyVersion>
</AssemblyInfo>
<Parameters />
<Docs>
<summary>Called by constructors in derived classes to initialize the <see cref="T:System.IdentityModel.Tokens.SecurityToken" /> class.</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="CanCreateKeyIdentifierClause<T>">
<MemberSignature Language="C#" Value="public virtual bool CanCreateKeyIdentifierClause<T> () where T : System.IdentityModel.Tokens.SecurityKeyIdentifierClause;" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance bool CanCreateKeyIdentifierClause<(class System.IdentityModel.Tokens.SecurityKeyIdentifierClause) T>() cil managed" />
<MemberSignature Language="DocId" Value="M:System.IdentityModel.Tokens.SecurityToken.CanCreateKeyIdentifierClause``1" />
<MemberSignature Language="VB.NET" Value="Public Overridable Function CanCreateKeyIdentifierClause(Of T As SecurityKeyIdentifierClause) () As Boolean" />
<MemberSignature Language="F#" Value="abstract member CanCreateKeyIdentifierClause : unit -> bool (requires 'T :> System.IdentityModel.Tokens.SecurityKeyIdentifierClause)
override this.CanCreateKeyIdentifierClause : unit -> bool (requires 'T :> System.IdentityModel.Tokens.SecurityKeyIdentifierClause)" Usage="securityToken.CanCreateKeyIdentifierClause " />
<MemberSignature Language="C++ CLI" Value="public:
generic <typename T>
 where T : System::IdentityModel::Tokens::SecurityKeyIdentifierClause virtual bool CanCreateKeyIdentifierClause();" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.IdentityModel</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.ServiceModel.Primitives</AssemblyName>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Private.ServiceModel</AssemblyName>
<AssemblyVersion>4.10.3.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<TypeParameters>
<TypeParameter Name="T">
<Constraints>
<BaseTypeName>System.IdentityModel.Tokens.SecurityKeyIdentifierClause</BaseTypeName>
</Constraints>
</TypeParameter>
</TypeParameters>
<Parameters />
<Docs>
<typeparam name="T">A <see cref="T:System.IdentityModel.Tokens.SecurityKeyIdentifierClause" /> that specifies the key identifier to create.</typeparam>
<summary>Gets a value that indicates whether this security token is capable of creating the specified key identifier.</summary>
<returns>
<see langword="true" /> when <paramref name="T" /> is of type <see cref="T:System.IdentityModel.Tokens.SecurityKeyIdentifierClause" />; otherwise, <see langword="false" />.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use the <xref:System.IdentityModel.Tokens.SecurityToken.CanCreateKeyIdentifierClause%2A> method to determine whether a security token can create a specific key identifier. To create the key identifier call the <xref:System.IdentityModel.Tokens.SecurityToken.CreateKeyIdentifierClause%2A> method.
The default implementation supports key identifier clauses of type <xref:System.IdentityModel.Tokens.LocalIdKeyIdentifierClause>.
]]></format>
</remarks>
<altmember cref="M:System.IdentityModel.Tokens.SecurityToken.CreateKeyIdentifierClause``1" />
<altmember cref="T:System.IdentityModel.Tokens.LocalIdKeyIdentifierClause" />
</Docs>
</Member>
<Member MemberName="CreateKeyIdentifierClause<T>">
<MemberSignature Language="C#" Value="public virtual T CreateKeyIdentifierClause<T> () where T : System.IdentityModel.Tokens.SecurityKeyIdentifierClause;" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance !!T CreateKeyIdentifierClause<(class System.IdentityModel.Tokens.SecurityKeyIdentifierClause) T>() cil managed" />
<MemberSignature Language="DocId" Value="M:System.IdentityModel.Tokens.SecurityToken.CreateKeyIdentifierClause``1" />
<MemberSignature Language="VB.NET" Value="Public Overridable Function CreateKeyIdentifierClause(Of T As SecurityKeyIdentifierClause) () As T" />
<MemberSignature Language="F#" Value="abstract member CreateKeyIdentifierClause : unit -> 'T (requires 'T :> System.IdentityModel.Tokens.SecurityKeyIdentifierClause)
override this.CreateKeyIdentifierClause : unit -> 'T (requires 'T :> System.IdentityModel.Tokens.SecurityKeyIdentifierClause)" Usage="securityToken.CreateKeyIdentifierClause " />
<MemberSignature Language="C++ CLI" Value="public:
generic <typename T>
 where T : System::IdentityModel::Tokens::SecurityKeyIdentifierClause virtual T CreateKeyIdentifierClause();" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.IdentityModel</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.ServiceModel.Primitives</AssemblyName>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Private.ServiceModel</AssemblyName>
<AssemblyVersion>4.10.3.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>T</ReturnType>
</ReturnValue>
<TypeParameters>
<TypeParameter Name="T">
<Constraints>
<BaseTypeName>System.IdentityModel.Tokens.SecurityKeyIdentifierClause</BaseTypeName>
</Constraints>
</TypeParameter>
</TypeParameters>
<Parameters />
<Docs>
<typeparam name="T">A <see cref="T:System.IdentityModel.Tokens.SecurityKeyIdentifierClause" /> that specifies the key identifier to create.</typeparam>
<summary>Creates the specified key identifier clause.</summary>
<returns>A <see cref="T:System.IdentityModel.Tokens.SecurityKeyIdentifierClause" /> that is a key identifier clause for the security token.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use the <xref:System.IdentityModel.Tokens.SecurityToken.CanCreateKeyIdentifierClause%2A> method to determine whether a security token can create a specific key identifier. To create the key identifier call the <xref:System.IdentityModel.Tokens.SecurityToken.CreateKeyIdentifierClause%2A> method.
The default implementation supports key identifier clauses of type <xref:System.IdentityModel.Tokens.LocalIdKeyIdentifierClause>. If a key identifier clause of type <xref:System.IdentityModel.Tokens.LocalIdKeyIdentifierClause> cannot be created, a <xref:System.NotSupportedException> is thrown.
]]></format>
</remarks>
<altmember cref="M:System.IdentityModel.Tokens.SecurityToken.CanCreateKeyIdentifierClause``1" />
<altmember cref="T:System.IdentityModel.Tokens.LocalIdKeyIdentifierClause" />
</Docs>
</Member>
<Member MemberName="Id">
<MemberSignature Language="C#" Value="public abstract string Id { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance string Id" />
<MemberSignature Language="DocId" Value="P:System.IdentityModel.Tokens.SecurityToken.Id" />
<MemberSignature Language="VB.NET" Value="Public MustOverride ReadOnly Property Id As String" />
<MemberSignature Language="F#" Value="member this.Id : string" Usage="System.IdentityModel.Tokens.SecurityToken.Id" />
<MemberSignature Language="C++ CLI" Value="public:
 abstract property System::String ^ Id { System::String ^ get(); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.IdentityModel</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.ServiceModel.Primitives</AssemblyName>
<AssemblyVersion>4.7.0.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Private.ServiceModel</AssemblyName>
<AssemblyVersion>4.10.3.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets a unique identifier of the security token.</summary>
<value>The unique identifier of the security token.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Typically, when a security token is serialized into XML, the `Id` attribute for the security token is set to the value of the <xref:System.IdentityModel.Tokens.SecurityToken.Id%2A> property.
## Examples
The code examples that are used in the <xref:System.IdentityModel.Tokens.SecurityToken> topics are taken from the `Custom Token` sample. This sample provides custom classes that enable processing of Simple Web Tokens (SWT). It includes an implementation of a `SimpleWebToken` class and a `SimpleWebTokenHandler` class, as well as other classes that support SWT tokens. For information about this sample and other samples available for WIF and about where to download them, see [WIF Code Sample Index](/previous-versions/dotnet/framework/windows-identity-foundation/wif-code-sample-index). The following code shows the override of the <xref:System.IdentityModel.Tokens.SecurityToken.Id%2A> property.
:::code language="csharp" source="~/snippets/csharp/System.IdentityModel.Tokens/SecurityToken/Overview/simplewebtokenconstants.cs" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.IdentityModel.Tokens/SecurityToken/Overview/simplewebtoken.cs" id="Snippet3":::
:::code language="csharp" source="~/snippets/csharp/System.IdentityModel.Tokens/SecurityToken/Overview/simplewebtoken.cs" id="Snippet4":::
]]></format>
</remarks>
<block subset="none" type="overrides">
<para>You must override the <see cref="P:System.IdentityModel.Tokens.SecurityToken.Id" /> property.</para>
</block>
</Docs>
</Member>
<Member MemberName="MatchesKeyIdentifierClause">
<MemberSignature Language="C#" Value="public virtual bool MatchesKeyIdentifierClause (System.IdentityModel.Tokens.SecurityKeyIdentifierClause keyIdentifierClause);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance bool MatchesKeyIdentifierClause(class System.IdentityModel.Tokens.SecurityKeyIdentifierClause keyIdentifierClause) cil managed" />
<MemberSignature Language="DocId" Value="M:System.IdentityModel.Tokens.SecurityToken.MatchesKeyIdentifierClause(System.IdentityModel.Tokens.SecurityKeyIdentifierClause)" />
<MemberSignature Language="VB.NET" Value="Public Overridable Function MatchesKeyIdentifierClause (keyIdentifierClause As SecurityKeyIdentifierClause) As Boolean" />
<MemberSignature Language="F#" Value="abstract member MatchesKeyIdentifierClause : System.IdentityModel.Tokens.SecurityKeyIdentifierClause -> bool
override this.MatchesKeyIdentifierClause : System.IdentityModel.Tokens.SecurityKeyIdentifierClause -> bool" Usage="securityToken.MatchesKeyIdentifierClause keyIdentifierClause" />
<MemberSignature Language="C++ CLI" Value="public:
 virtual bool MatchesKeyIdentifierClause(System::IdentityModel::Tokens::SecurityKeyIdentifierClause ^ keyIdentifierClause);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.IdentityModel</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.ServiceModel.Primitives</AssemblyName>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Private.ServiceModel</AssemblyName>
<AssemblyVersion>4.10.3.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="keyIdentifierClause" Type="System.IdentityModel.Tokens.SecurityKeyIdentifierClause" Index="0" FrameworkAlternate="netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;dotnet-plat-ext-6.0;dotnet-plat-ext-7.0;netframework-4.8.1;dotnet-plat-ext-8.0;dotnet-plat-ext-9.0;net-8.0;netstandard-2.0" />
</Parameters>
<Docs>
<param name="keyIdentifierClause">A <see cref="T:System.IdentityModel.Tokens.SecurityKeyIdentifierClause" /> to compare to this instance.</param>
<summary>Returns a value that indicates whether the key identifier for this instance can be resolved to the specified key identifier.</summary>
<returns>
<see langword="true" /> if <paramref name="keyIdentifierClause" /> is a <see cref="T:System.IdentityModel.Tokens.SecurityKeyIdentifierClause" /> and it has the same unique identifier as the <see cref="P:System.IdentityModel.Tokens.SecurityToken.Id" /> property; otherwise, <see langword="false" />.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The default implementation supports key identifier clauses of type <xref:System.IdentityModel.Tokens.LocalIdKeyIdentifierClause>
]]></format>
</remarks>
<altmember cref="T:System.IdentityModel.Tokens.LocalIdKeyIdentifierClause" />
</Docs>
</Member>
<Member MemberName="ResolveKeyIdentifierClause">
<MemberSignature Language="C#" Value="public virtual System.IdentityModel.Tokens.SecurityKey ResolveKeyIdentifierClause (System.IdentityModel.Tokens.SecurityKeyIdentifierClause keyIdentifierClause);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance class System.IdentityModel.Tokens.SecurityKey ResolveKeyIdentifierClause(class System.IdentityModel.Tokens.SecurityKeyIdentifierClause keyIdentifierClause) cil managed" />
<MemberSignature Language="DocId" Value="M:System.IdentityModel.Tokens.SecurityToken.ResolveKeyIdentifierClause(System.IdentityModel.Tokens.SecurityKeyIdentifierClause)" />
<MemberSignature Language="VB.NET" Value="Public Overridable Function ResolveKeyIdentifierClause (keyIdentifierClause As SecurityKeyIdentifierClause) As SecurityKey" />
<MemberSignature Language="F#" Value="abstract member ResolveKeyIdentifierClause : System.IdentityModel.Tokens.SecurityKeyIdentifierClause -> System.IdentityModel.Tokens.SecurityKey
override this.ResolveKeyIdentifierClause : System.IdentityModel.Tokens.SecurityKeyIdentifierClause -> System.IdentityModel.Tokens.SecurityKey" Usage="securityToken.ResolveKeyIdentifierClause keyIdentifierClause" />
<MemberSignature Language="C++ CLI" Value="public:
 virtual System::IdentityModel::Tokens::SecurityKey ^ ResolveKeyIdentifierClause(System::IdentityModel::Tokens::SecurityKeyIdentifierClause ^ keyIdentifierClause);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.IdentityModel</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.ServiceModel.Primitives</AssemblyName>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Private.ServiceModel</AssemblyName>
<AssemblyVersion>4.10.3.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.IdentityModel.Tokens.SecurityKey</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="keyIdentifierClause" Type="System.IdentityModel.Tokens.SecurityKeyIdentifierClause" Index="0" FrameworkAlternate="netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;dotnet-plat-ext-6.0;dotnet-plat-ext-7.0;netframework-4.8.1;dotnet-plat-ext-8.0;dotnet-plat-ext-9.0;net-8.0;netstandard-2.0" />
</Parameters>
<Docs>
<param name="keyIdentifierClause">A <see cref="T:System.IdentityModel.Tokens.SecurityKeyIdentifierClause" /> to get the key for.</param>
<summary>Gets the key for the specified key identifier clause.</summary>
<returns>A <see cref="T:System.IdentityModel.Tokens.SecurityKey" /> that represents the key.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.IdentityModel.Tokens.SecurityToken.ResolveKeyIdentifierClause%2A> method calls the <xref:System.IdentityModel.Tokens.SecurityToken.MatchesKeyIdentifierClause%2A> to first determine whether the specified key identifier clause is the same as this instance.
The default implementation returns the first element of the <xref:System.IdentityModel.Tokens.SecurityToken.SecurityKeys%2A> collection if the collection is not empty and if <xref:System.IdentityModel.Tokens.SecurityToken.MatchesKeyIdentifierClause%2A> returns `true`; otherwise, it returns `null`.
]]></format>
</remarks>
<block subset="none" type="overrides">
<para>When you inherit from <see cref="T:System.IdentityModel.Tokens.SecurityToken" />, and implement the <see cref="M:System.IdentityModel.Tokens.SecurityToken.ResolveKeyIdentifierClause(System.IdentityModel.Tokens.SecurityKeyIdentifierClause)" /> method and <paramref name="keyIdentifierClause" /> cannot be resolved, return <see langword="null" />. An exception should not be thrown from the <see cref="M:System.IdentityModel.Tokens.SecurityToken.ResolveKeyIdentifierClause(System.IdentityModel.Tokens.SecurityKeyIdentifierClause)" /> method.</para>
</block>
<altmember cref="M:System.IdentityModel.Tokens.SecurityToken.MatchesKeyIdentifierClause(System.IdentityModel.Tokens.SecurityKeyIdentifierClause)" />
<altmember cref="T:System.IdentityModel.Tokens.LocalIdKeyIdentifierClause" />
</Docs>
</Member>
<Member MemberName="SecurityKeys">
<MemberSignature Language="C#" Value="public abstract System.Collections.ObjectModel.ReadOnlyCollection<System.IdentityModel.Tokens.SecurityKey> SecurityKeys { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance class System.Collections.ObjectModel.ReadOnlyCollection`1<class System.IdentityModel.Tokens.SecurityKey> SecurityKeys" />
<MemberSignature Language="DocId" Value="P:System.IdentityModel.Tokens.SecurityToken.SecurityKeys" />
<MemberSignature Language="VB.NET" Value="Public MustOverride ReadOnly Property SecurityKeys As ReadOnlyCollection(Of SecurityKey)" />
<MemberSignature Language="F#" Value="member this.SecurityKeys : System.Collections.ObjectModel.ReadOnlyCollection<System.IdentityModel.Tokens.SecurityKey>" Usage="System.IdentityModel.Tokens.SecurityToken.SecurityKeys" />
<MemberSignature Language="C++ CLI" Value="public:
 abstract property System::Collections::ObjectModel::ReadOnlyCollection<System::IdentityModel::Tokens::SecurityKey ^> ^ SecurityKeys { System::Collections::ObjectModel::ReadOnlyCollection<System::IdentityModel::Tokens::SecurityKey ^> ^ get(); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.IdentityModel</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.ServiceModel.Primitives</AssemblyName>
<AssemblyVersion>4.7.0.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Private.ServiceModel</AssemblyName>
<AssemblyVersion>4.10.3.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Collections.ObjectModel.ReadOnlyCollection<System.IdentityModel.Tokens.SecurityKey></ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the cryptographic keys associated with the security token.</summary>
<value>A <see cref="T:System.Collections.ObjectModel.ReadOnlyCollection`1" /> of type <see cref="T:System.IdentityModel.Tokens.SecurityKey" /> that contains the set of keys associated with the security token.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use the <xref:System.IdentityModel.Tokens.SamlSecurityToken.SecurityKeys%2A> property to set the cryptographic keys for this security token to protect tokens or a SOAP message. The keys can be used, among other things, to digitally sign or encrypt either tokens or SOAP messages.
## Examples
The code examples that are used in the <xref:System.IdentityModel.Tokens.SecurityToken> topics are taken from the `Custom Token` sample. This sample provides custom classes that enable processing of Simple Web Tokens (SWT). It includes an implementation of a `SimpleWebToken` class and a `SimpleWebTokenHandler` class, as well as other classes that support SWT tokens. For information about this sample and other samples available for WIF and about where to download them, see [WIF Code Sample Index](/previous-versions/dotnet/framework/windows-identity-foundation/wif-code-sample-index). The following code shows the override of the <xref:System.IdentityModel.Tokens.SecurityToken.SecurityKeys%2A> property.
:::code language="csharp" source="~/snippets/csharp/System.IdentityModel.Tokens/SecurityToken/Overview/simplewebtokenconstants.cs" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.IdentityModel.Tokens/SecurityToken/Overview/simplewebtoken.cs" id="Snippet3":::
:::code language="csharp" source="~/snippets/csharp/System.IdentityModel.Tokens/SecurityToken/Overview/simplewebtoken.cs" id="Snippet5":::
]]></format>
</remarks>
<block subset="none" type="overrides">
<para>You must override the <see cref="P:System.IdentityModel.Tokens.SecurityToken.SecurityKeys" /> property.</para>
</block>
</Docs>
</Member>
<Member MemberName="ValidFrom">
<MemberSignature Language="C#" Value="public abstract DateTime ValidFrom { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance valuetype System.DateTime ValidFrom" />
<MemberSignature Language="DocId" Value="P:System.IdentityModel.Tokens.SecurityToken.ValidFrom" />
<MemberSignature Language="VB.NET" Value="Public MustOverride ReadOnly Property ValidFrom As DateTime" />
<MemberSignature Language="F#" Value="member this.ValidFrom : DateTime" Usage="System.IdentityModel.Tokens.SecurityToken.ValidFrom" />
<MemberSignature Language="C++ CLI" Value="public:
 abstract property DateTime ValidFrom { DateTime get(); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.IdentityModel</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.ServiceModel.Primitives</AssemblyName>
<AssemblyVersion>4.7.0.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Private.ServiceModel</AssemblyName>
<AssemblyVersion>4.10.3.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.DateTime</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the first instant in time at which this security token is valid.</summary>
<value>A <see cref="T:System.DateTime" /> that represents the instant in time at which this security token is first valid.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use the <xref:System.IdentityModel.Tokens.SecurityToken.ValidFrom%2A> and <xref:System.IdentityModel.Tokens.SecurityToken.ValidTo%2A> properties to determine the time period in which a <xref:System.IdentityModel.Tokens.SecurityToken> token is valid. The <xref:System.IdentityModel.Tokens.SecurityToken.ValidFrom%2A> and <xref:System.IdentityModel.Tokens.SecurityToken.ValidTo%2A> properties represent the first and last instants in time in which the security token is valid, respectively.
## Examples
The code examples that are used in the <xref:System.IdentityModel.Tokens.SecurityToken> topics are taken from the `Custom Token` sample. This sample provides custom classes that enable processing of Simple Web Tokens (SWT). It includes an implementation of a `SimpleWebToken` class and a `SimpleWebTokenHandler` class, as well as other classes that support SWT tokens. For information about this sample and other samples available for WIF and about where to download them, see [WIF Code Sample Index](/previous-versions/dotnet/framework/windows-identity-foundation/wif-code-sample-index). The following code shows the override of the <xref:System.IdentityModel.Tokens.SecurityToken.ValidFrom%2A> property.
:::code language="csharp" source="~/snippets/csharp/System.IdentityModel.Tokens/SecurityToken/Overview/simplewebtokenconstants.cs" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.IdentityModel.Tokens/SecurityToken/Overview/simplewebtoken.cs" id="Snippet3":::
:::code language="csharp" source="~/snippets/csharp/System.IdentityModel.Tokens/SecurityToken/Overview/simplewebtoken.cs" id="Snippet6":::
:::code language="csharp" source="~/snippets/csharp/System.IdentityModel.Tokens/SecurityToken/Overview/simplewebtoken.cs" id="Snippet8":::
]]></format>
</remarks>
<block subset="none" type="overrides">
<para>You must override the <see cref="P:System.IdentityModel.Tokens.SecurityToken.ValidFrom" /> property.</para>
</block>
</Docs>
</Member>
<Member MemberName="ValidTo">
<MemberSignature Language="C#" Value="public abstract DateTime ValidTo { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance valuetype System.DateTime ValidTo" />
<MemberSignature Language="DocId" Value="P:System.IdentityModel.Tokens.SecurityToken.ValidTo" />
<MemberSignature Language="VB.NET" Value="Public MustOverride ReadOnly Property ValidTo As DateTime" />
<MemberSignature Language="F#" Value="member this.ValidTo : DateTime" Usage="System.IdentityModel.Tokens.SecurityToken.ValidTo" />
<MemberSignature Language="C++ CLI" Value="public:
 abstract property DateTime ValidTo { DateTime get(); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.IdentityModel</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.ServiceModel.Primitives</AssemblyName>
<AssemblyVersion>4.7.0.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Private.ServiceModel</AssemblyName>
<AssemblyVersion>4.10.3.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.DateTime</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the last instant in time at which this security token is valid.</summary>
<value>A <see cref="T:System.DateTime" /> that represents the last instant in time at which this security token is valid.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use the <xref:System.IdentityModel.Tokens.SecurityToken.ValidFrom%2A> and <xref:System.IdentityModel.Tokens.SecurityToken.ValidTo%2A> properties to determine the time period in which a <xref:System.IdentityModel.Tokens.SecurityToken> token is valid. The <xref:System.IdentityModel.Tokens.SecurityToken.ValidFrom%2A> and <xref:System.IdentityModel.Tokens.SecurityToken.ValidTo%2A> properties represent the first and last instants in time in which the security token is valid, respectively.
## Examples
The code examples that are used in the <xref:System.IdentityModel.Tokens.SecurityToken> topics are taken from the `Custom Token` sample. This sample provides custom classes that enable processing of Simple Web Tokens (SWT). It includes an implementation of a `SimpleWebToken` class and a `SimpleWebTokenHandler` class, as well as other classes that support SWT tokens. For information about this sample and other samples available for WIF and about where to download them, see [WIF Code Sample Index](/previous-versions/dotnet/framework/windows-identity-foundation/wif-code-sample-index). The following code shows the override of the <xref:System.IdentityModel.Tokens.SecurityToken.ValidTo%2A> property.
:::code language="csharp" source="~/snippets/csharp/System.IdentityModel.Tokens/SecurityToken/Overview/simplewebtokenconstants.cs" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.IdentityModel.Tokens/SecurityToken/Overview/simplewebtoken.cs" id="Snippet3":::
:::code language="csharp" source="~/snippets/csharp/System.IdentityModel.Tokens/SecurityToken/Overview/simplewebtoken.cs" id="Snippet7":::
:::code language="csharp" source="~/snippets/csharp/System.IdentityModel.Tokens/SecurityToken/Overview/simplewebtoken.cs" id="Snippet8":::
]]></format>
</remarks>
<block subset="none" type="overrides">
<para>You must override the <see cref="P:System.IdentityModel.Tokens.SecurityToken.ValidTo" /> property.</para>
</block>
</Docs>
</Member>
</Members>
</Type>