summaryrefslogtreecommitdiffstats
path: root/projecttemplates/MvcRelyingParty/Code/OpenIdRelyingPartyService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'projecttemplates/MvcRelyingParty/Code/OpenIdRelyingPartyService.cs')
-rw-r--r--projecttemplates/MvcRelyingParty/Code/OpenIdRelyingPartyService.cs46
1 files changed, 46 insertions, 0 deletions
diff --git a/projecttemplates/MvcRelyingParty/Code/OpenIdRelyingPartyService.cs b/projecttemplates/MvcRelyingParty/Code/OpenIdRelyingPartyService.cs
new file mode 100644
index 0000000..2300e48
--- /dev/null
+++ b/projecttemplates/MvcRelyingParty/Code/OpenIdRelyingPartyService.cs
@@ -0,0 +1,46 @@
+namespace MvcRelyingParty {
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Web;
+ using DotNetOpenAuth.OpenId;
+ using DotNetOpenAuth.OpenId.RelyingParty;
+
+ public interface IOpenIdRelyingParty {
+ IAuthenticationRequest CreateRequest(Identifier userSuppliedIdentifier, Realm realm, Uri returnTo);
+
+ IAuthenticationResponse GetResponse();
+ }
+
+ /// <summary>
+ /// A wrapper around the standard <see cref="OpenIdRelyingParty"/> class.
+ /// </summary>
+ public class OpenIdRelyingPartyService : IOpenIdRelyingParty {
+ /// <summary>
+ /// The OpenID relying party to use for logging users in.
+ /// </summary>
+ /// <remarks>
+ /// This is static because it is thread-safe and is more expensive
+ /// to create than we want to run through for every single page request.
+ /// </remarks>
+ private static OpenIdRelyingParty relyingParty = new OpenIdRelyingParty();
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="OpenIdRelyingPartyService"/> class.
+ /// </summary>
+ public OpenIdRelyingPartyService() {
+ }
+
+ #region IOpenIdRelyingParty Members
+
+ public IAuthenticationRequest CreateRequest(Identifier userSuppliedIdentifier, Realm realm, Uri returnTo) {
+ return relyingParty.CreateRequest(userSuppliedIdentifier, realm, returnTo);
+ }
+
+ public IAuthenticationResponse GetResponse() {
+ return relyingParty.GetResponse();
+ }
+
+ #endregion
+ }
+}