blob: 07a4dd525ca107551e7e62f50b5107cf997b03e2 (
plain)
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
|
//-----------------------------------------------------------------------
// <copyright file="MockOpenIdExtension.cs" company="Outercurve Foundation">
// Copyright (c) Outercurve Foundation. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace DotNetOpenAuth.Test.Mocks {
using System;
using System.Collections.Generic;
using System.Linq;
using DotNetOpenAuth.Messaging;
using DotNetOpenAuth.OpenId.Extensions;
using DotNetOpenAuth.OpenId.Messages;
internal class MockOpenIdExtension : IOpenIdMessageExtension {
internal const string MockTypeUri = "http://mockextension";
internal static readonly StandardOpenIdExtensionFactory.CreateDelegate Factory = (typeUri, data, baseMessage, isProviderRole) => {
if (typeUri == MockTypeUri) {
return new MockOpenIdExtension();
}
return null;
};
private IDictionary<string, string> extraData = new Dictionary<string, string>();
internal MockOpenIdExtension() {
}
/// <summary>
/// Initializes a new instance of the <see cref="MockOpenIdExtension"/> class.
/// </summary>
/// <param name="partValue">The value of the 'Part' parameter.</param>
/// <param name="extraValue">The value of the 'data' parameter.</param>
internal MockOpenIdExtension(string partValue, string extraValue) {
this.Part = partValue;
this.Data = extraValue;
}
#region IOpenIdMessageExtension Members
public string TypeUri {
get { return MockTypeUri; }
}
public IEnumerable<string> AdditionalSupportedTypeUris {
get { return Enumerable.Empty<string>(); }
}
/// <summary>
/// Gets or sets a value indicating whether this extension was
/// signed by the OpenID Provider.
/// </summary>
/// <value>
/// <c>true</c> if this instance is signed by the provider; otherwise, <c>false</c>.
/// </value>
public bool IsSignedByRemoteParty { get; set; }
#endregion
#region IMessage Properties
public Version Version {
get { return new Version(1, 0); }
}
public IDictionary<string, string> ExtraData {
get { return this.extraData; }
}
#endregion
[MessagePart]
internal string Part { get; set; }
internal string Data {
get {
string data;
this.extraData.TryGetValue("data", out data);
return data;
}
set {
this.extraData["data"] = value;
}
}
public override bool Equals(object obj) {
MockOpenIdExtension other = obj as MockOpenIdExtension;
if (other == null) {
return false;
}
return this.Part.EqualsNullSafe(other.Part) &&
this.Data.EqualsNullSafe(other.Data);
}
public override int GetHashCode() {
return 1; // mock doesn't need a good hash code algorithm
}
#region IMessage methods
public void EnsureValidMessage() {
}
#endregion
}
}
|