blob: af9c5db1d973c6b2b70624c0da72172fa12d4d28 (
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
|
//-----------------------------------------------------------------------
// <copyright file="OpenIdCoordinator.cs" company="Andrew Arnott">
// Copyright (c) Andrew Arnott. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace DotNetOpenAuth.Test.OpenId {
using System;
using DotNetOpenAuth.Messaging;
using DotNetOpenAuth.Messaging.Bindings;
using DotNetOpenAuth.OpenId;
using DotNetOpenAuth.OpenId.Provider;
using DotNetOpenAuth.OpenId.RelyingParty;
using DotNetOpenAuth.Test.Mocks;
internal class OpenIdCoordinator : CoordinatorBase<OpenIdRelyingParty, OpenIdProvider> {
internal OpenIdCoordinator(Action<OpenIdRelyingParty> rpAction, Action<OpenIdProvider> opAction)
: base(WrapAction(rpAction), WrapAction(opAction)) {
}
internal OpenIdProvider Provider { get; set; }
internal OpenIdRelyingParty RelyingParty { get; set; }
internal override void Run() {
this.EnsurePartiesAreInitialized();
var rpCoordinatingChannel = new CoordinatingChannel(this.RelyingParty.Channel, this.IncomingMessageFilter, this.OutgoingMessageFilter);
var opCoordinatingChannel = new CoordinatingChannel(this.Provider.Channel, this.IncomingMessageFilter, this.OutgoingMessageFilter);
rpCoordinatingChannel.RemoteChannel = opCoordinatingChannel;
opCoordinatingChannel.RemoteChannel = rpCoordinatingChannel;
this.RelyingParty.Channel = rpCoordinatingChannel;
this.Provider.Channel = opCoordinatingChannel;
RunCore(this.RelyingParty, this.Provider);
}
private static Action<OpenIdRelyingParty> WrapAction(Action<OpenIdRelyingParty> action) {
ErrorUtilities.VerifyArgumentNotNull(action, "action");
return rp => {
action(rp);
((CoordinatingChannel)rp.Channel).Close();
};
}
private static Action<OpenIdProvider> WrapAction(Action<OpenIdProvider> action) {
ErrorUtilities.VerifyArgumentNotNull(action, "action");
return op => {
action(op);
((CoordinatingChannel)op.Channel).Close();
};
}
private void EnsurePartiesAreInitialized() {
if (this.RelyingParty == null) {
this.RelyingParty = new OpenIdRelyingParty(new StandardRelyingPartyApplicationStore());
}
if (this.Provider == null) {
this.Provider = new OpenIdProvider(new StandardProviderApplicationStore());
}
}
}
}
|