Index: /trunk/sources/HeuristicLab.Hive.Server.Core/3.2/HeuristicLab.Hive.Server.Core-3.2.csproj
===================================================================
--- /trunk/sources/HeuristicLab.Hive.Server.Core/3.2/HeuristicLab.Hive.Server.Core-3.2.csproj	(revision 1768)
+++ /trunk/sources/HeuristicLab.Hive.Server.Core/3.2/HeuristicLab.Hive.Server.Core-3.2.csproj	(revision 1769)
@@ -87,6 +87,8 @@
     <Compile Include="DbTestApp.cs" />
     <Compile Include="ExecutionEngineFacade.cs" />
+    <Compile Include="HivePermissionManager.cs" />
     <Compile Include="HiveServerCorePlugin.cs" />
     <Compile Include="HiveServerMessages.Designer.cs" />
+    <Compile Include="InternalInterfaces\IHivePermissionManager.cs" />
     <Compile Include="InternalInterfaces\IInternalJobManager.cs" />
     <Compile Include="InternalInterfaces\IScheduler.cs" />
Index: /trunk/sources/HeuristicLab.Hive.Server.Core/3.2/InternalInterfaces/IHivePermissionManager.cs
===================================================================
--- /trunk/sources/HeuristicLab.Hive.Server.Core/3.2/InternalInterfaces/IHivePermissionManager.cs	(revision 1769)
+++ /trunk/sources/HeuristicLab.Hive.Server.Core/3.2/InternalInterfaces/IHivePermissionManager.cs	(revision 1769)
@@ -0,0 +1,7 @@
+﻿using System;
+namespace HeuristicLab.Hive.Server.Core.InternalInterfaces {
+  public interface IHivePermissionManager {
+    bool CheckPermission(Guid sessionID, Guid actionID, Guid entityId);
+    Guid Login(string username, string password);
+  }
+}
Index: /trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ServerConsoleFacade.cs
===================================================================
--- /trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ServerConsoleFacade.cs	(revision 1768)
+++ /trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ServerConsoleFacade.cs	(revision 1769)
@@ -28,4 +28,5 @@
 using HeuristicLab.Hive.Contracts;
 using HeuristicLab.Security.Contracts.Interfaces;
