public List<MetadataControlAccess> GetMetadataControlsAccess( SecureSession session, Application application, MetadataControlList metadataControlsList, RoleList roleList, int versionNumber, AccessLevel? defaultAccessLevel = null) { throw new NotImplementedException(); }
public void SelectHighest() { Application application = new Application { FormId = "form-1", OrganisationId = "org-1", WorkflowState = "New" }; User user = new User { Id = "user-1", Roles = new Dictionary<string, string> { { "role-1", "role-1" }, { "role-3", "role-3" } } }; user.Organisations.Add("org-1", "Organisation One"); MetadataControlList metadataControls = new MetadataControlList() { MetadataControls = new List<string> { "application-status" } }; List<MetadataControlAccess> metadataControlsAccess = this.provider.GetMetadataControlsAccess(new SecureSession(user), application, metadataControls, this.roleList, 1); Assert.AreEqual(AccessLevel.Read, metadataControlsAccess[0].AccessLevel); }
/// <summary> /// Gets the control access level for each control in <paramref name="metadataControlsList"/>. /// </summary> /// <param name="session">The session.</param> /// <param name="application">The application the user is trying to access.</param> /// <param name="metadataControlsList">The metadata controls list.</param> /// <param name="roleList">The list of roles.</param> /// <param name="versionNumber">The version number.</param> /// <param name="defaultAccessLevel">The default access level to use when there is no entitlement for a metadata control. If not set it will default to the application base access level.</param> /// <returns> /// The metadata controls entitlements that the user has. /// </returns> public List<MetadataControlAccess> GetMetadataControlsAccess(SecureSession session, Application application, MetadataControlList metadataControlsList, RoleList roleList, int versionNumber, AccessLevel? defaultAccessLevel = null) { var userRoles = this.DetermineRolesForUser(session, roleList, application); var metadataControlEntitlements = this.securityService.GetMetadataEntitlements(application.FormId, versionNumber, application.WorkflowState, userRoles.Keys); metadataControlEntitlements.Merge(); if (session.AuthenticatedUser.IsAdministrator()) { defaultAccessLevel = AccessLevel.Read; } else { defaultAccessLevel = defaultAccessLevel ?? AccessLevel.NoAccess; } return metadataControlsList.MetadataControls.Select( controlName => { var entitlement = metadataControlEntitlements.FirstOrDefault(e => e.ControlName == controlName); if (entitlement == null) { return new MetadataControlAccess(controlName, defaultAccessLevel.Value); } return new MetadataControlAccess(controlName, entitlement.AccessLevel); }).ToList(); }
/// <summary> /// Gets the control access level for each control in <paramref name="metadataControlsList"/>. /// </summary> /// <param name="session">The session.</param> /// <param name="application">The application the user is trying to access.</param> /// <param name="metadataControlsList">The control list.</param> /// <param name="roleList">The list of roles.</param> /// <param name="versionNumber">The version number.</param> /// <param name="defaultAccessLevel">The default access level to use when there is no entitlement for a metadata control. If not set it will default to the application base access level.</param> /// <returns> /// The control entitlements that the user has. /// </returns> public List<MetadataControlAccess> GetMetadataControlsAccess(SecureSession session, Application application, MetadataControlList metadataControlsList, RoleList roleList, int versionNumber, AccessLevel? defaultAccessLevel = null) { return this.wrappedProvider.GetMetadataControlsAccess(session, application, metadataControlsList, roleList, versionNumber); }