Free cookie consent management tool by TermsFeed Policy Generator

Changeset 6463


Ignore:
Timestamp:
06/21/11 16:51:03 (11 years ago)
Author:
cneumuel
Message:

#1233

  • created user interface for experiment sharing
  • created UserManager which provides access to the users
  • inserted a lot of security and authorization checks serverside
  • minor fixes in experiment manager
Location:
branches/HeuristicLab.Hive-3.4/sources
Files:
13 added
4 deleted
22 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.ExperimentManager/3.4/HeuristicLab.Clients.Hive.ExperimentManager-3.4.csproj

    r6418 r6463  
    102102  </PropertyGroup>
    103103  <ItemGroup>
     104    <Reference Include="HeuristicLab.Clients.Hive.ExperimentManager-3.4, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
    104105    <Reference Include="HeuristicLab.Collections-3.3">
    105106      <HintPath>C:\Program Files\HeuristicLab 3.3\HeuristicLab.Collections-3.3.dll</HintPath>
     
    151152  </ItemGroup>
    152153  <ItemGroup>
     154    <Compile Include="Views\HiveExperimentManagerView.cs">
     155      <SubType>UserControl</SubType>
     156    </Compile>
     157    <Compile Include="Views\HiveExperimentManagerView.Designer.cs">
     158      <DependentUpon>HiveExperimentManagerView.cs</DependentUpon>
     159    </Compile>
     160    <Compile Include="MenuItems\ExperimentManagerMenuItem.cs" />
     161    <Compile Include="Views\HiveExperimentPermissionListView.cs">
     162      <SubType>UserControl</SubType>
     163    </Compile>
     164    <Compile Include="Views\HiveExperimentPermissionListView.Designer.cs">
     165      <DependentUpon>HiveExperimentPermissionListView.cs</DependentUpon>
     166    </Compile>
     167    <Compile Include="Views\HiveExperimentPermissionView.cs">
     168      <SubType>UserControl</SubType>
     169    </Compile>
     170    <Compile Include="Views\HiveExperimentPermissionView.Designer.cs">
     171      <DependentUpon>HiveExperimentPermissionView.cs</DependentUpon>
     172    </Compile>
    153173    <Compile Include="Views\RefreshableHiveExperimentListView.cs">
    154174      <SubType>UserControl</SubType>
     
    157177      <DependentUpon>RefreshableHiveExperimentListView.cs</DependentUpon>
    158178    </Compile>
    159     <Compile Include="Views\HiveExperimentManagerView.cs">
    160       <SubType>UserControl</SubType>
    161     </Compile>
    162     <Compile Include="Views\HiveExperimentManagerView.Designer.cs">
    163       <DependentUpon>HiveExperimentManagerView.cs</DependentUpon>
    164     </Compile>
    165     <Compile Include="MenuItems\ExperimentManagerMenuItem.cs" />
    166179    <Compile Include="Views\RefreshableHiveExperimentView.cs">
    167180      <SubType>UserControl</SubType>
     
    200213      <DependentUpon>HiveExperimentManagerView.cs</DependentUpon>
    201214      <SubType>Designer</SubType>
     215    </EmbeddedResource>
     216    <EmbeddedResource Include="Views\HiveExperimentPermissionView.resx">
     217      <DependentUpon>HiveExperimentPermissionView.cs</DependentUpon>
    202218    </EmbeddedResource>
    203219    <EmbeddedResource Include="Views\RefreshableHiveExperimentView.resx">
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.ExperimentManager/3.4/Views/RefreshableHiveExperimentView.Designer.cs

    r6444 r6463  
    5454      this.stateTabPage = new System.Windows.Forms.TabPage();
    5555      this.stateLogViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
     56      this.sharingTabPage = new System.Windows.Forms.TabPage();
     57      this.hiveExperimentPermissionListView = new HeuristicLab.Clients.Hive.ExperimentManager.Views.HiveExperimentPermissionListView();
    5658      this.logTabPage = new System.Windows.Forms.TabPage();
    5759      this.logView = new HeuristicLab.Core.Views.LogView();
     
    7779      this.calculatingLabel = new System.Windows.Forms.Label();
    7880      this.jobsLabel = new System.Windows.Forms.Label();
     81      this.refreshPermissionsButton = new System.Windows.Forms.Button();
    7982      this.tabControl.SuspendLayout();
    8083      this.jobsTabPage.SuspendLayout();
    8184      this.stateTabPage.SuspendLayout();
     85      this.sharingTabPage.SuspendLayout();
    8286      this.logTabPage.SuspendLayout();
    8387      this.infoGroupBox.SuspendLayout();
     
    9195      this.tabControl.Controls.Add(this.jobsTabPage);
    9296      this.tabControl.Controls.Add(this.stateTabPage);
     97      this.tabControl.Controls.Add(this.sharingTabPage);
    9398      this.tabControl.Controls.Add(this.logTabPage);
    9499      this.tabControl.Location = new System.Drawing.Point(0, 78);
     
    132137      this.stateTabPage.Size = new System.Drawing.Size(709, 426);
    133138      this.stateTabPage.TabIndex = 6;
    134       this.stateTabPage.Text = "State";
     139      this.stateTabPage.Text = "States";
    135140      this.stateTabPage.UseVisualStyleBackColor = true;
    136141      //
     
    149154      this.stateLogViewHost.ViewType = null;
    150155      //
     156      // sharingTabPage
     157      //
     158      this.sharingTabPage.Controls.Add(this.refreshPermissionsButton);
     159      this.sharingTabPage.Controls.Add(this.hiveExperimentPermissionListView);
     160      this.sharingTabPage.Location = new System.Drawing.Point(4, 22);
     161      this.sharingTabPage.Name = "sharingTabPage";
     162      this.sharingTabPage.Size = new System.Drawing.Size(709, 426);
     163      this.sharingTabPage.TabIndex = 7;
     164      this.sharingTabPage.Text = "Sharing";
     165      this.sharingTabPage.UseVisualStyleBackColor = true;
     166      //
     167      // hiveExperimentPermissionListView
     168      //
     169      this.hiveExperimentPermissionListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     170                  | System.Windows.Forms.AnchorStyles.Left)
     171                  | System.Windows.Forms.AnchorStyles.Right)));
     172      this.hiveExperimentPermissionListView.Caption = "HiveExperimentPermissionList View";
     173      this.hiveExperimentPermissionListView.Content = null;
     174      this.hiveExperimentPermissionListView.Location = new System.Drawing.Point(3, 33);
     175      this.hiveExperimentPermissionListView.Name = "hiveExperimentPermissionListView";
     176      this.hiveExperimentPermissionListView.ReadOnly = false;
     177      this.hiveExperimentPermissionListView.Size = new System.Drawing.Size(703, 390);
     178      this.hiveExperimentPermissionListView.TabIndex = 0;
     179      //
    151180      // logTabPage
    152181      //
     
    167196      this.logView.Name = "logView";
    168197      this.logView.ReadOnly = false;
    169       this.logView.Size = new System.Drawing.Size(813, 494);
     198      this.logView.Size = new System.Drawing.Size(709, 426);
    170199      this.logView.TabIndex = 0;
    171200      //
     
    381410      this.jobsLabel.TabIndex = 0;
    382411      this.jobsLabel.Text = "Jobs:";
     412      //
     413      // refreshPermissionsButton
     414      //
     415      this.refreshPermissionsButton.Image = ((System.Drawing.Image)(resources.GetObject("refreshPermissionsButton.Image")));
     416      this.refreshPermissionsButton.Location = new System.Drawing.Point(3, 3);
     417      this.refreshPermissionsButton.Name = "refreshPermissionsButton";
     418      this.refreshPermissionsButton.Size = new System.Drawing.Size(24, 24);
     419      this.refreshPermissionsButton.TabIndex = 23;
     420      this.toolTip.SetToolTip(this.refreshPermissionsButton, "Refresh Data");
     421      this.refreshPermissionsButton.UseVisualStyleBackColor = true;
     422      this.refreshPermissionsButton.Click += new System.EventHandler(this.refreshPermissionsButton_Click);
    383423      //
    384424      // RefreshableHiveExperimentView
     
    406446      this.jobsTabPage.ResumeLayout(false);
    407447      this.stateTabPage.ResumeLayout(false);
     448      this.sharingTabPage.ResumeLayout(false);
    408449      this.logTabPage.ResumeLayout(false);
    409450      this.infoGroupBox.ResumeLayout(false);
     
    443484    private System.Windows.Forms.TabPage stateTabPage;
    444485    private ViewHost stateLogViewHost;
     486    private System.Windows.Forms.TabPage sharingTabPage;
     487    private HiveExperimentPermissionListView hiveExperimentPermissionListView;
     488    private System.Windows.Forms.Button refreshPermissionsButton;
    445489
    446490  }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.ExperimentManager/3.4/Views/RefreshableHiveExperimentView.cs

    r6444 r6463  
    2121
    2222using System;
     23using System.ComponentModel;
    2324using System.Linq;
    2425using System.Threading;
     
    7980      Content.HiveExperiment.HiveJobsChanged += new EventHandler(Content_HiveJobChanged);
    8081      Content.HiveExperiment.IsProgressingChanged += new EventHandler(Content_IsProgressingChanged);
    81     }
     82      Content.HiveExperiment.PropertyChanged += new PropertyChangedEventHandler(HiveExperiment_PropertyChanged);
     83    }
     84   
    8285    private void DeregisterHiveExperimentEvents() {
    8386      Content.HiveExperiment.ExecutionStateChanged -= new EventHandler(Content_ExecutionStateChanged);
     
    8588      Content.HiveExperiment.HiveJobsChanged -= new EventHandler(Content_HiveJobChanged);
    8689      Content.HiveExperiment.IsProgressingChanged -= new EventHandler(Content_IsProgressingChanged);
     90      Content.HiveExperiment.PropertyChanged -= new PropertyChangedEventHandler(HiveExperiment_PropertyChanged);
    8791    }
    8892
    8993    private void RegisterHiveJobEvents() {
    90       Content.HiveExperiment.HiveJobs.ItemsAdded += new Collections.CollectionItemsChangedEventHandler<HiveJob>(HiveJobs_ItemsAdded_Removed_Reset);
    91       Content.HiveExperiment.HiveJobs.ItemsRemoved += new Collections.CollectionItemsChangedEventHandler<HiveJob>(HiveJobs_ItemsAdded_Removed_Reset);
    92       Content.HiveExperiment.HiveJobs.CollectionReset += new Collections.CollectionItemsChangedEventHandler<HiveJob>(HiveJobs_ItemsAdded_Removed_Reset);
     94      Content.HiveExperiment.HiveJobs.ItemsAdded += new CollectionItemsChangedEventHandler<HiveJob>(HiveJobs_ItemsAdded_Removed_Reset);
     95      Content.HiveExperiment.HiveJobs.ItemsRemoved += new CollectionItemsChangedEventHandler<HiveJob>(HiveJobs_ItemsAdded_Removed_Reset);
     96      Content.HiveExperiment.HiveJobs.CollectionReset += new CollectionItemsChangedEventHandler<HiveJob>(HiveJobs_ItemsAdded_Removed_Reset);
    9397    }
    9498    private void DeregisterHiveJobEvents() {
    95       Content.HiveExperiment.HiveJobs.ItemsAdded -= new Collections.CollectionItemsChangedEventHandler<HiveJob>(HiveJobs_ItemsAdded_Removed_Reset);
    96       Content.HiveExperiment.HiveJobs.ItemsRemoved -= new Collections.CollectionItemsChangedEventHandler<HiveJob>(HiveJobs_ItemsAdded_Removed_Reset);
    97       Content.HiveExperiment.HiveJobs.CollectionReset -= new Collections.CollectionItemsChangedEventHandler<HiveJob>(HiveJobs_ItemsAdded_Removed_Reset);
     99      Content.HiveExperiment.HiveJobs.ItemsAdded -= new CollectionItemsChangedEventHandler<HiveJob>(HiveJobs_ItemsAdded_Removed_Reset);
     100      Content.HiveExperiment.HiveJobs.ItemsRemoved -= new CollectionItemsChangedEventHandler<HiveJob>(HiveJobs_ItemsAdded_Removed_Reset);
     101      Content.HiveExperiment.HiveJobs.CollectionReset -= new CollectionItemsChangedEventHandler<HiveJob>(HiveJobs_ItemsAdded_Removed_Reset);
    98102    }
    99103
     
    116120        logView.Content = Content.Log;
    117121      }
     122      hiveExperimentPermissionListView.Content = null; // has to be filled by refresh button
    118123      Content_JobStatisticsChanged(this, EventArgs.Empty);
    119124      Content_HiveExperimentChanged(this, EventArgs.Empty);
     
    121126      Content_IsProgressingChanged(this, EventArgs.Empty);
    122127      Content_StateLogListChanged(this, EventArgs.Empty);
     128      HiveExperiment_PropertyChanged(this, new PropertyChangedEventArgs("Id"));
    123129      SetEnabledStateOfControls();
    124130    }
     
    277283      }
    278284    }
     285
     286    private void HiveExperiment_PropertyChanged(object sender, PropertyChangedEventArgs e) {
     287      if(this.Content != null && e.PropertyName == "Id") this.hiveExperimentPermissionListView.HiveExperimentId = this.Content.HiveExperiment.Id;
     288    }
    279289    #endregion
    280290
     
    320330      }, null);
    321331    }
     332
     333    private void refreshPermissionsButton_Click(object sender, EventArgs e) {
     334      hiveExperimentPermissionListView.Content = HiveClient.GetHiveExperimentPermissions(this.Content.HiveExperiment.Id);
     335    }
     336
     337
    322338    #endregion
    323339
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.ExperimentManager/3.4/Views/RefreshableHiveExperimentView.resx

    r6373 r6463  
    119119  </resheader>
    120120  <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    121   <data name="startButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
    122     <value>
    123         iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
    124         YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAAK/wAA
    125         Cv8BNGKaggAAALBJREFUOE9j+P//PwMlGKvmsv3ZbsQaitWAhBkR/4k1BKcBlmX6RBmC1YCoKUH/N9xa
    126         /J8YQ7AaEDzBG2Q7UYZgNcCnyxlsAAhHLQrA6xKsBjg2W/zP2BAL1mzbrP9fp1jhv0QaN4hWQ48drAaY
    127         1+ihaOZPYMGqGWQYVgP0SpXhNuPTjNMAlXwpsLMJacZpgHSGIFGacRogksyJ089EBSK20MaVNyjKiTi9
    128         QGxOBKkDACT9xOni1RbMAAAAAElFTkSuQmCC
    129 </value>
    130   </data>
    131   <metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    132     <value>17, 17</value>
    133   </metadata>
    134   <data name="stopButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
    135     <value>
    136         iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
    137         YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAAK/wAA
    138         Cv8BNGKaggAAAWtJREFUOE/Nkz9IAmEYxl0KGqKtMVpaIiEoipYIgnByCSGhSQiCNBqCMiqwsr8clChF
    139         YmYSSikeWEbZH2qwEhKhwhAXjQwKEbw0zyue7nO7hgtyqOEbf7/ne5+XVwJAUsorCSbB/0xAeT+xSBcw
    140         685B52QwYU9jdOMFw+ZnDK0+YtCUyHzvSzACge/jH7hLcAg8FHB4w8IbZOEKsLD4s5AqdnheWLpAQJKj
    141         TxyCUa4IOi/yWPPlsOJlMGePoU6+JS4g376NczgKsdg+y8PIg3pnBmPWV6ipMGq61sUFZOarCAf3JZ98
    142         8I75XQKnoDEmoRg5RXW7QVxACvOHWdhO8lim36C1ptFvSEI5E4NsYA9VLUviAtK255qFcT+LSXsKahMP
    143         66OQa0Po7HOholEvLiCr2jxmMG2LQEOFoBw/55M96FA50NpjRlmDTlxA9tym8qGpl0Z9twO1Mktx7srm
    144         BZRLp34W/Oao/v4WvgBcI/R+TmAaZAAAAABJRU5ErkJggg==
    145 </value>
    146   </data>
    147   <data name="resetButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
    148     <value>
    149         iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
    150         YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAAK/wAA
    151         Cv8BNGKaggAAAX9JREFUOE9j+P//PwMlmCLNIIupa0Dv5r//Ybht7bf/jSs+/69d/P5/xbxX/0tmP/9f
    152         MP3x/9JZj4EWI7yN4oKuDb/+bzr57f/KQ1/+L9jz6f/lBz//965997956RuwIXnTX/zXDV2F2wCQrSsO
    153         fvk/b9en/7ee/AIp/N+w5M3/0rkv/+dMff4/qffZf1W/RbgNADl5zo5P/x++/AHWDAIls1/+z5ry/H9C
    154         79P/Ya2P/8u5zcJtAMi/Nx99hmtGZhy7/Oa/V+3D/2J2k3AbAPJn87I3/09deQnXG9355H9g0yMw36H0
    155         /n9+s27cBoBCuhxoSM605/93HrkL1hTQ8Oi/W9UDMNss7+5/ToNW3AaAoikb6N9EoH/D2x7/n7Puwn/X
    156         ivv/bYrvgQ3Qy7j1n1WnEbcBoDiO63n6P7Tl0X+fuof/ncrv/7cuvPffJPsO2AD1JCIMsEza9h+EjWM2
    157         /NcKXv5fwWMuOOB4TTr/s+k24XcB0BKSkzbJGtAtodgAAJMl+qgyDSjjAAAAAElFTkSuQmCC
    158 </value>
    159   </data>
    160   <data name="pauseButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
    161     <value>
    162         iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
    163         YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAAK/wAA
    164         Cv8BNGKaggAAAL5JREFUOE9j+P//PwMlmCLNIIsHoQG9m//+79rw63/e1EefQE5E56OHF4YXQJqvPvzz
    165         Xzd0FVDtfwZ0PkED2tZ++3/r6e//qn6LwAag8wka0Lji8//LD3//l3ObBTYAnU/QgNrF7/+fuP77v5jd
    166         JLAB6HyCBlTMe/V/94Wf//nNusEGoPMJGlAy+/n/9Sd//uc0aAUbgM4naEDB9Mf/F+z5/J9VpxFsADqf
    167         oAGg+GfTbYIbgM4naACpGWvg8wIAkX3yJyVePz4AAAAASUVORK5CYII=
    168 </value>
    169   </data>
    170   <data name="refreshButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
     121  <data name="refreshPermissionsButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
    171122    <value>
    172123        iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGOfPtRkwAAACBjSFJNAACH
     
    229180</value>
    230181  </data>
     182  <metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     183    <value>17, 17</value>
     184  </metadata>
     185  <data name="startButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
     186    <value>
     187        iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
     188        YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAAK/wAA
     189        Cv8BNGKaggAAALBJREFUOE9j+P//PwMlGKvmsv3ZbsQaitWAhBkR/4k1BKcBlmX6RBmC1YCoKUH/N9xa
     190        /J8YQ7AaEDzBG2Q7UYZgNcCnyxlsAAhHLQrA6xKsBjg2W/zP2BAL1mzbrP9fp1jhv0QaN4hWQ48drAaY
     191        1+ihaOZPYMGqGWQYVgP0SpXhNuPTjNMAlXwpsLMJacZpgHSGIFGacRogksyJ089EBSK20MaVNyjKiTi9
     192        QGxOBKkDACT9xOni1RbMAAAAAElFTkSuQmCC
     193</value>
     194  </data>
     195  <data name="stopButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
     196    <value>
     197        iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
     198        YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAAK/wAA
     199        Cv8BNGKaggAAAWtJREFUOE/Nkz9IAmEYxl0KGqKtMVpaIiEoipYIgnByCSGhSQiCNBqCMiqwsr8clChF
     200        YmYSSikeWEbZH2qwEhKhwhAXjQwKEbw0zyue7nO7hgtyqOEbf7/ne5+XVwJAUsorCSbB/0xAeT+xSBcw
     201        685B52QwYU9jdOMFw+ZnDK0+YtCUyHzvSzACge/jH7hLcAg8FHB4w8IbZOEKsLD4s5AqdnheWLpAQJKj
     202        TxyCUa4IOi/yWPPlsOJlMGePoU6+JS4g376NczgKsdg+y8PIg3pnBmPWV6ipMGq61sUFZOarCAf3JZ98
     203        8I75XQKnoDEmoRg5RXW7QVxACvOHWdhO8lim36C1ptFvSEI5E4NsYA9VLUviAtK255qFcT+LSXsKahMP
     204        66OQa0Po7HOholEvLiCr2jxmMG2LQEOFoBw/55M96FA50NpjRlmDTlxA9tym8qGpl0Z9twO1Mktx7srm
     205        BZRLp34W/Oao/v4WvgBcI/R+TmAaZAAAAABJRU5ErkJggg==
     206</value>
     207  </data>
     208  <data name="resetButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
     209    <value>
     210        iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
     211        YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAAK/wAA
     212        Cv8BNGKaggAAAX9JREFUOE9j+P//PwMlmCLNIIupa0Dv5r//Ybht7bf/jSs+/69d/P5/xbxX/0tmP/9f
     213        MP3x/9JZj4EWI7yN4oKuDb/+bzr57f/KQ1/+L9jz6f/lBz//965997956RuwIXnTX/zXDV2F2wCQrSsO
     214        fvk/b9en/7ee/AIp/N+w5M3/0rkv/+dMff4/qffZf1W/RbgNADl5zo5P/x++/AHWDAIls1/+z5ry/H9C
     215        79P/Ya2P/8u5zcJtAMi/Nx99hmtGZhy7/Oa/V+3D/2J2k3AbAPJn87I3/09deQnXG9355H9g0yMw36H0
     216        /n9+s27cBoBCuhxoSM605/93HrkL1hTQ8Oi/W9UDMNss7+5/ToNW3AaAoikb6N9EoH/D2x7/n7Puwn/X
     217        ivv/bYrvgQ3Qy7j1n1WnEbcBoDiO63n6P7Tl0X+fuof/ncrv/7cuvPffJPsO2AD1JCIMsEza9h+EjWM2
     218        /NcKXv5fwWMuOOB4TTr/s+k24XcB0BKSkzbJGtAtodgAAJMl+qgyDSjjAAAAAElFTkSuQmCC
     219</value>
     220  </data>
     221  <data name="pauseButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
     222    <value>
     223        iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
     224        YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAAK/wAA
     225        Cv8BNGKaggAAAL5JREFUOE9j+P//PwMlmCLNIIsHoQG9m//+79rw63/e1EefQE5E56OHF4YXQJqvPvzz
     226        Xzd0FVDtfwZ0PkED2tZ++3/r6e//qn6LwAag8wka0Lji8//LD3//l3ObBTYAnU/QgNrF7/+fuP77v5jd
     227        JLAB6HyCBlTMe/V/94Wf//nNusEGoPMJGlAy+/n/9Sd//uc0aAUbgM4naEDB9Mf/F+z5/J9VpxFsADqf
     228        oAGg+GfTbYIbgM4naACpGWvg8wIAkX3yJyVePz4AAAAASUVORK5CYII=
     229</value>
     230  </data>
     231  <data name="refreshButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
     232    <value>
     233        iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGOfPtRkwAAACBjSFJNAACH
     234        DwAAjA8AAP1SAACBQAAAfXkAAOmLAAA85QAAGcxzPIV3AAAKOWlDQ1BQaG90b3Nob3AgSUNDIHByb2Zp
     235        bGUAAEjHnZZ3VFTXFofPvXd6oc0wAlKG3rvAANJ7k15FYZgZYCgDDjM0sSGiAhFFRJoiSFDEgNFQJFZE
     236        sRAUVLAHJAgoMRhFVCxvRtaLrqy89/Ly++Osb+2z97n77L3PWhcAkqcvl5cGSwGQyhPwgzyc6RGRUXTs
     237        AIABHmCAKQBMVka6X7B7CBDJy82FniFyAl8EAfB6WLwCcNPQM4BOB/+fpFnpfIHomAARm7M5GSwRF4g4
     238        JUuQLrbPipgalyxmGCVmvihBEcuJOWGRDT77LLKjmNmpPLaIxTmns1PZYu4V8bZMIUfEiK+ICzO5nCwR
     239        3xKxRoowlSviN+LYVA4zAwAUSWwXcFiJIjYRMYkfEuQi4uUA4EgJX3HcVyzgZAvEl3JJS8/hcxMSBXQd
     240        li7d1NqaQffkZKVwBALDACYrmcln013SUtOZvBwAFu/8WTLi2tJFRbY0tba0NDQzMv2qUP91829K3NtF
     241        ehn4uWcQrf+L7a/80hoAYMyJarPziy2uCoDOLQDI3fti0zgAgKSobx3Xv7oPTTwviQJBuo2xcVZWlhGX
     242        wzISF/QP/U+Hv6GvvmckPu6P8tBdOfFMYYqALq4bKy0lTcinZ6QzWRy64Z+H+B8H/nUeBkGceA6fwxNF
     243        hImmjMtLELWbx+YKuGk8Opf3n5r4D8P+pMW5FonS+BFQY4yA1HUqQH7tBygKESDR+8Vd/6NvvvgwIH55
     244        4SqTi3P/7zf9Z8Gl4iWDm/A5ziUohM4S8jMX98TPEqABAUgCKpAHykAd6ABDYAasgC1wBG7AG/iDEBAJ
     245        VgMWSASpgA+yQB7YBApBMdgJ9oBqUAcaQTNoBcdBJzgFzoNL4Bq4AW6D+2AUTIBnYBa8BgsQBGEhMkSB
     246        5CEVSBPSh8wgBmQPuUG+UBAUCcVCCRAPEkJ50GaoGCqDqqF6qBn6HjoJnYeuQIPQXWgMmoZ+h97BCEyC
     247        qbASrAUbwwzYCfaBQ+BVcAK8Bs6FC+AdcCXcAB+FO+Dz8DX4NjwKP4PnEIAQERqiihgiDMQF8UeikHiE
     248        j6xHipAKpAFpRbqRPuQmMorMIG9RGBQFRUcZomxRnqhQFAu1BrUeVYKqRh1GdaB6UTdRY6hZ1Ec0Ga2I
     249        1kfboL3QEegEdBa6EF2BbkK3oy+ib6Mn0K8xGAwNo42xwnhiIjFJmLWYEsw+TBvmHGYQM46Zw2Kx8lh9
     250        rB3WH8vECrCF2CrsUexZ7BB2AvsGR8Sp4Mxw7rgoHA+Xj6vAHcGdwQ3hJnELeCm8Jt4G749n43PwpfhG
     251        fDf+On4Cv0CQJmgT7AghhCTCJkIloZVwkfCA8JJIJKoRrYmBRC5xI7GSeIx4mThGfEuSIemRXEjRJCFp
     252        B+kQ6RzpLuklmUzWIjuSo8gC8g5yM/kC+RH5jQRFwkjCS4ItsUGiRqJDYkjiuSReUlPSSXK1ZK5kheQJ
     253        yeuSM1J4KS0pFymm1HqpGqmTUiNSc9IUaVNpf+lU6RLpI9JXpKdksDJaMm4ybJkCmYMyF2TGKQhFneJC
     254        YVE2UxopFykTVAxVm+pFTaIWU7+jDlBnZWVkl8mGyWbL1sielh2lITQtmhcthVZKO04bpr1borTEaQln
     255        yfYlrUuGlszLLZVzlOPIFcm1yd2WeydPl3eTT5bfJd8p/1ABpaCnEKiQpbBf4aLCzFLqUtulrKVFS48v
     256        vacIK+opBimuVTyo2K84p6Ss5KGUrlSldEFpRpmm7KicpFyufEZ5WoWiYq/CVSlXOavylC5Ld6Kn0Cvp
     257        vfRZVUVVT1Whar3qgOqCmrZaqFq+WpvaQ3WCOkM9Xr1cvUd9VkNFw08jT6NF454mXpOhmai5V7NPc15L
     258        Wytca6tWp9aUtpy2l3audov2Ax2yjoPOGp0GnVu6GF2GbrLuPt0berCehV6iXo3edX1Y31Kfq79Pf9AA
     259        bWBtwDNoMBgxJBk6GWYathiOGdGMfI3yjTqNnhtrGEcZ7zLuM/5oYmGSYtJoct9UxtTbNN+02/R3Mz0z
     260        llmN2S1zsrm7+QbzLvMXy/SXcZbtX3bHgmLhZ7HVosfig6WVJd+y1XLaSsMq1qrWaoRBZQQwShiXrdHW
     261        ztYbrE9Zv7WxtBHYHLf5zdbQNtn2iO3Ucu3lnOWNy8ft1OyYdvV2o/Z0+1j7A/ajDqoOTIcGh8eO6o5s
     262        xybHSSddpySno07PnU2c+c7tzvMuNi7rXM65Iq4erkWuA24ybqFu1W6P3NXcE9xb3Gc9LDzWepzzRHv6
     263        eO7yHPFS8mJ5NXvNelt5r/Pu9SH5BPtU+zz21fPl+3b7wX7efrv9HqzQXMFb0ekP/L38d/s/DNAOWBPw
     264        YyAmMCCwJvBJkGlQXlBfMCU4JvhI8OsQ55DSkPuhOqHC0J4wybDosOaw+XDX8LLw0QjjiHUR1yIVIrmR
     265        XVHYqLCopqi5lW4r96yciLaILoweXqW9KnvVldUKq1NWn46RjGHGnIhFx4bHHol9z/RnNjDn4rziauNm
     266        WS6svaxnbEd2OXuaY8cp40zG28WXxU8l2CXsTphOdEisSJzhunCruS+SPJPqkuaT/ZMPJX9KCU9pS8Wl
     267        xqae5Mnwknm9acpp2WmD6frphemja2zW7Fkzy/fhN2VAGasyugRU0c9Uv1BHuEU4lmmfWZP5Jiss60S2
     268        dDYvuz9HL2d7zmSue+63a1FrWWt78lTzNuWNrXNaV78eWh+3vmeD+oaCDRMbPTYe3kTYlLzpp3yT/LL8
     269        V5vDN3cXKBVsLBjf4rGlpVCikF84stV2a9021DbutoHt5turtn8sYhddLTYprih+X8IqufqN6TeV33za
     270        Eb9joNSydP9OzE7ezuFdDrsOl0mX5ZaN7/bb3VFOLy8qf7UnZs+VimUVdXsJe4V7Ryt9K7uqNKp2Vr2v
     271        Tqy+XeNc01arWLu9dn4fe9/Qfsf9rXVKdcV17w5wD9yp96jvaNBqqDiIOZh58EljWGPft4xvm5sUmoqb
     272        PhziHRo9HHS4t9mqufmI4pHSFrhF2DJ9NProje9cv+tqNWytb6O1FR8Dx4THnn4f+/3wcZ/jPScYJ1p/
     273        0Pyhtp3SXtQBdeR0zHYmdo52RXYNnvQ+2dNt293+o9GPh06pnqo5LXu69AzhTMGZT2dzz86dSz83cz7h
     274        /HhPTM/9CxEXbvUG9g5c9Ll4+ZL7pQt9Tn1nL9tdPnXF5srJq4yrndcsr3X0W/S3/2TxU/uA5UDHdavr
     275        XTesb3QPLh88M+QwdP6m681Lt7xuXbu94vbgcOjwnZHokdE77DtTd1PuvriXeW/h/sYH6AdFD6UeVjxS
     276        fNTws+7PbaOWo6fHXMf6Hwc/vj/OGn/2S8Yv7ycKnpCfVEyqTDZPmU2dmnafvvF05dOJZ+nPFmYKf5X+
     277        tfa5zvMffnP8rX82YnbiBf/Fp99LXsq/PPRq2aueuYC5R69TXy/MF72Rf3P4LeNt37vwd5MLWe+x7ys/
     278        6H7o/ujz8cGn1E+f/gUDmPP8usTo0wAAAAlwSFlzAAALDAAACwwBP0AiyAAAABl0RVh0U29mdHdhcmUA
     279        UGFpbnQuTkVUIHYzLjUuNUmK/OAAAAJiSURBVDhPnZNtSFNRHMbdzAgV/DC0bL4R5rSNEjOjiJkhUfpB
     280        Aikog74ERV+iIipymgvXbFZrW1NrFoQhQUr2phQxcK0XGWx+2JhGdrfWNmduM1N3r9vTPcNF0vVLFx4O
     281        h3Of33nO+f9PUtLSRwcHkunQEJ8OGzOZGXMq8/NjJqsMZuZ9NhMyrqKnX/HIr/Peu5KE55+RmR3JM419
     282        QLtRg/rHR1HVVQvprX243C+HjXKE6LD5iMqoBycg4usR9I++RN3zBsgmFFC4NLjiUKHJ0YYTn86h8k4N
     283        rBN2lNzcxg1weMaDxHx14gZq+w4hq2kD1sk34pjxVBzU7LgehxQoxdyAC0+b0WA6ie3qPWgf1GLU5cSY
     284        l0JOiyieKqFseSE34IDhMKSd+9FneQFmMSamF2Np/sA0bG7nMoigMZ8bUNFZhfNPZMRcyopHMzFer2UA
     285        +QoJchXFIDsTc8ZFITdgi3YnRr7Y4Jv8kUJu2eMN5Li/+1O+eSfXeHyB1eycT7l9a52fKW4AuyOWtJcd
     286        kyN0bJfb4+fNR6L8uYUo7xer2blommxYyQ0oM1Ris34Him+XBwvaJGFhqwgd5odYoKMCkoiFVHcM30eJ
     287        doUybjVIoXTp4iUrVJXCQtnJccAmyCUprNQYah7VY31jEXeCTbqKPwACEanLYflqZztwHF2mnnhXklIe
     288        f3CaG8DGRtG1smU1J6aEkZiFMhHuve3lBuS1ivHM+hpCtnH+NiUaiJgVQxoEQsxuzregf9MN9qLwzmHB
     289        pd4W1OoOIv1sFtLPZKFaXQftYDemwkyqZ4rmr/ga/2fhN/0cpIchJAs6AAAAAElFTkSuQmCC
     290</value>
     291  </data>
    231292  <metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    232293    <value>25</value>
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/HeuristicLab.Clients.Hive-3.4.csproj

    r6452 r6463  
    115115    <Compile Include="Jobs\ItemJob.cs" />
    116116    <Compile Include="RefreshableHiveExperiment.cs" />
     117    <Compile Include="ServiceClients\HiveExperimentPermission.cs" />
    117118    <Compile Include="StateLogList.cs" />
    118119    <Compile Include="StateLogListList.cs" />
     
    156157    <Compile Include="ServiceClients\NamedHiveItem.cs" />
    157158    <Compile Include="ServiceClients\Heartbeat.cs" />
    158     <Compile Include="ServiceClients\HiveExperimentPermission.cs" />
    159159    <Compile Include="ServiceClients\HiveItem.cs" />
    160160    <Compile Include="ServiceClients\JobData.cs" />
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/HiveClient.cs

    r6452 r6463  
    110110          HiveClient.Instance.UploadExperiment((RefreshableHiveExperiment)item, cancellationToken);
    111111        }
     112        if (item is HiveExperimentPermission) {
     113          var hep = (HiveExperimentPermission)item;
     114          hep.GrantedUserId = ServiceLocator.Instance.CallHiveService((s) => s.GetUserIdByUsername(hep.GrantedUserName));
     115          if (hep.GrantedUserId == Guid.Empty) {
     116            throw new ArgumentException(string.Format("The user {0} was not found.", hep.GrantedUserName));
     117          }
     118          ServiceLocator.Instance.CallHiveService((s) => s.GrantPermission(hep.HiveExperimentId, hep.GrantedUserId, hep.Permission));
     119        }
    112120      } else {
    113121        if (item is HiveExperiment)
     
    138146      if (item is RefreshableHiveExperiment)
    139147        ServiceLocator.Instance.CallHiveService(s => s.DeleteHiveExperiment(item.Id));
     148      if (item is HiveExperimentPermission) {
     149        var hep = (HiveExperimentPermission)item;
     150        ServiceLocator.Instance.CallHiveService(s => s.RevokePermission(hep.HiveExperimentId, hep.GrantedUserId));
     151      }
    140152      item.Id = Guid.Empty;
    141153    }
     
    241253          .ContinueWith((x) => refreshableHiveExperiment.Log.LogException(x.Exception), TaskContinuationOptions.OnlyOnFaulted));
    242254        }
    243         Task.WaitAll(tasks.ToArray());
     255        try {
     256          Task.WaitAll(tasks.ToArray());
     257        }
     258        catch (AggregateException ae) {
     259          if (!ae.InnerExceptions.All(e => e is TaskCanceledException)) throw ae; // for some reason the WaitAll throws a AggregateException containg a TaskCanceledException. i don't know where it comes from, however the tasks all finish properly, so for now just ignore it
     260        }
    244261      }
    245262      finally {
     
    281298    private void UploadJobWithChildren(IProgress progress, HiveJob hiveJob, HiveJob parentHiveJob, IEnumerable<Guid> groups, int[] jobCount, int totalJobCount, Guid configPluginId, Guid hiveExperimentId, ILog log, bool isPrivileged, CancellationToken cancellationToken) {
    282299      jobUploadSemaphore.WaitOne();
     300      bool semaphoreReleased = false;
    283301      try {
    284302        cancellationToken.ThrowIfCancellationRequested();
     
    337355          .ContinueWith((x) => log.LogException(x.Exception), TaskContinuationOptions.OnlyOnFaulted));
    338356        }
    339         Task.WaitAll(tasks.ToArray());
     357        jobUploadSemaphore.Release(); semaphoreReleased = true; // the semaphore has to be release before waitall!
     358        try {
     359          Task.WaitAll(tasks.ToArray());
     360        }
     361        catch (AggregateException ae) {
     362          if (!ae.InnerExceptions.All(e => e is TaskCanceledException)) throw ae; // for some reason the WaitAll throws a AggregateException containg a TaskCanceledException. i don't know where it comes from, however the tasks all finish properly, so for now just ignore it
     363        }
    340364      }
    341365      finally {
    342         jobUploadSemaphore.Release();
     366        if(!semaphoreReleased) jobUploadSemaphore.Release();
    343367      }
    344368    }
     
    441465      }
    442466    }
     467
     468    public static HiveItemCollection<HiveExperimentPermission> GetHiveExperimentPermissions(Guid hiveExperimentId) {
     469      return ServiceLocator.Instance.CallHiveService((service) => {
     470        IEnumerable<HiveExperimentPermission> heps = service.GetHiveExperimentPermissions(hiveExperimentId);
     471        foreach (var hep in heps) {
     472          hep.GrantedUserName = service.GetUsernameByUserId(hep.GrantedUserId);
     473        }
     474        return new HiveItemCollection<HiveExperimentPermission>(heps);
     475      });
     476    }
    443477  }
    444478}
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ServiceClients/HiveExperimentPermission.cs

    r6372 r6463  
    2020#endregion
    2121
     22using System.ComponentModel;
    2223using HeuristicLab.Common;
    2324
    2425namespace HeuristicLab.Clients.Hive {
    25 
    2626  public partial class HiveExperimentPermission : IDeepCloneable, IContent {
    2727
    28     public HiveExperimentPermission() { }
    29 
    30     protected HiveExperimentPermission(HiveExperimentPermission original, Cloner cloner) {
    31       cloner.RegisterClonedObject(original, this);
     28    private string grantedUserName;
     29    public string GrantedUserName {
     30      get { return grantedUserName; }
     31      set { grantedUserName = value; OnPropertyChanged(new PropertyChangedEventArgs("GrantedUserName")); }
    3232    }
    3333
    34     public object Clone() {
    35       return Clone(new Cloner());
     34    #region Constructors and Cloning
     35    public HiveExperimentPermission() {
     36      this.Permission = Hive.Permission.ReadOnly;
     37      this.PropertyChanged += new PropertyChangedEventHandler(HiveExperimentPermission_PropertyChanged);
    3638    }
    3739
    38     public IDeepCloneable Clone(Cloner cloner) {
     40    protected HiveExperimentPermission(HiveExperimentPermission original, Cloner cloner)
     41      : base(original, cloner) {
     42      this.GrantedByUserId = original.GrantedByUserId;
     43      this.GrantedUserId = original.GrantedUserId;
     44      this.HiveExperimentId = original.HiveExperimentId;
     45      this.Permission = original.Permission;
     46    }
     47    public override IDeepCloneable Clone(Cloner cloner) {
    3948      return new HiveExperimentPermission(this, cloner);
     49    }
     50    #endregion
     51
     52    private void HiveExperimentPermission_PropertyChanged(object sender, PropertyChangedEventArgs e) {
     53      OnToStringChanged();
     54    }
     55
     56    public override string ToString() {
     57      return string.Format("{0}: {1}", GrantedUserName, Permission.ToString());
    4058    }
    4159  }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ServiceClients/HiveServiceClient.cs

    r6454 r6463  
    214214    [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.SlaveGroup))]
    215215    [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.Plugin))]
     216    [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.HiveExperimentPermission))]
    216217    [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.PluginData))]
    217218    [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.LightweightJob))]
     
    606607       
    607608        [System.Runtime.Serialization.OptionalFieldAttribute()]
     609        private HeuristicLab.Clients.Hive.Permission PermissionField;
     610       
     611        [System.Runtime.Serialization.OptionalFieldAttribute()]
    608612        private string ResourceNamesField;
    609613       
     
    706710                    this.OwnerUserIdField = value;
    707711                    this.RaisePropertyChanged("OwnerUserId");
     712                }
     713            }
     714        }
     715       
     716        [System.Runtime.Serialization.DataMemberAttribute()]
     717        public HeuristicLab.Clients.Hive.Permission Permission
     718        {
     719            get
     720            {
     721                return this.PermissionField;
     722            }
     723            set
     724            {
     725                if ((this.PermissionField.Equals(value) != true))
     726                {
     727                    this.PermissionField = value;
     728                    this.RaisePropertyChanged("Permission");
    708729                }
    709730            }
     
    10881109    [System.Diagnostics.DebuggerStepThroughAttribute()]
    10891110    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
     1111    [System.Runtime.Serialization.DataContractAttribute(Name="HiveExperimentPermission", Namespace="http://schemas.datacontract.org/2004/07/HeuristicLab.Services.Hive.Common.DataTra" +
     1112        "nsfer")]
     1113    [System.SerializableAttribute()]
     1114    public partial class HiveExperimentPermission : HeuristicLab.Clients.Hive.HiveItem
     1115    {
     1116       
     1117        [System.Runtime.Serialization.OptionalFieldAttribute()]
     1118        private System.Guid GrantedByUserIdField;
     1119       
     1120        [System.Runtime.Serialization.OptionalFieldAttribute()]
     1121        private System.Guid GrantedUserIdField;
     1122       
     1123        [System.Runtime.Serialization.OptionalFieldAttribute()]
     1124        private System.Guid HiveExperimentIdField;
     1125       
     1126        [System.Runtime.Serialization.OptionalFieldAttribute()]
     1127        private HeuristicLab.Clients.Hive.Permission PermissionField;
     1128       
     1129        [System.Runtime.Serialization.DataMemberAttribute()]
     1130        public System.Guid GrantedByUserId
     1131        {
     1132            get
     1133            {
     1134                return this.GrantedByUserIdField;
     1135            }
     1136            set
     1137            {
     1138                if ((this.GrantedByUserIdField.Equals(value) != true))
     1139                {
     1140                    this.GrantedByUserIdField = value;
     1141                    this.RaisePropertyChanged("GrantedByUserId");
     1142                }
     1143            }
     1144        }
     1145       
     1146        [System.Runtime.Serialization.DataMemberAttribute()]
     1147        public System.Guid GrantedUserId
     1148        {
     1149            get
     1150            {
     1151                return this.GrantedUserIdField;
     1152            }
     1153            set
     1154            {
     1155                if ((this.GrantedUserIdField.Equals(value) != true))
     1156                {
     1157                    this.GrantedUserIdField = value;
     1158                    this.RaisePropertyChanged("GrantedUserId");
     1159                }
     1160            }
     1161        }
     1162       
     1163        [System.Runtime.Serialization.DataMemberAttribute()]
     1164        public System.Guid HiveExperimentId
     1165        {
     1166            get
     1167            {
     1168                return this.HiveExperimentIdField;
     1169            }
     1170            set
     1171            {
     1172                if ((this.HiveExperimentIdField.Equals(value) != true))
     1173                {
     1174                    this.HiveExperimentIdField = value;
     1175                    this.RaisePropertyChanged("HiveExperimentId");
     1176                }
     1177            }
     1178        }
     1179       
     1180        [System.Runtime.Serialization.DataMemberAttribute()]
     1181        public HeuristicLab.Clients.Hive.Permission Permission
     1182        {
     1183            get
     1184            {
     1185                return this.PermissionField;
     1186            }
     1187            set
     1188            {
     1189                if ((this.PermissionField.Equals(value) != true))
     1190                {
     1191                    this.PermissionField = value;
     1192                    this.RaisePropertyChanged("Permission");
     1193                }
     1194            }
     1195        }
     1196    }
     1197   
     1198    [System.Diagnostics.DebuggerStepThroughAttribute()]
     1199    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
    10901200    [System.Runtime.Serialization.DataContractAttribute(Name="PluginData", Namespace="http://schemas.datacontract.org/2004/07/HeuristicLab.Services.Hive.Common.DataTra" +
    10911201        "nsfer")]
     
    13301440        [System.Runtime.Serialization.EnumMemberAttribute()]
    13311441        Failed = 7,
     1442    }
     1443   
     1444    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
     1445    [System.Runtime.Serialization.DataContractAttribute(Name="Permission", Namespace="http://schemas.datacontract.org/2004/07/HeuristicLab.Services.Hive.Common.DataTra" +
     1446        "nsfer")]
     1447    public enum Permission : int
     1448    {
     1449       
     1450        [System.Runtime.Serialization.EnumMemberAttribute()]
     1451        NotAllowed = 0,
     1452       
     1453        [System.Runtime.Serialization.EnumMemberAttribute()]
     1454        ReadOnly = 1,
     1455       
     1456        [System.Runtime.Serialization.EnumMemberAttribute()]
     1457        Full = 2,
    13321458    }
    13331459   
     
    17831909    {
    17841910       
     1911        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/DeleteSlave", ReplyAction="http://tempuri.org/IHiveService/DeleteSlaveResponse")]
     1912        void DeleteSlave(System.Guid slaveId);
     1913       
     1914        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/DeleteSlaveGroup", ReplyAction="http://tempuri.org/IHiveService/DeleteSlaveGroupResponse")]
     1915        void DeleteSlaveGroup(System.Guid slaveGroupId);
     1916       
     1917        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/AddResourceToGroup", ReplyAction="http://tempuri.org/IHiveService/AddResourceToGroupResponse")]
     1918        void AddResourceToGroup(System.Guid slaveGroupId, System.Guid resourceId);
     1919       
    17851920        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/RemoveResourceFromGroup", ReplyAction="http://tempuri.org/IHiveService/RemoveResourceFromGroupResponse")]
    17861921        void RemoveResourceFromGroup(System.Guid slaveGroupId, System.Guid resourceId);
     
    18071942        System.Collections.Generic.List<HeuristicLab.Clients.Hive.Downtime> GetDowntimesForResource(System.Guid resourceId);
    18081943       
     1944        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/GetUsernameByUserId", ReplyAction="http://tempuri.org/IHiveService/GetUsernameByUserIdResponse")]
     1945        string GetUsernameByUserId(System.Guid userId);
     1946       
     1947        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/GetUserIdByUsername", ReplyAction="http://tempuri.org/IHiveService/GetUserIdByUsernameResponse")]
     1948        System.Guid GetUserIdByUsername(string username);
     1949       
    18091950        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/AddJob", ReplyAction="http://tempuri.org/IHiveService/AddJobResponse")]
    18101951        System.Guid AddJob(HeuristicLab.Clients.Hive.Job job, HeuristicLab.Clients.Hive.JobData jobData, System.Collections.Generic.List<System.Guid> resourceIds);
     
    18722013        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/DeleteHiveExperiment", ReplyAction="http://tempuri.org/IHiveService/DeleteHiveExperimentResponse")]
    18732014        void DeleteHiveExperiment(System.Guid hiveExperimentId);
     2015       
     2016        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/GrantPermission", ReplyAction="http://tempuri.org/IHiveService/GrantPermissionResponse")]
     2017        void GrantPermission(System.Guid hiveExperimentId, System.Guid grantedUserId, HeuristicLab.Clients.Hive.Permission permission);
     2018       
     2019        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/RevokePermission", ReplyAction="http://tempuri.org/IHiveService/RevokePermissionResponse")]
     2020        void RevokePermission(System.Guid hiveExperimentId, System.Guid grantedUserId);
     2021       
     2022        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/GetHiveExperimentPermissions", ReplyAction="http://tempuri.org/IHiveService/GetHiveExperimentPermissionsResponse")]
     2023        System.Collections.Generic.List<HeuristicLab.Clients.Hive.HiveExperimentPermission> GetHiveExperimentPermissions(System.Guid hiveExperimentId);
    18742024       
    18752025        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/Hello", ReplyAction="http://tempuri.org/IHiveService/HelloResponse")]
     
    19242074        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/UpdateSlaveGroup", ReplyAction="http://tempuri.org/IHiveService/UpdateSlaveGroupResponse")]
    19252075        void UpdateSlaveGroup(HeuristicLab.Clients.Hive.SlaveGroup slaveGroup);
    1926        
    1927         [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/DeleteSlave", ReplyAction="http://tempuri.org/IHiveService/DeleteSlaveResponse")]
    1928         void DeleteSlave(System.Guid slaveId);
    1929        
    1930         [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/DeleteSlaveGroup", ReplyAction="http://tempuri.org/IHiveService/DeleteSlaveGroupResponse")]
    1931         void DeleteSlaveGroup(System.Guid slaveGroupId);
    1932        
    1933         [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/AddResourceToGroup", ReplyAction="http://tempuri.org/IHiveService/AddResourceToGroupResponse")]
    1934         void AddResourceToGroup(System.Guid slaveGroupId, System.Guid resourceId);
    19352076    }
    19362077   
     
    19692110        }
    19702111       
     2112        public void DeleteSlave(System.Guid slaveId)
     2113        {
     2114            base.Channel.DeleteSlave(slaveId);
     2115        }
     2116       
     2117        public void DeleteSlaveGroup(System.Guid slaveGroupId)
     2118        {
     2119            base.Channel.DeleteSlaveGroup(slaveGroupId);
     2120        }
     2121       
     2122        public void AddResourceToGroup(System.Guid slaveGroupId, System.Guid resourceId)
     2123        {
     2124            base.Channel.AddResourceToGroup(slaveGroupId, resourceId);
     2125        }
     2126       
    19712127        public void RemoveResourceFromGroup(System.Guid slaveGroupId, System.Guid resourceId)
    19722128        {
     
    20092165        }
    20102166       
     2167        public string GetUsernameByUserId(System.Guid userId)
     2168        {
     2169            return base.Channel.GetUsernameByUserId(userId);
     2170        }
     2171       
     2172        public System.Guid GetUserIdByUsername(string username)
     2173        {
     2174            return base.Channel.GetUserIdByUsername(username);
     2175        }
     2176       
    20112177        public System.Guid AddJob(HeuristicLab.Clients.Hive.Job job, HeuristicLab.Clients.Hive.JobData jobData, System.Collections.Generic.List<System.Guid> resourceIds)
    20122178        {
     
    21192285        }
    21202286       
     2287        public void GrantPermission(System.Guid hiveExperimentId, System.Guid grantedUserId, HeuristicLab.Clients.Hive.Permission permission)
     2288        {
     2289            base.Channel.GrantPermission(hiveExperimentId, grantedUserId, permission);
     2290        }
     2291       
     2292        public void RevokePermission(System.Guid hiveExperimentId, System.Guid grantedUserId)
     2293        {
     2294            base.Channel.RevokePermission(hiveExperimentId, grantedUserId);
     2295        }
     2296       
     2297        public System.Collections.Generic.List<HeuristicLab.Clients.Hive.HiveExperimentPermission> GetHiveExperimentPermissions(System.Guid hiveExperimentId)
     2298        {
     2299            return base.Channel.GetHiveExperimentPermissions(hiveExperimentId);
     2300        }
     2301       
    21212302        public void Hello(HeuristicLab.Clients.Hive.Slave slave)
    21222303        {
     
    22032384            base.Channel.UpdateSlaveGroup(slaveGroup);
    22042385        }
    2205        
    2206         public void DeleteSlave(System.Guid slaveId)
    2207         {
    2208             base.Channel.DeleteSlave(slaveId);
    2209         }
    2210        
    2211         public void DeleteSlaveGroup(System.Guid slaveGroupId)
    2212         {
    2213             base.Channel.DeleteSlaveGroup(slaveGroupId);
    2214         }
    2215        
    2216         public void AddResourceToGroup(System.Guid slaveGroupId, System.Guid resourceId)
    2217         {
    2218             base.Channel.AddResourceToGroup(slaveGroupId, resourceId);
    2219         }
    22202386    }
    22212387}
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Common/3.4/DataTransfer/HiveExperimentPermission.cs

    r6372 r6463  
    2626  [DataContract]
    2727  [Serializable]
    28   public class HiveExperimentPermission {
     28  public class HiveExperimentPermission : HiveItem {
     29    // info: this class is derived from HiveItem to simplify handling on the client side, altough it does not have a Id.
    2930    [DataMember]
    3031    public Guid HiveExperimentId { get; set; }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Common/3.4/DataTransfer/Permission.cs

    r6457 r6463  
    3030    /// User can only download and view experiments
    3131    /// </summary>
    32     ReadOnly,
    33 
    34     /// <summary>
    35     /// User can also  experiments
    36     /// </summary>
    37     Write,
     32    Read,
    3833
    3934    /// <summary>
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Common/3.4/ServiceContracts/IHiveService.cs

    r6457 r6463  
    111111
    112112    #region HiveExperimentPermission Methods
     113    [OperationContract]
    113114    void GrantPermission(Guid hiveExperimentId, Guid grantedUserId, Permission permission);
     115
     116    [OperationContract]
    114117    void RevokePermission(Guid hiveExperimentId, Guid grantedUserId);
     118
     119    [OperationContract]
     120    IEnumerable<HiveExperimentPermission> GetHiveExperimentPermissions(Guid hiveExperimentId);
    115121    #endregion
    116122
     
    205211    #endregion
    206212
     213    #region User Methods
     214    [OperationContract]
     215    string GetUsernameByUserId(Guid userId);
     216
     217    [OperationContract]
     218    Guid GetUserIdByUsername(string username);
     219    #endregion
    207220  }
    208221}
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Tests/DaoTests.cs

    r6452 r6463  
    235235      perm.GrantedByUserId = he.OwnerUserId;
    236236      perm.GrantedUserId = Guid.NewGuid();
    237       perm.Permission = Permission.Write;
     237      perm.Permission = Permission.Full;
    238238      dao.AddHiveExperimentPermission(perm);
    239239
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Tests/HeuristicLab.Services.Hive-3.4.Tests.csproj

    r6369 r6463  
    7272  <ItemGroup>
    7373    <Compile Include="Mocks\MockAuthenticationManager.cs" />
     74    <Compile Include="Mocks\MockUserManager.cs" />
    7475    <Compile Include="ServiceTests.cs" />
    7576    <Compile Include="Mocks\MockAuthorizationManager.cs" />
     
    108109    <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
    109110    <Reference Include="System" />
     111    <Reference Include="System.Configuration" />
    110112    <Reference Include="System.Data" />
    111113    <Reference Include="System.Data.DataSetExtensions" />
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Tests/Mocks/MockAuthorizationManager.cs

    r6457 r6463  
    2424namespace HeuristicLab.Services.Hive.Tests.Mocks {
    2525  public class MockAuthorizationManager : IAuthorizationManager {
    26     public static Guid MockUserId1 = new Guid("6C7911A1-46EA-4E51-97DF-5582653AAFCE");
    27     public static Guid MockUserId2 = new Guid("897660EB-C90F-4054-988C-D39D530A0A02");
    28     public static Guid MockUserId3 = new Guid("9F7B4EA8-A38D-4BC2-802F-E148AC7A6A87");
    29 
    30     private Guid userId = MockUserId1;
    31 
    32     public Guid UserId {
    33       get { return userId; }
     26    public void Authorize(Guid userId) {
     27      // ok.
    3428    }
    3529
    36     public void AuthorizeJobs(params Guid[] jobId) {
    37       // o.k.
     30    public void AuthorizeForJob(Guid jobId, Common.DataTransfer.Permission requiredPermission) {
     31      // ok.
    3832    }
    3933
    40     public void Authorize(Guid userId) {
    41       // o.k.
    42     }
    43    
    44     internal void SetUserId(Guid id) {
    45       this.userId = id;
     34    public void AuthorizeForExperiment(Guid experimentId, Common.DataTransfer.Permission requiredPermission) {
     35      // ok.
    4636    }
    4737  }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Tests/Mocks/MockServiceLocator.cs

    r6457 r6463  
    2020#endregion
    2121
     22using System;
    2223using HeuristicLab.Services.Hive.DataAccess;
    2324using HeuristicLab.Services.Hive.Tests.Mocks;
    24 using System;
    2525
    2626namespace HeuristicLab.Services.Hive.Tests {
     
    3636    }
    3737
    38     private MockAuthorizationManager mockAuthorizationManager = new MockAuthorizationManager();
     38    //private MockAuthorizationManager mockAuthorizationManager = new MockAuthorizationManager();
    3939    public IAuthorizationManager AuthorizationManager {
    40       get { return mockAuthorizationManager; }
     40      get { return defaultServiceLocator.AuthorizationManager; }
    4141    }
    4242
     
    5151      get { return defaultServiceLocator.TransactionManager; }
    5252    }
    53 
     53    private MockUserManager mockUserManager = new MockUserManager();
     54    public IUserManager UserManager {
     55      get { return mockUserManager; }
     56    }
    5457    public HeartbeatManager HeartbeatManager {
    5558      get { return defaultServiceLocator.HeartbeatManager; }
     
    5760
    5861    #region Special mocking methods
    59     public void SetCurrentUser(Guid id) {
    60       mockAuthorizationManager.SetUserId(id);
     62    public void SetCurrentUserId(Guid userId) {
     63      mockUserManager.SetUserId(userId);
    6164    }
    62 
    6365    #endregion
    6466  }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Tests/ServiceTests.cs

    r6457 r6463  
    303303    public void TestHiveExperimentPermissions() {
    304304      var service = GetLocalService();
    305       mockServiceLocator.SetCurrentUser(MockAuthorizationManager.MockUserId1);
     305      mockServiceLocator.SetCurrentUserId(MockUserManager.MockUserId1);
    306306
    307307      // create hive experiment
     
    311311      var e1loaded = service.GetHiveExperiment(e1.Id);
    312312      Assert.AreEqual(Permission.Full, e1loaded.Permission);
    313 
     313      var allExp = service.GetHiveExperiments();
     314      Assert.AreEqual(1, allExp.Count(x => x.Id == e1.Id));
     315     
    314316      // change to user2
    315       mockServiceLocator.SetCurrentUser(MockAuthorizationManager.MockUserId2);
    316       e1loaded = service.GetHiveExperiment(e1.Id);
    317       Assert.AreEqual(null, e1loaded); // no access
     317      mockServiceLocator.SetCurrentUserId(MockUserManager.MockUserId2);
     318      try {
     319        e1loaded = service.GetHiveExperiment(e1.Id);
     320        Assert.Fail("Access should not be possible");
     321      } catch { /* ok, cool */ }
     322      allExp = service.GetHiveExperiments();
     323      Assert.AreEqual(0, allExp.Count(x => x.Id == e1.Id));
    318324
    319325      // user2 should not be able to grant permissions
    320326      try {
    321         service.GrantPermission(e1.Id, MockAuthorizationManager.MockUserId2, Permission.ReadOnly);
     327        service.GrantPermission(e1.Id, MockUserManager.MockUserId2, Permission.Read);
    322328        Assert.Fail("Should not be possible to grant permission due to missing permission for User2");
    323329      }
     
    325331
    326332      // switch back to user1 (owner) and grant user2 permissions
    327       mockServiceLocator.SetCurrentUser(MockAuthorizationManager.MockUserId1);
    328       service.GrantPermission(e1.Id, MockAuthorizationManager.MockUserId2, Permission.ReadOnly);
     333      mockServiceLocator.SetCurrentUserId(MockUserManager.MockUserId1);
     334      service.GrantPermission(e1.Id, MockUserManager.MockUserId2, Permission.Read);
    329335
    330336      // back to user2
    331       mockServiceLocator.SetCurrentUser(MockAuthorizationManager.MockUserId2);
     337      mockServiceLocator.SetCurrentUserId(MockUserManager.MockUserId2);
    332338      e1loaded = service.GetHiveExperiment(e1.Id);
    333       Assert.AreEqual(Permission.ReadOnly, e1loaded.Permission);
     339      Assert.AreEqual(Permission.Read, e1loaded.Permission);
     340      allExp = service.GetHiveExperiments();
     341      Assert.AreEqual(1, allExp.Count(x => x.Id == e1.Id));
    334342
    335343      // user2 should still not be able to grant permissions
    336344      try {
    337         service.GrantPermission(e1.Id, MockAuthorizationManager.MockUserId2, Permission.ReadOnly);
     345        service.GrantPermission(e1.Id, MockUserManager.MockUserId2, Permission.Read);
    338346        Assert.Fail("Should not be possible to grant permission due to missing permission for User2");
    339347      }
     
    341349
    342350      // back to user1
    343       mockServiceLocator.SetCurrentUser(MockAuthorizationManager.MockUserId1);
    344       service.GrantPermission(e1.Id, MockAuthorizationManager.MockUserId2, Permission.Full);
     351      mockServiceLocator.SetCurrentUserId(MockUserManager.MockUserId1);
     352      service.GrantPermission(e1.Id, MockUserManager.MockUserId2, Permission.Full);
    345353
    346354      // back to user2
    347       mockServiceLocator.SetCurrentUser(MockAuthorizationManager.MockUserId2);
     355      mockServiceLocator.SetCurrentUserId(MockUserManager.MockUserId2);
    348356      e1loaded = service.GetHiveExperiment(e1.Id);
    349357      Assert.AreEqual(Permission.Full, e1loaded.Permission);
    350 
     358      allExp = service.GetHiveExperiments();
     359      Assert.AreEqual(1, allExp.Count(x => x.Id == e1.Id));
     360     
    351361      // grant rights to user3, now this should be possible due to full permissions
    352       service.GrantPermission(e1.Id, MockAuthorizationManager.MockUserId3, Permission.ReadOnly);
     362      service.GrantPermission(e1.Id, MockUserManager.MockUserId3, Permission.Read);
    353363
    354364      // back to user1 and revoke rights for user2
    355       mockServiceLocator.SetCurrentUser(MockAuthorizationManager.MockUserId1);
    356       service.RevokePermission(e1.Id, MockAuthorizationManager.MockUserId2);
     365      mockServiceLocator.SetCurrentUserId(MockUserManager.MockUserId1);
     366      service.RevokePermission(e1.Id, MockUserManager.MockUserId2);
    357367
    358368      // back to user2
    359       mockServiceLocator.SetCurrentUser(MockAuthorizationManager.MockUserId2);
    360       e1loaded = service.GetHiveExperiment(e1.Id);
    361       Assert.AreEqual(null, e1loaded); // no access
    362 
     369      mockServiceLocator.SetCurrentUserId(MockUserManager.MockUserId2);
     370      try {
     371        e1loaded = service.GetHiveExperiment(e1.Id);
     372        Assert.Fail("Access should not be possible");
     373      }
     374      catch { /* ok, cool */ }
     375      allExp = service.GetHiveExperiments();
     376      Assert.AreEqual(0, allExp.Count(x => x.Id == e1.Id));
     377
     378      // back to user1
     379      mockServiceLocator.SetCurrentUserId(MockUserManager.MockUserId1);
    363380      service.DeleteHiveExperiment(e1.Id);
    364381    }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Web/Hive-3.4/Web.config

    r6458 r6463  
    11<?xml version="1.0"?>
    22<configuration>
    3   <configSections>
    4     <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    5       <section name="HeuristicLab.Services.Hive.DataAccess.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
    6       <section name="HeuristicLab.Services.Hive.Common.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
    7     </sectionGroup>
    8   </configSections>
    9   <appSettings>
    10   <add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\TempImageFiles\;" />
    11  </appSettings>
    12  <applicationSettings>
    13     <HeuristicLab.Services.Hive.DataAccess.Settings>
    14       <!-- Timeout for long running database command (storing or loading jobData) -->
    15       <setting name="LongRunningDatabaseCommandTimeout" serializeAs="String">
    16         <value>00:05:33</value>
    17       </setting>
    18     </HeuristicLab.Services.Hive.DataAccess.Settings>
    19     <HeuristicLab.Services.Hive.Common.Settings>
    20       <!-- If a slave does not send a heartbeat for this time, it is set offline which means all of its jobs are rescheduled -->
    21       <setting name="SlaveHeartbeatTimeout" serializeAs="String">
    22         <value>00:01:00</value>
    23       </setting>
    24       <!-- When a job is in state `Calculating` this is the maximum time it does not have to send heartbeats, otherwise its rescheduled -->
    25       <setting name="CalculatingJobHeartbeatTimeout" serializeAs="String">
    26         <value>00:05:30</value>
    27       </setting>
    28       <!-- When a job is in state `Transferring` this is the maximum time it does not have to send heartbeats, otherwise its rescheduled -->
    29       <setting name="TransferringJobHeartbeatTimeout" serializeAs="String">
    30         <value>00:05:30</value>
    31       </setting>
    32     </HeuristicLab.Services.Hive.Common.Settings>
    33   </applicationSettings>
    34   <connectionStrings>
    35     <add name="HeuristicLab.Authentication" connectionString="data source=localhost;Integrated Security=SSPI;Initial Catalog=HeuristicLab.Authentication"/>
    36   </connectionStrings>
    37   <system.web>
    38     <httpHandlers>
    39    <add path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    40     validate="false" />
    41   </httpHandlers>
    42   <compilation debug="true" targetFramework="4.0">
    43       <assemblies>
    44         <add assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></assemblies></compilation>
    45     <membership>
    46       <providers>
    47         <clear/>
    48         <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="HeuristicLab.Authentication" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="HeuristicLab.Authentication"/>
    49       </providers>
    50     </membership>
    51     <roleManager enabled="true">
    52       <providers>
    53         <clear/>
    54         <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="HeuristicLab.Authentication" applicationName="HeuristicLab.Authentication"/>
    55       </providers>
    56     </roleManager>
    57     <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
    58    <controls>
    59     <add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting"
    60      assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    61    </controls>
    62   </pages>
    63     <httpRuntime maxRequestLength="1048576"/>
    64   </system.web>
    65   <system.serviceModel>
    66     <diagnostics>
    67       <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" maxMessagesToLog="3000"/>
    68     </diagnostics>
    69     <bindings>
    70       <wsHttpBinding>
    71         <binding name="WSHttpBinding_IHiveService" receiveTimeout="00:10:00" sendTimeout="00:10:00" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
    72           <readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647"/>
    73           <security mode="Message">
    74             <transport clientCredentialType="Certificate"/>
    75             <message clientCredentialType="UserName"/>
    76           </security>
    77         </binding>
    78       </wsHttpBinding>
    79     </bindings>
    80     <behaviors>
    81       <serviceBehaviors>
    82         <behavior name="ServiceBehaviour_IHiveService">
    83           <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
    84           <serviceMetadata httpGetEnabled="true" httpsGetEnabled="false"/>
    85           <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
    86           <serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true"/>
    87           <serviceAuthorization principalPermissionMode="UseAspNetRoles" roleProviderName="AspNetSqlRoleProvider"/>
    88           <serviceCredentials>
    89             <serviceCertificate findValue="localhost" x509FindType="FindBySubjectName"/>
    90             <userNameAuthentication userNamePasswordValidationMode="MembershipProvider" membershipProviderName="AspNetSqlMembershipProvider"/>
    91           </serviceCredentials>
    92           <serviceSecurityAudit auditLogLocation="Application" suppressAuditFailure="false" messageAuthenticationAuditLevel="SuccessOrFailure"/>
    93           <serviceThrottling maxConcurrentCalls="100"/>
    94           <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
    95         </behavior>
    96       </serviceBehaviors>
    97     </behaviors>
    98     <services>
    99       <service behaviorConfiguration="ServiceBehaviour_IHiveService" name="HeuristicLab.Services.Hive.HiveService">
    100         <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="" name="MexEndpoint" contract="IMetadataExchange"/>
    101         <endpoint binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IHiveService" name="WSHttpBinding_IHiveService" contract="HeuristicLab.Services.Hive.Common.ServiceContracts.IHiveService"/>
    102       </service>
    103     </services>
    104     <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
    105   </system.serviceModel>
    106   <system.webServer>
    107   <directoryBrowse enabled="true" />
    108   <handlers>
    109    <remove name="ChartImageHandler" />
    110    <add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD,POST"
    111     path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    112   </handlers>
    113  </system.webServer>
     3  <configSections>
     4    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     5      <section name="HeuristicLab.Services.Hive.DataAccess.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
     6      <section name="HeuristicLab.Services.Hive.Common.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
     7    </sectionGroup>
     8  </configSections>
     9  <appSettings>
     10    <add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\TempImageFiles\;" />
     11  </appSettings>
     12  <applicationSettings>
     13    <HeuristicLab.Services.Hive.DataAccess.Settings>
     14      <!-- Timeout for long running database command (storing or loading jobData) -->
     15      <setting name="LongRunningDatabaseCommandTimeout" serializeAs="String">
     16        <value>00:05:33</value>
     17      </setting>
     18    </HeuristicLab.Services.Hive.DataAccess.Settings>
     19    <HeuristicLab.Services.Hive.Common.Settings>
     20      <!-- If a slave does not send a heartbeat for this time, it is set offline which means all of its jobs are rescheduled -->
     21      <setting name="SlaveHeartbeatTimeout" serializeAs="String">
     22        <value>00:01:00</value>
     23      </setting>
     24      <!-- When a job is in state `Calculating` this is the maximum time it does not have to send heartbeats, otherwise its rescheduled -->
     25      <setting name="CalculatingJobHeartbeatTimeout" serializeAs="String">
     26        <value>00:05:30</value>
     27      </setting>
     28      <!-- When a job is in state `Transferring` this is the maximum time it does not have to send heartbeats, otherwise its rescheduled -->
     29      <setting name="TransferringJobHeartbeatTimeout" serializeAs="String">
     30        <value>00:05:30</value>
     31      </setting>
     32    </HeuristicLab.Services.Hive.Common.Settings>
     33  </applicationSettings>
     34  <connectionStrings>
     35    <add name="HeuristicLab.Authentication" connectionString="data source=localhost;Integrated Security=SSPI;Initial Catalog=HeuristicLab.Authentication"/>
     36  </connectionStrings>
     37  <system.web>
     38    <compilation debug="true" targetFramework="4.0">
     39      <assemblies>
     40        <add assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
     41      </assemblies>
     42    </compilation>
     43    <membership>
     44      <providers>
     45        <clear/>
     46        <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="HeuristicLab.Authentication" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="HeuristicLab.Authentication"/>
     47      </providers>
     48    </membership>
     49    <roleManager enabled="true">
     50      <providers>
     51        <clear/>
     52        <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="HeuristicLab.Authentication" applicationName="HeuristicLab.Authentication"/>
     53      </providers>
     54    </roleManager>
     55    <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
     56      <controls>
     57        <add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting"
     58         assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
     59      </controls>
     60    </pages>
     61    <httpRuntime maxRequestLength="1048576"/>
     62  </system.web>
     63  <system.serviceModel>
     64    <diagnostics>
     65      <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" maxMessagesToLog="3000"/>
     66    </diagnostics>
     67    <bindings>
     68      <wsHttpBinding>
     69        <binding name="WSHttpBinding_IHiveService" receiveTimeout="00:10:00" sendTimeout="00:10:00" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
     70          <readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647"/>
     71          <security mode="Message">
     72            <transport clientCredentialType="Certificate"/>
     73            <message clientCredentialType="UserName"/>
     74          </security>
     75        </binding>
     76      </wsHttpBinding>
     77    </bindings>
     78    <behaviors>
     79      <serviceBehaviors>
     80        <behavior name="ServiceBehaviour_IHiveService">
     81          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
     82          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="false"/>
     83          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
     84          <serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true"/>
     85          <serviceAuthorization principalPermissionMode="UseAspNetRoles" roleProviderName="AspNetSqlRoleProvider"/>
     86          <serviceCredentials>
     87            <serviceCertificate findValue="localhost" x509FindType="FindBySubjectName"/>
     88            <userNameAuthentication userNamePasswordValidationMode="MembershipProvider" membershipProviderName="AspNetSqlMembershipProvider"/>
     89          </serviceCredentials>
     90          <serviceSecurityAudit auditLogLocation="Application" suppressAuditFailure="false" messageAuthenticationAuditLevel="SuccessOrFailure"/>
     91          <serviceThrottling maxConcurrentCalls="100"/>
     92          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
     93        </behavior>
     94      </serviceBehaviors>
     95    </behaviors>
     96    <services>
     97      <service behaviorConfiguration="ServiceBehaviour_IHiveService" name="HeuristicLab.Services.Hive.HiveService">
     98        <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="" name="MexEndpoint" contract="IMetadataExchange"/>
     99        <endpoint binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IHiveService" name="WSHttpBinding_IHiveService" contract="HeuristicLab.Services.Hive.Common.ServiceContracts.IHiveService"/>
     100      </service>
     101    </services>
     102    <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
     103  </system.serviceModel>
     104  <system.webServer>
     105    <directoryBrowse enabled="true" />
     106    <handlers>
     107      <remove name="ChartImageHandler" />
     108      <add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD,POST"
     109       path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
     110    </handlers>
     111  </system.webServer> 
    114112</configuration>
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/HeuristicLab.Services.Hive-3.4.csproj

    r6369 r6463  
    103103  </ItemGroup>
    104104  <ItemGroup>
     105    <Compile Include="Interfaces\IUserManager.cs" />
     106    <Compile Include="Manager\UserManager.cs" />
    105107    <None Include="HeuristicLabServicesHivePlugin.cs.frame" />
    106108    <None Include="Properties\AssemblyInfo.cs.frame" />
    107     <Compile Include="AuthenticationManager.cs" />
    108     <Compile Include="HeartbeatManager.cs" />
     109    <Compile Include="Manager\AuthenticationManager.cs" />
     110    <Compile Include="Manager\HeartbeatManager.cs" />
    109111    <Compile Include="Interfaces\IAuthenticationManager.cs" />
    110112    <Compile Include="Interfaces\ILifecycleManager.cs" />
    111113    <Compile Include="Interfaces\IServiceLocator.cs" />
    112     <Compile Include="AuthorizationManager.cs" />
     114    <Compile Include="Manager\AuthorizationManager.cs" />
    113115    <Compile Include="HeuristicLabServicesHivePlugin.cs" />
    114     <Compile Include="LifecycleManager.cs" />
     116    <Compile Include="Manager\LifecycleManager.cs" />
    115117    <Compile Include="HiveRoles.cs" />
    116118    <Compile Include="HiveService.cs" />
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/HiveService.cs

    r6457 r6463  
    5151      get { return ServiceLocator.Instance.LifecycleManager; }
    5252    }
     53    private IUserManager userManager {
     54      get { return ServiceLocator.Instance.UserManager; }
     55    }
    5356    private HeartbeatManager heartbeatManager {
    5457      get { return ServiceLocator.Instance.HeartbeatManager; }
     
    6669        }
    6770        dao.AddJobData(jobData);
    68         dao.UpdateJobState(job.Id, JobState.Waiting, null, author.UserId, null);
     71        dao.UpdateJobState(job.Id, JobState.Waiting, null, userManager.CurrentUserId, null);
    6972        return jobData.JobId;
    7073      }, false, true);
     
    8184    public Job GetJob(Guid jobId) {
    8285      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
     86      author.AuthorizeForJob(jobId, Permission.Read);
    8387      return dao.GetJob(jobId);
    8488    }
     
    8690    public IEnumerable<Job> GetJobs() {
    8791      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    88       return dao.GetJobs(x => true);
     92      var jobs = dao.GetJobs(x => true);
     93      foreach (var job in jobs)
     94        author.AuthorizeForJob(job.Id, Permission.Read);
     95      return jobs;
    8996    }
    9097
    9198    public IEnumerable<LightweightJob> GetLightweightJobs(IEnumerable<Guid> jobIds) {
    9299      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    93       return dao.GetJobs(x => jobIds.Contains(x.JobId)).Select(x => new LightweightJob(x)).ToArray();
     100      var jobs = dao.GetJobs(x => jobIds.Contains(x.JobId)).Select(x => new LightweightJob(x)).ToArray();
     101      foreach (var job in jobs)
     102        author.AuthorizeForJob(job.Id, Permission.Read);
     103      return jobs;
    94104    }
    95105
    96106    public IEnumerable<LightweightJob> GetLightweightChildJobs(Guid? parentJobId, bool recursive, bool includeParent) {
    97107      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    98       return GetChildJobs(parentJobId, recursive, includeParent).Select(x => new LightweightJob(x)).ToArray();
     108      var jobs = GetChildJobs(parentJobId, recursive, includeParent).Select(x => new LightweightJob(x)).ToArray();
     109      foreach (var job in jobs)
     110        author.AuthorizeForJob(job.Id, Permission.Read);
     111      return jobs;
    99112    }
    100113
    101114    public IEnumerable<LightweightJob> GetLightweightExperimentJobs(Guid experimentId) {
    102115      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     116      author.AuthorizeForExperiment(experimentId, Permission.Read);
    103117      return dao.GetJobs(x => x.HiveExperimentId == experimentId).Select(x => new LightweightJob(x)).ToArray();
    104118    }
     
    106120    public JobData GetJobData(Guid jobId) {
    107121      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
     122      author.AuthorizeForJob(jobId, Permission.Read);
    108123      return dao.GetJobData(jobId);
    109124    }
     
    111126    public void UpdateJob(Job job) {
    112127      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
     128      author.AuthorizeForJob(job.Id, Permission.Full);
    113129      trans.UseTransaction(() => {
    114130        dao.UpdateJob(job);
     
    118134    public void UpdateJobData(Job job, JobData jobData) {
    119135      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
     136      author.AuthorizeForJob(job.Id, Permission.Full);
     137      author.AuthorizeForJob(jobData.JobId, Permission.Full);
    120138      //trans.UseTransaction(() => { // cneumuel: try without transaction
    121139      jobData.LastUpdate = DateTime.Now;
     
    127145    public void DeleteJob(Guid jobId) {
    128146      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
     147      author.AuthorizeForJob(jobId, Permission.Full);
    129148      trans.UseTransaction(() => {
    130149        dao.DeleteJob(jobId);
     
    134153    public void DeleteChildJobs(Guid parentJobId) {
    135154      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
     155      author.AuthorizeForJob(parentJobId, Permission.Full);
    136156      trans.UseTransaction(() => {
    137157        var jobs = GetChildJobs(parentJobId, true, false);
     
    145165    public Job UpdateJobState(Guid jobId, JobState jobState, Guid? slaveId, Guid? userId, string exception) {
    146166      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
     167      author.AuthorizeForJob(jobId, Permission.Full);
    147168      return trans.UseTransaction(() => {
    148169        Job job = dao.UpdateJobState(jobId, jobState, slaveId, userId, exception);
     
    166187    public IEnumerable<Job> GetJobsByResourceId(Guid resourceId) {
    167188      authen.AuthenticateForAnyRole(HiveRoles.Administrator);
    168       return trans.UseTransaction(() => dao.GetJobsByResourceId(resourceId));
     189      var jobs = trans.UseTransaction(() => dao.GetJobsByResourceId(resourceId));
     190      foreach(var job in jobs)
     191        author.AuthorizeForJob(job.Id, Permission.Read);
     192      return jobs;
    169193    }
    170194    #endregion
     
    173197    public void StopJob(Guid jobId) {
    174198      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
     199      author.AuthorizeForJob(jobId, Permission.Full);
    175200      trans.UseTransaction(() => {
    176201        var job = dao.GetJob(jobId);
     
    188213    public void PauseJob(Guid jobId) {
    189214      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
     215      author.AuthorizeForJob(jobId, Permission.Full);
    190216      trans.UseTransaction(() => {
    191217        var job = dao.GetJob(jobId);
     
    201227    public void RestartJob(Guid jobId) {
    202228      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    203       trans.UseTransaction(() => {
    204         Job job = dao.UpdateJobState(jobId, JobState.Waiting, null, author.UserId, string.Empty);
     229      author.AuthorizeForJob(jobId, Permission.Full);
     230      trans.UseTransaction(() => {
     231        Job job = dao.UpdateJobState(jobId, JobState.Waiting, null, userManager.CurrentUserId, string.Empty);
    205232        job.Command = null;
    206233        dao.UpdateJob(job);
     
    212239    public HiveExperiment GetHiveExperiment(Guid id) {
    213240      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     241      author.AuthorizeForExperiment(id, Permission.Read);
    214242      var hiveExperiment = dao.GetHiveExperiments(x =>
    215243            x.HiveExperimentId == id
    216             && (x.OwnerUserId == author.UserId || x.HiveExperimentPermissions.Count(hep => hep.Permission != Permission.NotAllowed && hep.GrantedUserId == author.UserId) > 0)
     244            && (x.OwnerUserId == userManager.CurrentUserId || x.HiveExperimentPermissions.Count(hep => hep.Permission != Permission.NotAllowed && hep.GrantedUserId == userManager.CurrentUserId) > 0)
    217245          ).FirstOrDefault();
    218       if (hiveExperiment != null) hiveExperiment.Permission = dao.GetPermissionForExperiment(hiveExperiment.Id, author.UserId);
     246      if (hiveExperiment != null) hiveExperiment.Permission = dao.GetPermissionForExperiment(hiveExperiment.Id, userManager.CurrentUserId);
    219247      return hiveExperiment;
    220248    }
     
    222250    public IEnumerable<HiveExperiment> GetHiveExperiments() {
    223251      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    224       var hiveExperiments = dao.GetHiveExperiments(x => x.OwnerUserId == author.UserId || x.HiveExperimentPermissions.Count(hep => hep.Permission != Permission.NotAllowed && hep.GrantedUserId == author.UserId) > 0);
    225       foreach (var he in hiveExperiments)
    226         he.Permission = dao.GetPermissionForExperiment(he.Id, author.UserId);
     252      var hiveExperiments = dao.GetHiveExperiments(x => x.OwnerUserId == userManager.CurrentUserId || x.HiveExperimentPermissions.Count(hep => hep.Permission != Permission.NotAllowed && hep.GrantedUserId == userManager.CurrentUserId) > 0);
     253      foreach (var he in hiveExperiments) {
     254        author.AuthorizeForExperiment(he.Id, Permission.Read);
     255        he.Permission = dao.GetPermissionForExperiment(he.Id, userManager.CurrentUserId);
     256      }
    227257      return hiveExperiments;
    228258    }
     
    231261      authen.AuthenticateForAnyRole(HiveRoles.Administrator);
    232262      var hiveExperiments = dao.GetHiveExperiments(x => true);
    233       foreach (var he in hiveExperiments)
    234         he.Permission = dao.GetPermissionForExperiment(he.Id, author.UserId);
     263      foreach (var he in hiveExperiments) // no authorization here, since this method is admin-only! (admin is allowed to read all jobs)
     264        he.Permission = dao.GetPermissionForExperiment(he.Id, userManager.CurrentUserId);
    235265      return hiveExperiments;
    236266    }
     
    239269      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    240270      return trans.UseTransaction(() => {
    241         hiveExperimentDto.OwnerUserId = author.UserId;
     271        hiveExperimentDto.OwnerUserId = userManager.CurrentUserId;
    242272        hiveExperimentDto.DateCreated = DateTime.Now;
    243273        return dao.AddHiveExperiment(hiveExperimentDto);
     
    247277    public void UpdateHiveExperiment(HiveExperiment hiveExperimentDto) {
    248278      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     279      author.AuthorizeForExperiment(hiveExperimentDto.Id, Permission.Full);
    249280      trans.UseTransaction(() => {
    250281        dao.UpdateHiveExperiment(hiveExperimentDto);
     
    254285    public void DeleteHiveExperiment(Guid hiveExperimentId) {
    255286      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     287      author.AuthorizeForExperiment(hiveExperimentId, Permission.Full);
    256288      trans.UseTransaction(() => {
    257289        HiveExperiment he = dao.GetHiveExperiment(hiveExperimentId);
     
    267299        HiveExperiment he = dao.GetHiveExperiment(hiveExperimentId);
    268300        if (he == null) throw new FaultException<FaultReason>(new FaultReason("Could not find hiveExperiment with id " + hiveExperimentId));
    269         Permission perm = dao.GetPermissionForExperiment(he.Id, author.UserId);
     301        Permission perm = dao.GetPermissionForExperiment(he.Id, userManager.CurrentUserId);
    270302        if (perm != Permission.Full) throw new FaultException<FaultReason>(new FaultReason("Not allowed to grant permissions for this experiment"));
    271         dao.SetHiveExperimentPermission(hiveExperimentId, author.UserId, grantedUserId, permission);
     303        dao.SetHiveExperimentPermission(hiveExperimentId, userManager.CurrentUserId, grantedUserId, permission);
    272304      });
    273305    }
     
    278310        HiveExperiment he = dao.GetHiveExperiment(hiveExperimentId);
    279311        if (he == null) throw new FaultException<FaultReason>(new FaultReason("Could not find hiveExperiment with id " + hiveExperimentId));
    280         Permission perm = dao.GetPermissionForExperiment(he.Id, author.UserId);
     312        Permission perm = dao.GetPermissionForExperiment(he.Id, userManager.CurrentUserId);
    281313        if (perm != Permission.Full) throw new FaultException<FaultReason>(new FaultReason("Not allowed to grant permissions for this experiment"));
    282         dao.SetHiveExperimentPermission(hiveExperimentId, author.UserId, grantedUserId, Permission.NotAllowed);
     314        dao.SetHiveExperimentPermission(hiveExperimentId, userManager.CurrentUserId, grantedUserId, Permission.NotAllowed);
     315      });
     316    }
     317    public IEnumerable<HiveExperimentPermission> GetHiveExperimentPermissions(Guid hiveExperimentId) {
     318      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     319      return trans.UseTransaction(() => {
     320        Permission currentUserPermission = dao.GetPermissionForExperiment(hiveExperimentId, userManager.CurrentUserId);
     321        if (currentUserPermission != Permission.Full) throw new FaultException<FaultReason>(new FaultReason("Not allowed to list permissions for this experiment"));
     322        return dao.GetHiveExperimentPermissions(x => x.HiveExperimentId == hiveExperimentId);
    283323      });
    284324    }
     
    341381      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    342382      return trans.UseTransaction(() => {
    343         plugin.UserId = author.UserId;
     383        plugin.UserId = userManager.CurrentUserId;
    344384        plugin.DateCreated = DateTime.Now;
    345385
     
    369409    }
    370410
     411    // note: this is a possible security problem, since a client is able to download all plugins, which may contain proprietary code (which can be disassembled)
     412    //       change so that only with GetPluginByHash it is possible to download plugins
    371413    public IEnumerable<Plugin> GetPlugins() {
    372414      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
     
    376418    public IEnumerable<PluginData> GetPluginDatas(List<Guid> pluginIds) {
    377419      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    378       List<PluginData> pluginDatas = new List<PluginData>();
    379 
     420      var pluginDatas = new List<PluginData>();
    380421      return trans.UseTransaction(() => {
    381422        foreach (Guid guid in pluginIds) {
     
    394435    #region Slave Methods
    395436    public Guid AddSlave(Slave slave) {
    396       authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     437      authen.AuthenticateForAnyRole(HiveRoles.Administrator);
    397438      return trans.UseTransaction(() => dao.AddSlave(slave));
    398439    }
    399440
    400441    public Guid AddSlaveGroup(SlaveGroup slaveGroup) {
    401       authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     442      authen.AuthenticateForAnyRole(HiveRoles.Administrator);
    402443      return trans.UseTransaction(() => dao.AddSlaveGroup(slaveGroup));
    403444    }
    404445
    405446    public Slave GetSlave(Guid slaveId) {
    406       authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     447      authen.AuthenticateForAnyRole(HiveRoles.Administrator);
    407448      return dao.GetSlave(slaveId);
    408449    }
    409450
    410451    public SlaveGroup GetSlaveGroup(Guid slaveGroupId) {
    411       authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     452      authen.AuthenticateForAnyRole(HiveRoles.Administrator);
    412453      return dao.GetSlaveGroup(slaveGroupId);
    413454    }
    414455
    415456    public IEnumerable<Slave> GetSlaves() {
    416       authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     457      authen.AuthenticateForAnyRole(HiveRoles.Administrator);
    417458      return dao.GetSlaves(x => true);
    418459    }
    419460
    420461    public IEnumerable<SlaveGroup> GetSlaveGroups() {
    421       authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     462      authen.AuthenticateForAnyRole(HiveRoles.Administrator);
    422463      return dao.GetSlaveGroups(x => true);
    423464    }
    424465
    425466    public void UpdateSlave(Slave slave) {
    426       authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     467      authen.AuthenticateForAnyRole(HiveRoles.Administrator);
    427468      trans.UseTransaction(() => {
    428469        dao.UpdateSlave(slave);
     
    431472
    432473    public void UpdateSlaveGroup(SlaveGroup slaveGroup) {
    433       authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     474      authen.AuthenticateForAnyRole(HiveRoles.Administrator);
    434475      trans.UseTransaction(() => {
    435476        dao.UpdateSlaveGroup(slaveGroup);
     
    438479
    439480    public void DeleteSlave(Guid slaveId) {
    440       authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     481      authen.AuthenticateForAnyRole(HiveRoles.Administrator);
    441482      trans.UseTransaction(() => {
    442483        dao.DeleteSlave(slaveId);
     
    445486
    446487    public void DeleteSlaveGroup(Guid slaveGroupId) {
    447       authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     488      authen.AuthenticateForAnyRole(HiveRoles.Administrator);
    448489      trans.UseTransaction(() => {
    449490        dao.DeleteSlaveGroup(slaveGroupId);
     
    452493
    453494    public void AddResourceToGroup(Guid slaveGroupId, Guid resourceId) {
    454       authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     495      authen.AuthenticateForAnyRole(HiveRoles.Administrator);
    455496      trans.UseTransaction(() => {
    456497        var resource = dao.GetResource(resourceId);
     
    461502
    462503    public void RemoveResourceFromGroup(Guid slaveGroupId, Guid resourceId) {
    463       authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     504      authen.AuthenticateForAnyRole(HiveRoles.Administrator);
    464505      trans.UseTransaction(() => {
    465506        var resource = dao.GetResource(resourceId);
     
    470511
    471512    public Guid GetResourceId(string resourceName) {
    472       authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     513      authen.AuthenticateForAnyRole(HiveRoles.Administrator);
    473514      return trans.UseTransaction(() => {
    474515        var resource = dao.GetResources(x => x.Name == resourceName).FirstOrDefault();
     
    482523
    483524    public void TriggerLifecycle(bool force) {
     525      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Slave);
    484526      // use a serializable transaction here to ensure not two threads execute this simultaniously (mutex-lock would not work since IIS may use multiple AppDomains)
    485527      trans.UseTransaction(() => {
     
    519561    #endregion
    520562
     563    #region User Methods
     564    public string GetUsernameByUserId(Guid userId) {
     565      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     566      var user = ServiceLocator.Instance.UserManager.GetUserById(userId);
     567      if (user != null)
     568        return user.UserName;
     569      else
     570        return null;
     571    }
     572
     573    public Guid GetUserIdByUsername(string username) {
     574      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     575      var user = ServiceLocator.Instance.UserManager.GetUserByName(username);
     576      return user != null ? (Guid)user.ProviderUserKey : Guid.Empty;
     577    }
     578    #endregion
     579
    521580    #region Helper Methods
    522581    private IEnumerable<Job> GetChildJobs(Guid? parentJobId, bool recursive, bool includeParent) {
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/Interfaces/IAuthorizationManager.cs

    r6372 r6463  
    2121
    2222using System;
     23using HeuristicLab.Services.Hive.Common.DataTransfer;
    2324namespace HeuristicLab.Services.Hive {
    2425  public interface IAuthorizationManager {
    25     /// <summary>
    26     /// Returns the UserId of the currently authenticated user
    27     /// </summary>
    28     Guid UserId { get; }
    29 
    3026    /// <summary>
    3127    /// Compares the current UserId with the given userId and takes appropriate actions if the mismatch
    3228    /// </summary>
    3329    void Authorize(Guid userId);
     30
     31    void AuthorizeForJob(Guid jobId, Permission requiredPermission);
     32
     33    void AuthorizeForExperiment(Guid experimentId, Permission requiredPermission);
    3434  }
    3535}
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/Interfaces/IServiceLocator.cs

    r6452 r6463  
    2929    ILifecycleManager LifecycleManager { get; }
    3030    ITransactionManager TransactionManager { get; }
     31    IUserManager UserManager { get; }
    3132    HeartbeatManager HeartbeatManager { get; }
    3233  }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/ServiceLocator.cs

    r6452 r6463  
    7474    }
    7575
     76    private IUserManager userManager;
     77    public IUserManager UserManager {
     78      get {
     79        if (userManager == null) userManager = new UserManager();
     80        return userManager;
     81      }
     82    }
     83
    7684    private HeartbeatManager heartbeatManager;
    7785    public HeartbeatManager HeartbeatManager {
Note: See TracChangeset for help on using the changeset viewer.