Ejemplo n.º 1
0
		protected void cancelButton_Click(object sender, EventArgs e) {
			this.RegisterAsyncTask(
				new PageAsyncTask(
					async ct => {
						var req = ProviderEndpoint.PendingAuthenticationRequest;
						if (req != null) {
							req.IsAuthenticated = false;
							var providerEndpoint = new ProviderEndpoint();
							var response = await providerEndpoint.PrepareResponseAsync(Response.ClientDisconnectedToken);
							await response.SendAsync(new HttpContextWrapper(this.Context), Response.ClientDisconnectedToken);
							this.Context.Response.End();
						}
					}));
		}
Ejemplo n.º 2
0
		protected void Page_Load(object sender, EventArgs e) {
			this.RegisterAsyncTask(
				new PageAsyncTask(
					async ct => {
						// The user may have just completed a login.  If they're logged in, see if we can complete the OpenID login.
						if (User.Identity.IsAuthenticated && ProviderEndpoint.PendingAuthenticationRequest != null) {
							await
								Util.ProcessAuthenticationChallengeAsync(
									ProviderEndpoint.PendingAuthenticationRequest, Response.ClientDisconnectedToken);
							if (ProviderEndpoint.PendingAuthenticationRequest.IsAuthenticated.HasValue) {
								var providerEndpoint = new ProviderEndpoint();
								var responseMessage = await providerEndpoint.PrepareResponseAsync(this.Response.ClientDisconnectedToken);
								await responseMessage.SendAsync(new HttpContextWrapper(this.Context), this.Response.ClientDisconnectedToken);
								this.Context.Response.End();
							}
						}
					}));
		}
Ejemplo n.º 3
0
		protected void Yes_Click(object sender, EventArgs e) {
			this.RegisterAsyncTask(
				new PageAsyncTask(
					async ct => {
						if (!Page.IsValid || ProviderEndpoint.PendingRequest == null) {
							return;
						}

						if (this.OAuthPanel.Visible) {
							string grantedScope = null;
							if (this.oauthPermission.Checked) {
								// This SIMPLE sample merely uses the realm as the consumerKey,
								// but in a real app this will probably involve a database lookup to translate
								// the realm to a known consumerKey.
								grantedScope = string.Empty; // we don't scope individual access rights on this sample
							}

							OAuthHybrid.ServiceProvider.AttachAuthorizationResponse(ProviderEndpoint.PendingRequest, grantedScope);
						}

						var sregRequest = ProviderEndpoint.PendingRequest.GetExtension<ClaimsRequest>();
						ClaimsResponse sregResponse = null;
						if (sregRequest != null) {
							sregResponse = this.profileFields.GetOpenIdProfileFields(sregRequest);
							ProviderEndpoint.PendingRequest.AddResponseExtension(sregResponse);
						}
						var papeRequest = ProviderEndpoint.PendingRequest.GetExtension<PolicyRequest>();
						PolicyResponse papeResponse = null;
						if (papeRequest != null) {
							papeResponse = new PolicyResponse();
							papeResponse.NistAssuranceLevel = NistAssuranceLevel.InsufficientForLevel1;
							ProviderEndpoint.PendingRequest.AddResponseExtension(papeResponse);
						}

						if (ProviderEndpoint.PendingAuthenticationRequest != null) {
							ProviderEndpoint.PendingAuthenticationRequest.IsAuthenticated = true;
						} else {
							ProviderEndpoint.PendingAnonymousRequest.IsApproved = true;
						}
						Debug.Assert(
							ProviderEndpoint.PendingRequest.IsResponseReady, "Setting authentication should be all that's necessary.");

						var provider = new ProviderEndpoint();
						var response = await provider.PrepareResponseAsync();
						await response.SendAsync();
					}));
		}
Ejemplo n.º 4
0
		protected void No_Click(object sender, EventArgs e) {
			this.RegisterAsyncTask(
				new PageAsyncTask(
					async ct => {
						if (ProviderEndpoint.PendingRequest == null) {
							return;
						}

						if (ProviderEndpoint.PendingAuthenticationRequest != null) {
							ProviderEndpoint.PendingAuthenticationRequest.IsAuthenticated = false;
						} else {
							ProviderEndpoint.PendingAnonymousRequest.IsApproved = false;
						}
						Debug.Assert(
							ProviderEndpoint.PendingRequest.IsResponseReady, "Setting authentication should be all that's necessary.");
						var provider = new ProviderEndpoint();
						var response = await provider.PrepareResponseAsync();
						await response.SendAsync();
					}));
		}