blob: 803e4712ca1e20b9c5844c1dd0b85e338d76705c (
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
|
//-----------------------------------------------------------------------
// <copyright file="MockSigningBindingElement.cs" company="Andrew Arnott">
// Copyright (c) Andrew Arnott. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace DotNetOpenAuth.Test.Mocks {
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DotNetOpenAuth.Messaging;
using DotNetOpenAuth.Messaging.Bindings;
internal class MockSigningBindingElement : IChannelBindingElement {
internal const string MessageSignature = "mocksignature";
#region IChannelBindingElement Members
MessageProtections IChannelBindingElement.Protection {
get { return MessageProtections.TamperProtection; }
}
/// <summary>
/// Gets or sets the channel that this binding element belongs to.
/// </summary>
public Channel Channel { get; set; }
MessageProtections? IChannelBindingElement.PrepareMessageForSending(IProtocolMessage message) {
ITamperResistantProtocolMessage signedMessage = message as ITamperResistantProtocolMessage;
if (signedMessage != null) {
signedMessage.Signature = MessageSignature;
return MessageProtections.TamperProtection;
}
return null;
}
MessageProtections? IChannelBindingElement.PrepareMessageForReceiving(IProtocolMessage message) {
ITamperResistantProtocolMessage signedMessage = message as ITamperResistantProtocolMessage;
if (signedMessage != null) {
if (signedMessage.Signature != MessageSignature) {
throw new InvalidSignatureException(message);
}
return MessageProtections.TamperProtection;
}
return null;
}
#endregion
}
}
|