Free cookie consent management tool by TermsFeed Policy Generator

source: branches/WebApplication/MVC2/HeuristicLabWeb.PluginHost/HLWebPluginHost/Helpers/Query.cs @ 5920

Last change on this file since 5920 was 5920, checked in by cfleisch, 13 years ago

#1439 Authentication process modified to work well with query plugin

File size: 1.3 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Web;
5using HLWebPluginHost.OKBQueryService;
6using System.ServiceModel.Security;
7
8namespace HLWebPluginHost.Helpers
9{
10    public class Query
11    {
12        public static QueryServiceClient GetClientFactory() {
13            return GetClientFactory(GetSessionString("Username"), GetSessionString("Password"));
14        }
15
16        public static QueryServiceClient GetClientFactory(string username, string password) {
17            try {
18                QueryServiceClient client = new QueryServiceClient();
19                client.ClientCredentials.UserName.UserName = username;
20                client.ClientCredentials.UserName.Password = password;
21                client.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
22                client.GetFilters();
23                return client;
24            }
25            catch {
26            }
27            return null;
28        }
29
30        public static string GetSessionString(string name) {
31            if (name != null) {
32                object o = HttpContext.Current.Session[name];
33                if (o != null) {
34                    return o.ToString();
35                }
36            }
37            return string.Empty;
38        }
39    }
40}
Note: See TracBrowser for help on using the repository browser.