39d9aa6fbd0feeaf4aabed781535bf49bc1b379e
[mono.git] / mcs / class / referencesource / System.IdentityModel / System / IdentityModel / Tokens / SamlAssertionKeyIdentifierClause.cs
1 //-----------------------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation.  All rights reserved.
3 //-----------------------------------------------------------------------------
4
5 namespace System.IdentityModel.Tokens
6 {
7     using System.Globalization;
8
9     public class SamlAssertionKeyIdentifierClause : SecurityKeyIdentifierClause
10     {
11         readonly string assertionId;
12         readonly string valueType;
13         readonly string tokenTypeUri;
14         readonly string binding;
15         readonly string location;
16         readonly string authorityKind;
17
18         public SamlAssertionKeyIdentifierClause(string assertionId)
19             : this(assertionId, null, 0)
20         {
21         }
22
23         public SamlAssertionKeyIdentifierClause(string assertionId, byte[] derivationNonce, int derivationLength)
24             : this(assertionId, derivationNonce, derivationLength, null, null, null, null, null)
25         {
26         }
27
28         internal SamlAssertionKeyIdentifierClause(string assertionId, byte[] derivationNonce, int derivationLength, string valueType, string tokenTypeUri, string binding, string location, string authorityKind)
29             : base(null, derivationNonce, derivationLength)
30         {
31             if (assertionId == null)
32             {
33                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("assertionId");
34             }
35             this.assertionId = assertionId;
36             this.valueType = valueType;
37             this.tokenTypeUri = tokenTypeUri;
38             this.binding = binding;
39             this.location = location;
40             this.authorityKind = authorityKind;
41         }
42
43         public string AssertionId
44         {
45             get { return this.assertionId; }
46         }
47
48         internal string TokenTypeUri
49         {
50             get { return this.tokenTypeUri; }
51         }
52
53         internal string ValueType
54         {
55             get { return this.valueType; }
56         }
57
58         internal string Binding
59         {
60             get { return this.binding; }
61         }
62
63         internal string Location
64         {
65             get { return this.location; }
66         }
67
68         internal string AuthorityKind
69         {
70             get { return this.authorityKind; }
71         }
72
73         public override bool Matches(SecurityKeyIdentifierClause keyIdentifierClause)
74         {
75             SamlAssertionKeyIdentifierClause that = keyIdentifierClause as SamlAssertionKeyIdentifierClause;
76
77             // PreSharp 
78             #pragma warning suppress 56506
79             return ReferenceEquals(this, that) || (that != null && that.Matches(this.assertionId));
80         }
81
82         public bool Matches(string assertionId)
83         {
84             return this.assertionId == assertionId;
85         }
86
87         public override string ToString()
88         {
89             return string.Format(CultureInfo.InvariantCulture, "SamlAssertionKeyIdentifierClause(AssertionId = '{0}')", this.AssertionId);
90         }
91     }
92 }