示例#1
0
        public bool RequestAndCheck()
        {
            bool ret = false;

            HttpContext context = WebApplication.CurrentContext;
            HttpRequest request = context.Request;

            string invalidateHandle = request.UriArgs["openid.invalidate_handle"];

            if (invalidateHandle == null)
            {
                var discover = new DiscoverRequest();
                discover.Request(context.OverlayNode, DiscoverRequest.Google_Discover_OpenID_Endpoint);

                var auth = new WebAuth();

                var ub = new UriBuilder(context.Request.Uri);

                lock (sync)
                {
                    if (!CacheAssociations.ContainsKey(auth.ToStringHandle()))
                    {
                        CacheAssociations.Add(auth.ToStringHandle(),
                                              new KeyAssociation(auth.ToStringHandle()));
                    }
                }

                var realm   = ub.Uri.ToString();
                var authReq = new AuthenticationRequest(discover, realm,
                                                        auth.ToStringHandle(), realm, AppNode);

                context.Reply.RedirectTo(authReq.UrlRedirectTo());
            }
            else
            {
                lock (sync)
                {
                    ret = CacheAssociations.ContainsKey(invalidateHandle);
                    if (ret)
                    {
                        CacheAssociations.Remove(invalidateHandle);
                    }
                }
            }

            return(ret);
        }