/// <summary> /// Processes an incoming request at the OpenID Provider endpoint. /// </summary> /// <param name="requestInfo">The request info.</param> /// <param name="response">The response.</param> private void ProcessRequest(HttpRequestInfo requestInfo, HttpListenerResponse response) { IRequest request = this.hostedProvider.Provider.GetRequest(requestInfo); if (request == null) { App.Logger.Error("A request came in that did not carry an OpenID message."); response.ContentType = "text/html"; response.StatusCode = (int)HttpStatusCode.BadRequest; using (StreamWriter sw = new StreamWriter(response.OutputStream)) { sw.WriteLine("<html><body>This is an OpenID Provider endpoint.</body></html>"); } return; } this.Dispatcher.Invoke((Action) delegate { if (!request.IsResponseReady) { var authRequest = request as IAuthenticationRequest; if (authRequest != null) { switch (checkidRequestList.SelectedIndex) { case 0: if (authRequest.IsDirectedIdentity) { authRequest.ClaimedIdentifier = new Uri(this.hostedProvider.UserIdentityPageBase, "directedidentity"); authRequest.LocalIdentifier = authRequest.ClaimedIdentifier; } authRequest.IsAuthenticated = true; break; case 1: authRequest.IsAuthenticated = false; break; case 2: IntPtr oldForegroundWindow = NativeMethods.GetForegroundWindow(); bool stoleFocus = NativeMethods.SetForegroundWindow(this); CheckIdWindow.ProcessAuthentication(this.hostedProvider, authRequest); if (stoleFocus) { NativeMethods.SetForegroundWindow(oldForegroundWindow); } break; } } } }); this.hostedProvider.Provider.PrepareResponse(request).Send(response); }
/// <summary> /// Processes an incoming request at the OpenID Provider endpoint. /// </summary> /// <param name="requestInfo">The request info.</param> /// <param name="response">The response.</param> private void ProcessRequest(HttpRequestBase requestInfo, HttpListenerResponse response) { IRequest request = this.hostedProvider.Provider.GetRequest(requestInfo); if (request == null) { App.Logger.Error("A request came in that did not carry an OpenID message."); response.ContentType = "text/html"; response.StatusCode = (int)HttpStatusCode.BadRequest; using (StreamWriter sw = new StreamWriter(response.OutputStream)) { sw.WriteLine("<html><body>This is an OpenID Provider endpoint.</body></html>"); } return; } this.Dispatcher.Invoke((Action) delegate { if (!request.IsResponseReady) { var authRequest = request as IAuthenticationRequest; if (authRequest != null) { switch (this.checkidRequestList.SelectedIndex) { case 0: if (authRequest.IsDirectedIdentity) { string userIdentityPageBase = this.hostedProvider.UserIdentityPageBase.AbsoluteUri; if (this.capitalizedHostName.IsChecked.Value) { userIdentityPageBase = (this.hostedProvider.UserIdentityPageBase.Scheme + Uri.SchemeDelimiter + this.hostedProvider.UserIdentityPageBase.Authority).ToUpperInvariant() + this.hostedProvider.UserIdentityPageBase.PathAndQuery; } string leafPath = "directedidentity"; if (this.directedIdentityTrailingPeriodsCheckbox.IsChecked.Value) { leafPath += "."; } authRequest.ClaimedIdentifier = Identifier.Parse(userIdentityPageBase + leafPath, true); authRequest.LocalIdentifier = authRequest.ClaimedIdentifier; } authRequest.IsAuthenticated = true; break; case 1: authRequest.IsAuthenticated = false; break; case 2: IntPtr oldForegroundWindow = NativeMethods.GetForegroundWindow(); bool stoleFocus = NativeMethods.SetForegroundWindow(this); CheckIdWindow.ProcessAuthentication(this.hostedProvider, authRequest); if (stoleFocus) { NativeMethods.SetForegroundWindow(oldForegroundWindow); } break; } } } }); this.hostedProvider.Provider.PrepareResponse(request).Send(response); }