Changeset 1579 for trunk/sources/HeuristicLab.Hive.Contracts
- Timestamp:
- 04/16/09 17:44:58 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Hive.Contracts/3.2/WcfSettings.cs
r1530 r1579 1 using System; 1 #define USE_MSG_BINDING 2 using System; 2 3 using System.Collections.Generic; 3 4 using System.Linq; … … 11 12 public static class WcfSettings { 12 13 14 public const string SERVERCERT = "HIVE-Server"; 15 public const int DEFAULTPORT = 9000; 16 17 /// <summary> 18 /// Gets a pre-defined binding using TCP for secure transport. 19 /// </summary> 20 /// <returns>A binding type of <see cref="NetTcpBinding"/></returns> 13 21 public static Binding GetBinding() { 22 #if USE_MSG_BINDING 14 23 NetTcpBinding binding = new NetTcpBinding(SecurityMode.Message); 24 #else 25 NetTcpBinding binding = new NetTcpBinding(SecurityMode.TransportWithMessageCredential); 26 binding.Security.Message.ClientCredentialType = MessageCredentialType.Certificate; 27 #endif 15 28 return binding; 16 29 } 17 30 31 /// <summary> 32 /// Defines the used certificate for authentification located in a certification store. 33 /// </summary> 34 /// <param name="svchost">A service for which this certificate is applicable.</param> 35 public static void SetServiceCertificate(ServiceHost svchost) { 36 svchost.Credentials.ServiceCertificate.SetCertificate( 37 StoreLocation.LocalMachine, 38 StoreName.My, 39 X509FindType.FindBySubjectName, 40 SERVERCERT); 41 } 42 43 /// <summary> 44 /// Gets the currently active IP address. 45 /// <remarks>If more than one IP connections is active, the first one will be used.</remarks> 46 /// </summary> 47 /// <returns></returns> 18 48 public static string GetActiveIP() { 19 49 return System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpConnections()[0].LocalEndPoint.Address.ToString(); 20 50 } 21 51 52 /// <summary> 53 /// Gets the default port used for HIVE services. 54 /// </summary> 55 /// <returns></returns> 22 56 public static int GetDefaultPort() { 23 return 9000;57 return DEFAULTPORT; 24 58 } 25 59 } 26 60 27 // WARNUNG: Dieser Code wird nur für Testzertifikate benötigt, wie sie beispielsweise von makecert erstellt werden. 28 // Sie sollten diesen Code nicht in einer Produktionsumgebung verwenden. 61 /// <summary> 62 /// This class verifies the certificate defined by <see cref="SetServerCertificate"></see> method. Normally, 63 /// the verification process is managed by the underlying operating system. 64 /// </summary> 65 /// <remarks> 66 /// WARNUNG: Dieser Code wird nur für Testzertifikate benötigt, wie sie beispielsweise von makecert erstellt werden. 67 /// Sie sollten diesen Code nicht in einer Produktionsumgebung verwenden. 68 /// </remarks> 29 69 public class PermissiveCertificatePolicy { 30 70 string subjectName; … … 44 84 return true; 45 85 } 46 47 86 return false; 48 87 }
Note: See TracChangeset
for help on using the changeset viewer.