public Task LoadConsentFormAsync() { _ = _loadConsentFormCompletionSource.TrySetCanceled(); _loadConsentFormCompletionSource = new TaskCompletionSource <bool>(); ConsentForm.LoadWithCompletionHandler(LoadConsentFormCompletionHandler); return(_loadConsentFormCompletionSource.Task); }
public virtual async Task <IActionResult> Index(ConsentForm form) { if (form == null) { throw new ArgumentNullException(nameof(form)); } var userCode = form.UserCode(); var authorizationRequest = await this.GetAuthorizationRequestAsync(userCode); if (authorizationRequest == null) { return(this.View(nameof(this.Index), await this.CreateDeviceViewModelAsync(userCode))); } if (form.Accept) { await this.ValidateConsentAsync(authorizationRequest, form); } if (!this.ModelState.IsValid) { return(this.View(this.ConsentViewPath, await this.CreateConsentViewModelAsync(authorizationRequest, form))); } var consentResponse = await(form.Accept ? this.AcceptConsentAsync(authorizationRequest, form) : this.RejectConsentAsync(authorizationRequest)); await this.DeviceInteraction.HandleRequestAsync(userCode, consentResponse); return(this.View("Confirmation")); }
public virtual async Task <IActionResult> Index(ConsentForm form) { if (form == null) { throw new ArgumentNullException(nameof(form)); } var authorizationRequest = await this.GetAuthorizationRequestAsync(form.ReturnUrl); if (form.Accept) { await this.ValidateConsentAsync(authorizationRequest, form); } if (!this.ModelState.IsValid) { return(this.View(await this.CreateConsentViewModelAsync(authorizationRequest, form, form.ReturnUrl))); } var consentResponse = await(form.Accept ? this.AcceptConsentAsync(authorizationRequest, form) : this.RejectConsentAsync(authorizationRequest)); await this.Facade.Interaction.GrantConsentAsync(authorizationRequest, consentResponse); return(authorizationRequest.IsNativeClient() ? await this.Redirect(form.ReturnUrl, this.Facade.IdentityServer.CurrentValue.Redirection.SecondsBeforeRedirect) : this.Redirect(form.ReturnUrl)); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { modalOverlay.Visible = false; OthersAlert.Visible = false; UserBO userbo = new UserBO(); String currentLoggedInUser = Request.Cookies["CurrentLoggedInUser"].Value; user currentuser = userbo.getUserById(currentLoggedInUser); string id = Request.QueryString["id"]; ConsentFormBO consentformbo = new ConsentFormBO(); ConsentForm consentFormData = consentformbo.getConsentFormByFormID(id); TitleLB.Text = consentFormData.Title; DescriptionTB.Text = consentFormData.Description; if (consentFormData.FoodPreferrence == "True") { foodprefcard.Visible = true; } else { foodprefcard.Visible = false; } if (currentuser.role == "Student") { alertLB.Visible = true; signgroup.Visible = false; } else if (currentuser.role == "Parent") { alertLB.Visible = false; signgroup.Visible = true; } } }
protected void ConsentFormList_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Select") { int index = Convert.ToInt32(e.CommandArgument); GridViewRow row = ConsentFormList.Rows[index]; ConsentFormBO consentformbo = new ConsentFormBO(); ConsentForm obj = new ConsentForm(); obj = consentformbo.getConsentFormByFormID(row.Cells[0].Text); ViewFormTitleLB.Text = obj.Title; ViewFormDescriptionTB.Text = obj.Description; FormInfoDiv.Visible = true; if (Boolean.Parse(obj.FoodPreferrence.ToString())) { ViewFormFoodPrefCard.Visible = true; } else { ViewFormFoodPrefCard.Visible = false; } } else if (e.CommandName == "viewParticipants") { //insert page to view participants int index = Convert.ToInt32(e.CommandArgument); GridViewRow row = ConsentFormList.Rows[index]; Response.Redirect("ConsentFormStatus.aspx?FormId=" + row.Cells[0].Text + "&FoodPref=" + row.Cells[5].Text); } }
public static string UserCode(this ConsentForm consentForm) { if (consentForm == null) { throw new ArgumentNullException(nameof(consentForm)); } return(consentForm.Dictionary.TryGetValue(QueryStringKeys.UserCode, out var userCode) ? userCode : null); }
private void LoadConsentForm() { String privacyUrl = BaseContext.GetString(Resource.String.privacy_url); form = new ConsentForm.Builder(this, privacyUrl). WithListener(this). WithPersonalizedAdsOption(). WithNonPersonalizedAdsOption(). Build(); form.Load(); }
public ConsentFormPage(ConsentForm form, StyleSheet styles, Action <ConsentFormResult> onConfirm) { InitializeComponent(); if (styles != null) { this.Resources.Add(styles); } this.onConfirm = onConfirm; this.results = form.Requests.ToDictionary(request => request.ConsentKey, request => request.IsGranted ?? false); form.Requests.ToList().ForEach(request => this.ConsentRequests.Children.Add(CreateConsentView(request))); this.BindingContext = form; this.CloseWhenBackgroundIsClicked = false; }
public static void UserCode(this ConsentForm consentForm, string userCode) { if (consentForm == null) { throw new ArgumentNullException(nameof(consentForm)); } if (userCode == null) { consentForm.Dictionary.Remove(QueryStringKeys.UserCode); } else { consentForm.Dictionary[QueryStringKeys.UserCode] = userCode; } }
public List<ConsentForm> selectUnsignedFormsByUser(String UserID, String School, String Class) { //get conn string string DBConnect; DBConnect = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString; //make adapter SqlDataAdapter da; //make dataset to store results (ResultSet equivalent in Java) DataSet ds = new DataSet(); StringBuilder sqlCommand = new StringBuilder(); sqlCommand.AppendLine("Select * from ConsentForms where RecievingClasses Like @paraClass and School=@paraSchool and ConsentFormID NOT IN (Select FormID from FormEntries where SignerID =@paraUserID)"); List<ConsentForm> objList = new List<ConsentForm>(); SqlConnection myConn = new SqlConnection(DBConnect); da = new SqlDataAdapter(sqlCommand.ToString(), myConn); da.SelectCommand.Parameters.AddWithValue("paraUserId", UserID); da.SelectCommand.Parameters.AddWithValue("paraClass", "%"+Class+"%"); da.SelectCommand.Parameters.AddWithValue("paraSchool", School); da.Fill(ds, "formsTable"); //Executes command and fills data set with the results int rec_cnt = ds.Tables["formsTable"].Rows.Count; //recordcount if (rec_cnt == 0) //no record has been found { //return a null object objList = null; } else if (rec_cnt > 0) { for (int i = 0; i < rec_cnt; i++) { DataRow row = ds.Tables["formsTable"].Rows[i]; ConsentForm obj = new ConsentForm(); obj.ConsentFormID = int.Parse(row["ConsentFormID"].ToString()); obj.SenderID = row["SenderID"].ToString(); obj.RecievingClasses = row["RecievingClasses"].ToString(); obj.School = row["School"].ToString(); obj.FormStatus = row["Status"].ToString(); obj.Title = row["Title"].ToString(); obj.Description = row["Description"].ToString(); obj.FoodPreferrence = row["FoodPreferrence"].ToString(); objList.Add(obj); } } return objList; }
protected internal virtual async Task <ConsentForm> CreateConsentFormAsync(AuthorizationRequest authorizationRequest, ConsentForm postedForm, string returnUrl) { if (authorizationRequest == null) { throw new ArgumentNullException(nameof(authorizationRequest)); } var form = new ConsentForm { ReturnUrl = returnUrl }; form.IdentityResources.Add(authorizationRequest.ValidatedResources.Resources.IdentityResources.Select(this.CreateScopeViewModel)); form.ApiScopes.Add(authorizationRequest.ValidatedResources.Resources.ApiScopes.Select(this.CreateScopeViewModel)); if (this.Facade.IdentityServer.CurrentValue.Consent.OfflineAccessEnabled && authorizationRequest.ValidatedResources.Resources.OfflineAccess) { form.ApiScopes.Add(new ScopeViewModel { Checked = true, Emphasize = true, Name = IdentityServerConstants.StandardScopes.OfflineAccess }); } // ReSharper disable InvertIf if (postedForm != null) { foreach (var(key, value) in postedForm.Dictionary) { form.Dictionary.Add(key, value); } foreach (var scope in form.IdentityResources) { scope.Checked = postedForm.ConsentedIdentityResources.Contains(scope.Name, StringComparer.OrdinalIgnoreCase); } foreach (var scope in form.ApiScopes) { scope.Checked = postedForm.ConsentedApiScopes.Contains(scope.Name, StringComparer.OrdinalIgnoreCase); } } // ReSharper restore InvertIf return(await Task.FromResult(form)); }
protected void DraftList_SelectedIndexChanged(object sender, EventArgs e) { GridViewRow row = DraftList.SelectedRow; updateFormDiv.Visible = true; ConsentFormBO consentformbo = new ConsentFormBO(); ConsentForm obj = new ConsentForm(); UserBO userbo = new UserBO(); obj = consentformbo.getDraftConsentFormByFormID(row.Cells[0].Text); List <String> RecievingClasses = obj.RecievingClasses.Split(',').ToList <String>(); List <String> TeachingClasses = userbo.getTeachersTeachingClasses(Request.Cookies["CurrentLoggedInUser"].Value); List <String> newTeachClasses = new List <string>(); foreach (String i in TeachingClasses) { if (RecievingClasses.Contains(i)) { //dont add anything } else { newTeachClasses.Add(i); } } updateSelectedClassesListBox.DataSource = newTeachClasses; updateSelectedClassesListBox.DataBind(); updateSelectedClassesListBox_Selected.DataSource = RecievingClasses; updateSelectedClassesListBox_Selected.DataBind(); hiddenFieldID.Text = obj.ConsentFormID.ToString(); UpdateTitleTB.Text = obj.Title; UpdateDescriptionTB.Text = obj.Description; UpdateFoodPreferrences.Checked = Boolean.Parse(obj.FoodPreferrence.ToString()); if (UpdateFoodPreferrences.Checked) { foodprefcardupdate.Visible = true; } else { foodprefcardupdate.Visible = false; } }
public ConsentForm getConsentFormByFormID(String FormID) { //get conn string string DBConnect; DBConnect = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString; //make adapter SqlDataAdapter da; //make dataset to store results (ResultSet equivalent in Java) DataSet ds = new DataSet(); StringBuilder sqlCommand = new StringBuilder(); sqlCommand.AppendLine("Select * from [ConsentForms] where"); sqlCommand.AppendLine("ConsentFormID = @paraConsentFormID"); ConsentForm obj = new ConsentForm(); SqlConnection myConn = new SqlConnection(DBConnect); da = new SqlDataAdapter(sqlCommand.ToString(), myConn); da.SelectCommand.Parameters.AddWithValue("paraConsentFormID", FormID); da.Fill(ds, "formsTable"); //Executes command and fills data set with the results int rec_cnt = ds.Tables["formsTable"].Rows.Count; //recordcount if (rec_cnt == 0) //no record has been found { //return a null object obj = null; } else if (rec_cnt > 0) { DataRow row = ds.Tables["formsTable"].Rows[0]; obj.ConsentFormID = int.Parse(row["ConsentFormID"].ToString()); obj.SenderID = row["SenderID"].ToString(); obj.RecievingClasses = row["RecievingClasses"].ToString(); obj.School = row["School"].ToString(); obj.FormStatus = row["Status"].ToString(); obj.Title = row["Title"].ToString(); obj.Description = row["Description"].ToString(); obj.FoodPreferrence = row["FoodPreferrence"].ToString(); } return obj; }
protected internal virtual async Task ValidateRememberConsentAsync(AuthorizationRequest authorizationRequest, ConsentForm form) { if (authorizationRequest == null) { throw new ArgumentNullException(nameof(authorizationRequest)); } if (form == null) { throw new ArgumentNullException(nameof(form)); } await Task.CompletedTask; if (form.Persistent && !authorizationRequest.Client.AllowRememberConsent) { this.ModelState.AddModelError(nameof(form.Persistent), this.GetLocalizedValue("errors/not-allowed", nameof(form.Persistent))); } }
protected internal virtual async Task <ConsentViewModel> CreateConsentViewModelAsync(AuthorizationRequest authorizationRequest, ConsentForm postedForm) { if (authorizationRequest == null) { throw new ArgumentNullException(nameof(authorizationRequest)); } var model = await this.CreateConsentViewModelAsync(authorizationRequest, postedForm, null); return(model); }
public void loadConsentForm() { consentForm = new ConsentForm.Builder().withListener(this).build(); consentForm?.load(); }
protected internal virtual async Task ValidateConsentAsync(AuthorizationRequest authorizationRequest, ConsentForm form) { await this.ValidateRequiredIdentityResourcesAsync(authorizationRequest, form); await this.ValidateOfflineAccessAsync(authorizationRequest, form); await this.ValidateInvalidIdentityResourcesAsync(authorizationRequest, form); await this.ValidateInvalidApiScopesAsync(authorizationRequest, form); await this.ValidateRememberConsentAsync(authorizationRequest, form); }
protected internal virtual async Task <ConsentViewModel> CreateConsentViewModelAsync(AuthorizationRequest authorizationRequest, ConsentForm postedForm, string returnUrl) { if (authorizationRequest == null) { throw new ArgumentNullException(nameof(authorizationRequest)); } var model = new ConsentViewModel { Client = authorizationRequest.Client, Form = await this.CreateConsentFormAsync(authorizationRequest, postedForm, returnUrl), PersistenceEnabled = authorizationRequest.Client.AllowRememberConsent }; return(await Task.FromResult(model)); }
protected internal virtual async Task ValidateRequiredIdentityResourcesAsync(AuthorizationRequest authorizationRequest, ConsentForm form) { if (authorizationRequest == null) { throw new ArgumentNullException(nameof(authorizationRequest)); } if (form == null) { throw new ArgumentNullException(nameof(form)); } await Task.CompletedTask; foreach (var requiredIdentityResource in authorizationRequest.ValidatedResources.Resources.IdentityResources.Where(identityResource => identityResource.Required)) { if (!form.ConsentedIdentityResources.Contains(requiredIdentityResource.Name, StringComparer.OrdinalIgnoreCase)) { this.ModelState.AddModelError(requiredIdentityResource.Name, this.GetLocalizedValue("errors/required", requiredIdentityResource.Name)); } } }
protected internal virtual async Task ValidateInvalidApiScopesAsync(AuthorizationRequest authorizationRequest, ConsentForm form) { if (authorizationRequest == null) { throw new ArgumentNullException(nameof(authorizationRequest)); } if (form == null) { throw new ArgumentNullException(nameof(form)); } await Task.CompletedTask; const string nullKey = "null-api-scope"; foreach (var key in form.ConsentedApiScopes.Where(key => !string.Equals(key, IdentityServerConstants.StandardScopes.OfflineAccess, StringComparison.OrdinalIgnoreCase))) { if (!authorizationRequest.ValidatedResources.Resources.ApiScopes.Any(apiScope => string.Equals(key, apiScope.Name, StringComparison.OrdinalIgnoreCase))) { this.ModelState.AddModelError(key ?? nullKey, this.GetLocalizedValue("errors/invalid-api-scope", key ?? nullKey)); } } }
protected internal virtual async Task <ConsentResponse> AcceptConsentAsync(AuthorizationRequest authorizationRequest, ConsentForm form) { if (authorizationRequest == null) { throw new ArgumentNullException(nameof(authorizationRequest)); } if (form == null) { throw new ArgumentNullException(nameof(form)); } var consentResponse = new ConsentResponse { Description = form.Description, RememberConsent = form.Persistent, ScopesValuesConsented = form.ConsentedIdentityResources.Concat(form.ConsentedApiScopes).ToArray() }; await this.Facade.Events.RaiseAsync(new ConsentGrantedEvent(this.User.GetSubjectId(), authorizationRequest.Client.ClientId, authorizationRequest.ValidatedResources.RawScopeValues, consentResponse.ScopesValuesConsented, consentResponse.RememberConsent)); return(consentResponse); }
protected internal virtual async Task ValidateOfflineAccessAsync(AuthorizationRequest authorizationRequest, ConsentForm form) { if (authorizationRequest == null) { throw new ArgumentNullException(nameof(authorizationRequest)); } if (form == null) { throw new ArgumentNullException(nameof(form)); } await Task.CompletedTask; const string offlineAccessScopeName = IdentityServerConstants.StandardScopes.OfflineAccess; if (!form.ConsentedApiScopes.Contains(offlineAccessScopeName, StringComparer.OrdinalIgnoreCase)) { return; } if (!this.Facade.IdentityServer.CurrentValue.Consent.OfflineAccessEnabled) { this.ModelState.AddModelError(offlineAccessScopeName, this.GetLocalizedValue("errors/not-enabled", offlineAccessScopeName)); } if (!authorizationRequest.ValidatedResources.Resources.OfflineAccess) { this.ModelState.AddModelError(offlineAccessScopeName, this.GetLocalizedValue("errors/not-enabled-for-client", offlineAccessScopeName)); } }
protected internal virtual async Task ValidateInvalidIdentityResourcesAsync(AuthorizationRequest authorizationRequest, ConsentForm form) { if (authorizationRequest == null) { throw new ArgumentNullException(nameof(authorizationRequest)); } if (form == null) { throw new ArgumentNullException(nameof(form)); } await Task.CompletedTask; const string nullKey = "null-identity-resource"; foreach (var key in form.ConsentedIdentityResources) { if (!authorizationRequest.ValidatedResources.Resources.IdentityResources.Any(identityResource => string.Equals(key, identityResource.Name, StringComparison.OrdinalIgnoreCase))) { this.ModelState.AddModelError(key ?? nullKey, this.GetLocalizedValue("errors/invalid-identity-resource", key ?? nullKey)); } } }