Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HiveProjectManagement/HeuristicLab.Clients.Common/3.3/SecurityExceptionUtil.cs @ 15517

Last change on this file since 15517 was 15401, checked in by jkarder, 7 years ago

#2839:

  • worked on hive administrator view
  • updated service clients
File size: 1.3 KB
RevLine 
[15401]1using System;
2using System.ServiceModel.Security;
3using System.Threading.Tasks;
4using HeuristicLab.PluginInfrastructure;
5
6namespace HeuristicLab.Clients.Hive {
7  public class SecurityExceptionUtil {
8    public static void TryAndReportSecurityExceptions(Action action, Action finallyCallback = null) {
9      try {
10        action();
11      } catch (MessageSecurityException ex) {
12        ErrorHandling.ShowErrorDialog("There is something wrong with the applied security. Are your credentials correct?", ex);
13      } catch (SecurityAccessDeniedException ex) {
14        ErrorHandling.ShowErrorDialog("The security authorization request failed. Are you a Hive administrator?", ex);
15      } finally {
16        finallyCallback?.Invoke();
17      }
18    }
19
20    public static async Task TryAsyncAndReportSecurityExceptions(Action action, Action finallyCallback = null) {
21      try {
22        await Task.Run(action);
23      } catch (MessageSecurityException ex) {
24        ErrorHandling.ShowErrorDialog("There is something wrong with the applied security. Are your credentials correct?", ex);
25      } catch (SecurityAccessDeniedException ex) {
26        ErrorHandling.ShowErrorDialog("The security authorization request failed. Are you a Hive administrator?", ex);
27      } finally {
28        finallyCallback?.Invoke();
29      }
30    }
31  }
32}
Note: See TracBrowser for help on using the repository browser.