Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/Authorization/AuthorizationManager.cs @ 4337

Last change on this file since 4337 was 4337, checked in by cneumuel, 14 years ago

changed Slave.Core WCF-Proxy to stateless object

File size: 1.2 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Security.Principal;
6using System.ServiceModel;
7using System.Threading;
8using System.Security;
9using HeuristicLab.Hive.Server.DataAccess;
10using HeuristicLab.Hive.Server.Core.InternalInterfaces;
11
12namespace HeuristicLab.Hive.Server.Core.Authorization {
13  public class AuthorizationManager : IAuthorizationManager {
14    private IContextFactory contextFactory = ServiceLocator.GetContextFactory();
15
16    public void AuthorizeForJobs(params Guid[] jobIds) {
17      if (!(Identity.IsAuthenticated && IsAuthorizedForJobs(jobIds))) {
18        throw new SecurityException("User '" + Identity.Name + "' is not authorized to access job (Id: " + string.Join(", ", jobIds.Select(x => x.ToString()).ToArray()) + ")");
19      }
20    }
21
22    public string UserId {
23      get { return Identity.Name; }
24    }
25   
26    private bool IsAuthorizedForJobs(params Guid[] jobIds) {
27      return DaoLocator.JobDao.IsUserAuthorizedForJobs(Identity.Name, jobIds);
28    }
29
30    private IIdentity Identity {
31      get { return ServiceSecurityContext.Current.PrimaryIdentity; }
32    }
33  }
34}
Note: See TracBrowser for help on using the repository browser.