Free cookie consent management tool by TermsFeed Policy Generator

Changeset 2065


Ignore:
Timestamp:
06/19/09 12:06:02 (15 years ago)
Author:
mbecirov
Message:

#586: Added authorization components.

Location:
trunk/sources
Files:
16 added
1 deleted
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Grid.HiveBridge/3.2

    • Property svn:ignore set to
      obj
      bin
  • trunk/sources/HeuristicLab.Hive.Server.Console/3.2/HeuristicLab.Hive.Server.Console-3.2.csproj

    r1956 r2065  
    122122    </Compile>
    123123    <Compile Include="HiveServerConsolePlugin.cs" />
     124    <Compile Include="LogonDlg.cs">
     125      <SubType>Form</SubType>
     126    </Compile>
     127    <Compile Include="LogonDlg.Designer.cs">
     128      <DependentUpon>LogonDlg.cs</DependentUpon>
     129    </Compile>
    124130    <Compile Include="Properties\AssemblyInfo.cs" />
    125131    <EmbeddedResource Include="AddGroup.resx">
     
    140146      <DependentUpon>HiveServerManagementConsole.cs</DependentUpon>
    141147      <SubType>Designer</SubType>
     148    </EmbeddedResource>
     149    <EmbeddedResource Include="LogonDlg.resx">
     150      <DependentUpon>LogonDlg.cs</DependentUpon>
    142151    </EmbeddedResource>
    143152    <EmbeddedResource Include="Properties\Resources.resx">
  • trunk/sources/HeuristicLab.Hive.Server.Console/3.2/HiveServerConsole.Designer.cs

    r1717 r2065  
    4545    /// </summary>
    4646    private void InitializeComponent() {
     47      System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(HiveServerConsole));
    4748      this.gbConfiguration = new System.Windows.Forms.GroupBox();
    4849      this.lblPort = new System.Windows.Forms.Label();
     
    5758      this.tbPwd = new System.Windows.Forms.TextBox();
    5859      this.lblError = new System.Windows.Forms.Label();
     60      this.pictureBox1 = new System.Windows.Forms.PictureBox();
     61      this.btnCancel = new System.Windows.Forms.Button();
    5962      this.gbConfiguration.SuspendLayout();
    6063      this.gpUser.SuspendLayout();
     64      ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
    6165      this.SuspendLayout();
    6266      //
     
    6771      this.gbConfiguration.Controls.Add(this.tbPort);
    6872      this.gbConfiguration.Controls.Add(this.tbIp);
    69       this.gbConfiguration.Location = new System.Drawing.Point(12, 100);
     73      this.gbConfiguration.Location = new System.Drawing.Point(188, 100);
    7074      this.gbConfiguration.Name = "gbConfiguration";
    7175      this.gbConfiguration.Size = new System.Drawing.Size(283, 82);
     
    110114      // btnLogin
    111115      //
    112       this.btnLogin.Location = new System.Drawing.Point(179, 188);
     116      this.btnLogin.Location = new System.Drawing.Point(355, 193);
    113117      this.btnLogin.Name = "btnLogin";
    114118      this.btnLogin.Size = new System.Drawing.Size(116, 23);
     
    125129      this.gpUser.Controls.Add(this.lblUsername);
    126130      this.gpUser.Controls.Add(this.tbPwd);
    127       this.gpUser.Location = new System.Drawing.Point(12, 12);
     131      this.gpUser.Location = new System.Drawing.Point(188, 12);
    128132      this.gpUser.Name = "gpUser";
    129133      this.gpUser.Size = new System.Drawing.Size(283, 82);
     
    171175      this.lblError.AutoSize = true;
    172176      this.lblError.ForeColor = System.Drawing.Color.Red;
    173       this.lblError.Location = new System.Drawing.Point(16, 238);
     177      this.lblError.Location = new System.Drawing.Point(12, 193);
    174178      this.lblError.Name = "lblError";
    175179      this.lblError.Size = new System.Drawing.Size(0, 13);
    176180      this.lblError.TabIndex = 5;
    177181      //
     182      // pictureBox1
     183      //
     184      this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
     185      this.pictureBox1.Location = new System.Drawing.Point(12, 12);
     186      this.pictureBox1.Name = "pictureBox1";
     187      this.pictureBox1.Size = new System.Drawing.Size(170, 170);
     188      this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
     189      this.pictureBox1.TabIndex = 8;
     190      this.pictureBox1.TabStop = false;
     191      //
     192      // btnCancel
     193      //
     194      this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
     195      this.btnCancel.Location = new System.Drawing.Point(259, 193);
     196      this.btnCancel.Name = "btnCancel";
     197      this.btnCancel.Size = new System.Drawing.Size(90, 23);
     198      this.btnCancel.TabIndex = 9;
     199      this.btnCancel.Text = "&Cancel";
     200      this.btnCancel.UseVisualStyleBackColor = true;
     201      this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
     202      //
    178203      // HiveServerConsole
    179204      //
     
    181206      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    182207      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    183       this.ClientSize = new System.Drawing.Size(311, 225);
     208      this.BackColor = System.Drawing.Color.White;
     209      this.CancelButton = this.btnCancel;
     210      this.ClientSize = new System.Drawing.Size(482, 226);
     211      this.Controls.Add(this.btnCancel);
     212      this.Controls.Add(this.pictureBox1);
    184213      this.Controls.Add(this.lblError);
    185214      this.Controls.Add(this.gpUser);
    186215      this.Controls.Add(this.btnLogin);
    187216      this.Controls.Add(this.gbConfiguration);
     217      this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
    188218      this.Name = "HiveServerConsole";
    189       this.Text = "Server Console";
     219      this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
     220      this.Text = "Server Console Logon";
    190221      this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.HiveServerConsole_KeyPress);
    191222      this.gbConfiguration.ResumeLayout(false);
     
    193224      this.gpUser.ResumeLayout(false);
    194225      this.gpUser.PerformLayout();
     226      ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
    195227      this.ResumeLayout(false);
    196228      this.PerformLayout();
     
    212244    private System.Windows.Forms.TextBox tbPwd;
    213245    private System.Windows.Forms.Label lblError;
     246    private System.Windows.Forms.PictureBox pictureBox1;
     247    private System.Windows.Forms.Button btnCancel;
    214248  }
    215249}
  • trunk/sources/HeuristicLab.Hive.Server.Console/3.2/HiveServerConsole.cs

    r1832 r2065  
    3333using System.Security.Cryptography;
    3434using System.Net;
     35using System.Threading;
    3536
    3637namespace HeuristicLab.Hive.Server.ServerConsole {
     
    4243    public HiveServerConsole() {
    4344      InitializeComponent();
     45#if(DEBUG)
    4446      tbIp.Text = "10.20.53.1";
    4547      tbPort.Text = WcfSettings.GetDefaultPort().ToString();
    4648      tbUserName.Text = "test45";
    4749      tbPwd.Text = "test";
     50#endif
    4851    }
    4952
     
    7073        information.closeFormEvent += new closeForm(EnableForm);
    7174        information.Show();
    72       } else {
    73         lblError.Text = "Problem with login";
    74       }
     75      }
    7576    }
    7677
     
    8182    /// <returns></returns>
    8283    private bool IsValid() {
    83       if ((tbUserName.Text != "") &&
    84           (tbPwd.Text != "") &&
    85           (tbIp.Text != "") &&
    86           (tbPort.Text != "")) {
     84      Thread t = new Thread(new ThreadStart(ShowWaitDlg));
     85      if (IsFormValidated()) {
     86        IPAddress ipAdress = IPAddress.Parse(tbIp.Text);
     87        int port = int.Parse(tbPort.Text);
     88        IServerConsoleFacade scf = ServiceLocator.GetServerConsoleFacade();
    8789        try {
    88           IPAddress ipAdress;
    89           int port;
    90           if ((IPAddress.TryParse(tbIp.Text, out ipAdress)) &&
    91             int.TryParse(tbPort.Text, out port)) {
    92             IServerConsoleFacade scf = ServiceLocator.GetServerConsoleFacade();
    93             Response resp = scf.Login(tbUserName.Text, tbPwd.Text);
    94             string str = resp.StatusMessage;
    95             if (resp.StatusMessage != "Logged in") {
    96               return false;
    97             }
    98           } else {
    99             lblError.Text = "IP or Port not valid";
    100           }
     90          lblError.Text = "Trying to logon...";
     91          t.Start();
     92          Response resp = scf.Login(tbUserName.Text, tbPwd.Text);
     93          t.Abort();
     94          if (resp.StatusMessage == "Logged in") return true;
     95          lblError.Text = resp.StatusMessage;
    10196        }
    10297        catch (Exception ex) {
    103           lblError.Text = "Server not online";
     98          //login failed
     99          lblError.Text = "Logon failed!";
     100          t.Abort();
    104101          return false;
    105102        }
    106         return true;
    107       } else {
    108         if (tbUserName.Text == "") {
    109           lblError.Text = "Please type in Username";
    110         } else if (tbPwd.Text == "") {
    111           lblError.Text = "Please type in Password";
    112         } else if (tbPort.Text == "") {
    113           lblError.Text = "Please type in Port";
    114         } else if (tbIp.Text == "") {
    115           lblError.Text = "Please type in IP-Adress";
    116         }
    117         return false;
    118103      }
     104      //validation failed
     105      t.Abort();
     106      return false;
     107    }
     108
     109    private void ShowWaitDlg() {
     110      LogonDlg dlg = new LogonDlg();
     111      dlg.ShowDialog();
     112    }
     113
     114    /// <summary>
     115    /// Validates the form.
     116    /// </summary>
     117    /// <returns></returns>
     118    private bool IsFormValidated() {
     119      bool isValid = true;
     120      if (String.IsNullOrEmpty(tbUserName.Text)) {
     121        lblError.Text = "Please type in Username.";
     122        isValid = false;
     123      }
     124      if (String.IsNullOrEmpty(tbPwd.Text)) {
     125        lblError.Text = "Please type in Password.";
     126        isValid = false;
     127      }
     128      if (String.IsNullOrEmpty(tbIp.Text)) {
     129        lblError.Text = "Please type in Port.";
     130        isValid = false;
     131      }
     132      if (String.IsNullOrEmpty(tbPort.Text)) {
     133        lblError.Text = "Please type in IP-Address.";
     134        isValid = false;
     135      }
     136      try {
     137        int.Parse(tbPort.Text);
     138      }
     139      catch (Exception ex) {
     140        isValid = false;
     141        lblError.Text = "Please verify entered Port.";
     142      }
     143      try {
     144        IPAddress.Parse(tbIp.Text);
     145      }
     146      catch (Exception ex) {
     147        isValid = false;
     148        lblError.Text = "Please verify entered IP address.";
     149      }
     150      return isValid;
    119151    }
    120152
     
    124156        ServiceLocator.ShutDownFacade();
    125157        if (error == true) {
    126           lblError.Text = "Something went wrong with the server";
     158          lblError.Text = "Establishing server connection failed.";
    127159        }
    128160      }
     
    134166      }
    135167    }
     168
     169    private void btnCancel_Click(object sender, EventArgs e) {
     170      Dispose();
     171    }
    136172  }
    137173}
  • trunk/sources/HeuristicLab.Hive.Server.Console/3.2/HiveServerConsole.resx

    r1530 r2065  
    118118    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
    119119  </resheader>
     120  <assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
     121  <data name="pictureBox1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
     122    <value>
     123        R0lGODlh7gDTAPcAAAAAAIAAAACAAICAAAAAgIAAgACAgMDAwMDcwKbK8AQEBAgICAwMDBERERYWFhwc
     124        HCIiIikpKVVVVU1NTUJCQjk5Of98gP9QUNYAk8zs/+/Wxufn1q2pkDMAAGYAAJkAAMwAAAAzADMzAGYz
     125        AJkzAMwzAP8zAABmADNmAGZmAJlmAMxmAP9mAACZADOZAGaZAJmZAMyZAP+ZAADMADPMAGbMAJnMAMzM
     126        AP/MAGb/AJn/AMz/AAAAMzMAM2YAM5kAM8wAM/8AMwAzMzMzM2YzM5kzM8wzM/8zMwBmMzNmM2ZmM5lm
     127        M8xmM/9mMwCZMzOZM2aZM5mZM8yZM/+ZMwDMMzPMM2bMM5nMM8zMM//MMzP/M2b/M5n/M8z/M///MwAA
     128        ZjMAZmYAZpkAZswAZv8AZgAzZjMzZmYzZpkzZswzZv8zZgBmZjNmZmZmZplmZsxmZgCZZjOZZmaZZpmZ
     129        ZsyZZv+ZZgDMZjPMZpnMZszMZv/MZgD/ZjP/Zpn/Zsz/Zv8AzMwA/wCZmZkzmZkAmcwAmQAAmTMzmWYA
     130        mcwzmf8AmQBmmTNmmWYzmZlmmcxmmf8zmTOZmWaZmZmZmcyZmf+ZmQDMmTPMmWbMZpnMmczMmf/MmQD/
     131        mTP/mWbMmZn/mcz/mf//mQAAzDMAmWYAzJkAzMwAzAAzmTMzzGYzzJkzzMwzzP8zzABmzDNmzGZmmZlm
     132        zMxmzP9mmQCZzDOZzGaZzJmZzMyZzP+ZzADMzDPMzGbMzJnMzMzMzP/MzAD/zDP/zGb/mZn/zMz/zP//
     133        zDMAzGYA/5kA/wAzzDMz/2Yz/5kz/8wz//8z/wBm/zNm/2ZmzJlm/8xm//9mzACZ/zOZ/2aZ/5mZ/8yZ
     134        //+Z/wDM/zPM/2bM/5nM/8zM///M/zP//2b/zJn//8z///9mZmb/Zv//ZmZm//9m/2b//6UAIV9fX3d3
     135        d4aGhpaWlsvLy7KystfX193d3ePj4+rq6vHx8fj4+P/78KCgpICAgP8AAAD/AP//AAAA//8A/wD/////
     136        /ywAAAAA7gDTAAAI/wD/CRxIsKDBgwgTKlzIsKFDhPUydEtAsWKGDPUeatzIsaPHjyBDihxJMEPFkygp
     137        0iPJsqXLlzBjbqSXsibKjDJz6tzJs+fAiTaDUuzms6jRo0gT1hPKtCLOpFCjSmVJs6nVp1Ozat0K0arX
     138        BFzDitX69evYs2h9lv1KNK3btyxNrvWaAa7duxuXzv2KFa/fvwP3rgVM+K9cwV77Fl58FvFgxpDHHnZs
     139        tW7ky1n1UjaLuTNUwRf3WvZMuqfmsjgncy7NOufelQNVe21N+2XVsqMDz4Vdu3fIvYpPr/ZNfKPsprlL
     140        zk1evLnSvQqhO5+eULTC40zbUt8u8HZZhsC5c/+XvlD4bPHTsQtljlB9UN7oiZNnaN5q/OLubbJPmL/m
     141        /vud1ddUXuEB2FqBGvVXk4GsCciUR68xSNp8HFEoIWMKovRfQxmetOGFdzkolEgWgvgXULiJ1KFFJhYm
     142        YlAkIdgiXiV65N1wM8J1Y2UtyZijWz6SONePcK1I0YcdWUdkWjUK+diSY6H4FZI2zqUdlFvtaJ9MQWIZ
     143        VZcsvWiTl1oZmQCVIZkJH5lJNdmSmAuyCZWZaKq4nJxIwZlSUW7iGROYCNEjkUkXzaMYf336+Wai3SF3
     144        qEERKroTo/+kWB6lkn6kJVNIbvrgQkpmChOgApnpFKhDivpSqF05thCdqi7/mmp0m6G61qOxVjhrdZsl
     145        gOs/eqKUq0ieBnXlQcEOSOutw4JEaqW9UvRrshU16xGstvb6IbbWapSoqcZeumu3DHHLa7QUlYuptdSm
     146        Cx660r7LLLnZfrUmQvDGK+6T9B5kakPtNnXvQc92S2mxgg1M8Lj9lnpnQwjPxY3CBpnbcMAPRbzbQ+tm
     147        WvBA9HCT768F/dswsOsGzBTJBX3s8Vwst5wvgQw3qzFKxzaUL1gbsWqtywTlm7PONccqJV0dgatf0g83
     148        i3FH88A7D4Qw/9w0zdHGfNDNJw0tKdcVee0QvM5WnSvQC0cL0tOqWszR0YiJ7ZDbfnbsb7R1tjqvpHTP
     149        /4S3nWvJjaXdyGY9EtomRuokZSSxLSfY1cbYa1wb40k4orU2fvl9fVdJWd7qrgU6gI6PpLKHLm0unplT
     150        p06Z1g91bmLpkru6qtlLIj434y/R3iLkCQj+kdLu3i567ri7BDzqfxYtoewhnX6mTNDH53uPiMGepPMA
     151        +my86hCDT9v1LSk9afIMis8hYjypT1r1poPGE/zO6U711TKRvx39h9vPdODp4973vqMW9HEHbgIrisl6
     152        srz7NLAoUTueAisnHv99pF2ji577CrNAPu3NJ/wrzQZ79sEC8ss5IWwJAkeElBReRn86MdJnDNgbCxLL
     153        UnkaIVxgqJNkZZAlivONDv+35xWK9WSIaAHeD7GXGKm4kDBIfBuO2kRDz3ivhVNEygNbw0MGIi0rNnxL
     154        GMP0RTAKcDFK5EoRt7JCoRhxMWNk4sq20kXD4G8qCgrLE4F0xqPASSxBhEwb3yMWMS1RJluETB2Pgpyx
     155        BLIwcRwVU96YlEWmJZF6nKNk7viXKJIkP0zqY1oGuTS0vCgtZhKeKT0JxKAcsn1VFCMF0bIet1iSjqxs
     156        pU0oOZVIevCEaFGP9mYITLekES4RjNNb9kjFEq5yTHbxZQw5SUv/3AV4qpzKLXtZE15uRZrNW4s32ViT
     157        YUplm0bBZJGUeRc1hbKYb0nmSf6Czp4wMyrmeWVS7un/GlE6UkNQjOWcqAmXlLTOjv40TS51cjRzfnOW
     158        3HQmXlSzmHrCxKJaichFLoIhghploWQCaehweLL1SRAqAXNov8C5EVJ2s6RYI2AOEwpTgbB0bDStqU1z
     159        OpJj6jRBHg0nan4a0yzmhJ8l7WAPRSqqm6atLON8i0Y9hJHOgFSdhImYPssU1P5J1C/JOqiLcolUPHZ1
     160        mWf9iFNByD7GeLKsUSEezwqDzYsyNSbLw5lbIerVocKxV1EtpA4xmhW5zvOvJ+0rXyoKL5U+FJ7/Iylg
     161        DNu1jia2bF+9y84gM8Yr+mVnjs0o+AhLlnxtVSqP9JZA7ZLXWnKWp40CIGRa68rI/+xxrUWhbSkZg064
     162        anNnpzVrTu96PngF9p1+dYhLUxJcM5INM4skbViWK9PLpPap9vKMbgFqxT4q1broKk31iOuT7R6JNX3y
     163        rVgo25q66q26InwdbcDkzvE5prlj8Z10pSq/Gt4Rt2FZrVXHhUHn3Ay/aE0sgM8iqNpShzw+3Y5GLxLa
     164        yACvddQ9LFEbkyoBb/hLg2nXh1EpThmO+JlTuuyJM7mzU624mi2e64v/2WIEz5hyNb7xWSirnwrruCX0
     165        yHCMh0zkIhv5yEhOspKXzOQmw4vHTo6ylKf8ZOlR+cpYzvJQtczlLnvZdlD+spjHbGTLWJnMaE5zi5Wj
     166        5ja7mTfJyXmznOdMZOzS+c54dl6e98xnZZ2rz4DuM9ECTWg61ynMhU50kUeHaEU7+m+aavSjJz2lhgQE
     167        ADs=
     168</value>
     169  </data>
    120170</root>
  • trunk/sources/HeuristicLab.Hive.Server.Core/3.2/HeuristicLab.Hive.Server.Core-3.2.csproj

    r1941 r2065  
    8585  </ItemGroup>
    8686  <ItemGroup>
     87    <Compile Include="Authorization\HivePermissions.cs" />
     88    <Compile Include="Authorization\PermissionCollection.cs" />
     89    <Compile Include="Authorization\PermissionContext.cs" />
     90    <Compile Include="Authorization\PermissionException.cs" />
     91    <Compile Include="Authorization\Policy.cs" />
     92    <Compile Include="Authorization\PolicyCollection.cs" />
    8793    <Compile Include="ClientCommunicator.cs" />
    8894    <Compile Include="ClientFacade.cs" />
     
    9096    <Compile Include="DbTestApp.cs" />
    9197    <Compile Include="ExecutionEngineFacade.cs" />
    92     <Compile Include="HivePermissionManager.cs" />
     98    <Compile Include="Authorization\HivePermissionManager.cs" />
    9399    <Compile Include="HiveServerCorePlugin.cs" />
    94100    <Compile Include="HiveServerMessages.Designer.cs" />
     
    98104    <Compile Include="JobManager.cs" />
    99105    <Compile Include="LifecycleManager.cs" />
    100     <Compile Include="PermissiveSecurityConstants.cs" />
    101106    <Compile Include="Properties\AssemblyInfo.cs" />
    102107    <Compile Include="ServerConsoleFacade.cs" />
     
    112117    <None Include="app.config" />
    113118    <None Include="HeuristicLab.snk" />
     119    <EmbeddedResource Include="Authorization\HivePermissionSet.xsd">
     120      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     121    </EmbeddedResource>
    114122    <None Include="Properties\AssemblyInfo.frame" />
    115123    <None Include="Properties\Settings.settings">
     
    148156    </ProjectReference>
    149157  </ItemGroup>
     158  <ItemGroup>
     159    <EmbeddedResource Include="Authorization\HivePermissionSet.xml">
     160      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     161    </EmbeddedResource>
     162  </ItemGroup>
     163  <ItemGroup>
     164    <Content Include="Authorization\HivePermissionPolicy.xml" />
     165  </ItemGroup>
    150166  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    151167  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
  • trunk/sources/HeuristicLab.Hive.Server.Core/3.2/InternalInterfaces/IHivePermissionManager.cs

    r1769 r2065  
    22namespace HeuristicLab.Hive.Server.Core.InternalInterfaces {
    33  public interface IHivePermissionManager {
     4    /// <summary>
     5    /// Checks user permission against predefined policy in database.
     6    /// </summary>
     7    /// <param name="permission">the name of policy defined in xml-file</param>
     8    /// <param name="sessionID">the users current session ID</param>
     9    /// <param name="entityID"></param>
     10    /// <exception cref="PermissionException">thrown when access denied</exception>
     11    void Authorize(string policyName, Guid sessionID, Guid entityID);
    412    bool CheckPermission(Guid sessionID, Guid actionID, Guid entityId);
    513    Guid Login(string username, string password);
  • trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ServerConsoleFacade.cs

    r2005 r2065  
    2929using HeuristicLab.Security.Contracts.Interfaces;
    3030using HeuristicLab.Hive.Server.Core.InternalInterfaces;
     31using System.ServiceModel;
     32
    3133
    3234namespace HeuristicLab.Hive.Server.Core {
     
    4547      Response resp = new Response();
    4648     
    47       /*
    4849      sessionID = secMan.Login(username, password);
    4950      if (sessionID == Guid.Empty) {
     
    5556          ApplicationConstants.RESPONSE_SERVERCONSOLE_LOGIN_SUCCESS;
    5657      }
    57       */
    58       sessionID = Guid.Empty;
    59       resp.Success = true;
    60       resp.StatusMessage = ApplicationConstants.RESPONSE_SERVERCONSOLE_LOGIN_SUCCESS;
    6158      return resp;
    6259    }
     
    6461
    6562    public ResponseList<ClientInfo> GetAllClients() {
    66       if (HasPermission(PermissiveSecurityAction.List_AllClients))
    67         return clientManager.GetAllClients();
    68       else
    69         throw new PermissionException();
     63      secMan.Authorize("AccessClients", sessionID, Guid.Empty);
     64      return clientManager.GetAllClients();
    7065    }
    7166
    7267    public ResponseList<ClientGroup> GetAllClientGroups() {
    73       if (HasPermission(PermissiveSecurityAction.List_AllClientGroups))
    74         return clientManager.GetAllClientGroups();
    75       else
    76         throw new PermissionException();
     68      secMan.Authorize("AccessClientGroup", sessionID, Guid.Empty);
     69      return clientManager.GetAllClientGroups();
    7770    }
    7871
    7972    public ResponseList<UpTimeStatistics> GetAllUpTimeStatistics() {
    80       if (HasPermission(PermissiveSecurityAction.Show_Statistics))
    81         return clientManager.GetAllUpTimeStatistics();
    82       else
    83         throw new PermissionException();
     73      secMan.Authorize("AccessStatistics", sessionID, Guid.Empty);
     74      return clientManager.GetAllUpTimeStatistics();
    8475    }
    8576
    8677    public ResponseObject<ClientGroup> AddClientGroup(ClientGroup clientGroup) {
    87       if (HasPermission(PermissiveSecurityAction.Add_ClientGroup))
    88         return clientManager.AddClientGroup(clientGroup);
    89       else
    90         throw new PermissionException();
     78      secMan.Authorize("AddClientGroup", sessionID, Guid.Empty);
     79      return clientManager.AddClientGroup(clientGroup);
    9180    }
    9281
    9382    public Response AddResourceToGroup(Guid clientGroupId, Resource resource) {
    94       if (HasPermission(PermissiveSecurityAction.Add_Resource))
    95         return clientManager.AddResourceToGroup(clientGroupId, resource);
    96       else
    97         throw new PermissionException();
     83      secMan.Authorize("AddResource", sessionID, Guid.Empty);               
     84      return clientManager.AddResourceToGroup(clientGroupId, resource);
    9885    }
    9986
    10087    public Response DeleteResourceFromGroup(Guid clientGroupId, Guid resourceId) {
    101       if (HasPermission(PermissiveSecurityAction.Delete_Resource))
    10288        return clientManager.DeleteResourceFromGroup(clientGroupId, resourceId);
    103       else
    104         throw new PermissionException();
    10589    }
    10690
    107 
    108     public ResponseList<HeuristicLab.Hive.Contracts.BusinessObjects.Job> GetAllJobs() {
    109       if (HasPermission(PermissiveSecurityAction.Get_AllJobs))
    110         return jobManager.GetAllJobs();
    111       else
    112         throw new PermissionException();
     91    public ResponseList<Job> GetAllJobs() {
     92      secMan.Authorize("AccessJobs", sessionID, Guid.Empty);
     93      return jobManager.GetAllJobs();
    11394    }
    11495
    115     public ResponseObject<HeuristicLab.Hive.Contracts.BusinessObjects.Job> GetJobById(Guid jobId) {
     96    public ResponseObject<Job> GetJobById(Guid jobId) {
     97      secMan.Authorize("AccessJobs", sessionID, jobId);
    11698      return jobManager.GetJobById(jobId);
    11799    }
    118100
    119101    public ResponseObject<Job> AddNewJob(Job job) {
    120       if (HasPermission(PermissiveSecurityAction.Add_Job))
    121         return jobManager.AddNewJob(job);
    122       else
    123         throw new PermissionException();
     102      secMan.Authorize("AddJob", sessionID, job.Id);
     103      return jobManager.AddNewJob(job);
    124104    }
    125105
    126106    public ResponseObject<JobResult> GetLastJobResultOf(Guid jobId, bool requested) {
    127       if (HasPermission(PermissiveSecurityAction.Get_LastJobResult))
    128         return jobManager.GetLastJobResultOf(jobId, requested);
    129       else
    130         throw new PermissionException();
     107      secMan.Authorize("AccessJobResults", sessionID, jobId);
     108      return jobManager.GetLastJobResultOf(jobId, requested);
    131109    }
    132110
    133111    public ResponseList<JobResult> GetAllJobResults(Guid jobId) {
    134       if (HasPermission(PermissiveSecurityAction.Get_AllJobResults))
    135         return jobManager.GetAllJobResults(jobId);
    136       else
    137         throw new PermissionException();
     112      secMan.Authorize("AccessJobResults", sessionID, jobId); 
     113      return jobManager.GetAllJobResults(jobId);
    138114    }
    139115
    140116    public Response RemoveJob(Guid jobId) {
    141       if (HasPermission(PermissiveSecurityAction.Remove_Job))
    142         return jobManager.RemoveJob(jobId);
    143       else
    144         throw new PermissionException();
     117      secMan.Authorize("RemoveJob", sessionID, jobId);
     118      return jobManager.RemoveJob(jobId);
    145119    }
    146120
    147121    public Response RequestSnapshot(Guid jobId) {
    148       if (HasPermission(PermissiveSecurityAction.Request_Snapshot))
    149         return jobManager.RequestSnapshot(jobId);
    150       else
    151         throw new PermissionException();
     122      secMan.Authorize("AccessJobResults", sessionID, jobId); 
     123      return jobManager.RequestSnapshot(jobId);
    152124    }
    153125
    154126    public Response AbortJob(Guid jobId) {
    155       if (HasPermission(PermissiveSecurityAction.Abort_Job))
    156         return jobManager.AbortJob(jobId);
    157       else
    158         throw new PermissionException();
     127      secMan.Authorize("AbortJob", sessionID, Guid.Empty);
     128      return jobManager.AbortJob(jobId);
    159129    }
    160130
    161131    public ResponseObject<List<ClientGroup>> GetAllGroupsOfResource(Guid resourceId) {
    162       if (HasPermission(PermissiveSecurityAction.Get_AllGroupsOfResource))
    163         return clientManager.GetAllGroupsOfResource(resourceId);
    164       else
    165         throw new PermissionException();     
     132      secMan.Authorize("AccessUserGroup", sessionID, Guid.Empty);
     133      return clientManager.GetAllGroupsOfResource(resourceId);
    166134    }
    167135
    168136    public Response DeleteClientGroup(Guid clientGroupId) {
     137      secMan.Authorize("DeleteClientGroup", sessionID, Guid.Empty);
    169138      return clientManager.DeleteClientGroup(clientGroupId);
    170139    }
    171140
    172   /*
    173     private bool HasPermission(Guid action) {
    174       return (sessionID == Guid.Empty) ? false : secMan.CheckPermission(sessionID, action, Guid.Empty);
    175     }
    176 
    177     private bool HasPermission(Guid action, Guid entityId) {
    178       return (sessionID == Guid.Empty) ? false : secMan.CheckPermission(sessionID, action, entityId);
    179     }
    180    */
    181 
    182     [Obsolete("Only for testing!")]
    183     private bool HasPermission(Guid g) { return true; }
    184     [Obsolete("Only for testing!")]
    185     private bool HasPermission(Guid g, Guid f) { return true; }
    186 
    187     public class PermissionException : Exception {
    188       public PermissionException()
    189         : base("Current user has insufficent rights for this action!") {
    190       }
    191 
    192       public PermissionException(string msg)
    193         : base(msg) {
    194       }
    195 
    196 
    197     }
    198 
    199141    public ResponseList<Project> GetAllProjects() {
     142      secMan.Authorize("AccessProjects", sessionID, Guid.Empty);
    200143      return jobManager.GetAllProjects();
    201144    }
    202145
    203146    public Response CreateProject(Project project) {
     147      secMan.Authorize("CreateProjects", sessionID, Guid.Empty);
    204148      return jobManager.CreateProject(project);
    205149    }
    206150
    207151    public Response ChangeProject(Project project) {
     152      secMan.Authorize("ChangeProjects", sessionID, Guid.Empty);
    208153      return jobManager.ChangeProject(project);
    209154    }
    210155
    211156    public Response DeleteProject(Guid projectId) {
     157      secMan.Authorize("DeleteProjects", sessionID, projectId);
    212158      return jobManager.DeleteProject(projectId);
    213159    }
    214160
    215161    public ResponseList<Job> GetJobsByProject(Guid projectId) {
     162      secMan.Authorize("AccessJobs", sessionID, Guid.Empty);
    216163      return jobManager.GetJobsByProject(projectId);
    217164    }
  • trunk/sources/HeuristicLab.Hive.Server/3.2/HeuristicLab.Hive.Server-3.2.csproj

    r1534 r2065  
    112112      <AutoGen>True</AutoGen>
    113113      <DependentUpon>Resources.resx</DependentUpon>
     114      <DesignTime>True</DesignTime>
    114115    </Compile>
    115116    <None Include="Properties\AssemblyInfo.frame" />
     
    139140    </ProjectReference>
    140141  </ItemGroup>
     142  <ItemGroup>
     143    <None Include="Resources\HeuristicLab.ico" />
     144  </ItemGroup>
    141145  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    142146  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
  • trunk/sources/HeuristicLab.Hive.Server/3.2/HiveServerApplication.cs

    r1939 r2065  
    3030using HeuristicLab.Hive.Contracts;
    3131using HeuristicLab.Hive.Contracts.Interfaces;
     32using HeuristicLab.Hive.Server.Properties;
    3233
    3334namespace HeuristicLab.Hive.Server {
     
    158159
    159160        lifecycleManager.Init();
    160 
    161161        Form mainForm = new MainForm(baseAddrDict);
    162 
    163162        Application.Run(mainForm);
    164 
     163       
    165164        lifecycleManager.Shutdown();
    166165      }
  • trunk/sources/HeuristicLab.Hive.Server/3.2/MainForm.Designer.cs

    r1530 r2065  
    2929        private void InitializeComponent()
    3030        {
     31          this.components = new System.ComponentModel.Container();
    3132          this.label1 = new System.Windows.Forms.Label();
    32           this.lblAddress1 = new System.Windows.Forms.Label();
    33           this.label2 = new System.Windows.Forms.Label();
    34           this.lblAddress2 = new System.Windows.Forms.Label();
    35           this.label3 = new System.Windows.Forms.Label();
    36           this.lblAddress3 = new System.Windows.Forms.Label();
     33          this.rtfServices = new System.Windows.Forms.RichTextBox();
     34          this.ni = new System.Windows.Forms.NotifyIcon(this.components);
     35          this.ctxNotifyMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
     36          this.tsShowInfo = new System.Windows.Forms.ToolStripMenuItem();
     37          this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
     38          this.tsExit = new System.Windows.Forms.ToolStripMenuItem();
     39          this.btnClose = new System.Windows.Forms.Button();
     40          this.ctxNotifyMenu.SuspendLayout();
    3741          this.SuspendLayout();
    3842          //
     
    4044          //
    4145          this.label1.AutoSize = true;
    42           this.label1.Location = new System.Drawing.Point(18, 18);
     46          this.label1.Location = new System.Drawing.Point(12, 9);
    4347          this.label1.Name = "label1";
    44           this.label1.Size = new System.Drawing.Size(183, 13);
     48          this.label1.Size = new System.Drawing.Size(97, 13);
    4549          this.label1.TabIndex = 0;
    46           this.label1.Text = "Hive Server Client Facade running @";
     50          this.label1.Text = "Available Services:";
    4751          //
    48           // lblAddress1
     52          // rtfServices
    4953          //
    50           this.lblAddress1.AutoSize = true;
    51           this.lblAddress1.Location = new System.Drawing.Point(18, 43);
    52           this.lblAddress1.Name = "lblAddress1";
    53           this.lblAddress1.Size = new System.Drawing.Size(44, 13);
    54           this.lblAddress1.TabIndex = 1;
    55           this.lblAddress1.Text = "address";
     54          this.rtfServices.Location = new System.Drawing.Point(12, 25);
     55          this.rtfServices.Name = "rtfServices";
     56          this.rtfServices.ReadOnly = true;
     57          this.rtfServices.Size = new System.Drawing.Size(280, 121);
     58          this.rtfServices.TabIndex = 1;
     59          this.rtfServices.Text = "";
    5660          //
    57           // label2
     61          // ni
    5862          //
    59           this.label2.AutoSize = true;
    60           this.label2.Location = new System.Drawing.Point(18, 76);
    61           this.label2.Name = "label2";
    62           this.label2.Size = new System.Drawing.Size(195, 13);
    63           this.label2.TabIndex = 2;
    64           this.label2.Text = "Hive Server Console Facade running @";
     63          this.ni.ContextMenuStrip = this.ctxNotifyMenu;
     64          this.ni.Text = "notifyIcon1";
     65          this.ni.Visible = true;
    6566          //
    66           // lblAddress2
     67          // ctxNotifyMenu
    6768          //
    68           this.lblAddress2.AutoSize = true;
    69           this.lblAddress2.Location = new System.Drawing.Point(18, 102);
    70           this.lblAddress2.Name = "lblAddress2";
    71           this.lblAddress2.Size = new System.Drawing.Size(44, 13);
    72           this.lblAddress2.TabIndex = 3;
    73           this.lblAddress2.Text = "address";
     69          this.ctxNotifyMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
     70            this.tsShowInfo,
     71            this.toolStripSeparator1,
     72            this.tsExit});
     73          this.ctxNotifyMenu.Name = "ctxNotifyMenu";
     74          this.ctxNotifyMenu.Size = new System.Drawing.Size(106, 54);
    7475          //
    75           // label3
     76          // tsShowInfo
    7677          //
    77           this.label3.AutoSize = true;
    78           this.label3.Location = new System.Drawing.Point(18, 131);
    79           this.label3.Name = "label3";
    80           this.label3.Size = new System.Drawing.Size(206, 13);
    81           this.label3.TabIndex = 4;
    82           this.label3.Text = "Hive Execution Engine Facade running @";
     78          this.tsShowInfo.Name = "tsShowInfo";
     79          this.tsShowInfo.Size = new System.Drawing.Size(105, 22);
     80          this.tsShowInfo.Text = "&Info";
     81          this.tsShowInfo.Click += new System.EventHandler(this.ShowInfo);
    8382          //
    84           // lblAddress3
     83          // toolStripSeparator1
    8584          //
    86           this.lblAddress3.AutoSize = true;
    87           this.lblAddress3.Location = new System.Drawing.Point(18, 159);
    88           this.lblAddress3.Name = "lblAddress3";
    89           this.lblAddress3.Size = new System.Drawing.Size(44, 13);
    90           this.lblAddress3.TabIndex = 5;
    91           this.lblAddress3.Text = "address";
     85          this.toolStripSeparator1.Name = "toolStripSeparator1";
     86          this.toolStripSeparator1.Size = new System.Drawing.Size(102, 6);
     87          //
     88          // tsExit
     89          //
     90          this.tsExit.Name = "tsExit";
     91          this.tsExit.Size = new System.Drawing.Size(105, 22);
     92          this.tsExit.Text = "E&xit";
     93          this.tsExit.Click += new System.EventHandler(this.CloseApp);
     94          //
     95          // btnClose
     96          //
     97          this.btnClose.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     98          this.btnClose.Location = new System.Drawing.Point(279, 1);
     99          this.btnClose.Name = "btnClose";
     100          this.btnClose.Size = new System.Drawing.Size(22, 21);
     101          this.btnClose.TabIndex = 2;
     102          this.btnClose.Text = "X";
     103          this.btnClose.UseVisualStyleBackColor = true;
     104          this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
    92105          //
    93106          // MainForm
    94107          //
     108          this.AcceptButton = this.btnClose;
    95109          this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    96110          this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    97           this.ClientSize = new System.Drawing.Size(304, 181);
    98           this.Controls.Add(this.lblAddress3);
    99           this.Controls.Add(this.label3);
    100           this.Controls.Add(this.lblAddress2);
    101           this.Controls.Add(this.label2);
    102           this.Controls.Add(this.lblAddress1);
     111          this.CancelButton = this.btnClose;
     112          this.ClientSize = new System.Drawing.Size(304, 166);
     113          this.ControlBox = false;
     114          this.Controls.Add(this.btnClose);
     115          this.Controls.Add(this.rtfServices);
    103116          this.Controls.Add(this.label1);
     117          this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
    104118          this.Name = "MainForm";
     119          this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
    105120          this.Text = "Hive Server";
     121          this.TopMost = true;
     122          this.ctxNotifyMenu.ResumeLayout(false);
    106123          this.ResumeLayout(false);
    107124          this.PerformLayout();
     
    112129
    113130        private System.Windows.Forms.Label label1;
    114         private System.Windows.Forms.Label lblAddress1;
    115         private System.Windows.Forms.Label label2;
    116         private System.Windows.Forms.Label lblAddress2;
    117         private System.Windows.Forms.Label label3;
    118         private System.Windows.Forms.Label lblAddress3;
     131        private System.Windows.Forms.RichTextBox rtfServices;
     132        private System.Windows.Forms.NotifyIcon ni;
     133        private System.Windows.Forms.ContextMenuStrip ctxNotifyMenu;
     134        private System.Windows.Forms.ToolStripMenuItem tsShowInfo;
     135        private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
     136        private System.Windows.Forms.ToolStripMenuItem tsExit;
     137        private System.Windows.Forms.Button btnClose;
    119138    }
    120139}
  • trunk/sources/HeuristicLab.Hive.Server/3.2/MainForm.cs

    r1530 r2065  
    77using System.Text;
    88using System.Windows.Forms;
     9using HeuristicLab.Hive.Server.Properties;
    910
    1011namespace HeuristicLab.Hive.Server
     
    1314        public MainForm(Dictionary<string, Uri> addresses) {
    1415          InitializeComponent();
     16          this.Visible = false;
     17
    1518          Uri uri;
     19          StringBuilder servicesTxt = new StringBuilder();
    1620          addresses.TryGetValue(HiveServerApplication.STR_ClientCommunicator, out uri);
    17           if(uri!=null)
    18             this.lblAddress1.Text = uri.ToString();
     21          if (uri != null)
     22            servicesTxt.AppendLine(String.Format("Server Client: {0}", uri));
    1923          addresses.TryGetValue(HiveServerApplication.STR_ServerConsoleFacade, out uri);
    2024          if (uri != null)
    21             this.lblAddress2.Text = uri.ToString();
     25            servicesTxt.AppendLine(String.Format("Server Console: {0}", uri));
    2226          addresses.TryGetValue(HiveServerApplication.STR_ExecutionEngineFacade, out uri);
    2327          if (uri != null)
    24             this.lblAddress3.Text = uri.ToString();
     28            servicesTxt.AppendLine(String.Format("Execution Engine: {0}", uri));
     29
     30          rtfServices.AppendText(servicesTxt.ToString());
     31
     32          ni.Icon = Resources.HeuristicLab;
     33          ni.BalloonTipTitle = "HL Hive Server Services";
     34          ni.BalloonTipText = servicesTxt.ToString();
     35          ni.BalloonTipIcon = ToolTipIcon.Info;
     36          ni.Text = "HL Hive Server Services";
     37          ni.ShowBalloonTip(10000);
     38        }
     39
     40        private void CloseApp(object sender, EventArgs e) {
     41          Dispose();
     42        }
     43
     44        private void ShowInfo(object sender, EventArgs e) {
     45          this.Visible = true;
     46        }
     47
     48        private void btnClose_Click(object sender, EventArgs e) {
     49          this.Visible = false;
    2550        }
    2651
  • trunk/sources/HeuristicLab.Hive.Server/3.2/MainForm.resx

    r1530 r2065  
    118118    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
    119119  </resheader>
     120  <metadata name="ni.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     121    <value>17, 17</value>
     122  </metadata>
     123  <metadata name="ctxNotifyMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     124    <value>77, 17</value>
     125  </metadata>
    120126</root>
  • trunk/sources/HeuristicLab.Hive.Server/3.2/Properties/Resources.Designer.cs

    r713 r2065  
    22// <auto-generated>
    33//     This code was generated by a tool.
    4 //     Runtime Version:2.0.50727.3053
     4//     Runtime Version:2.0.50727.3082
    55//
    66//     Changes to this file may cause incorrect behavior and will be lost if
     
    99//------------------------------------------------------------------------------
    1010
    11 namespace HeuristicLab.Hive.Server.Properties
    12 {
    13 
    14 
     11namespace HeuristicLab.Hive.Server.Properties {
     12    using System;
     13   
     14   
    1515    /// <summary>
    1616    ///   A strongly-typed resource class, for looking up localized strings, etc.
     
    2323    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    2424    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
    25     internal class Resources
    26     {
    27 
     25    internal class Resources {
     26       
    2827        private static global::System.Resources.ResourceManager resourceMan;
    29 
     28       
    3029        private static global::System.Globalization.CultureInfo resourceCulture;
    31 
     30       
    3231        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
    33         internal Resources()
    34         {
     32        internal Resources() {
    3533        }
    36 
     34       
    3735        /// <summary>
    3836        ///   Returns the cached ResourceManager instance used by this class.
    3937        /// </summary>
    4038        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
    41         internal static global::System.Resources.ResourceManager ResourceManager
    42         {
    43             get
    44             {
    45                 if ((resourceMan == null))
    46                 {
     39        internal static global::System.Resources.ResourceManager ResourceManager {
     40            get {
     41                if (object.ReferenceEquals(resourceMan, null)) {
    4742                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("HeuristicLab.Hive.Server.Properties.Resources", typeof(Resources).Assembly);
    4843                    resourceMan = temp;
     
    5146            }
    5247        }
    53 
     48       
    5449        /// <summary>
    5550        ///   Overrides the current thread's CurrentUICulture property for all
     
    5752        /// </summary>
    5853        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
    59         internal static global::System.Globalization.CultureInfo Culture
    60         {
    61             get
    62             {
     54        internal static global::System.Globalization.CultureInfo Culture {
     55            get {
    6356                return resourceCulture;
    6457            }
    65             set
    66             {
     58            set {
    6759                resourceCulture = value;
     60            }
     61        }
     62       
     63        internal static System.Drawing.Icon HeuristicLab {
     64            get {
     65                object obj = ResourceManager.GetObject("HeuristicLab", resourceCulture);
     66                return ((System.Drawing.Icon)(obj));
    6867            }
    6968        }
  • trunk/sources/HeuristicLab.Hive.Server/3.2/Properties/Resources.resx

    r713 r2065  
    4747    mimetype: application/x-microsoft.net.object.binary.base64
    4848    value   : The object must be serialized with
    49             : System.Serialization.Formatters.Binary.BinaryFormatter
     49            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
    5050            : and then encoded with base64 encoding.
    5151   
     
    6161    -->
    6262  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
     63    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
    6364    <xsd:element name="root" msdata:IsDataSet="true">
    6465      <xsd:complexType>
     
    6970                <xsd:element name="value" type="xsd:string" minOccurs="0" />
    7071              </xsd:sequence>
    71               <xsd:attribute name="name" type="xsd:string" />
     72              <xsd:attribute name="name" use="required" type="xsd:string" />
    7273              <xsd:attribute name="type" type="xsd:string" />
    7374              <xsd:attribute name="mimetype" type="xsd:string" />
     75              <xsd:attribute ref="xml:space" />
    7476            </xsd:complexType>
    7577          </xsd:element>
     
    8688                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
    8789              </xsd:sequence>
    88               <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
     90              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
    8991              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
    9092              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
     93              <xsd:attribute ref="xml:space" />
    9194            </xsd:complexType>
    9295          </xsd:element>
     
    115118    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
    116119  </resheader>
     120  <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
     121  <data name="HeuristicLab" type="System.Resources.ResXFileRef, System.Windows.Forms">
     122    <value>..\Resources\HeuristicLab.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
     123  </data>
    117124</root>
  • trunk/sources/HeuristicLab.Security.Core/3.2/SecurityCoreTest.cs

    r1771 r2065  
    66using HeuristicLab.Security.Contracts.BusinessObjects;
    77using HeuristicLab.Hive.Server.Core;
     8using System.Diagnostics;
    89
    910namespace HeuristicLab.Security.Core {
    1011    [ClassInfo(Name = "Security Test App",
    1112        Description = "Test Application for the Security Service",
    12         AutoRestart = true)]
     13        AutoRestart = false)]
    1314  class SecurityCoreTest : ApplicationBase {
    1415
     
    166167        manager.RemovePermission(permission.Id);
    167168      }
    168       #region TEST DATA INSERT SECTION for MB
    169 
    170       private void InsertTestDataForPermissionCheck() {
    171         int numberOfUsers = 10;
    172 
    173         List<User> users = new List<User>();
    174         for (int i = 0; i < numberOfUsers; i++) {
    175           users.Add(MB_InsertTestUser());
    176         }
    177         MB_AssignGroups(users);
    178        
    179       }
    180 
    181       private User MB_InsertTestUser() {
    182         Random rand = new Random(DateTime.Now.Millisecond);
    183         int usr = rand.Next(1000);
    184         User user = new User();
    185         user.Login = "test" + usr.ToString();
    186         user.SetHashedPassword("test");
    187         user.Name = "test" + usr.ToString();
    188         return manager.AddNewUser(user);
    189       }
    190 
    191       /// <summary>
    192       /// Splits the given users into two groups and assigns them. Some will be not assigned.
    193       /// </summary>
    194       /// <param name="users"></param>
    195       private void MB_AssignGroups(List<User> users) {
    196         UserGroup group01 = new UserGroup();
    197         group01.Name = "Test Group 01";
    198 
    199         UserGroup group02 = new UserGroup();
    200         group02.Name = "Test Group 02";
    201 
    202         //three-way split users into group1, group2 and none
    203         int idx = users.Count / 3;
    204         for (int i = 0; i < idx; i++) {
    205           group01.Members.Add(users[i]);
    206         }
    207         for (int i = idx; i < users.Count / 2; i++) {
    208           group02.Members.Add(users[i]);
    209         }
    210         manager.AddNewUserGroup(group01);
    211         manager.AddNewUserGroup(group02);
    212        
    213       }
    214 
    215       private void MB_AddPermission(List<User> users) {
    216         if (users.Count < 2) return;
    217         /*
    218         Permission permission = new Permission();
    219         //permission.Id = PermissiveSecurityAction.Add_Job;
    220         permission.Name = "ADD_JOB";
    221         permission.Description = "Add new jobs";
    222         permission.Plugin = "HeuristicLab.Hive.Server";
    223         manager.AddPermission(permission);
    224         */
    225         //grant permission to random users
    226         Random rand = new Random(DateTime.Now.Millisecond);
    227         for (int i = 0; i < users.Count/2; i++) {
    228           int idx = rand.Next(users.Count);
    229           //manager.GrantPermission(users[i].Id, permission.Id, Guid.Empty);
    230           manager.GrantPermission(users[i].Id, PermissiveSecurityAction.Add_Job, Guid.Empty);
    231         }
    232       }
    233 
    234       #endregion
     169 
     170
     171      public void InsertClientUser() {
     172        PermissionCollection pc = HivePermissions.GetPermissions();
     173        Debug.WriteLine("Revoke permissions....");
     174        try {
     175          UserGroup group = manager.GetUserGroupByName("Projektmitglieder");
     176          manager.RevokePermission(group.Id, pc[pc.Convert(HivePermissions.Usermanagement.Client.Read)].Id, Guid.Empty);
     177          manager.RevokePermission(group.Id, pc[pc.Convert(HivePermissions.Usermanagement.ClientGroup.Read)].Id, Guid.Empty);
     178        }
     179        catch (Exception ex) {
     180          Debug.WriteLine(ex.Message);
     181        }
     182        Debug.WriteLine("Remove user...");
     183        try {
     184          manager.RemoveUser(manager.GetUserByName("HIVE User").Id);
     185        }
     186        catch (Exception ex) {
     187          Debug.WriteLine(ex.Message);
     188        }
     189        Debug.WriteLine("Remove group....");
     190        try {
     191          manager.RemoveUserGroup(manager.GetUserGroupByName("Projektmitglieder").Id);
     192        }
     193        catch (Exception ex) {
     194          Debug.WriteLine(ex.Message);
     195        }
     196
     197        User user = new User();
     198        user.Login = "hive";
     199        user.SetHashedPassword("hive");
     200        user.Name = "HIVE User";
     201        Debug.WriteLine("Adding user...");
     202        try {
     203          user = manager.AddNewUser(user);
     204        }
     205        catch (Exception ex) {
     206          Debug.WriteLine(ex.Message);
     207        }
     208
     209        UserGroup grp = new UserGroup();
     210        grp.Name = "Projektmitglieder";
     211        grp.Members.Add(user);
     212        Debug.WriteLine("Adding group...");
     213        try {
     214          manager.AddNewUserGroup(grp);
     215        }
     216        catch (Exception ex) {
     217          Debug.WriteLine(ex.Message);
     218        }
     219        Debug.WriteLine("Grant permissions...");
     220        try {
     221          manager.GrantPermission(grp.Id, pc[pc.Convert(HivePermissions.Usermanagement.Client.Read)].Id, Guid.Empty);
     222          manager.GrantPermission(grp.Id, pc[pc.Convert(HivePermissions.Usermanagement.ClientGroup.Read)].Id, Guid.Empty);
     223        }
     224        catch (Exception ex) {
     225          Debug.WriteLine(ex.Message);
     226        }
     227      }
     228
     229      public void InsertSuperUser() {
     230        Debug.WriteLine("Revoke permissions...");
     231        try {
     232          UserGroup group = manager.GetUserGroupByName("Administratoren");
     233          foreach (Permission item in HivePermissions.GetPermissions()) {
     234            manager.RevokePermission(group.Id, item.Id, Guid.Empty);
     235          }
     236        }
     237        catch (Exception ex) {
     238          Debug.WriteLine(ex.Message);
     239        }
     240        Debug.WriteLine("Revoke permissions from admin...");
     241        try {
     242          Guid g = manager.GetUserByName("HIVE Admin").Id;
     243          foreach (Permission item in HivePermissions.GetPermissions()) {
     244            manager.RevokePermission(g, item.Id, Guid.Empty);
     245          }
     246        }
     247        catch (Exception ex) {
     248          Debug.WriteLine(ex.Message);
     249        }
     250        Debug.WriteLine("Removing user...");
     251        try {
     252          manager.RemoveUser(manager.GetUserByName("HIVE Admin").Id);
     253        }
     254        catch (Exception ex) {
     255          Debug.WriteLine(ex.Message);
     256        }
     257        Debug.WriteLine("Removing group...");
     258        try {
     259          manager.RemoveUserGroup(manager.GetUserGroupByName("Administratoren").Id);
     260        }
     261        catch (Exception ex) {
     262          Debug.WriteLine(ex.Message);
     263        }
     264
     265        User user = new User();
     266        user.Login = "admin";
     267        user.SetHashedPassword("admin");
     268        user.Name = "HIVE Admin";
     269        Debug.WriteLine("Grant ALL permissions to admin...");
     270        foreach (Permission item in HivePermissions.GetPermissions()) {
     271          manager.GrantPermission(user.Id, item.Id, Guid.Empty);
     272        }
     273        Debug.WriteLine("Adding user...");
     274        try {
     275          user = manager.AddNewUser(user);
     276        }
     277        catch (Exception ex) {
     278          Debug.WriteLine(ex.Message);
     279        }
     280
     281        UserGroup grp = new UserGroup();
     282        grp.Name = "Administratoren";
     283        grp.Members.Add(user);
     284        Debug.WriteLine("Adding group...");
     285        try {
     286          manager.AddNewUserGroup(grp);
     287        }
     288        catch (Exception ex) {
     289          Debug.WriteLine(ex.Message);
     290        }
     291        Debug.WriteLine("Adding permissions...");
     292        //admins allowed to do everything ;)
     293        foreach (Permission item in HivePermissions.GetPermissions()) {
     294          manager.GrantPermission(grp.Id, item.Id, Guid.Empty);
     295        }
     296      }
     297
     298      public void InsertHivePermissions() {
     299        foreach (Permission item in HivePermissions.GetPermissions()) {
     300          try {
     301            manager.AddPermission(item);
     302          }
     303          catch (Exception ex) {
     304            Debug.WriteLine(ex.Message);
     305          }
     306        }
     307      }
     308
    235309      public override void Run() {
    236310        //testPermissionsGroup();
    237         InsertTestDataForPermissionCheck();
     311       
     312        InsertHivePermissions();
     313        InsertClientUser();
     314        InsertSuperUser();
     315        Debug.WriteLine("Complete!");
    238316      }
    239317    }
Note: See TracChangeset for help on using the changeset viewer.