+using HeuristicLab.Hive.Server.Core.InternalInterfaces;
 
 namespace HeuristicLab.Hive.Server.Core {
@@ -37,7 +38,5 @@
       ServiceLocator.GetJobManager();
 
-    //private IPermissionManager permManager = ServiceLocator.GetPermissionManager();
-
-    #region IServerConsoleFacade Members
+    private IHivePermissionManager secMan = ServiceLocator.GetHivePermissionManager();
 
     public Guid sessionID = Guid.Empty;
@@ -45,27 +44,18 @@
     public Response Login(string username, string password) {
       Response resp = new Response();
-      /*
-      sessionID = permManager.Authenticate(username, password);
+      sessionID = secMan.Login(username, password);
       if (sessionID == Guid.Empty)
         resp.Success = false;
       else {
-       
         resp.Success = true;
         resp.StatusMessage =
           ApplicationConstants.RESPONSE_SERVERCONSOLE_LOGIN_SUCCESS;
       }
-       */
-      resp.Success = true;
-      resp.StatusMessage =
-        ApplicationConstants.RESPONSE_SERVERCONSOLE_LOGIN_SUCCESS;
       return resp;
     }
 
-    #endregion
-
-    #region IClientManager Members
 
     public ResponseList<ClientInfo> GetAllClients() {
-      if (hasPermission(PermissiveSecurityAction.List_AllClients))
+      if (HasPermission(PermissiveSecurityAction.List_AllClients))
         return clientManager.GetAllClients();
       else
@@ -74,5 +64,5 @@
 
     public ResponseList<ClientGroup> GetAllClientGroups() {
-      if (hasPermission(PermissiveSecurityAction.List_AllClientGroups))
+      if (HasPermission(PermissiveSecurityAction.List_AllClientGroups))
         return clientManager.GetAllClientGroups();
       else
@@ -81,5 +71,5 @@
 
     public ResponseList<UpTimeStatistics> GetAllUpTimeStatistics() {
-      if (hasPermission(PermissiveSecurityAction.Show_Statistics))
+      if (HasPermission(PermissiveSecurityAction.Show_Statistics))
         return clientManager.GetAllUpTimeStatistics();
       else
@@ -88,5 +78,5 @@
 
     public Response AddClientGroup(ClientGroup clientGroup) {
-      if (hasPermission(PermissiveSecurityAction.Add_ClientGroup))
+      if (HasPermission(PermissiveSecurityAction.Add_ClientGroup))
         return clientManager.AddClientGroup(clientGroup);
       else
@@ -95,5 +85,5 @@
 
     public Response AddResourceToGroup(Guid clientGroupId, Resource resource) {
-      if (hasPermission(PermissiveSecurityAction.Add_Resource))
+      if (HasPermission(PermissiveSecurityAction.Add_Resource))
         return clientManager.AddResourceToGroup(clientGroupId, resource);
       else
@@ -102,5 +92,5 @@
 
     public Response DeleteResourceFromGroup(Guid clientGroupId, Guid resourceId) {
-      if (hasPermission(PermissiveSecurityAction.Delete_Resource))
+      if (HasPermission(PermissiveSecurityAction.Delete_Resource))
         return clientManager.DeleteResourceFromGroup(clientGroupId, resourceId);
       else
@@ -108,10 +98,7 @@
     }
 
-    #endregion
-
-    #region IJobManager Members
 
     public ResponseList<HeuristicLab.Hive.Contracts.BusinessObjects.Job> GetAllJobs() {
-      if (hasPermission(PermissiveSecurityAction.Get_AllJobs))
+      if (HasPermission(PermissiveSecurityAction.Get_AllJobs))
         return jobManager.GetAllJobs();
       else
@@ -120,5 +107,5 @@
 
     public ResponseObject<Job> AddNewJob(Job job) {
-      if (hasPermission(PermissiveSecurityAction.Add_Job))
+      if (hasPermission(PermissiveSecurityAction.Add_Job, job.Client.Id))
         return jobManager.AddNewJob(job);
       else
@@ -127,5 +114,5 @@
 
     public ResponseObject<JobResult> GetLastJobResultOf(Guid jobId, bool requested) {
-      if (hasPermission(PermissiveSecurityAction.Get_LastJobResult))
+      if (HasPermission(PermissiveSecurityAction.Get_LastJobResult))
         return jobManager.GetLastJobResultOf(jobId, requested);
       else
@@ -134,5 +121,5 @@
 
     public ResponseObject<List<JobResult>> GetAllJobResults(Guid jobId) {
-      if (hasPermission(PermissiveSecurityAction.Get_AllJobResults))
+      if (HasPermission(PermissiveSecurityAction.Get_AllJobResults))
         return jobManager.GetAllJobResults(jobId);
       else
@@ -141,5 +128,5 @@
 
     public Response RemoveJob(Guid jobId) {
-      if (hasPermission(PermissiveSecurityAction.Remove_Job))
+      if (HasPermission(PermissiveSecurityAction.Remove_Job))
         return jobManager.RemoveJob(jobId);
       else
@@ -148,5 +135,5 @@
 
     public Response RequestSnapshot(Guid jobId) {
-      if (hasPermission(PermissiveSecurityAction.Request_Snapshot))
+      if (HasPermission(PermissiveSecurityAction.Request_Snapshot))
         return jobManager.RequestSnapshot(jobId);
       else
@@ -155,5 +142,5 @@
 
     public Response AbortJob(Guid jobId) {
-      if (hasPermission(PermissiveSecurityAction.Abort_Job))
+      if (HasPermission(PermissiveSecurityAction.Abort_Job))
         return jobManager.AbortJob(jobId);
       else
@@ -161,12 +148,25 @@
     }
 
-    private bool hasPermission(Guid action) {
-      return true;
-      /*
-      if (sessionID == Guid.Empty)
-        throw new Exception("sessionID is not set! Please check if user is successfully logged on!");
-      return permManager.CheckPermission(sessionID, action, Guid.Empty);
-       */
+    public ResponseObject<List<ClientGroup>> GetAllGroupsOfResource(Guid resourceId) {
+      if (HasPermission(PermissiveSecurityAction.Get_AllGroupsOfResource))
+        return clientManager.GetAllGroupsOfResource(resourceId);
+      else
+        throw new PermissionException();      
     }
+
+  /*
+    private bool HasPermission(Guid action) {
+      return (sessionID == Guid.Empty) ? false : secMan.CheckPermission(sessionID, action, Guid.Empty);
+    }
+
+    private bool HasPermission(Guid action, Guid entityId) {
+      return (sessionID == Guid.Empty) ? false : secMan.CheckPermission(sessionID, action, entityId);
+    }
+   */
+
+    [Obsolete("Only for testing!")]
+    private bool HasPermission(Guid g) { return true; }
+    [Obsolete("Only for testing!")]
+    private bool hasPermission(Guid g, Guid f) { return true; }
 
     public class PermissionException : Exception {
@@ -182,9 +182,5 @@
     }
 
-    public ResponseObject<List<ClientGroup>> GetAllGroupsOfResource(Guid resourceId) {
-      return clientManager.GetAllGroupsOfResource(resourceId);
-    }
 
-    #endregion
   }
 }
