Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7360


Ignore:
Timestamp:
01/18/12 13:04:34 (13 years ago)
Author:
ascheibe
Message:

#1174 the administration and run creation service now verify that the user has the appropriate roles

Location:
branches/OKB (trunk integration)/HeuristicLab.Services.OKB/3.3
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/OKB (trunk integration)/HeuristicLab.Services.OKB/3.3/Administration/AdministrationService.cs

    r7331 r7360  
    2424using System.Linq;
    2525using System.ServiceModel;
     26using HeuristicLab.Services.Access;
    2627using HeuristicLab.Services.OKB.DataAccess;
    2728
     
    3233  [ServiceBehavior(IncludeExceptionDetailInFaults = true)]
    3334  public class AdministrationService : IAdministrationService {
     35    IRoleVerifier roleVerifier = AccessServiceLocator.Instance.RoleVerifier;
     36
    3437    #region Platform Methods
    3538    public DataTransfer.Platform GetPlatform(long id) {
     39      roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator);
     40
    3641      using (OKBDataContext okb = new OKBDataContext()) {
    3742        return Convert.ToDto(okb.Platforms.FirstOrDefault(x => x.Id == id));
     
    3944    }
    4045    public IEnumerable<DataTransfer.Platform> GetPlatforms() {
     46      roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator);
     47
    4148      using (OKBDataContext okb = new OKBDataContext()) {
    4249        return okb.Platforms.Select(x => Convert.ToDto(x)).ToArray();
     
    4451    }
    4552    public long AddPlatform(DataTransfer.Platform dto) {
     53      roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator);
     54
    4655      using (OKBDataContext okb = new OKBDataContext()) {
    4756        DataAccess.Platform entity = Convert.ToEntity(dto); entity.Id = 0;
     
    5261    }
    5362    public void UpdatePlatform(DataTransfer.Platform dto) {
     63      roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator);
     64
    5465      using (OKBDataContext okb = new OKBDataContext()) {
    5566        DataAccess.Platform entity = okb.Platforms.FirstOrDefault(x => x.Id == dto.Id);
     
    5970    }
    6071    public void DeletePlatform(long id) {
     72      roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator);
     73
    6174      using (OKBDataContext okb = new OKBDataContext()) {
    6275        DataAccess.Platform entity = okb.Platforms.FirstOrDefault(x => x.Id == id);
     
    6982    #region AlgorithmClass Methods
    7083    public DataTransfer.AlgorithmClass GetAlgorithmClass(long id) {
     84      roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator);
     85
    7186      using (OKBDataContext okb = new OKBDataContext()) {
    7287        return Convert.ToDto(okb.AlgorithmClasses.FirstOrDefault(x => x.Id == id));
     
    7489    }
    7590    public IEnumerable<DataTransfer.AlgorithmClass> GetAlgorithmClasses() {
     91      roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator);
     92
    7693      using (OKBDataContext okb = new OKBDataContext()) {
    7794        return okb.AlgorithmClasses.Select(x => Convert.ToDto(x)).ToArray();
     
    7996    }
    8097    public long AddAlgorithmClass(DataTransfer.AlgorithmClass dto) {
     98      roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator);
     99
    81100      using (OKBDataContext okb = new OKBDataContext()) {
    82101        DataAccess.AlgorithmClass entity = Convert.ToEntity(dto); entity.Id = 0;
     
    87106    }
    88107    public void UpdateAlgorithmClass(DataTransfer.AlgorithmClass dto) {
     108      roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator);
     109
    89110      using (OKBDataContext okb = new OKBDataContext()) {
    90111        DataAccess.AlgorithmClass entity = okb.AlgorithmClasses.FirstOrDefault(x => x.Id == dto.Id);
     
    94115    }
    95116    public void DeleteAlgorithmClass(long id) {
     117      roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator);
     118
    96119      using (OKBDataContext okb = new OKBDataContext()) {
    97120        DataAccess.AlgorithmClass entity = okb.AlgorithmClasses.FirstOrDefault(x => x.Id == id);
     
    104127    #region Algorithm Methods
    105128    public DataTransfer.Algorithm GetAlgorithm(long id) {
     129      roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator);
     130
    106131      using (OKBDataContext okb = new OKBDataContext()) {
    107132        return Convert.ToDto(okb.Algorithms.FirstOrDefault(x => x.Id == id));
     
    109134    }
    110135    public IEnumerable<DataTransfer.Algorithm> GetAlgorithms() {
     136      roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator);
     137
    111138      using (OKBDataContext okb = new OKBDataContext()) {
    112139        return okb.Algorithms.Select(x => Convert.ToDto(x)).ToArray();
     
    114141    }
    115142    public long AddAlgorithm(DataTransfer.Algorithm dto) {
     143      roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator);
     144
    116145      using (OKBDataContext okb = new OKBDataContext()) {
    117146        DataAccess.Algorithm entity = Convert.ToEntity(dto, okb); entity.Id = 0;
     
    122151    }
    123152    public void UpdateAlgorithm(DataTransfer.Algorithm dto) {
     153      roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator);
     154
    124155      using (OKBDataContext okb = new OKBDataContext()) {
    125156        DataAccess.Algorithm entity = okb.Algorithms.FirstOrDefault(x => x.Id == dto.Id);
     
    129160    }
    130161    public void DeleteAlgorithm(long id) {
     162      roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator);
     163
    131164      using (OKBDataContext okb = new OKBDataContext()) {
    132165        DataAccess.Algorithm entity = okb.Algorithms.FirstOrDefault(x => x.Id == id);
     
    136169    }
    137170    public IEnumerable<Guid> GetAlgorithmUsers(long algorithmId) {
     171      roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator);
     172
    138173      using (OKBDataContext okb = new OKBDataContext()) {
    139174        return okb.AlgorithmUsers.Where(x => x.AlgorithmId == algorithmId).Select(x => x.UserId).ToArray();
     
    141176    }
    142177    public void UpdateAlgorithmUsers(long algorithmId, IEnumerable<Guid> users) {
     178      roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator);
     179
    143180      using (OKBDataContext okb = new OKBDataContext()) {
    144181        okb.AlgorithmUsers.DeleteAllOnSubmit(okb.AlgorithmUsers.Where(x => x.AlgorithmId == algorithmId));
     
    148185    }
    149186    public byte[] GetAlgorithmData(long algorithmId) {
     187      roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator);
     188
    150189      using (OKBDataContext okb = new OKBDataContext()) {
    151190        var data = okb.Algorithms.Where(x => x.Id == algorithmId).Select(x => x.BinaryData).FirstOrDefault();
     
    155194    }
    156195    public void UpdateAlgorithmData(long algorithmId, byte[] data) {
     196      roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator);
     197
    157198      using (OKBDataContext okb = new OKBDataContext()) {
    158199        var entity = okb.Algorithms.Where(x => x.Id == algorithmId).FirstOrDefault();
     
    166207    #region ProblemClass Methods
    167208    public DataTransfer.ProblemClass GetProblemClass(long id) {
     209      roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator);
     210
    168211      using (OKBDataContext okb = new OKBDataContext()) {
    169212        return Convert.ToDto(okb.ProblemClasses.FirstOrDefault(x => x.Id == id));
     
    171214    }
    172215    public IEnumerable<DataTransfer.ProblemClass> GetProblemClasses() {
     216      roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator);
     217
    173218      using (OKBDataContext okb = new OKBDataContext()) {
    174219        return okb.ProblemClasses.Select(x => Convert.ToDto(x)).ToArray();
     
    176221    }
    177222    public long AddProblemClass(DataTransfer.ProblemClass dto) {
     223      roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator);
     224
    178225      using (OKBDataContext okb = new OKBDataContext()) {
    179226        DataAccess.ProblemClass entity = Convert.ToEntity(dto); entity.Id = 0;
     
    184231    }
    185232    public void UpdateProblemClass(DataTransfer.ProblemClass dto) {
     233      roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator);
     234
    186235      using (OKBDataContext okb = new OKBDataContext()) {
    187236        DataAccess.ProblemClass entity = okb.ProblemClasses.FirstOrDefault(x => x.Id == dto.Id);
     
    191240    }
    192241    public void DeleteProblemClass(long id) {
     242      roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator);
     243
    193244      using (OKBDataContext okb = new OKBDataContext()) {
    194245        DataAccess.ProblemClass entity = okb.ProblemClasses.FirstOrDefault(x => x.Id == id);
     
    201252    #region Problem Methods
    202253    public DataTransfer.Problem GetProblem(long id) {
     254      roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator);
     255
    203256      using (OKBDataContext okb = new OKBDataContext()) {
    204257        return Convert.ToDto(okb.Problems.FirstOrDefault(x => x.Id == id));
     
    206259    }
    207260    public IEnumerable<DataTransfer.Problem> GetProblems() {
     261      roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator);
     262
    208263      using (OKBDataContext okb = new OKBDataContext()) {
    209264        return okb.Problems.Select(x => Convert.ToDto(x)).ToArray();
     
    211266    }
    212267    public long AddProblem(DataTransfer.Problem dto) {
     268      roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator);
     269
    213270      using (OKBDataContext okb = new OKBDataContext()) {
    214271        DataAccess.Problem entity = Convert.ToEntity(dto, okb); entity.Id = 0;
     
    219276    }
    220277    public void UpdateProblem(DataTransfer.Problem dto) {
     278      roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator);
     279
    221280      using (OKBDataContext okb = new OKBDataContext()) {
    222281        DataAccess.Problem entity = okb.Problems.FirstOrDefault(x => x.Id == dto.Id);
     
    226285    }
    227286    public void DeleteProblem(long id) {
     287      roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator);
     288
    228289      using (OKBDataContext okb = new OKBDataContext()) {
    229290        DataAccess.Problem entity = okb.Problems.FirstOrDefault(x => x.Id == id);
     
    233294    }
    234295    public IEnumerable<Guid> GetProblemUsers(long problemId) {
     296      roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator);
     297
    235298      using (OKBDataContext okb = new OKBDataContext()) {
    236299        return okb.ProblemUsers.Where(x => x.ProblemId == problemId).Select(x => x.UserId).ToArray();
     
    238301    }
    239302    public void UpdateProblemUsers(long problemId, IEnumerable<Guid> users) {
     303      roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator);
     304
    240305      using (OKBDataContext okb = new OKBDataContext()) {
    241306        okb.ProblemUsers.DeleteAllOnSubmit(okb.ProblemUsers.Where(x => x.ProblemId == problemId));
     
    245310    }
    246311    public byte[] GetProblemData(long problemId) {
     312      roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator);
     313
    247314      using (OKBDataContext okb = new OKBDataContext()) {
    248315        var data = okb.Problems.Where(x => x.Id == problemId).Select(x => x.BinaryData).FirstOrDefault();
     
    252319    }
    253320    public void UpdateProblemData(long problemId, byte[] data) {
     321      roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator);
     322
    254323      using (OKBDataContext okb = new OKBDataContext()) {
    255324        var entity = okb.Problems.Where(x => x.Id == problemId).FirstOrDefault();
  • branches/OKB (trunk integration)/HeuristicLab.Services.OKB/3.3/HeuristicLab.Services.OKB-3.3.csproj

    r7349 r7360  
    106106  </PropertyGroup>
    107107  <ItemGroup>
     108    <Reference Include="HeuristicLab.GeoIP">
     109      <HintPath>..\..\..\ClientUserManagement\ServerBinaries\HeuristicLab.GeoIP.dll</HintPath>
     110    </Reference>
     111    <Reference Include="HeuristicLab.Services.Access">
     112      <HintPath>..\..\..\ClientUserManagement\ServerBinaries\HeuristicLab.Services.Access.dll</HintPath>
     113    </Reference>
     114    <Reference Include="HeuristicLab.Services.Access.DataAccess">
     115      <HintPath>..\..\..\ClientUserManagement\ServerBinaries\HeuristicLab.Services.Access.DataAccess.dll</HintPath>
     116    </Reference>
    108117    <Reference Include="Microsoft.CSharp" />
    109118    <Reference Include="System" />
  • branches/OKB (trunk integration)/HeuristicLab.Services.OKB/3.3/RunCreation/RunCreationService.cs

    r7331 r7360  
    2424using System.Linq;
    2525using System.ServiceModel;
     26using HeuristicLab.Services.Access;
    2627using HeuristicLab.Services.OKB.DataAccess;
    2728
     
    3233  [ServiceBehavior(IncludeExceptionDetailInFaults = true)]
    3334  public class RunCreationService : IRunCreationService {
     35    IRoleVerifier roleVerifier = AccessServiceLocator.Instance.RoleVerifier;
     36
    3437    public IEnumerable<DataTransfer.Algorithm> GetAlgorithms(string platformName) {
     38      roleVerifier.AuthenticateForAnyRole(OKBRoles.OKBAdministrator, OKBRoles.OKBUser);
     39
    3540      using (OKBDataContext okb = new OKBDataContext()) {
    3641        DataLoadOptions dlo = new DataLoadOptions();
     
    4348
    4449    public byte[] GetAlgorithmData(long algorithmId) {
     50      roleVerifier.AuthenticateForAnyRole(OKBRoles.OKBAdministrator, OKBRoles.OKBUser);
     51
    4552      using (OKBDataContext okb = new OKBDataContext()) {
    4653        return okb.Algorithms.Where(x => x.Id == algorithmId).Select(x => x.BinaryData.Data.ToArray()).FirstOrDefault();
     
    4956
    5057    public IEnumerable<DataTransfer.Problem> GetProblems(string platformName) {
     58      roleVerifier.AuthenticateForAnyRole(OKBRoles.OKBAdministrator, OKBRoles.OKBUser);
     59
    5160      using (OKBDataContext okb = new OKBDataContext()) {
    5261        DataLoadOptions dlo = new DataLoadOptions();
     
    5968
    6069    public byte[] GetProblemData(long problemId) {
     70      roleVerifier.AuthenticateForAnyRole(OKBRoles.OKBAdministrator, OKBRoles.OKBUser);
     71
    6172      using (OKBDataContext okb = new OKBDataContext()) {
    6273        return okb.Problems.Where(x => x.Id == problemId).Select(x => x.BinaryData.Data.ToArray()).FirstOrDefault();
     
    6576
    6677    public void AddRun(DataTransfer.Run run) {
     78      roleVerifier.AuthenticateForAnyRole(OKBRoles.OKBAdministrator, OKBRoles.OKBUser);
     79
    6780      using (OKBDataContext okb = new OKBDataContext()) {
    6881        DataAccess.Run entity = Convert.ToEntity(run, okb);
Note: See TracChangeset for help on using the changeset viewer.