Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/25/17 17:20:15 (7 years ago)
Author:
jkarder
Message:

#2839: worked on Project and ProjectPermission service methods

Location:
branches/HiveProjectManagement/HeuristicLab.Services.Hive/3.3
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/HiveProjectManagement/HeuristicLab.Services.Hive/3.3/HiveService.cs

    r15379 r15380  
    636636    public void DeleteProject(Guid projectId) {
    637637      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator);
    638       AuthorizationManager.AuthorizeForResourceAdministration(projectId);
     638      AuthorizationManager.AuthorizeForProjectAdministration(projectId);
    639639      var pm = PersistenceManager;
    640640      using (new PerformanceLogger("DeleteProject")) {
     
    665665        var currentUserId = UserManager.CurrentUserId;
    666666        return pm.UseTransaction(() => {
    667           var resourcePermissions = projectPermissionDao.GetAll();
     667          var projectPermissions = projectPermissionDao.GetAll();
    668668          return projectDao.GetAll().ToList()
    669669            .Where(x => isAdministrator
    670670              || x.OwnerUserId == currentUserId
    671               || UserManager.VerifyUser(currentUserId, resourcePermissions
     671              || UserManager.VerifyUser(currentUserId, projectPermissions
    672672                  .Where(y => y.ProjectId == x.ProjectId)
    673673                  .Select(z => z.GrantedUserId)
     
    684684    public void GrantProjectPermissions(Guid projectId, Guid[] grantedUserIds) {
    685685      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     686      AuthorizationManager.AuthorizeForProjectAdministration(projectId);
    686687      var pm = PersistenceManager;
    687688      using (new PerformanceLogger("GrantProjectPermissions")) {
     
    704705    public void RevokeProjectPermissions(Guid projectId, Guid[] grantedUserIds) {
    705706      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     707      AuthorizationManager.AuthorizeForProjectAdministration(projectId);
    706708      var pm = PersistenceManager;
    707709      using (new PerformanceLogger("RevokeProjectPermissions")) {
    708710        var projectPermissionDao = pm.ProjectPermissionDao;
    709711        pm.UseTransaction(() => {
    710           AuthorizeForProject(pm, projectId);
    711712          projectPermissionDao.DeleteByProjectAndGrantedUserId(projectId, grantedUserIds);
    712713          pm.SubmitChanges();
  • branches/HiveProjectManagement/HeuristicLab.Services.Hive/3.3/Interfaces/IAuthorizationManager.cs

    r14185 r15380  
    3535
    3636    void AuthorizeForResourceAdministration(Guid resourceId);
     37
     38    void AuthorizeForProjectAdministration(Guid projectId);
    3739  }
    3840}
  • branches/HiveProjectManagement/HeuristicLab.Services.Hive/3.3/Manager/AuthorizationManager.cs

    r14185 r15380  
    8181    }
    8282
     83    public void AuthorizeForProjectAdministration(Guid projectId) {
     84      var pm = PersistenceManager;
     85      var projectDao = pm.ProjectDao;
     86      pm.UseTransaction(() => {
     87        var project = projectDao.GetById(projectId);
     88        if (project == null) throw new SecurityException(NOT_AUTHORIZED);
     89        if (project.OwnerUserId != UserManager.CurrentUserId
     90            && !RoleVerifier.IsInRole(HiveRoles.Administrator)) {
     91          throw new SecurityException(NOT_AUTHORIZED);
     92        }
     93      });
     94    }
     95
    8396    private DA.Permission GetPermissionForJob(IPersistenceManager pm, Guid jobId, Guid userId) {
    8497      var jobDao = pm.JobDao;
  • branches/HiveProjectManagement/HeuristicLab.Services.Hive/3.3/ServiceContracts/IHiveService.cs

    r15379 r15380  
    149149    #endregion
    150150
    151     #region ResourcePermission Methods
    152     [OperationContract]
    153     void GrantResourcePermissions(Guid resourceId, Guid[] grantedUserIds);
    154 
    155     [OperationContract]
    156     void RevokeResourcePermissions(Guid resourceId, Guid[] grantedUserIds);
    157 
    158     [OperationContract]
    159     IEnumerable<ProjectPermission> GetResourcePermissions(Guid resourceId);
     151    #region ProjectPermission Methods
     152    [OperationContract]
     153    void GrantProjectPermissions(Guid projectId, Guid[] grantedUserIds);
     154
     155    [OperationContract]
     156    void RevokeProjectPermissions(Guid projectId, Guid[] grantedUserIds);
     157
     158    [OperationContract]
     159    IEnumerable<ProjectPermission> GetProjectPermissions(Guid projectId);
    160160    #endregion
    161161
Note: See TracChangeset for help on using the changeset viewer.