Changeset 1648 for trunk/sources
- Timestamp:
- 04/24/09 12:07:58 (16 years ago)
- Location:
- trunk/sources/HeuristicLab.Hive.Server.Core/3.2
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Hive.Server.Core/3.2/HeuristicLab.Hive.Server.Core-3.2.csproj
r1534 r1648 93 93 <Compile Include="JobManager.cs" /> 94 94 <Compile Include="LifecycleManager.cs" /> 95 <Compile Include="PermissiveSecurityConstants.cs" /> 95 96 <Compile Include="Properties\AssemblyInfo.cs" /> 96 97 <Compile Include="ServerConsoleFacade.cs" /> … … 137 138 <Name>HeuristicLab.PluginInfrastructure</Name> 138 139 </ProjectReference> 140 <ProjectReference Include="..\..\HeuristicLab.Security.Contracts\3.2\HeuristicLab.Security.Contracts-3.2.csproj"> 141 <Project>{D59E852C-F205-4647-8C05-EB9ED1CF44E9}</Project> 142 <Name>HeuristicLab.Security.Contracts-3.2</Name> 143 </ProjectReference> 139 144 </ItemGroup> 140 145 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> -
trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ServerConsoleFacade.cs
r1627 r1648 27 27 using HeuristicLab.Hive.Contracts.BusinessObjects; 28 28 using HeuristicLab.Hive.Contracts; 29 using HeuristicLab.Security.Contracts.Interfaces; 29 30 30 31 namespace HeuristicLab.Hive.Server.Core { … … 36 37 ServiceLocator.GetJobManager(); 37 38 38 private String loginName = null;39 private IPermissionManager permManager = ServiceLocator.GetPermissionManager(); 39 40 40 41 #region IServerConsoleFacade Members 41 42 43 public Guid sessionID = Guid.Empty; 44 42 45 public Response Login(string username, string password) { 43 46 Response resp = new Response(); 44 45 loginName = username; 46 47 resp.Success = true; 48 resp.StatusMessage = 49 ApplicationConstants.RESPONSE_SERVERCONSOLE_LOGIN_SUCCESS; 50 47 sessionID = permManager.Authenticate(username, password); 48 if (sessionID == Guid.Empty) 49 resp.Success = false; 50 else { 51 resp.Success = true; 52 resp.StatusMessage = 53 ApplicationConstants.RESPONSE_SERVERCONSOLE_LOGIN_SUCCESS; 54 } 51 55 return resp; 52 56 } … … 57 61 58 62 public ResponseList<ClientInfo> GetAllClients() { 59 return clientManager.GetAllClients(); 63 if (hasPermission(PermissiveSecurityAction.List_AllClients)) 64 return clientManager.GetAllClients(); 65 else 66 throw new PermissionException(); 60 67 } 61 68 62 69 public ResponseList<ClientGroup> GetAllClientGroups() { 63 return clientManager.GetAllClientGroups(); 70 if (hasPermission(PermissiveSecurityAction.List_AllClientGroups)) 71 return clientManager.GetAllClientGroups(); 72 else 73 throw new PermissionException(); 64 74 } 65 75 66 76 public ResponseList<UpTimeStatistics> GetAllUpTimeStatistics() { 67 return clientManager.GetAllUpTimeStatistics(); 77 if (hasPermission(PermissiveSecurityAction.Show_Statistics)) 78 return clientManager.GetAllUpTimeStatistics(); 79 else 80 throw new PermissionException(); 68 81 } 69 82 70 83 public Response AddClientGroup(ClientGroup clientGroup) { 71 return clientManager.AddClientGroup(clientGroup); 84 if (hasPermission(PermissiveSecurityAction.Add_ClientGroup)) 85 return clientManager.AddClientGroup(clientGroup); 86 else 87 throw new PermissionException(); 72 88 } 73 89 74 90 public Response AddResourceToGroup(Guid clientGroupId, Resource resource) { 75 return clientManager.AddResourceToGroup(clientGroupId, resource); 91 if (hasPermission(PermissiveSecurityAction.Add_Resource)) 92 return clientManager.AddResourceToGroup(clientGroupId, resource); 93 else 94 throw new PermissionException(); 76 95 } 77 96 78 97 public Response DeleteResourceFromGroup(Guid clientGroupId, Guid resourceId) { 79 return clientManager.DeleteResourceFromGroup(clientGroupId, resourceId); 98 if (hasPermission(PermissiveSecurityAction.Delete_Resource)) 99 return clientManager.DeleteResourceFromGroup(clientGroupId, resourceId); 100 else 101 throw new PermissionException(); 80 102 } 81 103 … … 85 107 86 108 public ResponseList<HeuristicLab.Hive.Contracts.BusinessObjects.Job> GetAllJobs() { 87 return jobManager.GetAllJobs(); 109 if (hasPermission(PermissiveSecurityAction.Get_AllJobs)) 110 return jobManager.GetAllJobs(); 111 else 112 throw new PermissionException(); 88 113 } 114 89 115 public ResponseObject<Job> AddNewJob(Job job) { 90 return jobManager.AddNewJob(job); 116 if (hasPermission(PermissiveSecurityAction.Add_Job)) 117 return jobManager.AddNewJob(job); 118 else 119 throw new PermissionException(); 91 120 } 92 121 93 122 public ResponseObject<JobResult> GetLastJobResultOf(Guid jobId, bool requested) { 94 return jobManager.GetLastJobResultOf(jobId, requested); 123 if (hasPermission(PermissiveSecurityAction.Get_LastJobResult)) 124 return jobManager.GetLastJobResultOf(jobId, requested); 125 else 126 throw new PermissionException(); 127 } 128 129 public ResponseObject<List<JobResult>> GetAllJobResults(Guid jobId) { 130 if (hasPermission(PermissiveSecurityAction.Get_AllJobResults)) 131 return jobManager.GetAllJobResults(jobId); 132 else 133 throw new PermissionException(); 95 134 } 96 135 97 136 public Response RemoveJob(Guid jobId) { 98 return jobManager.RemoveJob(jobId); 137 if (hasPermission(PermissiveSecurityAction.Remove_Job)) 138 return jobManager.RemoveJob(jobId); 139 else 140 throw new PermissionException(); 99 141 } 100 142 101 143 public Response RequestSnapshot(Guid jobId) { 102 return jobManager.RequestSnapshot(jobId); 144 if (hasPermission(PermissiveSecurityAction.Request_Snapshot)) 145 return jobManager.RequestSnapshot(jobId); 146 else 147 throw new PermissionException(); 103 148 } 104 149 105 150 public Response AbortJob(Guid jobId) { 106 return jobManager.AbortJob(jobId); 151 if (hasPermission(PermissiveSecurityAction.Abort_Job)) 152 return jobManager.AbortJob(jobId); 153 else 154 throw new PermissionException(); 107 155 } 108 156 109 public ResponseObject<List<JobResult>> GetAllJobResults(Guid jobId) { 110 throw new NotImplementedException(); 157 private bool hasPermission(Guid action) { 158 return true; 159 /* 160 if (sessionID == Guid.Empty) 161 throw new Exception("sessionID is not set! Please check if user is successfully logged on!"); 162 return permManager.CheckPermission(sessionID, action, Guid.Empty); 163 */ 164 } 165 166 public class PermissionException : Exception { 167 public PermissionException() 168 : base("Current user has insufficent rights for this action!") { 169 } 170 171 public PermissionException(string msg) 172 : base(msg) { 173 } 174 175 111 176 } 112 177 113 178 #endregion 179 114 180 } 115 181 } -
trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ServiceLocator.cs
r1530 r1648 28 28 using HeuristicLab.DataAccess.Interfaces; 29 29 using System.Data.SqlClient; 30 using HeuristicLab.Security.Contracts.Interfaces; 30 31 31 32 /// <summary> … … 47 48 48 49 private static IScheduler scheduler = null; 50 51 private static IPermissionManager permManager = null; 49 52 50 53 /// <summary> … … 129 132 return scheduler; 130 133 } 134 135 /// <summary> 136 /// Gets the permission manager 137 /// </summary> 138 /// <returns></returns> 139 [MethodImpl(MethodImplOptions.Synchronized)] 140 public static IPermissionManager GetPermissionManager() { 141 if (permManager == null) 142 permManager = discoveryService.GetInstances<IPermissionManager>()[0]; 143 return permManager; 144 145 } 131 146 }
Note: See TracChangeset
for help on using the changeset viewer.