#region License Information
/* HeuristicLab
* Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
*
* This file is part of HeuristicLab.
*
* HeuristicLab is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HeuristicLab is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HeuristicLab. If not, see .
*/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.Security.Cryptography.X509Certificates;
using System.Reflection;
namespace HeuristicLab.PluginInfrastructure.Advanced.DeploymentService {
///
/// Factory class to generated administration client instances for the deployment service.
///
public static class AdminClientFactory {
private static byte[] serverCrtData;
///
/// static constructor loads the embedded service certificate
///
static AdminClientFactory() {
var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("HeuristicLab.PluginInfrastructure.Advanced.DeploymentService.servdev.cer");
serverCrtData = new byte[stream.Length];
stream.Read(serverCrtData, 0, serverCrtData.Length);
}
///
/// Factory method to create new administration clients for the deployment service.
/// Sets the connection string and user credentials from values provided in settings.
/// HeuristicLab.PluginInfrastructure.Properties.Settings.Default.UpdateLocationUserName
/// HeuristicLab.PluginInfrastructure.Properties.Settings.Default.UpdateLocationPassword
/// HeuristicLab.PluginInfrastructure.Properties.Settings.Default.UpdateLocationnAdministrationAddress
///
///
/// A new instance of an adimistration client
public static AdminClient CreateClient() {
var client = new AdminClient();
client.ClientCredentials.UserName.UserName = HeuristicLab.PluginInfrastructure.Properties.Settings.Default.UpdateLocationUserName;
client.ClientCredentials.UserName.Password = HeuristicLab.PluginInfrastructure.Properties.Settings.Default.UpdateLocationPassword;
client.Endpoint.Address = new EndpointAddress(HeuristicLab.PluginInfrastructure.Properties.Settings.Default.UpdateLocationAdministrationAddress);
client.ClientCredentials.ServiceCertificate.DefaultCertificate = new X509Certificate2(serverCrtData);
client.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = System.ServiceModel.Security.X509CertificateValidationMode.None;
return client;
}
}
}