/// <summary> /// Cancels the login process. /// </summary> private void cancelLoginProcess() { try { NameValueCollection form = Request.Form; // get form which has send the request AuthSession authSession = new AuthSession(form["secsignid"], form["authsessionid"], form["requestid"], null, null, null); SecSignIDApi secSignIDApi = new SecSignIDApi(); // cancel auth session secSignIDApi.CancelAuthSession(authSession); // render previous page if (PreviousPage != null) { Response.Redirect(PreviousPage.AppRelativeVirtualPath); } else { Response.Redirect("Default.aspx"); } } catch (System.Exception ex) { handleError(ex, false); } }
/// <summary> /// Checks the authentication session status. /// </summary> private void checkAuthSessionState() { int authSessionState = AuthSession.NOSTATE; try { NameValueCollection form = Request.Form; // get form which has send the request AuthSession authSession = new AuthSession(form["secsignid"], form["authsessionid"], form["requestid"], null, null, null); SecSignIDApi secSignIDApi = new SecSignIDApi(); // check ticket state authSessionState = secSignIDApi.GetAuthSessionState(authSession); if (authSessionState == AuthSession.ACCEPTED) { Response.Redirect("Intern.aspx?secsignid=" + authSession.GetSecSignID()); } else if (authSessionState == AuthSession.PENDING || authSessionState == AuthSession.FETCHED) { this.lblMessage.Text = "The auth session is still pending... it has neither be accepted nor denied."; } else { if (authSessionState == AuthSession.DENIED) { Response.Write("You have denied the auth session..."); } // render previous page if (PreviousPage != null) { Response.Redirect(PreviousPage.AppRelativeVirtualPath); } else { Response.Redirect("Default.aspx"); } } } catch (System.Exception ex) { handleError(ex, false); } }
/// <summary> /// Requests the authentication session for login. /// </summary> /// <param name='secsignidString'>the secsign id the authentication session is for</param> private void requestAuthSessionForLogin(string secsignidString) { // request authentication session SecSignIDApi secSignIDApi = null; AuthSession authSession = null; try { secSignIDApi = new SecSignIDApi(); authSession = secSignIDApi.RequestAuthSession(secsignidString, "ASP.NET example how to use SecSignIDApi", Request.Url.Authority); // set all values this.secsignid.Value = authSession.GetSecSignID(); this.authsessionid.Value = authSession.GetAuthSessionID(); this.requestid.Value = authSession.GetRequestID(); this.servicename.Value = authSession.GetRequestingService(); this.serviceaddress.Value = authSession.GetRequestingServiceAddress(); this.authsessionicondata.Value = authSession.GetIconData(); this.authSessionIconDisplay.Src = "data:image/png;base64," + authSession.GetIconData(); this.authSessionIconDisplay.Alt = "SecSign ID Access Pass Icon"; } catch (System.Net.WebException ex) { handleError(ex, false); } catch (System.Exception ex) { if (secSignIDApi != null && authSession != null) { // we could get an auth session which has to be canceled now try { secSignIDApi.CancelAuthSession(authSession); } catch {} } handleError(ex, false); } }