2 using System
.Collections
.ObjectModel
;
3 using System
.IdentityModel
.Selectors
;
4 using System
.IdentityModel
.Tokens
;
5 using System
.Security
.Cryptography
.Xml
;
6 using System
.ServiceModel
;
7 using System
.ServiceModel
.Security
;
10 namespace System
.ServiceModel
.Security
.Tokens
12 internal class DerivedKeySecurityToken
: SecurityToken
15 SecurityKeyIdentifierClause reference
;
16 SecurityToken resolved_token
; // store resolved one.
17 int? generation
, offset
, length
;
19 string id
, name
, label
;
21 ReadOnlyCollection
<SecurityKey
> keys
;
22 ReferenceList reflist
;
24 public DerivedKeySecurityToken (string id
, string algorithm
,
25 SecurityKeyIdentifierClause reference
,
26 SymmetricSecurityKey referencedKey
,
34 algorithm
= algorithm
?? SecurityAlgorithms
.Psha1KeyDerivation
;
37 this.algorithm
= algorithm
;
38 this.reference
= reference
;
39 this.generation
= generation
;
46 SecurityKey key
= new InMemorySymmetricSecurityKey (
47 referencedKey
.GenerateDerivedKey (
49 Encoding
.UTF8
.GetBytes (label
?? Constants
.WsscDefaultLabel
),
53 keys
= new ReadOnlyCollection
<SecurityKey
> (
54 new SecurityKey
[] {key}
);
57 public override string Id
{
61 public override ReadOnlyCollection
<SecurityKey
> SecurityKeys
{
65 public override DateTime ValidFrom
{
66 get { return resolved_token.ValidFrom; }
69 public override DateTime ValidTo
{
70 get { return resolved_token.ValidTo; }
73 internal ReferenceList ReferenceList
{
74 get { return reflist; }
75 set { reflist = value; }
78 public SecurityKeyIdentifierClause TokenReference
{
79 get { return reference; }
82 public int? Generation
{
83 get { return generation; }
87 get { return length; }
91 get { return offset; }
98 public byte [] Nonce
{
106 public override bool MatchesKeyIdentifierClause (
107 SecurityKeyIdentifierClause keyIdentifierClause
)
109 LocalIdKeyIdentifierClause l
= keyIdentifierClause
110 as LocalIdKeyIdentifierClause
;
111 return l
!= null && l
.LocalId
== Id
;
114 public override SecurityKey
ResolveKeyIdentifierClause (
115 SecurityKeyIdentifierClause keyIdentifierClause
)
117 return MatchesKeyIdentifierClause (keyIdentifierClause
) ?