//----------------------------------------------------------------------- // // Copyright (c) Andrew Arnott. All rights reserved. // //----------------------------------------------------------------------- namespace OpenIdProviderWebForms.Code { using System; using System.Collections.Generic; using System.Linq; using System.Web; using DotNetOpenAuth.Messaging; using DotNetOpenAuth.OAuth; using DotNetOpenAuth.OAuth.ChannelElements; internal class OAuthHybrid { /// /// Initializes static members of the class. /// static OAuthHybrid() { ServiceProvider = new ServiceProvider(GetServiceDescription(), TokenManager); } internal static IServiceProviderTokenManager TokenManager { get { // This is merely a sample app. A real web app SHOULD NEVER store a memory-only // token manager in application. It should be an IServiceProviderTokenManager // implementation that is bound to a database. var tokenManager = (IServiceProviderTokenManager)HttpContext.Current.Application["TokenManager"]; if (tokenManager == null) { HttpContext.Current.Application["TokenManager"] = tokenManager = new InMemoryTokenManager(); } return tokenManager; } } internal static ServiceProvider ServiceProvider { get; private set; } internal static ServiceProviderDescription GetServiceDescription() { return new ServiceProviderDescription { TamperProtectionElements = new ITamperProtectionChannelBindingElement[] { new HmacSha1SigningBindingElement() }, }; } } }