Last change
on this file since 4333 was
4333,
checked in by cneumuel, 14 years ago
|
added authorizationManager which checks for permission to specific jobs (#1168)
|
File size:
1.0 KB
|
Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using System.Security.Principal;
|
---|
6 | using System.ServiceModel;
|
---|
7 | using System.Threading;
|
---|
8 | using System.Security;
|
---|
9 | using HeuristicLab.Hive.Server.DataAccess;
|
---|
10 | using HeuristicLab.Hive.Server.Core.InternalInterfaces;
|
---|
11 |
|
---|
12 | namespace HeuristicLab.Hive.Server.Core.Authorization {
|
---|
13 | public class AuthorizationManager : IAuthorizationManager {
|
---|
14 | private IContextFactory contextFactory = ServiceLocator.GetContextFactory();
|
---|
15 |
|
---|
16 | public void AuthorizeForJobs(params Guid[] jobId) {
|
---|
17 | if (!(Identity.IsAuthenticated && IsAuthorizedForJobs(jobId))) {
|
---|
18 | throw new SecurityException();
|
---|
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.