public bool ValidateOpenIDUser() { bool ret = true; HttpContext Context = HttpContext.Current; HttpSessionState Session = Context.Session; HttpRequest Request = Context.Request; Janrain.OpenId.Consumer.Consumer consumer; try { if (consumerSession == null) { consumerSession = new Janrain.OpenId.Session.SimpleSessionState(); } consumer = new Janrain.OpenId.Consumer.Consumer(consumerSession, Janrain.OpenId.Store.MemoryStore.GetInstance()); } catch { return false; } if (Request.QueryString["openid.mode"] != null && Request.QueryString["openid.mode"] != "Cancel") { try { _country = (Request.QueryString["openid.sreg.country"] ?? ""); _dayOfBirth = (Request.QueryString["openid.sreg.dob"] ?? ""); _email = (Request.QueryString["openid.sreg.email"] ?? ""); _fullname = (Request.QueryString["openid.sreg.fullname"] ?? ""); _gender = (Request.QueryString["openid.sreg.gender"] ?? ""); _language = (Request.QueryString["openid.sreg.language"] ?? ""); _nickname = (Request.QueryString["openid.sreg.nickname"] ?? ""); _postcode = (Request.QueryString["openid.sreg.postcode"] ?? ""); _timezone = (Request.QueryString["openid.sreg.timezone"] ?? ""); ConsumerResponse resp = consumer.Complete(Request.QueryString); string userIdentity = Utility.IdentityUrlToDisplayString(resp.IdentityUrl); MembershipUser user = GetUserByOpenId(userIdentity, true); ret = (user != null); if (ret) { FormsAuthentication.RedirectFromLoginPage(user.UserName, false); } else { OpenIdNotLinkedException exception = new OpenIdNotLinkedException(userIdentity); throw exception; } } catch (FailureException fexc) { if (WriteExceptionsToEventLog) { Utility.WriteToEventLog(fexc, "ValidateOpenIDUser"); } ret = false; } catch (OpenIdNotLinkedException nlEx) { throw nlEx; } catch (Exception fe) { if (WriteExceptionsToEventLog) { Utility.WriteToEventLog(fe, "ValidateOpenIDUser"); } throw new OpenIdMembershipProviderException(fe.Message, fe.Source, fe.StackTrace); } } else { ret = false; } return ret; }
public bool ValidateOpenIDUser() { bool ret = true; HttpContext Context = HttpContext.Current; HttpSessionState Session = Context.Session; HttpRequest Request = Context.Request; Janrain.OpenId.Consumer.Consumer consumer; try { if (consumerSession == null) { consumerSession = new Janrain.OpenId.Session.SimpleSessionState(); } consumer = new Janrain.OpenId.Consumer.Consumer(consumerSession, Janrain.OpenId.Store.MemoryStore.GetInstance()); } catch { return(false); } if (Request.QueryString["openid.mode"] != null && Request.QueryString["openid.mode"] != "Cancel") { try { _country = (Request.QueryString["openid.sreg.country"] ?? ""); _dayOfBirth = (Request.QueryString["openid.sreg.dob"] ?? ""); _email = (Request.QueryString["openid.sreg.email"] ?? ""); _fullname = (Request.QueryString["openid.sreg.fullname"] ?? ""); _gender = (Request.QueryString["openid.sreg.gender"] ?? ""); _language = (Request.QueryString["openid.sreg.language"] ?? ""); _nickname = (Request.QueryString["openid.sreg.nickname"] ?? ""); _postcode = (Request.QueryString["openid.sreg.postcode"] ?? ""); _timezone = (Request.QueryString["openid.sreg.timezone"] ?? ""); ConsumerResponse resp = consumer.Complete(Request.QueryString); string userIdentity = Utility.IdentityUrlToDisplayString(resp.IdentityUrl); MembershipUser user = GetUserByOpenId(userIdentity, true); ret = (user != null); if (ret) { FormsAuthentication.RedirectFromLoginPage(user.UserName, false); } else { OpenIdNotLinkedException exception = new OpenIdNotLinkedException(userIdentity); throw exception; } } catch (FailureException fexc) { if (WriteExceptionsToEventLog) { Utility.WriteToEventLog(fexc, "ValidateOpenIDUser"); } ret = false; } catch (OpenIdNotLinkedException nlEx) { throw nlEx; } catch (Exception fe) { if (WriteExceptionsToEventLog) { Utility.WriteToEventLog(fe, "ValidateOpenIDUser"); } throw new OpenIdMembershipProviderException(fe.Message, fe.Source, fe.StackTrace); } } else { ret = false; } return(ret); }