Free cookie consent management tool by TermsFeed Policy Generator

Changeset 6362 for branches


Ignore:
Timestamp:
06/06/11 10:31:53 (13 years ago)
Author:
cneumuel
Message:

#1233

  • changed roles authentication to use an AuthenticationManager instead of method attributes. this makes unit tests easier.
Location:
branches/HeuristicLab.Hive-3.4/sources
Files:
3 added
8 edited

Legend:

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

    r6361 r6362  
    361361  </ItemGroup>
    362362  <ItemGroup>
    363     <ProjectReference Include="..\HeuristicLab.Clients.Hive.Slave.ConsoleClient-3.4\HeuristicLab.Clients.Hive.Slave.ConsoleClient-3.4.csproj">
     363    <ProjectReference Include="..\..\..\HeuristicLab.Clients.Hive.Slave.ConsoleClient\HeuristicLab.Clients.Hive.Slave.ConsoleClient-3.4.csproj">
    364364      <Project>{464D70B8-2D91-485C-B622-22E4A4891C68}</Project>
    365365      <Name>HeuristicLab.Clients.Hive.Slave.ConsoleClient-3.4</Name>
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.HiveEngine/3.4/Tests/HeuristicLab.HiveEngine-3.4.Tests.csproj

    r6361 r6362  
    138138    <None Include="app_services.config" />
    139139    <None Include="app.config" />
    140     <None Include="Meta-GA - Meta Optimization Problem %28Genetic Programming - Symbolic Regression 3.4 scaled%29_small.hl">
    141       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    142     </None>
    143140  </ItemGroup>
    144141  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Tests/HeuristicLab.Services.Hive-3.4.Tests.csproj

    r6357 r6362  
    7171  </ItemGroup>
    7272  <ItemGroup>
     73    <Compile Include="Mocks\MockAuthenticationManager.cs" />
    7374    <Compile Include="ServiceTests.cs" />
    7475    <Compile Include="Mocks\MockAuthorizationManager.cs" />
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Tests/Mocks/MockServiceLocator.cs

    r5405 r6362  
    3030      this.defaultServiceLocator = defaultServiceLocator;
    3131    }
     32   
     33    public IAuthenticationManager AuthenticationManager {
     34      get { return new MockAuthenticationManager(); }
     35    }
    3236
    3337    public IAuthorizationManager AuthorizationManager {
     
    5458      }
    5559    }
     60
    5661  }
    5762}
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/HeuristicLab.Services.Hive-3.4.csproj

    r5852 r6362  
    108108    <None Include="HeuristicLabServicesHivePlugin.cs.frame" />
    109109    <None Include="Properties\AssemblyInfo.cs.frame" />
     110    <Compile Include="AuthenticationManager.cs" />
    110111    <Compile Include="HeartbeatManager.cs" />
     112    <Compile Include="Interfaces\IAuthenticationManager.cs" />
    111113    <Compile Include="Interfaces\ILifecycleManager.cs" />
    112114    <Compile Include="Interfaces\IServiceLocator.cs" />
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/HiveService.cs

    r6267 r6362  
    2121      get { return ServiceLocator.Instance.TransactionManager; }
    2222    }
    23     private IAuthorizationManager auth {
     23    private IAuthenticationManager authen {
     24      get { return ServiceLocator.Instance.AuthenticationManager; }
     25    }
     26    private IAuthorizationManager author {
    2427      get { return ServiceLocator.Instance.AuthorizationManager; }
    2528    }
     
    3235
    3336    #region Job Methods
    34     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
    35     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
    3637    public Guid AddJob(Job job, JobData jobData, IEnumerable<Guid> resourceIds) {
     38      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    3739      return trans.UseTransaction(() => {
    3840        job.Id = dao.AddJob(job);
     
    4749        }
    4850        dao.AddJobData(jobData);
    49         dao.UpdateJobState(job.Id, JobState.Waiting, null, auth.UserId, null);
     51        dao.UpdateJobState(job.Id, JobState.Waiting, null, author.UserId, null);
    5052        return jobData.JobId;
    5153      });
    5254    }
    5355
    54     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
    55     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
    5656    public Guid AddChildJob(Guid parentJobId, Job job, JobData jobData) {
     57      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    5758      return trans.UseTransaction(() => {
    5859        job.ParentJobId = parentJobId;
     
    6162    }
    6263
    63     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
    64     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
    65     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
    6664    public Job GetJob(Guid jobId) {
     65      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    6766      return dao.GetJob(jobId);
    6867    }
    6968
    70     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
    71     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
    7269    public IEnumerable<Job> GetJobs() {
     70      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    7371      return dao.GetJobs(x => true);
    7472    }
    7573
    76     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
    77     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
    7874    public IEnumerable<LightweightJob> GetLightweightJobs(IEnumerable<Guid> jobIds) {
     75      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    7976      return dao.GetJobs(x => jobIds.Contains(x.JobId)).Select(x => new LightweightJob(x)).ToArray();
    8077    }
    8178
    82     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
    83     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
    8479    public IEnumerable<LightweightJob> GetLightweightChildJobs(Guid? parentJobId, bool recursive, bool includeParent) {
     80      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    8581      return GetChildJobs(parentJobId, recursive, includeParent).Select(x => new LightweightJob(x)).ToArray();
    8682    }
    8783
    88     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
    89     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
    9084    public IEnumerable<LightweightJob> GetLightweightExperimentJobs(Guid experimentId) {
     85      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    9186      return dao.GetJobs(x => x.HiveExperimentId == experimentId).Select(x => new LightweightJob(x)).ToArray();
    9287    }
    9388
    94     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
    95     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
    96     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
    9789    public JobData GetJobData(Guid jobId) {
     90      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    9891      return dao.GetJobData(jobId);
    9992    }
    10093
    101     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
    102     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
    103     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
    10494    public void UpdateJob(Job job) {
     95      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    10596      trans.UseTransaction(() => {
    10697        dao.UpdateJob(job);
     
    10899    }
    109100
    110     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
    111     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
    112     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
    113101    public void UpdateJobData(Job job, JobData jobData) {
     102      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    114103      trans.UseTransaction(() => {
    115104        jobData.LastUpdate = DateTime.Now;
     
    119108    }
    120109
    121     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
    122     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
    123     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
    124110    public void DeleteJob(Guid jobId) {
     111      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    125112      trans.UseTransaction(() => {
    126113        dao.DeleteJob(jobId);
     
    128115    }
    129116
    130     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
    131     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
    132     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
    133117    public void DeleteChildJobs(Guid parentJobId) {
     118      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    134119      trans.UseTransaction(() => {
    135120        var jobs = GetChildJobs(parentJobId, true, false);
     
    141126    }
    142127
    143     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
    144     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
    145     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
    146128    public Job UpdateJobState(Guid jobId, JobState jobState, Guid? slaveId, Guid? userId, string exception) {
     129      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    147130      return trans.UseTransaction(() => {
    148131        Job job = dao.UpdateJobState(jobId, jobState, slaveId, userId, exception);
     
    166149
    167150    #region Job Control Methods
    168     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
    169     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
    170     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
    171151    public void StopJob(Guid jobId) {
     152      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    172153      trans.UseTransaction(() => {
    173154        var job = dao.GetJob(jobId);
     
    183164    }
    184165
    185     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
    186     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
    187     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
    188166    public void PauseJob(Guid jobId) {
     167      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    189168      trans.UseTransaction(() => {
    190169        var job = dao.GetJob(jobId);
     
    198177    }
    199178
    200     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
    201     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
    202     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
    203179    public void RestartJob(Guid jobId) {
    204       trans.UseTransaction(() => {
    205         Job job = dao.UpdateJobState(jobId, JobState.Waiting, null, auth.UserId, string.Empty);
     180      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
     181      trans.UseTransaction(() => {
     182        Job job = dao.UpdateJobState(jobId, JobState.Waiting, null, author.UserId, string.Empty);
    206183        job.Command = null;
    207184        dao.UpdateJob(job);
     
    211188
    212189    #region HiveExperiment Methods
    213     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
    214     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
    215190    public HiveExperiment GetHiveExperiment(Guid id) {
     191      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    216192      return dao.GetHiveExperiments(x =>
    217              x.HiveExperimentId == id
    218           && (x.OwnerUserId == auth.UserId || x.HiveExperimentPermissions.Count(hep => hep.Permission != Permission.NotAllowed && hep.GrantedUserId == auth.UserId) > 0)
    219           ).FirstOrDefault();
    220     }
    221 
    222     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
    223     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
     193        x.HiveExperimentId == id
     194        && (x.OwnerUserId == author.UserId || x.HiveExperimentPermissions.Count(hep => hep.Permission != Permission.NotAllowed && hep.GrantedUserId == author.UserId) > 0)
     195      ).FirstOrDefault();
     196    }
     197
    224198    public IEnumerable<HiveExperiment> GetHiveExperiments() {
    225       return dao.GetHiveExperiments(x => x.OwnerUserId == auth.UserId || x.HiveExperimentPermissions.Count(hep => hep.Permission != Permission.NotAllowed && hep.GrantedUserId == auth.UserId) > 0);
    226     }
    227 
    228     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]   
     199      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     200      return dao.GetHiveExperiments(x => x.OwnerUserId == author.UserId || x.HiveExperimentPermissions.Count(hep => hep.Permission != Permission.NotAllowed && hep.GrantedUserId == author.UserId) > 0);
     201    }
     202
    229203    public IEnumerable<HiveExperiment> GetAllHiveExperiments() {
     204      authen.AuthenticateForAnyRole(HiveRoles.Administrator);
    230205      return dao.GetHiveExperiments(x => true);
    231206    }
    232207
    233     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
    234     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
    235208    public Guid AddHiveExperiment(HiveExperiment hiveExperimentDto) {
    236       return trans.UseTransaction(() => {
    237         hiveExperimentDto.OwnerUserId = auth.UserId;
     209      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     210      return trans.UseTransaction(() => {
     211        hiveExperimentDto.OwnerUserId = author.UserId;
    238212        hiveExperimentDto.DateCreated = DateTime.Now;
    239213        return dao.AddHiveExperiment(hiveExperimentDto);
     
    241215    }
    242216
    243     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
    244     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
    245217    public void UpdateHiveExperiment(HiveExperiment hiveExperimentDto) {
     218      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    246219      trans.UseTransaction(() => {
    247220        dao.UpdateHiveExperiment(hiveExperimentDto);
     
    249222    }
    250223
    251     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
    252     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
    253224    public void DeleteHiveExperiment(Guid hiveExperimentId) {
     225      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    254226      trans.UseTransaction(() => {
    255227        HiveExperiment he = dao.GetHiveExperiment(hiveExperimentId);
     
    260232
    261233    #region Login Methods
    262     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
    263234    public void Hello(Slave slaveInfo) {
     235      authen.AuthenticateForAnyRole(HiveRoles.Slave);
    264236      trans.UseTransaction(() => {
    265237        var slave = dao.GetSlave(slaveInfo.Id);
     
    293265    }
    294266
    295     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
    296267    public void GoodBye(Guid slaveId) {
     268      authen.AuthenticateForAnyRole(HiveRoles.Slave);
    297269      trans.UseTransaction(() => {
    298270        var slave = dao.GetSlave(slaveId);
     
    306278
    307279    #region Heartbeat Methods
    308     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
    309280    public List<MessageContainer> Heartbeat(Heartbeat heartbeat) {
     281      authen.AuthenticateForAnyRole(HiveRoles.Slave);
    310282      TriggerLifecycle(false);
    311283      return trans.UseTransaction(() => heartbeatManager.ProcessHeartbeat(heartbeat));
     
    314286
    315287    #region Plugin Methods
    316     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
    317     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
    318288    public Guid AddPlugin(Plugin plugin, List<PluginData> pluginDatas) {
    319       return trans.UseTransaction(() => {
    320         plugin.UserId = auth.UserId;
     289      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     290      return trans.UseTransaction(() => {
     291        plugin.UserId = author.UserId;
    321292        plugin.DateCreated = DateTime.Now;
    322293        if (!plugin.IsLocal) {
     
    336307    }
    337308
    338     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
    339     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
    340     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
    341309    public Plugin GetPlugin(Guid pluginId) {
     310      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    342311      return dao.GetPlugin(pluginId);
    343312    }
    344313
    345     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
    346     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
    347     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
    348314    public IEnumerable<Plugin> GetPlugins() {
     315      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    349316      return dao.GetPlugins(x => x.IsLocal == false);
    350317    }
    351318
    352     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
    353     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
    354     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Slave)]
    355319    public IEnumerable<PluginData> GetPluginDatas(List<Guid> pluginIds) {
     320      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
    356321      List<PluginData> pluginDatas = new List<PluginData>();
    357322
     
    372337
    373338    #region Slave Methods
    374     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
    375     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
    376339    public Guid AddSlave(Slave slave) {
     340      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    377341      return trans.UseTransaction(() => dao.AddSlave(slave));
    378342    }
    379343
    380     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
    381     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
    382344    public Guid AddSlaveGroup(SlaveGroup slaveGroup) {
     345      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    383346      return trans.UseTransaction(() => dao.AddSlaveGroup(slaveGroup));
    384347    }
    385348
    386     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
    387     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
    388349    public Slave GetSlave(Guid slaveId) {
     350      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    389351      return dao.GetSlave(slaveId);
    390352    }
    391353
    392354    public SlaveGroup GetSlaveGroup(Guid slaveGroupId) {
     355      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    393356      return dao.GetSlaveGroup(slaveGroupId);
    394357    }
    395358
    396     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
    397     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
    398359    public IEnumerable<Slave> GetSlaves() {
     360      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    399361      return dao.GetSlaves(x => true);
    400362    }
    401363
    402     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
    403     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
    404364    public IEnumerable<SlaveGroup> GetSlaveGroups() {
     365      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    405366      return dao.GetSlaveGroups(x => true);
    406367    }
    407368
    408     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
    409     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
    410369    public void UpdateSlave(Slave slave) {
     370      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    411371      trans.UseTransaction(() => {
    412372        dao.UpdateSlave(slave);
     
    414374    }
    415375
    416     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
    417     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
    418376    public void UpdateSlaveGroup(SlaveGroup slaveGroup) {
     377      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    419378      trans.UseTransaction(() => {
    420379        dao.UpdateSlaveGroup(slaveGroup);
     
    422381    }
    423382
    424     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
    425     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
    426383    public void DeleteSlave(Guid slaveId) {
     384      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    427385      trans.UseTransaction(() => {
    428386        dao.DeleteSlave(slaveId);
     
    430388    }
    431389
    432     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
    433     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
    434390    public void DeleteSlaveGroup(Guid slaveGroupId) {
     391      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    435392      trans.UseTransaction(() => {
    436393        dao.DeleteSlaveGroup(slaveGroupId);
     
    438395    }
    439396
    440     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
    441     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
    442397    public void AddResourceToGroup(Guid slaveGroupId, Guid resourceId) {
     398      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    443399      trans.UseTransaction(() => {
    444400        var resource = dao.GetResource(resourceId);
     
    448404    }
    449405
    450     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
    451     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
    452406    public void RemoveResourceFromGroup(Guid slaveGroupId, Guid resourceId) {
     407      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    453408      trans.UseTransaction(() => {
    454409        var resource = dao.GetResource(resourceId);
     
    458413    }
    459414
    460     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
    461     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Client)]
    462415    public Guid GetResourceId(string resourceName) {
     416      authen.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
    463417      return trans.UseTransaction(() => {
    464418        var resource = dao.GetResources(x => x.Name == resourceName).FirstOrDefault();
     
    503457
    504458    #region Appointment Methods
    505 
    506     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
    507459    public Guid AddAppointment(Appointment appointment) {
     460      authen.AuthenticateForAnyRole(HiveRoles.Administrator);
    508461      return trans.UseTransaction(() => dao.AddAppointment(appointment));
    509462    }
    510463
    511     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
    512464    public void DeleteAppointment(Guid appointmentId) {
     465      authen.AuthenticateForAnyRole(HiveRoles.Administrator);
    513466      trans.UseTransaction(() => {
    514467        dao.DeleteAppointment(appointmentId);
     
    516469    }
    517470
    518     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
    519471    public void UpdateAppointment(Appointment appointment) {
     472      authen.AuthenticateForAnyRole(HiveRoles.Administrator);
    520473      trans.UseTransaction(() => {
    521474        dao.UpdateAppointment(appointment);
     
    523476    }
    524477
    525     // [PrincipalPermission(SecurityAction.Demand, Role = HiveRoles.Administrator)]
    526478    public IEnumerable<Appointment> GetScheduleForResource(Guid resourceId) {
     479      authen.AuthenticateForAnyRole(HiveRoles.Administrator);
    527480      return trans.UseTransaction(() => dao.GetAppointments(x => x.ResourceId == resourceId));
    528481    }
    529482
    530483    public IEnumerable<Job> GetJobsByResourceId(Guid resourceId) {
     484      authen.AuthenticateForAnyRole(HiveRoles.Administrator);
    531485      return trans.UseTransaction(() => dao.GetJobsByResourceId(resourceId));
    532486    }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/Interfaces/IServiceLocator.cs

    r5405 r6362  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    5 using HeuristicLab.Services.Hive.DataAccess;
     1using HeuristicLab.Services.Hive.DataAccess;
    62
    73namespace HeuristicLab.Services.Hive {
    84  public interface IServiceLocator {
    9 
     5    IAuthenticationManager AuthenticationManager { get; }
    106    IAuthorizationManager AuthorizationManager { get; }
    117    IHiveDao HiveDao { get; }
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.4/ServiceLocator.cs

    r5405 r6362  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    5 using HeuristicLab.Services.Hive.DataAccess;
     1using HeuristicLab.Services.Hive.DataAccess;
    62
    73namespace HeuristicLab.Services.Hive {
     
    3329    }
    3430
     31    private IAuthenticationManager authenticationManager;
     32    public IAuthenticationManager AuthenticationManager {
     33      get {
     34        if (authenticationManager == null) authenticationManager = new AuthenticationManager();
     35        return authenticationManager;
     36      }
     37    }
     38
    3539    private IAuthorizationManager authorizationManager;
    3640    public IAuthorizationManager AuthorizationManager {
Note: See TracChangeset for help on using the changeset viewer.