/// <summary> /// Executed every time page is loaded. Checks for OpenID-related requests, /// and processes, if present. /// </summary> /// <param name="sender">Object invoking this method.</param> /// <param name="e">EventArgs associated with the request.</param> protected void Page_Load(object sender, EventArgs e) { // need to store openid, email, newsletter bool etc. in database for first time user. if (!IsPostBack) { OpenIDConsumer openid = new OpenIDConsumer(); switch (openid.RequestedMode) { case RequestedMode.IdResolution: openid.Identity = this.Identity; SetAuthMode(openid); if (openid.Validate()) { _UserObject = openid.RetrieveUser(); FormPanel.Visible = false; StatusPanel.Visible = true; OnValidateSuccess(e); } else { FormPanel.Visible = true; StatusPanel.Visible = false; LLabel.Text = openid.GetError(); OnValidateFail(e); } break; case RequestedMode.CancelledByUser: FormPanel.Visible = true; StatusPanel.Visible = false; LLabel.Text = "Login request cancelled."; OnRemoteCancel(e); break; case RequestedMode.None: if (UserObject != null) { FormPanel.Visible = false; StatusPanel.Visible = true; } break; } } }
private void SetAuthMode(OpenIDConsumer openid) { openid.AuthMode = AuthMode; }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); // <input id="openIdPostback" type="hidden" Value="<%= GetPostBackEventReference() %>"/> //<input id="openIdLogin" type="hidden" /> Page.ClientScript.RegisterHiddenField("openIdLogin", null); ScriptManager.RegisterClientScriptBlock(this, typeof(OpenId), "test", "function openidpb(){" + GetPostBackEventReference() + "}", true); //Trace.TraceFinished += new TraceContextEventHandler(Trace_TraceFinished); if (!Page.IsPostBack) { OpenIDConsumer openid = new OpenIDConsumer(); switch (openid.RequestedMode) { case RequestedMode.IdResolution: openid.Identity = this.Identity; SetAuthMode(openid); if (openid.Validate()) { _UserObject = openid.RetrieveUser(); OnValidateSuccess(e); OnResponseProcessed(e); } else { //FormPanel.Visible = true; //StatusPanel.Visible = false; //LLabel.Text = TranslateError(openid.GetError()); OnValidateFail(e); OnResponseProcessed(e); } break; case RequestedMode.CancelledByUser: //FormPanel.Visible = true; //StatusPanel.Visible = false; //LLabel.Text = TranslateError(Errors.RequestCancelled); OnRemoteCancel(e); OnResponseProcessed(e); break; case RequestedMode.None: if (UserObject != null) { //FormPanel.Visible = false; //StatusPanel.Visible = true; } break; } } }
public void RaisePostBackEvent(string eventArgument) { OpenIDConsumer openid = new OpenIDConsumer(); SetAuthMode(openid); SimpleRegistration sr = new SimpleRegistration(openid); if (!String.IsNullOrEmpty(this.RequiredFields)) { sr.RequiredFields = this.RequiredFields; } if (!String.IsNullOrEmpty(this.OptionalFields)) { sr.OptionalFields = this.OptionalFields; } if (!String.IsNullOrEmpty(this.PolicyURL)) { sr.PolicyURL = this.PolicyURL; } if (String.IsNullOrEmpty(OpenIDServerURL)) { openid.Identity = Page.Request["openIdLogin"]; this.Identity = openid.Identity; } else { openid.UseDirectedIdentity = true; openid.OpenIDServer = OpenIDServerURL; } //OnLogin(e); openid.BeginAuth(); //if (openid.IsError()) //{ // LLabel.Text = TranslateError(openid.GetError()); //} //else //{ // LLabel.Text = ""; //} }
/// <summary> /// User has clicked the login button. Sets up a new OpenIDConsumer /// object and begins the authentication sequence. /// Fires the OnLogin event. /// </summary> /// <param name="sender">Object invoking this method.</param> /// <param name="e">EventArgs related to this request.</param> protected void Button_Click(object sender, EventArgs e) { OpenIDConsumer openid = new OpenIDConsumer(); SetAuthMode(openid); SimpleRegistration sr = new SimpleRegistration(openid); if (this.RequiredFields != null) { sr.RequiredFields = this.RequiredFields; } if (this.OptionalFields != null) { sr.OptionalFields = this.OptionalFields; } if (this.PolicyURL != null) { sr.PolicyURL = this.PolicyURL; } openid.Identity = openid_url.Text; this.Identity = openid.Identity; OnLogin(e); openid.BeginAuth(); if (openid.IsError()) { LLabel.Text = openid.GetError(); } else { LLabel.Text = ""; } }
private void SetAuthMode(OpenIDConsumer openid) { if (this.AuthMode == "stateless") { openid.AuthMode = AuthorizationMode.Stateless; } else { openid.AuthMode = AuthorizationMode.Stateful; } }