private static void InitializeService(ServiceImplement service) { string servNameCrt = "wcfservice"; string OU1 = "korisnik"; string OU2 = "admin"; NetTcpBinding binding = new NetTcpBinding(); binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Certificate; string address = "net.tcp://localhost:4000/IService"; ServiceHost host = new ServiceHost(service); ServiceSecurityAuditBehavior newAuditBehavior = new ServiceSecurityAuditBehavior(); host.Description.Behaviors.Remove <ServiceSecurityAuditBehavior>(); host.Description.Behaviors.Add(newAuditBehavior); host.AddServiceEndpoint(typeof(IService), binding, address); host.Credentials.ClientCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.Custom; host.Credentials.ClientCertificate.Authentication.CustomCertificateValidator = new ServiceCertificateValidator(); host.Credentials.ClientCertificate.Authentication.RevocationMode = X509RevocationMode.NoCheck; host.Credentials.ServiceCertificate.Certificate = CertificateManager.GetCertificateFromStorage(StoreName.My, StoreLocation.LocalMachine, servNameCrt, OU1, OU2); host.Open(); Console.WriteLine("WCFService is opened. Press <enter> to finish..."); }
public static void Main(string[] args) { Uri address = new Uri("http://localhost:8001/TradeService"); WSHttpBinding binding = new WSHttpBinding(); Type contract = typeof(ExchangeService.ITradeService); ServiceHost host = new ServiceHost(typeof(TradeService)); host.AddServiceEndpoint(contract, binding, address); // Add Auditing to the service ServiceSecurityAuditBehavior auditProvider = host.Description.Behaviors.Find <ServiceSecurityAuditBehavior>(); if (auditProvider == null) { auditProvider = new ServiceSecurityAuditBehavior(); } auditProvider.AuditLogLocation = AuditLogLocation.Application; auditProvider.MessageAuthenticationAuditLevel = AuditLevel.SuccessOrFailure; auditProvider.ServiceAuthorizationAuditLevel = AuditLevel.SuccessOrFailure; host.Description.Behaviors.Add(auditProvider); host.Open(); Console.WriteLine("The WCF Management trading service is available."); Console.ReadKey(); }
static void Main(string[] args) { NetTcpBinding binding = new NetTcpBinding(); binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows; string address = "net.tcp://localhost:10000/WCFLogger"; ServiceHost serviceHost = new ServiceHost(typeof(WCFLogger)); serviceHost.AddServiceEndpoint(typeof(IWCFLogger), binding, address); //Debugger.Launch(); serviceHost.Description.Behaviors.Remove <ServiceSecurityAuditBehavior>(); ServiceSecurityAuditBehavior newAudit = new ServiceSecurityAuditBehavior(); newAudit.AuditLogLocation = AuditLogLocation.Application; newAudit.ServiceAuthorizationAuditLevel = AuditLevel.SuccessOrFailure; newAudit.SuppressAuditFailure = true; serviceHost.Description.Behaviors.Remove <ServiceSecurityAuditBehavior>(); serviceHost.Description.Behaviors.Add(newAudit); WCFLogger wcfLogger = new WCFLogger(); serviceHost.Open(); Console.WriteLine("WCFLogger is opened. Press <enter> to exit..."); Console.ReadLine(); serviceHost.Close(); }
static void Main(string[] args) { /// srvCertCN.SubjectName should be set to the service's username. .NET WindowsIdentity class provides information about Windows user running the given process string srvCertCN = Formatter.ParseName(WindowsIdentity.GetCurrent().Name); //string srvCertCN = "PubSubService"; string addressPub = "net.tcp://localhost:9999/Publishers"; ServiceHost pubHost = ServiceHostHelper.PrepareHost(addressPub, typeof(PubService), typeof(IPublish), srvCertCN); string addressSub = "net.tcp://localhost:9999/Subscribers"; ServiceHost subHost = ServiceHostHelper.PrepareHost(addressSub, typeof(SubService), typeof(ISubscribe), srvCertCN); // Podesavanje Audit Behaviour-a ServiceSecurityAuditBehavior newAudit = new ServiceSecurityAuditBehavior(); newAudit.AuditLogLocation = AuditLogLocation.Application; newAudit.ServiceAuthorizationAuditLevel = AuditLevel.Success; // Brisanje default-nog i dodavanje novog Audit Behaviour-a subHost.Description.Behaviors.Remove <ServiceSecurityAuditBehavior>(); subHost.Description.Behaviors.Add(newAudit); OpenService(subHost, pubHost); }
public static ServiceHost HostServices(string port) { NetTcpBinding binding = new NetTcpBinding(); string address = "net.tcp://localhost:" + port + "/DBM"; ServiceHost host = new ServiceHost(typeof(Services)); host.AddServiceEndpoint(typeof(IServices), binding, address); ServiceSecurityAuditBehavior newAuditBehavior = new ServiceSecurityAuditBehavior(); host.Description.Behaviors.Remove(typeof(ServiceDebugBehavior)); host.Description.Behaviors.Add(new ServiceDebugBehavior() { IncludeExceptionDetailInFaults = false }); host.Description.Behaviors.Remove <ServiceSecurityAuditBehavior>(); host.Description.Behaviors.Add(newAuditBehavior); List <IAuthorizationPolicy> policies = new List <IAuthorizationPolicy>() { new MyAuthorizationPolicy() }; host.Authorization.ServiceAuthorizationManager = new MyAuthorizationManager(); host.Authorization.ExternalAuthorizationPolicies = policies.AsReadOnly(); host.Authorization.PrincipalPermissionMode = PrincipalPermissionMode.Custom; return(host); }
public void SpecifyAuditingBehavior(ServiceHost host) { ServiceSecurityAuditBehavior audit = new ServiceSecurityAuditBehavior(); audit.AuditLogLocation = AuditLogLocation.Application; host.Description.Behaviors.Remove <ServiceSecurityAuditBehavior>(); host.Description.Behaviors.Add(audit); }
protected internal override object CreateBehavior() { ServiceSecurityAuditBehavior behavior = new ServiceSecurityAuditBehavior(); behavior.AuditLogLocation = this.AuditLogLocation; behavior.SuppressAuditFailure = this.SuppressAuditFailure; behavior.ServiceAuthorizationAuditLevel = this.ServiceAuthorizationAuditLevel; behavior.MessageAuthenticationAuditLevel = this.MessageAuthenticationAuditLevel; return(behavior); }
private static void SetupLogging(ServiceHost host) { var newAudit = new ServiceSecurityAuditBehavior { AuditLogLocation = AuditLogLocation.Application, ServiceAuthorizationAuditLevel = AuditLevel.SuccessOrFailure, SuppressAuditFailure = true }; host.Description.Behaviors.Remove <ServiceSecurityAuditBehavior>(); host.Description.Behaviors.Add(newAudit); }
void ApplyAuditBehaviorSettings(BindingContext context) { ServiceSecurityAuditBehavior auditBehavior = context.BindingParameters.Find <ServiceSecurityAuditBehavior>(); if (auditBehavior != null) { this.auditBehavior = auditBehavior.Clone(); } else { this.auditBehavior = new ServiceSecurityAuditBehavior(); } }
static void Main(string[] args) { string srvCertCN = "service1"; /*Formatter.ParseName(WindowsIdentity.GetCurrent().Name)*/; NetTcpBinding binding = new NetTcpBinding(); binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Certificate; ServiceHost host = new ServiceHost(typeof(WCFService)); string address = "net.tcp://localhost:10001/Service"; host.AddServiceEndpoint(typeof(IWCFContract), binding, address); ServiceSecurityAuditBehavior newAuditBehavior = new ServiceSecurityAuditBehavior(); ////custom validation host.Credentials.ClientCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.Custom; host.Credentials.ClientCertificate.Authentication.CustomCertificateValidator = new ServiceCertValidator(); host.Credentials.ClientCertificate.Authentication.RevocationMode = X509RevocationMode.NoCheck; host.Credentials.ServiceCertificate.Certificate = CertManager.GetCertificateFromStorage(StoreName.My, StoreLocation.LocalMachine, srvCertCN); host.Description.Behaviors.Remove <ServiceSecurityAuditBehavior>(); host.Description.Behaviors.Add(newAuditBehavior); try { host.Open(); Console.WriteLine(srvCertCN); Console.WriteLine("WCFService is started.\nPress <enter> to stop ..."); Console.ReadLine(); } catch (Exception e) { Console.WriteLine("[ERROR] {0}", e.Message); Console.WriteLine("[StackTrace] {0}", e.StackTrace); } finally { host.Close(); } }
static void Main(string[] args) { NetTcpBinding binding = new NetTcpBinding(); binding.Security.Mode = SecurityMode.Message; binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows; string address = "net.tcp://localhost:9999/WCFService"; ServiceHost host = new ServiceHost(typeof(WCFService)); host.AddServiceEndpoint(typeof(IWCFService), binding, address); host.Authorization.ServiceAuthorizationManager = new CustomAuthorizationManager(); List <IAuthorizationPolicy> policies = new List <IAuthorizationPolicy>(); policies.Add(new CustomAuthorizationPolicy()); host.Authorization.ExternalAuthorizationPolicies = policies.AsReadOnly(); host.Authorization.PrincipalPermissionMode = PrincipalPermissionMode.Custom; host.Description.Behaviors.Remove(typeof(ServiceDebugBehavior)); host.Description.Behaviors.Add(new ServiceDebugBehavior() { IncludeExceptionDetailInFaults = true }); ServiceSecurityAuditBehavior newAudit = new ServiceSecurityAuditBehavior(); newAudit.AuditLogLocation = AuditLogLocation.Application; host.Description.Behaviors.Remove <ServiceSecurityAuditBehavior>(); host.Description.Behaviors.Add(newAudit); host.Open(); Console.WriteLine("Server service is started."); Console.WriteLine("Press <enter> to stop service..."); string name = WindowsIdentity.GetCurrent().Name; string authType = WindowsIdentity.GetCurrent().AuthenticationType; Console.WriteLine("Name: " + name); Console.ReadLine(); host.Close(); }
// Host the service within this EXE console application. //<snippet1> public static void Main() { // Get base address from appsettings in configuration. Uri baseAddress = new Uri(ConfigurationManager. AppSettings["baseAddress"]); // Create a ServiceHost for the CalculatorService type // and provide the base address. using (ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), baseAddress)) { //<snippet4> //<snippet3> //<snippet2> // Create a new auditing behavior and set the log location. ServiceSecurityAuditBehavior newAudit = new ServiceSecurityAuditBehavior(); newAudit.AuditLogLocation = AuditLogLocation.Application; //</snippet2> newAudit.MessageAuthenticationAuditLevel = AuditLevel.SuccessOrFailure; newAudit.ServiceAuthorizationAuditLevel = AuditLevel.SuccessOrFailure; //</snippet3> newAudit.SuppressAuditFailure = false; //</snippet4> //<snippet5> // Remove the old behavior and add the new. serviceHost.Description. Behaviors.Remove <ServiceSecurityAuditBehavior>(); serviceHost.Description.Behaviors.Add(newAudit); //</snippet5> // Open the ServiceHostBase to create listeners // and start listening for messages. serviceHost.Open(); // The service can now be accessed. Console.WriteLine("The service is ready."); Console.WriteLine("Press <ENTER> to terminate service."); Console.WriteLine(); Console.ReadLine(); // Close the ServiceHostBase to shutdown the service. serviceHost.Close(); } }
static void Main(string[] args) { NetTcpBinding binding = new NetTcpBinding(); binding.Security.Mode = SecurityMode.Transport; binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows; binding.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.EncryptAndSign; ServiceHost sh = new ServiceHost(typeof(Service)); sh.AddServiceEndpoint(typeof(IService), binding, "net.tcp://localhost:9000/Service"); sh.Description.Behaviors.Remove(typeof(ServiceDebugBehavior)); sh.Description.Behaviors.Add(new ServiceDebugBehavior() { IncludeExceptionDetailInFaults = true }); sh.Authorization.ServiceAuthorizationManager = new CustomServiceAuthorizationManager(); sh.Authorization.PrincipalPermissionMode = PrincipalPermissionMode.Custom; List <IAuthorizationPolicy> policies = new List <IAuthorizationPolicy>(); policies.Add(new CustomAutoriztionPolicy()); sh.Authorization.ExternalAuthorizationPolicies = policies.AsReadOnly(); ServiceSecurityAuditBehavior newAudit = new ServiceSecurityAuditBehavior(); newAudit.AuditLogLocation = AuditLogLocation.Application; newAudit.ServiceAuthorizationAuditLevel = AuditLevel.SuccessOrFailure; newAudit.SuppressAuditFailure = true; sh.Description.Behaviors.Remove <ServiceSecurityAuditBehavior>(); sh.Description.Behaviors.Add(newAudit); sh.Open(); Console.WriteLine("{0} je pokrenuo servis.", WindowsIdentity.GetCurrent().Name); Console.ReadLine(); sh.Close(); }
public void WfcServiceHost_Parse_BehaviorXML() { // Verify that we can parse behavior XML. WcfServiceHost host; host = new WcfServiceHost(new TestService()); host.AddServiceEndpoint(typeof(ITestService), @"binding=HTTP;uri=http://localhost:8008/Unit/Test.svc;settings=<wsHttpBinding><security mode=""None""/></wsHttpBinding>"); host.ExposeServiceDescription(null, null); host.AddBehaviors( @"<behavior> <serviceSecurityAudit auditLogLocation=""Application"" suppressAuditFailure=""true"" serviceAuthorizationAuditLevel=""Success"" messageAuthenticationAuditLevel=""SuccessOrFailure"" /> <serviceThrottling maxConcurrentCalls=""121"" maxConcurrentInstances=""122"" maxConcurrentSessions=""123"" /> <serviceTimeouts transactionTimeout=""10m"" /> </behavior> "); ServiceBehaviorAttribute serviceBehavior = (ServiceBehaviorAttribute)host.Host.Description.Behaviors[typeof(ServiceBehaviorAttribute)]; ServiceSecurityAuditBehavior serviceSecurityAudit = (ServiceSecurityAuditBehavior)host.Host.Description.Behaviors[typeof(ServiceSecurityAuditBehavior)]; ServiceThrottlingBehavior serviceThrottling = (ServiceThrottlingBehavior)host.Host.Description.Behaviors[typeof(ServiceThrottlingBehavior)]; Assert.IsNotNull(serviceBehavior); Assert.IsNotNull(serviceSecurityAudit); Assert.IsNotNull(serviceThrottling); Assert.AreEqual("00:10:00", serviceBehavior.TransactionTimeout); Assert.AreEqual(AuditLogLocation.Application, serviceSecurityAudit.AuditLogLocation); Assert.IsTrue(serviceSecurityAudit.SuppressAuditFailure); Assert.AreEqual(AuditLevel.Success, serviceSecurityAudit.ServiceAuthorizationAuditLevel); Assert.AreEqual(AuditLevel.SuccessOrFailure, serviceSecurityAudit.MessageAuthenticationAuditLevel); Assert.AreEqual(121, serviceThrottling.MaxConcurrentCalls); Assert.AreEqual(122, serviceThrottling.MaxConcurrentInstances); Assert.AreEqual(123, serviceThrottling.MaxConcurrentSessions); }
void IServiceBehavior.Validate(ServiceDescription description, ServiceHostBase serviceHostBase) { m_SecurityBehavior.UseAspNetProviders = UseAspNetProviders; m_SecurityBehavior.ApplicationName = ApplicationName; m_SecurityBehavior.ImpersonateAll = ImpersonateAll; m_SecurityBehavior.Validate(description, serviceHostBase); if (SecurityAuditEnabled) { ServiceSecurityAuditBehavior securityAudit = serviceHostBase.Description.Behaviors.Find <ServiceSecurityAuditBehavior>(); if (securityAudit == null) { securityAudit = new ServiceSecurityAuditBehavior(); securityAudit.MessageAuthenticationAuditLevel = AuditLevel.SuccessOrFailure; securityAudit.ServiceAuthorizationAuditLevel = AuditLevel.SuccessOrFailure; serviceHostBase.Description.Behaviors.Add(securityAudit); } } }
private void WriteAuditEvent(StreamSecurityUpgradeAcceptor securityUpgradeAcceptor, AuditLevel auditLevel, Exception exception) { if (((this.transportSettings.AuditBehavior.MessageAuthenticationAuditLevel & auditLevel) == auditLevel) && (securityUpgradeAcceptor != null)) { string clientIdentity = string.Empty; SecurityMessageProperty remoteSecurity = securityUpgradeAcceptor.GetRemoteSecurity(); if (remoteSecurity != null) { clientIdentity = GetIdentityNameFromContext(remoteSecurity); } ServiceSecurityAuditBehavior auditBehavior = this.transportSettings.AuditBehavior; if (auditLevel == AuditLevel.Success) { SecurityAuditHelper.WriteTransportAuthenticationSuccessEvent(auditBehavior.AuditLogLocation, auditBehavior.SuppressAuditFailure, null, this.Via, clientIdentity); } else { SecurityAuditHelper.WriteTransportAuthenticationFailureEvent(auditBehavior.AuditLogLocation, auditBehavior.SuppressAuditFailure, null, this.Via, clientIdentity, exception); } } }
static void Main(string[] args) { //string srvCertCN = "sbesservice"; string srvCertCN = CertManager.Formatter.ParseName(WindowsIdentity.GetCurrent().Name); NetTcpBinding binding = new NetTcpBinding(); binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Certificate; ServiceHost host = new ServiceHost(typeof(WCFService)); string address = "net.tcp://localhost:9999/Receiver"; host.AddServiceEndpoint(typeof(IWCFContract), binding, address); host.Credentials.ClientCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.Custom; host.Credentials.ClientCertificate.Authentication.CustomCertificateValidator = new ServiceCertValidator(); host.Credentials.ClientCertificate.Authentication.RevocationMode = X509RevocationMode.NoCheck; host.Credentials.ServiceCertificate.Certificate = Manager.GetCertificateFromStorage(StoreName.My, StoreLocation.LocalMachine, srvCertCN); host.Description.Behaviors.Remove(typeof(ServiceDebugBehavior)); host.Description.Behaviors.Add(new ServiceDebugBehavior() { IncludeExceptionDetailInFaults = true }); host.Authorization.ServiceAuthorizationManager = new CustomServiceAuthorizationManager(); host.Authorization.PrincipalPermissionMode = PrincipalPermissionMode.Custom; List <IAuthorizationPolicy> policies = new List <IAuthorizationPolicy>(); policies.Add(new CustomAuthorizationPolicy()); host.Authorization.ExternalAuthorizationPolicies = policies.AsReadOnly(); // log event podesavanja ServiceSecurityAuditBehavior newAudit = new ServiceSecurityAuditBehavior(); newAudit.AuditLogLocation = AuditLogLocation.Application; newAudit.ServiceAuthorizationAuditLevel = AuditLevel.SuccessOrFailure; newAudit.SuppressAuditFailure = true; host.Description.Behaviors.Remove <ServiceSecurityAuditBehavior>(); host.Description.Behaviors.Add(newAudit); Console.WriteLine("Korisnik {0} je pokrenuo servera", WindowsIdentity.GetCurrent().Name); try { host.Open(); Console.WriteLine("WCFService is started.\nPress <enter> to stop ..."); Console.ReadLine(); } catch (Exception e) { Console.WriteLine("[ERROR] {0}", e.Message); Console.WriteLine("[StackTrace] {0}", e.StackTrace); } finally { host.Close(); } }
public static void ConnectServer() { List <string> services = new List <string>(); NetTcpBinding bindingServis = new NetTcpBinding(); bindingServis.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows; string address1 = DBFunctions.LoadMyAddress(); string a = WindowsIdentity.GetCurrent().Name; string addressServis = "net.tcp://" + address1 + "/Update"; ServiceHost hostServis = new ServiceHost(typeof(Update)); ServiceSecurityAuditBehavior newAuditBehavior = new ServiceSecurityAuditBehavior(); hostServis.AddServiceEndpoint(typeof(IUpdate), bindingServis, addressServis); hostServis.Description.Behaviors.Remove <ServiceSecurityAuditBehavior>(); hostServis.Description.Behaviors.Add(newAuditBehavior); hostServis.Open(); services = DBFunctions.CitanjeKonfiguracije(); Console.WriteLine("Nastavaka konektovanja servisa"); Console.ReadLine(); List <IUpdate> listOfWCF = new List <IUpdate>(); List <ChannelFactory <IUpdate> > listOfChannelFactory = new List <ChannelFactory <IUpdate> >(); for (int i = 0; i < services.Count; i++) { NetTcpBinding bindingIzListe = new NetTcpBinding(); bindingIzListe.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows; string adresaIzListe = "net.tcp://" + services[i] + "/Update"; IUpdate wCFService; ChannelFactory <IUpdate> channelFactory = new ChannelFactory <IUpdate>(bindingIzListe, adresaIzListe); wCFService = channelFactory.CreateChannel(); listOfChannelFactory.Add(channelFactory); listOfWCF.Add(wCFService); } Logger log = new Logger(); Console.WriteLine("WCFService is opened. Press <enter> to finish..."); while (true) { for (int i = 0; i < listOfWCF.Count; i++) { try { byte[] db1 = listOfWCF[i].IntegrityUdate(); byte[] db2 = DBFunctions.MyDatabase(); if (db2 != null) { if (DBFunctions.CompareDataBases(db1, db2)) { Console.WriteLine("Databases are the same"); } else { Console.WriteLine("Database changed"); log.WriteToEventLog("NAS", a, i, "Preuzeta baza"); } } else { DBFunctions.DesierializeXml(db1); List <Entity> entities = DBFunctions.RecivedList(); DBFunctions.WriteInDatabase(entities, DateTime.UtcNow); Console.WriteLine("Database changed"); } } catch (Exception e) { try { Console.WriteLine(e.Message); NetTcpBinding bindingIzListe = new NetTcpBinding(); bindingIzListe.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows; string adresaIzListe = "net.tcp://" + services[i] + "/Update"; ChannelFactory <IUpdate> channelFactory = new ChannelFactory <IUpdate>(bindingIzListe, adresaIzListe); listOfWCF[i] = channelFactory.CreateChannel(); } catch (Exception ee) { Console.WriteLine(ee.Message); } } } Thread.Sleep(3000); } hostServis.Close(); }
static void Main(string[] args) { NetTcpBinding binding = new NetTcpBinding(); string address1 = "net.tcp://*****:*****@ {0}", DateTime.Now); Console.WriteLine("WCFComponentService2 started @ {0}", DateTime.Now); Console.WriteLine("WCFComponentService3 started @ {0}", DateTime.Now); Console.ReadLine(); host1.Close(); host2.Close(); host3.Close(); }
static void Main(string[] args) { //iscitavam podatke iz baze Console.ReadLine(); List <Automobil> iscitaniAutomobili = new List <Automobil>(); DataContractSerializer dcs = new DataContractSerializer(typeof(List <Automobil>)); using (Stream stream = new FileStream("Automobili.xml", FileMode.OpenOrCreate, FileAccess.Read)) { using (XmlDictionaryReader reader = XmlDictionaryReader.CreateTextReader(stream, new XmlDictionaryReaderQuotas())) { reader.ReadContentAsObject(); iscitaniAutomobili = (List <Automobil>)dcs.ReadObject(reader); } } foreach (var item in iscitaniAutomobili) { Podaci.automobili[item.Registracija] = item; } List <Korisnik> iscitaniKorisnici = new List <Korisnik>(); DataContractSerializer dcs1 = new DataContractSerializer(typeof(List <Korisnik>)); using (Stream stream = new FileStream("Korisnici.xml", FileMode.OpenOrCreate, FileAccess.Read)) { using (XmlDictionaryReader reader = XmlDictionaryReader.CreateTextReader(stream, new XmlDictionaryReaderQuotas())) { reader.ReadContentAsObject(); iscitaniKorisnici = (List <Korisnik>)dcs1.ReadObject(reader); } } foreach (var item in iscitaniKorisnici) { Podaci.korisnici[item.KorisnickoIme] = item; } List <Korisnik> iscitaniZahtjevi = new List <Korisnik>(); DataContractSerializer dcs2 = new DataContractSerializer(typeof(List <Korisnik>)); using (Stream stream = new FileStream("ZahtjeviZlCl.xml", FileMode.OpenOrCreate, FileAccess.Read)) { using (XmlDictionaryReader reader = XmlDictionaryReader.CreateTextReader(stream, new XmlDictionaryReaderQuotas())) { reader.ReadContentAsObject(); iscitaniZahtjevi = (List <Korisnik>)dcs2.ReadObject(reader); } } foreach (var item in iscitaniKorisnici) { Podaci.ZahtjevZlClana.Add(item); } string servNameCrt = SecurityManager.Formatter.ParseName(WindowsIdentity.GetCurrent().Name); //string servNameCrt = "wcfservicem"; //string OU1= "admin"; //string OU2 = "clan"; //string MachineName = Environment.MachineName; //string[] parts = MachineName.Split('-'); //string MachineNameSplit = String.Format("{0}", parts[0]); //logName = String.Format("{0}LogFile", MachineNameSplit); //logSourceName = String.Format("{0}LogSourceName", "net.tcp://localhost:4000"); NetTcpBinding binding = new NetTcpBinding(); binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Certificate; string address = "net.tcp://localhost:4000/WCFService"; Audit audit = new Audit(); ServiceHost host = new ServiceHost(typeof(Admin)); //-----konfigurisanje ServiceHost obj da podrze zapisivanje bezbj.dogadjaja ServiceSecurityAuditBehavior newAuditBehavior = new ServiceSecurityAuditBehavior(); host.Description.Behaviors.Remove <ServiceSecurityAuditBehavior>(); host.Description.Behaviors.Add(newAuditBehavior); //----- host.AddServiceEndpoint(typeof(IAdmin), binding, address); //host.Authorization.ServiceAuthorizationManager = new ServiceAuthorizationManager(); //provjeriti ! //host.Description.Behaviors.Remove(typeof(ServiceDebugBehavior)); //host.Description.Behaviors.Add(new ServiceDebugBehavior() { IncludeExceptionDetailInFaults = true }); host.Credentials.ClientCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.Custom; host.Credentials.ClientCertificate.Authentication.CustomCertificateValidator = new ServiceCertificateValidator(); host.Credentials.ClientCertificate.Authentication.RevocationMode = X509RevocationMode.NoCheck; host.Credentials.ServiceCertificate.Certificate = CertificateManager.GetCertificateFromStorage(StoreName.My, StoreLocation.LocalMachine, servNameCrt /*servNameCrt,OU1,OU2*/); //host.Credentials.ServiceCertificate.SetCertificate(StoreLocation.LocalMachine, StoreName.My,X509FindType.FindBySubjectName,servNameCrt); //host.Credentials.ServiceCertificate.SetCertificate(StoreLocation.LocalMachine, StoreName.My, X509FindType.FindByThumbprint,OU1); //host.Credentials.ServiceCertificate.SetCertificate(StoreLocation.LocalMachine, StoreName.My, X509FindType.FindByThumbprint,""); host.Open(); Console.WriteLine("WCFService is opened. Press <enter> to finish..."); Console.ReadLine(); host.Close(); }
protected TransportChannelListener(TransportBindingElement bindingElement, BindingContext context, System.ServiceModel.Channels.MessageEncoderFactory defaultMessageEncoderFactory, HostNameComparisonMode hostNameComparisonMode) : base(context.Binding) { HostNameComparisonModeHelper.Validate(hostNameComparisonMode); this.hostNameComparisonMode = hostNameComparisonMode; this.manualAddressing = bindingElement.ManualAddressing; this.maxBufferPoolSize = bindingElement.MaxBufferPoolSize; this.maxReceivedMessageSize = bindingElement.MaxReceivedMessageSize; Collection <MessageEncodingBindingElement> collection = context.BindingParameters.FindAll <MessageEncodingBindingElement>(); if (collection.Count > 1) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("MultipleMebesInParameters"))); } if (collection.Count == 1) { this.messageEncoderFactory = collection[0].CreateMessageEncoderFactory(); context.BindingParameters.Remove <MessageEncodingBindingElement>(); } else { this.messageEncoderFactory = defaultMessageEncoderFactory; } if (this.messageEncoderFactory != null) { this.messageVersion = this.messageEncoderFactory.MessageVersion; } else { this.messageVersion = System.ServiceModel.Channels.MessageVersion.None; } ServiceSecurityAuditBehavior behavior = context.BindingParameters.Find <ServiceSecurityAuditBehavior>(); if (behavior != null) { this.auditBehavior = behavior.Clone(); } else { this.auditBehavior = new ServiceSecurityAuditBehavior(); } if ((context.ListenUriMode == ListenUriMode.Unique) && (context.ListenUriBaseAddress == null)) { UriBuilder builder = new UriBuilder(this.Scheme, DnsCache.MachineName) { Path = this.GeneratedAddressPrefix }; context.ListenUriBaseAddress = builder.Uri; } UriSchemeKeyedCollection.ValidateBaseAddress(context.ListenUriBaseAddress, "baseAddress"); if ((context.ListenUriBaseAddress.Scheme != this.Scheme) && (string.Compare(context.ListenUriBaseAddress.Scheme, this.Scheme, StringComparison.OrdinalIgnoreCase) != 0)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("context.ListenUriBaseAddress", System.ServiceModel.SR.GetString("InvalidUriScheme", new object[] { context.ListenUriBaseAddress.Scheme, this.Scheme })); } if (context.ListenUriMode == ListenUriMode.Explicit) { this.SetUri(context.ListenUriBaseAddress, context.ListenUriRelativeAddress); } else { string listenUriRelativeAddress = context.ListenUriRelativeAddress; if ((listenUriRelativeAddress.Length > 0) && !listenUriRelativeAddress.EndsWith("/", StringComparison.Ordinal)) { listenUriRelativeAddress = listenUriRelativeAddress + "/"; } this.SetUri(context.ListenUriBaseAddress, listenUriRelativeAddress + Guid.NewGuid().ToString()); } this.transportManagerContainer = new TransportManagerContainer(this); }
private void FillBehaviorInfo(IServiceBehavior behavior, IWmiInstance existingInstance, out IWmiInstance instance) { instance = null; if (behavior is AspNetCompatibilityRequirementsAttribute) { instance = existingInstance.NewInstance("AspNetCompatibilityRequirementsAttribute"); AspNetCompatibilityRequirementsAttribute attribute = (AspNetCompatibilityRequirementsAttribute)behavior; instance.SetProperty("RequirementsMode", attribute.RequirementsMode.ToString()); } else if (behavior is ServiceCredentials) { instance = existingInstance.NewInstance("ServiceCredentials"); ServiceCredentials credentials = (ServiceCredentials)behavior; if ((credentials.ClientCertificate != null) && (credentials.ClientCertificate.Certificate != null)) { string str = string.Empty + string.Format(CultureInfo.InvariantCulture, "Certificate: {0}\n", new object[] { credentials.ClientCertificate.Certificate }); instance.SetProperty("ClientCertificate", str); } if ((credentials.IssuedTokenAuthentication != null) && (credentials.IssuedTokenAuthentication.KnownCertificates != null)) { string str2 = (string.Empty + string.Format(CultureInfo.InvariantCulture, "AllowUntrustedRsaIssuers: {0}\n", new object[] { credentials.IssuedTokenAuthentication.AllowUntrustedRsaIssuers }) + string.Format(CultureInfo.InvariantCulture, "CertificateValidationMode: {0}\n", new object[] { credentials.IssuedTokenAuthentication.CertificateValidationMode })) + string.Format(CultureInfo.InvariantCulture, "RevocationMode: {0}\n", new object[] { credentials.IssuedTokenAuthentication.RevocationMode }) + string.Format(CultureInfo.InvariantCulture, "TrustedStoreLocation: {0}\n", new object[] { credentials.IssuedTokenAuthentication.TrustedStoreLocation }); foreach (X509Certificate2 certificate in credentials.IssuedTokenAuthentication.KnownCertificates) { if (certificate != null) { str2 = str2 + string.Format(CultureInfo.InvariantCulture, "Known certificate: {0}\n", new object[] { certificate.FriendlyName }); } } str2 = str2 + string.Format(CultureInfo.InvariantCulture, "AudienceUriMode: {0}\n", new object[] { credentials.IssuedTokenAuthentication.AudienceUriMode }); if (credentials.IssuedTokenAuthentication.AllowedAudienceUris != null) { foreach (string str3 in credentials.IssuedTokenAuthentication.AllowedAudienceUris) { if (str3 != null) { str2 = str2 + string.Format(CultureInfo.InvariantCulture, "Allowed Uri: {0}\n", new object[] { str3 }); } } } instance.SetProperty("IssuedTokenAuthentication", str2); } if ((credentials.Peer != null) && (credentials.Peer.Certificate != null)) { string str4 = string.Empty + string.Format(CultureInfo.InvariantCulture, "Certificate: {0}\n", new object[] { credentials.Peer.Certificate.ToString(true) }); instance.SetProperty("Peer", str4); } if ((credentials.SecureConversationAuthentication != null) && (credentials.SecureConversationAuthentication.SecurityContextClaimTypes != null)) { string str5 = string.Empty; foreach (System.Type type in credentials.SecureConversationAuthentication.SecurityContextClaimTypes) { if (type != null) { str5 = str5 + string.Format(CultureInfo.InvariantCulture, "ClaimType: {0}\n", new object[] { type }); } } instance.SetProperty("SecureConversationAuthentication", str5); } if ((credentials.ServiceCertificate != null) && (credentials.ServiceCertificate.Certificate != null)) { instance.SetProperty("ServiceCertificate", credentials.ServiceCertificate.Certificate.ToString()); } if (credentials.UserNameAuthentication != null) { instance.SetProperty("UserNameAuthentication", string.Format(CultureInfo.InvariantCulture, "{0}: {1}", new object[] { "ValidationMode", credentials.UserNameAuthentication.UserNamePasswordValidationMode.ToString() })); } if (credentials.WindowsAuthentication != null) { instance.SetProperty("WindowsAuthentication", string.Format(CultureInfo.InvariantCulture, "{0}: {1}", new object[] { "AllowAnonymous", credentials.WindowsAuthentication.AllowAnonymousLogons.ToString() })); } } else if (behavior is ServiceAuthorizationBehavior) { instance = existingInstance.NewInstance("ServiceAuthorizationBehavior"); ServiceAuthorizationBehavior behavior2 = (ServiceAuthorizationBehavior)behavior; instance.SetProperty("ImpersonateCallerForAllOperations", behavior2.ImpersonateCallerForAllOperations); if (behavior2.RoleProvider != null) { instance.SetProperty("RoleProvider", behavior2.RoleProvider.ToString()); } if (behavior2.ServiceAuthorizationManager != null) { instance.SetProperty("ServiceAuthorizationManager", behavior2.ServiceAuthorizationManager.ToString()); } instance.SetProperty("PrincipalPermissionMode", behavior2.PrincipalPermissionMode.ToString()); } else if (behavior is ServiceSecurityAuditBehavior) { instance = existingInstance.NewInstance("ServiceSecurityAuditBehavior"); ServiceSecurityAuditBehavior behavior3 = (ServiceSecurityAuditBehavior)behavior; instance.SetProperty("AuditLogLocation", behavior3.AuditLogLocation.ToString()); instance.SetProperty("SuppressAuditFailure", behavior3.SuppressAuditFailure); instance.SetProperty("ServiceAuthorizationAuditLevel", behavior3.ServiceAuthorizationAuditLevel.ToString()); instance.SetProperty("MessageAuthenticationAuditLevel", behavior3.MessageAuthenticationAuditLevel.ToString()); } else if (behavior is ServiceBehaviorAttribute) { instance = existingInstance.NewInstance("ServiceBehaviorAttribute"); ServiceBehaviorAttribute attribute2 = (ServiceBehaviorAttribute)behavior; instance.SetProperty("AddressFilterMode", attribute2.AddressFilterMode.ToString()); instance.SetProperty("AutomaticSessionShutdown", attribute2.AutomaticSessionShutdown); instance.SetProperty("ConcurrencyMode", attribute2.ConcurrencyMode.ToString()); instance.SetProperty("ConfigurationName", attribute2.ConfigurationName); instance.SetProperty("IgnoreExtensionDataObject", attribute2.IgnoreExtensionDataObject); instance.SetProperty("IncludeExceptionDetailInFaults", attribute2.IncludeExceptionDetailInFaults); instance.SetProperty("InstanceContextMode", attribute2.InstanceContextMode.ToString()); instance.SetProperty("MaxItemsInObjectGraph", attribute2.MaxItemsInObjectGraph); instance.SetProperty("Name", attribute2.Name); instance.SetProperty("Namespace", attribute2.Namespace); instance.SetProperty("ReleaseServiceInstanceOnTransactionComplete", attribute2.ReleaseServiceInstanceOnTransactionComplete); instance.SetProperty("TransactionAutoCompleteOnSessionClose", attribute2.TransactionAutoCompleteOnSessionClose); instance.SetProperty("TransactionIsolationLevel", attribute2.TransactionIsolationLevel.ToString()); if (attribute2.TransactionTimeoutSet) { instance.SetProperty("TransactionTimeout", attribute2.TransactionTimeoutTimespan); } instance.SetProperty("UseSynchronizationContext", attribute2.UseSynchronizationContext); instance.SetProperty("ValidateMustUnderstand", attribute2.ValidateMustUnderstand); } else if (behavior is ServiceDebugBehavior) { instance = existingInstance.NewInstance("ServiceDebugBehavior"); ServiceDebugBehavior behavior4 = (ServiceDebugBehavior)behavior; if (null != behavior4.HttpHelpPageUrl) { instance.SetProperty("HttpHelpPageUrl", behavior4.HttpHelpPageUrl.ToString()); } instance.SetProperty("HttpHelpPageEnabled", behavior4.HttpHelpPageEnabled); if (null != behavior4.HttpsHelpPageUrl) { instance.SetProperty("HttpsHelpPageUrl", behavior4.HttpsHelpPageUrl.ToString()); } instance.SetProperty("HttpsHelpPageEnabled", behavior4.HttpsHelpPageEnabled); instance.SetProperty("IncludeExceptionDetailInFaults", behavior4.IncludeExceptionDetailInFaults); } else if (behavior is ServiceMetadataBehavior) { instance = existingInstance.NewInstance("ServiceMetadataBehavior"); ServiceMetadataBehavior behavior5 = (ServiceMetadataBehavior)behavior; if (null != behavior5.ExternalMetadataLocation) { instance.SetProperty("ExternalMetadataLocation", behavior5.ExternalMetadataLocation.ToString()); } instance.SetProperty("HttpGetEnabled", behavior5.HttpGetEnabled); if (null != behavior5.HttpGetUrl) { instance.SetProperty("HttpGetUrl", behavior5.HttpGetUrl.ToString()); } instance.SetProperty("HttpsGetEnabled", behavior5.HttpsGetEnabled); if (null != behavior5.HttpsGetUrl) { instance.SetProperty("HttpsGetUrl", behavior5.HttpsGetUrl.ToString()); } this.FillMetadataExporterInfo(instance, behavior5.MetadataExporter); } else if (behavior is ServiceThrottlingBehavior) { instance = existingInstance.NewInstance("ServiceThrottlingBehavior"); ServiceThrottlingBehavior behavior6 = (ServiceThrottlingBehavior)behavior; instance.SetProperty("MaxConcurrentCalls", behavior6.MaxConcurrentCalls); instance.SetProperty("MaxConcurrentSessions", behavior6.MaxConcurrentSessions); instance.SetProperty("MaxConcurrentInstances", behavior6.MaxConcurrentInstances); } else if (behavior is ServiceTimeoutsBehavior) { instance = existingInstance.NewInstance("ServiceTimeoutsBehavior"); ServiceTimeoutsBehavior behavior7 = (ServiceTimeoutsBehavior)behavior; instance.SetProperty("TransactionTimeout", behavior7.TransactionTimeout); } else if (behavior is IWmiInstanceProvider) { IWmiInstanceProvider provider = (IWmiInstanceProvider)behavior; instance = existingInstance.NewInstance(provider.GetInstanceType()); provider.FillInstance(instance); } else { instance = existingInstance.NewInstance("Behavior"); } if (instance != null) { instance.SetProperty("Type", behavior.GetType().FullName); } }
static void Main(string[] args) { Baza_podataka = napraviBazu(); serveri.Add("net.tcp://localhost:8888/WCFService"); serveri.Add("net.tcp://localhost:8887/WCFService"); serveri.Add("net.tcp://localhost:8886/WCFService"); string srvCertCN = Formatter.ParseName(WindowsIdentity.GetCurrent().Name); NetTcpBinding binding = new NetTcpBinding(); binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Certificate; string address = args[0]; ServiceHost host = new ServiceHost(typeof(WCFService)); host.AddServiceEndpoint(typeof(IWCFService), binding, address); host.Credentials.ServiceCertificate.Certificate = Manager.CertManager.GetCertificateFromStorage(StoreName.My, StoreLocation.LocalMachine, srvCertCN); Console.WriteLine(Manager.CertManager.GetCertificateFromStorage(StoreName.My, StoreLocation.LocalMachine, srvCertCN)); host.Credentials.ClientCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.ChainTrust; ///If CA doesn't have a CRL associated, WCF blocks every client because it cannot be validated host.Credentials.ClientCertificate.Authentication.RevocationMode = X509RevocationMode.NoCheck; NetTcpBinding binding1 = new NetTcpBinding(); binding1.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows; trenutna_adresa = args[1]; ServiceHost host1 = new ServiceHost(typeof(Replicator)); host1.AddServiceEndpoint(typeof(IReplicator), binding1, trenutna_adresa); host1.Description.Behaviors.Remove(typeof(ServiceDebugBehavior)); host1.Description.Behaviors.Add(new ServiceDebugBehavior() { IncludeExceptionDetailInFaults = true }); Thread t1 = new Thread(new ThreadStart(Replicator)); t1.Start(); host.Description.Behaviors.Remove(typeof(ServiceDebugBehavior)); host.Description.Behaviors.Add(new ServiceDebugBehavior() { IncludeExceptionDetailInFaults = true }); ServiceSecurityAuditBehavior newAudit = new ServiceSecurityAuditBehavior(); newAudit.AuditLogLocation = AuditLogLocation.Application; newAudit.ServiceAuthorizationAuditLevel = AuditLevel.SuccessOrFailure; newAudit.SuppressAuditFailure = true; host.Description.Behaviors.Remove <ServiceSecurityAuditBehavior>(); host.Description.Behaviors.Add(newAudit); host1.Description.Behaviors.Remove <ServiceSecurityAuditBehavior>(); host1.Description.Behaviors.Add(newAudit); host.Open(); host1.Open(); Console.WriteLine("WCFService is opened. Press <enter> to finish..."); Console.ReadLine(); host.Close(); }
protected TransportChannelListener(TransportBindingElement bindingElement, BindingContext context, System.ServiceModel.Channels.MessageEncoderFactory defaultMessageEncoderFactory, HostNameComparisonMode hostNameComparisonMode) : base(context.Binding) { Microsoft.ServiceBus.Channels.HostNameComparisonModeHelper.Validate(hostNameComparisonMode); this.hostNameComparisonMode = hostNameComparisonMode; this.manualAddressing = bindingElement.ManualAddressing; this.maxBufferPoolSize = bindingElement.MaxBufferPoolSize; this.maxReceivedMessageSize = bindingElement.MaxReceivedMessageSize; Collection <MessageEncodingBindingElement> messageEncodingBindingElements = context.BindingParameters.FindAll <MessageEncodingBindingElement>(); if (messageEncodingBindingElements.Count > 1) { throw Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(Microsoft.ServiceBus.SR.GetString(Resources.MultipleMebesInParameters, new object[0]))); } if (messageEncodingBindingElements.Count != 1) { this.messageEncoderFactory = defaultMessageEncoderFactory; } else { this.messageEncoderFactory = messageEncodingBindingElements[0].CreateMessageEncoderFactory(); context.BindingParameters.Remove <MessageEncodingBindingElement>(); } if (this.messageEncoderFactory == null) { this.messageVersion = System.ServiceModel.Channels.MessageVersion.None; } else { this.messageVersion = this.messageEncoderFactory.MessageVersion; } ServiceSecurityAuditBehavior serviceSecurityAuditBehavior = context.BindingParameters.Find <ServiceSecurityAuditBehavior>(); if (serviceSecurityAuditBehavior == null) { this.auditBehavior = new ServiceSecurityAuditBehavior(); } else { this.auditBehavior = (ServiceSecurityAuditBehavior)InvokeHelper.InvokeInstanceMethod(typeof(ServiceSecurityAuditBehavior), serviceSecurityAuditBehavior, "Clone", new object[0]); } if (context.ListenUriMode == ListenUriMode.Unique && context.ListenUriBaseAddress == null) { UriBuilder uriBuilder = new UriBuilder(this.Scheme, Microsoft.ServiceBus.Channels.DnsCache.MachineName) { Path = this.GeneratedAddressPrefix }; context.ListenUriBaseAddress = uriBuilder.Uri; } Microsoft.ServiceBus.Channels.UriSchemeKeyedCollection.ValidateBaseAddress(context.ListenUriBaseAddress, "baseAddress"); if (context.ListenUriBaseAddress.Scheme != this.Scheme && !context.ListenUriBaseAddress.Scheme.Equals("sbwss") && string.Compare(context.ListenUriBaseAddress.Scheme, this.Scheme, StringComparison.OrdinalIgnoreCase) != 0) { ExceptionUtility exceptionUtility = Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ExceptionUtility; string invalidUriScheme = Resources.InvalidUriScheme; object[] scheme = new object[] { context.ListenUriBaseAddress.Scheme, this.Scheme }; throw exceptionUtility.ThrowHelperArgument("context.ListenUriBaseAddress", Microsoft.ServiceBus.SR.GetString(invalidUriScheme, scheme)); } Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.DebugAssert(context.ListenUriRelativeAddress != null, ""); if (context.ListenUriMode != ListenUriMode.Explicit) { string listenUriRelativeAddress = context.ListenUriRelativeAddress; if (listenUriRelativeAddress.Length > 0 && !listenUriRelativeAddress.EndsWith("/", StringComparison.Ordinal)) { listenUriRelativeAddress = string.Concat(listenUriRelativeAddress, "/"); } System.Uri listenUriBaseAddress = context.ListenUriBaseAddress; Guid guid = Guid.NewGuid(); this.SetUri(listenUriBaseAddress, string.Concat(listenUriRelativeAddress, guid.ToString())); } else { this.SetUri(context.ListenUriBaseAddress, context.ListenUriRelativeAddress); } this.transportManagerContainer = new Microsoft.ServiceBus.Channels.TransportManagerContainer(this); }
static void Main(string[] args) { // communication protocol NetTcpBinding binding = new NetTcpBinding(); binding.Security.Mode = SecurityMode.Transport; binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows; binding.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.EncryptAndSign; string address = "net.tcp://localhost:9999/DomainControllerClient"; string addressService = "net.tcp://localhost:9999/DomainControllerService"; ServiceHost serviceHost = new ServiceHost(typeof(DomainController)); serviceHost.AddServiceEndpoint(typeof(IDomainControllerClient), binding, address); serviceHost.AddServiceEndpoint(typeof(IDomainControllerService), binding, addressService); serviceHost.Description.Behaviors.Remove(typeof(ServiceDebugBehavior)); serviceHost.Description.Behaviors.Add(new ServiceDebugBehavior() { IncludeExceptionDetailInFaults = true }); try { serviceHost.Open(); } catch (Exception e) { Console.WriteLine("Failed to start Domain Controller. Error: {0}", e.Message); Console.WriteLine("Press return to exit."); Console.ReadLine(); return; } //Authentication Service Audit ServiceSecurityAuditBehavior asAudit = new ServiceSecurityAuditBehavior(); asAudit.AuditLogLocation = AuditLogLocation.Application; asAudit.ServiceAuthorizationAuditLevel = AuditLevel.SuccessOrFailure; //Authentication Service Hosts ServiceHost ASHost = new ServiceHost(typeof(AuthService)); ASHost.Description.Behaviors.Remove <ServiceSecurityAuditBehavior>(); ASHost.Description.Behaviors.Add(asAudit); ASHost.AddServiceEndpoint(typeof(IAuthenticationService), binding, "net.tcp://localhost:10000/AuthService"); ASHost.Description.Behaviors.Remove(typeof(ServiceDebugBehavior)); ASHost.Description.Behaviors.Add(new ServiceDebugBehavior() { IncludeExceptionDetailInFaults = true }); try { ASHost.Open(); } catch (Exception e) { Console.WriteLine("Failed to start Authentication Service. Error: {0}", e.Message); Console.WriteLine("Press return to exit."); Console.ReadLine(); serviceHost.Close(); return; } //Ticket Granting Service Audit ServiceSecurityAuditBehavior tgsAudit = new ServiceSecurityAuditBehavior(); tgsAudit.AuditLogLocation = AuditLogLocation.Application; tgsAudit.ServiceAuthorizationAuditLevel = AuditLevel.SuccessOrFailure; //Ticket granting service Hosts ServiceHost TGSHost = new ServiceHost(typeof(TGService)); TGSHost.Description.Behaviors.Remove <ServiceSecurityAuditBehavior>(); TGSHost.Description.Behaviors.Add(tgsAudit); TGSHost.AddServiceEndpoint(typeof(ITicketGrantingService), binding, "net.tcp://localhost:10001/TGService"); TGSHost.Description.Behaviors.Remove(typeof(ServiceDebugBehavior)); TGSHost.Description.Behaviors.Add(new ServiceDebugBehavior() { IncludeExceptionDetailInFaults = true }); try { TGSHost.Open(); } catch (Exception e) { Console.WriteLine("Failed to start Ticket Granting Service. Error: {0}", e.Message); Console.WriteLine("Press return to exit."); Console.ReadLine(); ASHost.Close(); serviceHost.Close(); return; } Console.WriteLine("Server domain controller client started..."); Console.WriteLine("Server domain controller service started..."); Console.ReadLine(); ASHost.Close(); TGSHost.Close(); serviceHost.Close(); }
static void Main(string[] args) { /// srvCertCN.SubjectName should be set to the service's username. .NET WindowsIdentity class provides information about Windows user running the given process string srvCertCN = Formatter.ParseName(WindowsIdentity.GetCurrent().Name); //sbesserver NetTcpBinding binding = new NetTcpBinding(); binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Certificate; string address = "net.tcp://localhost:9999/Receiver"; ServiceHost host = new ServiceHost(typeof(WCFService)); host.AddServiceEndpoint(typeof(IWCFService), binding, address); ///Custom validation mode enables creation of a custom validator - CustomCertificateValidator host.Credentials.ClientCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.Custom; host.Credentials.ClientCertificate.Authentication.CustomCertificateValidator = new ServiceCertValidator(); ///If CA doesn't have a CRL associated, WCF blocks every client because it cannot be validated host.Credentials.ClientCertificate.Authentication.RevocationMode = X509RevocationMode.NoCheck; ///Set appropriate service's certificate on the host. Use CertManager class to obtain the certificate based on the "srvCertCN" host.Credentials.ServiceCertificate.Certificate = CertManager.GetCertificateFromStorage(StoreName.My, StoreLocation.LocalMachine, srvCertCN); ///Set custom policy host.Authorization.PrincipalPermissionMode = PrincipalPermissionMode.Custom; List <IAuthorizationPolicy> policies = new List <IAuthorizationPolicy>(); policies.Add(new CustomAuthorizationPolicy()); host.Authorization.ExternalAuthorizationPolicies = policies.AsReadOnly(); ///AuditBehaviour ServiceSecurityAuditBehavior newAudit = new ServiceSecurityAuditBehavior(); newAudit.AuditLogLocation = AuditLogLocation.Application; newAudit.ServiceAuthorizationAuditLevel = AuditLevel.SuccessOrFailure; host.Description.Behaviors.Remove <ServiceSecurityAuditBehavior>(); host.Description.Behaviors.Add(newAudit); Database.performances = Database.ReadPerformances(); Database.reservations = Database.ReadReservations(); Database.users = Database.ReadUsers(); Database.ReadDiscount(); try { host.Open(); Console.WriteLine("WCFService is started.\nPress <enter> to stop..."); Console.ReadLine(); } catch (Exception e) { Console.WriteLine("[ERROR] {0}", e.Message); Console.WriteLine("[StackTrace] {0}", e.StackTrace); Console.ReadLine(); } finally { host.Close(); } }
protected TransportChannelListener(TransportBindingElement bindingElement, BindingContext context, MessageEncoderFactory defaultMessageEncoderFactory, HostNameComparisonMode hostNameComparisonMode) : base(context.Binding) { HostNameComparisonModeHelper.Validate(hostNameComparisonMode); this.hostNameComparisonMode = hostNameComparisonMode; this.manualAddressing = bindingElement.ManualAddressing; this.maxBufferPoolSize = bindingElement.MaxBufferPoolSize; this.maxReceivedMessageSize = bindingElement.MaxReceivedMessageSize; Collection <MessageEncodingBindingElement> messageEncoderBindingElements = context.BindingParameters.FindAll <MessageEncodingBindingElement>(); if (messageEncoderBindingElements.Count > 1) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.MultipleMebesInParameters))); } else if (messageEncoderBindingElements.Count == 1) { this.messageEncoderFactory = messageEncoderBindingElements[0].CreateMessageEncoderFactory(); context.BindingParameters.Remove <MessageEncodingBindingElement>(); } else { this.messageEncoderFactory = defaultMessageEncoderFactory; } if (null != this.messageEncoderFactory) { this.messageVersion = this.messageEncoderFactory.MessageVersion; } else { this.messageVersion = MessageVersion.None; } ServiceSecurityAuditBehavior auditBehavior = context.BindingParameters.Find <ServiceSecurityAuditBehavior>(); if (auditBehavior != null) { this.auditBehavior = auditBehavior.Clone(); } else { this.auditBehavior = new ServiceSecurityAuditBehavior(); } if ((context.ListenUriMode == ListenUriMode.Unique) && (context.ListenUriBaseAddress == null)) { UriBuilder uriBuilder = new UriBuilder(this.Scheme, DnsCache.MachineName); uriBuilder.Path = this.GeneratedAddressPrefix; context.ListenUriBaseAddress = uriBuilder.Uri; } UriSchemeKeyedCollection.ValidateBaseAddress(context.ListenUriBaseAddress, "baseAddress"); if (context.ListenUriBaseAddress.Scheme != this.Scheme) { // URI schemes are case-insensitive, so try a case insensitive compare now if (string.Compare(context.ListenUriBaseAddress.Scheme, this.Scheme, StringComparison.OrdinalIgnoreCase) != 0) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument( "context.ListenUriBaseAddress", SR.GetString(SR.InvalidUriScheme, context.ListenUriBaseAddress.Scheme, this.Scheme)); } } Fx.Assert(context.ListenUriRelativeAddress != null, ""); // validated by BindingContext if (context.ListenUriMode == ListenUriMode.Explicit) { this.SetUri(context.ListenUriBaseAddress, context.ListenUriRelativeAddress); } else // ListenUriMode.Unique: { string relativeAddress = context.ListenUriRelativeAddress; if (relativeAddress.Length > 0 && !relativeAddress.EndsWith("/", StringComparison.Ordinal)) { relativeAddress += "/"; } this.SetUri(context.ListenUriBaseAddress, relativeAddress + Guid.NewGuid().ToString()); } this.transportManagerContainer = new TransportManagerContainer(this); }
void FillBehaviorInfo(IServiceBehavior behavior, IWmiInstance existingInstance, out IWmiInstance instance) { Fx.Assert(null != existingInstance, ""); Fx.Assert(null != behavior, ""); instance = null; if (behavior is AspNetCompatibilityRequirementsAttribute) { instance = existingInstance.NewInstance("AspNetCompatibilityRequirementsAttribute"); AspNetCompatibilityRequirementsAttribute specificBehavior = (AspNetCompatibilityRequirementsAttribute)behavior; instance.SetProperty(AdministrationStrings.RequirementsMode, specificBehavior.RequirementsMode.ToString()); } else if (behavior is ServiceCredentials) { instance = existingInstance.NewInstance("ServiceCredentials"); ServiceCredentials specificBehavior = (ServiceCredentials)behavior; if (specificBehavior.ClientCertificate != null && specificBehavior.ClientCertificate.Certificate != null) { string result = string.Empty; result += String.Format(CultureInfo.InvariantCulture, "Certificate: {0}\n", specificBehavior.ClientCertificate.Certificate); instance.SetProperty(AdministrationStrings.ClientCertificate, result); } if (specificBehavior.IssuedTokenAuthentication != null && specificBehavior.IssuedTokenAuthentication.KnownCertificates != null) { string result = string.Empty; result += String.Format(CultureInfo.InvariantCulture, "AllowUntrustedRsaIssuers: {0}\n", specificBehavior.IssuedTokenAuthentication.AllowUntrustedRsaIssuers); result += String.Format(CultureInfo.InvariantCulture, "CertificateValidationMode: {0}\n", specificBehavior.IssuedTokenAuthentication.CertificateValidationMode); result += String.Format(CultureInfo.InvariantCulture, "RevocationMode: {0}\n", specificBehavior.IssuedTokenAuthentication.RevocationMode); result += String.Format(CultureInfo.InvariantCulture, "TrustedStoreLocation: {0}\n", specificBehavior.IssuedTokenAuthentication.TrustedStoreLocation); foreach (X509Certificate2 certificate in specificBehavior.IssuedTokenAuthentication.KnownCertificates) { if (certificate != null) { result += String.Format(CultureInfo.InvariantCulture, "Known certificate: {0}\n", certificate.FriendlyName); } } result += String.Format(CultureInfo.InvariantCulture, "AudienceUriMode: {0}\n", specificBehavior.IssuedTokenAuthentication.AudienceUriMode); if (specificBehavior.IssuedTokenAuthentication.AllowedAudienceUris != null) { foreach (string str in specificBehavior.IssuedTokenAuthentication.AllowedAudienceUris) { if (str != null) { result += String.Format(CultureInfo.InvariantCulture, "Allowed Uri: {0}\n", str); } } } instance.SetProperty(AdministrationStrings.IssuedTokenAuthentication, result); } if (specificBehavior.Peer != null && specificBehavior.Peer.Certificate != null) { string result = string.Empty; result += String.Format(CultureInfo.InvariantCulture, "Certificate: {0}\n", specificBehavior.Peer.Certificate.ToString(true)); instance.SetProperty(AdministrationStrings.Peer, result); } if (specificBehavior.SecureConversationAuthentication != null && specificBehavior.SecureConversationAuthentication.SecurityContextClaimTypes != null) { string result = string.Empty; foreach (Type claimType in specificBehavior.SecureConversationAuthentication.SecurityContextClaimTypes) { if (claimType != null) { result += String.Format(CultureInfo.InvariantCulture, "ClaimType: {0}\n", claimType); } } instance.SetProperty(AdministrationStrings.SecureConversationAuthentication, result); } if (specificBehavior.ServiceCertificate != null && specificBehavior.ServiceCertificate.Certificate != null) { instance.SetProperty(AdministrationStrings.ServiceCertificate, specificBehavior.ServiceCertificate.Certificate.ToString()); } if (specificBehavior.UserNameAuthentication != null) { instance.SetProperty(AdministrationStrings.UserNameAuthentication, String.Format(CultureInfo.InvariantCulture, "{0}: {1}", AdministrationStrings.ValidationMode, specificBehavior.UserNameAuthentication.UserNamePasswordValidationMode.ToString())); } if (specificBehavior.WindowsAuthentication != null) { instance.SetProperty(AdministrationStrings.WindowsAuthentication, String.Format(CultureInfo.InvariantCulture, "{0}: {1}", AdministrationStrings.AllowAnonymous, specificBehavior.WindowsAuthentication.AllowAnonymousLogons.ToString())); } } else if (behavior is ServiceAuthorizationBehavior) { instance = existingInstance.NewInstance("ServiceAuthorizationBehavior"); ServiceAuthorizationBehavior specificBehavior = (ServiceAuthorizationBehavior)behavior; instance.SetProperty(AdministrationStrings.ImpersonateCallerForAllOperations, specificBehavior.ImpersonateCallerForAllOperations); instance.SetProperty(AdministrationStrings.ImpersonateOnSerializingReply, specificBehavior.ImpersonateOnSerializingReply); if (specificBehavior.RoleProvider != null) { instance.SetProperty(AdministrationStrings.RoleProvider, specificBehavior.RoleProvider.ToString()); } if (specificBehavior.ServiceAuthorizationManager != null) { instance.SetProperty(AdministrationStrings.ServiceAuthorizationManager, specificBehavior.ServiceAuthorizationManager.ToString()); } instance.SetProperty(AdministrationStrings.PrincipalPermissionMode, specificBehavior.PrincipalPermissionMode.ToString()); } else if (behavior is ServiceSecurityAuditBehavior) { instance = existingInstance.NewInstance("ServiceSecurityAuditBehavior"); ServiceSecurityAuditBehavior specificBehavior = (ServiceSecurityAuditBehavior)behavior; instance.SetProperty(AdministrationStrings.AuditLogLocation, specificBehavior.AuditLogLocation.ToString()); instance.SetProperty(AdministrationStrings.SuppressAuditFailure, specificBehavior.SuppressAuditFailure); instance.SetProperty(AdministrationStrings.ServiceAuthorizationAuditLevel, specificBehavior.ServiceAuthorizationAuditLevel.ToString()); instance.SetProperty(AdministrationStrings.MessageAuthenticationAuditLevel, specificBehavior.MessageAuthenticationAuditLevel.ToString()); } else if (behavior is ServiceBehaviorAttribute) { instance = existingInstance.NewInstance("ServiceBehaviorAttribute"); ServiceBehaviorAttribute serviceBehavior = (ServiceBehaviorAttribute)behavior; instance.SetProperty(AdministrationStrings.AddressFilterMode, serviceBehavior.AddressFilterMode.ToString()); instance.SetProperty(AdministrationStrings.AutomaticSessionShutdown, serviceBehavior.AutomaticSessionShutdown); instance.SetProperty(AdministrationStrings.ConcurrencyMode, serviceBehavior.ConcurrencyMode.ToString()); instance.SetProperty(AdministrationStrings.ConfigurationName, serviceBehavior.ConfigurationName); instance.SetProperty(AdministrationStrings.EnsureOrderedDispatch, serviceBehavior.EnsureOrderedDispatch); instance.SetProperty(AdministrationStrings.IgnoreExtensionDataObject, serviceBehavior.IgnoreExtensionDataObject); instance.SetProperty(AdministrationStrings.IncludeExceptionDetailInFaults, serviceBehavior.IncludeExceptionDetailInFaults); instance.SetProperty(AdministrationStrings.InstanceContextMode, serviceBehavior.InstanceContextMode.ToString()); instance.SetProperty(AdministrationStrings.MaxItemsInObjectGraph, serviceBehavior.MaxItemsInObjectGraph); instance.SetProperty(AdministrationStrings.Name, serviceBehavior.Name); instance.SetProperty(AdministrationStrings.Namespace, serviceBehavior.Namespace); instance.SetProperty(AdministrationStrings.ReleaseServiceInstanceOnTransactionComplete, serviceBehavior.ReleaseServiceInstanceOnTransactionComplete); instance.SetProperty(AdministrationStrings.TransactionAutoCompleteOnSessionClose, serviceBehavior.TransactionAutoCompleteOnSessionClose); instance.SetProperty(AdministrationStrings.TransactionIsolationLevel, serviceBehavior.TransactionIsolationLevel.ToString()); if (serviceBehavior.TransactionTimeoutSet) { instance.SetProperty(AdministrationStrings.TransactionTimeout, serviceBehavior.TransactionTimeoutTimespan); } instance.SetProperty(AdministrationStrings.UseSynchronizationContext, serviceBehavior.UseSynchronizationContext); instance.SetProperty(AdministrationStrings.ValidateMustUnderstand, serviceBehavior.ValidateMustUnderstand); } else if (behavior is ServiceDebugBehavior) { instance = existingInstance.NewInstance("ServiceDebugBehavior"); ServiceDebugBehavior specificBehavior = (ServiceDebugBehavior)behavior; if (null != specificBehavior.HttpHelpPageUrl) { instance.SetProperty(AdministrationStrings.HttpHelpPageUrl, specificBehavior.HttpHelpPageUrl.ToString()); } instance.SetProperty(AdministrationStrings.HttpHelpPageEnabled, specificBehavior.HttpHelpPageEnabled); if (null != specificBehavior.HttpsHelpPageUrl) { instance.SetProperty(AdministrationStrings.HttpsHelpPageUrl, specificBehavior.HttpsHelpPageUrl.ToString()); } instance.SetProperty(AdministrationStrings.HttpsHelpPageEnabled, specificBehavior.HttpsHelpPageEnabled); instance.SetProperty(AdministrationStrings.IncludeExceptionDetailInFaults, specificBehavior.IncludeExceptionDetailInFaults); } else if (behavior is ServiceMetadataBehavior) { instance = existingInstance.NewInstance("ServiceMetadataBehavior"); ServiceMetadataBehavior metadataBehavior = (ServiceMetadataBehavior)behavior; if (null != metadataBehavior.ExternalMetadataLocation) { instance.SetProperty(AdministrationStrings.ExternalMetadataLocation, metadataBehavior.ExternalMetadataLocation.ToString()); } instance.SetProperty(AdministrationStrings.HttpGetEnabled, metadataBehavior.HttpGetEnabled); if (null != metadataBehavior.HttpGetUrl) { instance.SetProperty(AdministrationStrings.HttpGetUrl, metadataBehavior.HttpGetUrl.ToString()); } instance.SetProperty(AdministrationStrings.HttpsGetEnabled, metadataBehavior.HttpsGetEnabled); if (null != metadataBehavior.HttpsGetUrl) { instance.SetProperty(AdministrationStrings.HttpsGetUrl, metadataBehavior.HttpsGetUrl.ToString()); } FillMetadataExporterInfo(instance, metadataBehavior.MetadataExporter); } else if (behavior is ServiceThrottlingBehavior) { instance = existingInstance.NewInstance("ServiceThrottlingBehavior"); ServiceThrottlingBehavior throttlingBehavior = (ServiceThrottlingBehavior)behavior; instance.SetProperty(AdministrationStrings.MaxConcurrentCalls, throttlingBehavior.MaxConcurrentCalls); instance.SetProperty(AdministrationStrings.MaxConcurrentSessions, throttlingBehavior.MaxConcurrentSessions); instance.SetProperty(AdministrationStrings.MaxConcurrentInstances, throttlingBehavior.MaxConcurrentInstances); } else if (behavior is ServiceTimeoutsBehavior) { instance = existingInstance.NewInstance("ServiceTimeoutsBehavior"); ServiceTimeoutsBehavior specificBehavior = (ServiceTimeoutsBehavior)behavior; instance.SetProperty(AdministrationStrings.TransactionTimeout, specificBehavior.TransactionTimeout); } else if (behavior is IWmiInstanceProvider) { IWmiInstanceProvider instanceProvider = (IWmiInstanceProvider)behavior; instance = existingInstance.NewInstance(instanceProvider.GetInstanceType()); instanceProvider.FillInstance(instance); } else { instance = existingInstance.NewInstance("Behavior"); } if (null != instance) { instance.SetProperty(AdministrationStrings.Type, behavior.GetType().FullName); } }
/// <summary> /// Parses the service behaviors encoded as XML and applies them to the hosted service. /// </summary> /// <param name="behaviors">The service behavior XML (or <c>null</c> or an empty string).</param> /// <remarks> /// <para> /// The current implementation supports the parsing of a limited set of possible /// service behaviors implemented by WCF. Support for the other behaviors will be /// added in a future release. Here's the current implementation status: /// </para> /// <list type="table"> /// <item> /// <term><see cref="DataContractSerializer" /></term> /// <description><b>Not Implemented</b></description> /// </item> /// <item> /// <term><see cref="PersistenceProvider" /></term> /// <description><b>Not Implemented</b></description> /// </item> /// <item> /// <term><see cref="ServiceAuthorizationBehavior" /></term> /// <description><b>Not Implemented</b></description> /// </item> /// <item> /// <term><see cref="ServiceCredentials" /></term> /// <description><b>Not Implemented</b></description> /// </item> /// <item> /// <term><see cref="ServiceDebugBehavior" /></term> /// <description><b>Not Implemented</b></description> /// </item> /// <item> /// <term><see cref="ServiceMetadataBehavior" /></term> /// <description><b>Not Implemented</b></description> /// </item> /// <item> /// <term><see cref="ServiceSecurityAuditBehavior" /></term> /// <description><b>Implemented</b></description> /// </item> /// <item> /// <term><see cref="ServiceThrottlingBehavior" /></term> /// <description><b>Implemented</b></description> /// </item> /// <item> /// <term><see cref="ServiceTimeoutsBehavior" /></term> /// <description><b>Implemented</b></description> /// </item> /// <item> /// <term><see cref="WorkflowRuntimeBehavior" /></term> /// <description><b>Not Implemented</b></description> /// </item> /// </list> /// <para> /// The XML format for a service behavior is the same as found in /// standard .NET configuration files. Here's an example: /// </para> /// <code language="none"> /// <behavior> /// <serviceThrottling maxConcurrentCalls="100" /> /// <serviceTimeouts transactionTimeout="00:01:00" /> /// </behavior> /// </code> /// </remarks> public void AddBehaviors(string behaviors) { if (string.IsNullOrWhiteSpace(behaviors)) { return; } LillTek.Xml.XmlNode root = LillTek.Xml.XmlNode.Parse(behaviors); if (root.Name != "behavior") { throw new ArgumentException("<behavior> expected as the root XML element."); } try { // Default service behavior attributes. ServiceBehaviorAttribute serviceBehavior = (ServiceBehaviorAttribute)host.Description.Behaviors[typeof(ServiceBehaviorAttribute)]; if (serviceBehavior != null) { string sTimeout; TimeSpan timeout; sTimeout = root["/serviceTimeouts/transactionTimeout"]; if (sTimeout != null) { timeout = Serialize.Parse(sTimeout, TimeSpan.Zero); if (timeout > TimeSpan.Zero) { serviceBehavior.TransactionTimeout = timeout.ToString(); } } } // ServiceSecurityAudit var serviceSecurityAudit = new ServiceSecurityAuditBehavior(); serviceSecurityAudit.AuditLogLocation = Serialize.Parse <AuditLogLocation>(root["/serviceSecurityAudit/auditLogLocation"], serviceSecurityAudit.AuditLogLocation); serviceSecurityAudit.MessageAuthenticationAuditLevel = Serialize.Parse <AuditLevel>(root["/serviceSecurityAudit/messageAuthenticationAuditLevel"], serviceSecurityAudit.MessageAuthenticationAuditLevel); serviceSecurityAudit.ServiceAuthorizationAuditLevel = Serialize.Parse <AuditLevel>(root["/serviceSecurityAudit/serviceAuthorizationAuditLevel"], serviceSecurityAudit.ServiceAuthorizationAuditLevel); serviceSecurityAudit.SuppressAuditFailure = Serialize.Parse(root["/serviceSecurityAudit/suppressAuditFailure"], serviceSecurityAudit.SuppressAuditFailure); host.Description.Behaviors.Add(serviceSecurityAudit); // ServiceThrottling var serviceThrottling = new ServiceThrottlingBehavior(); serviceThrottling.MaxConcurrentCalls = Serialize.Parse(root["/serviceThrottling/maxConcurrentCalls"], serviceThrottling.MaxConcurrentCalls); serviceThrottling.MaxConcurrentInstances = Serialize.Parse(root["/serviceThrottling/maxConcurrentInstances"], serviceThrottling.MaxConcurrentInstances); serviceThrottling.MaxConcurrentSessions = Serialize.Parse(root["/serviceThrottling/maxConcurrentSessions"], serviceThrottling.MaxConcurrentSessions); host.Description.Behaviors.Add(serviceThrottling); // Check for unsupported behaviors var unsupported = new string[] { "dataContractSerializer", "persistenceProvider", "serviceAuthorization", "serviceCredentials", "serviceDebug", "serviceMetadata", "workflowRuntime" }; foreach (string behavior in unsupported) { if (root.GetNode(behavior) != null) { throw new NotImplementedException(string.Format("<{0}> behavior parsing is not supported by the LillTek Platform at this time.", behavior)); } } } catch (Exception e) { throw new ArgumentException("Error parsing WcfServiceHost behavior: " + e.Message, e); } }