static void Main() { try { string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; ValueManager.ValueManagerType = typeof(MultiThreadValueManager <>).GetGenericTypeDefinition(); Console.WriteLine(@"Starting..."); var serverApplication = new ConsoleApplicationServerServerApplication(new SecurityStrategyComplex(typeof(SecuritySystemUser), typeof(SecuritySystemRole), new AuthenticationStandard())) { ConnectionString = connectionString }; Console.WriteLine(@"Setup..."); var worldCreatorTypeInfoSource = WorldCreatorTypeInfoSource.Instance; serverApplication.Setup(); Console.WriteLine(@"CheckCompatibility..."); serverApplication.CheckCompatibility(); XpandWcfDataServerHelper.AddKnownTypesForAll(serverApplication); serverApplication.Dispose(); Console.WriteLine(@"Starting server..."); IDataServerSecurity SecurityProviderHandler() => new SecurityStrategyComplex(typeof(SecuritySystemUser), typeof(SecuritySystemRole), new AuthenticationStandard()); var dataServer = new XpandSecuredDataServer(connectionString, XpoTypesInfoHelper.GetXpoTypeInfoSource().XPDictionary, SecurityProviderHandler); var serviceHost = new ServiceHost(new WcfSecuredDataServer(dataServer)); var defaultBinding = (WSHttpBinding)WcfDataServerHelper.CreateDefaultBinding(); defaultBinding.ReaderQuotas.MaxStringContentLength = 2147483647; serviceHost.AddServiceEndpoint(typeof(IWcfSecuredDataServer), defaultBinding, "http://*****:*****@"Server is started. Press Enter to stop."); Console.ReadLine(); Console.WriteLine(@"Stopping..."); serviceHost.Close(); Console.WriteLine(@"Server is stopped."); } catch (Exception e) { Console.WriteLine(@"Exception occurs: " + e.Message); Console.WriteLine(@"Press Enter to close."); Console.ReadLine(); } }
static void Main() { #if EASYTEST DevExpress.ExpressApp.Win.EasyTest.EasyTestRemotingRegistration.Register(); #endif Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); EditModelPermission.AlwaysGranted = Debugger.IsAttached; var winApplication = new SecuritySystemExampleWindowsFormsApplication(); try { winApplication.ConnectionString = "http://localhost:1451/DataServer"; XpandWcfDataServerHelper.AddKnownTypes(); var defaultBinding = (WSHttpBinding)WcfDataServerHelper.CreateDefaultBinding(); defaultBinding.ReaderQuotas.MaxStringContentLength = 2147483647; var clientDataServer = new WcfSecuredDataServerClient( defaultBinding, new EndpointAddress(winApplication.ConnectionString)); var securityClient = new ServerSecurityClient(clientDataServer, new ClientInfoFactory()) { IsSupportChangePassword = true }; winApplication.ApplicationName = "SecuritySystemExample"; winApplication.Security = securityClient; winApplication.CreateCustomObjectSpaceProvider += delegate(object sender, CreateCustomObjectSpaceProviderEventArgs e) { e.ObjectSpaceProvider = new DataServerObjectSpaceProvider(clientDataServer, securityClient); }; winApplication.UseOldTemplates = false; var worldCreatorTypeInfoSource = WorldCreatorTypeInfoSource.Instance; winApplication.Setup(); winApplication.Start(); clientDataServer.Close(); } catch (Exception e) { winApplication.HandleException(e); } }
protected void Session_Start(Object sender, EventArgs e) { WebApplication.SetInstance(Session, new PermissionPolicyExampleAspNetApplication()); string connectionString = "net.tcp://127.0.0.1:1451/DataServer"; WcfSecuredDataServerClient clientDataServer = new WcfSecuredDataServerClient( WcfDataServerHelper.CreateDefaultBinding(), new EndpointAddress(connectionString)); Session["DataServerClient"] = clientDataServer; WcfSecuredClient wcfSecuredClient = new WcfSecuredClient(WcfDataServerHelper.CreateNetTcpBinding(), new EndpointAddress(connectionString)); MiddleTierClientSecurity security = new MiddleTierClientSecurity(wcfSecuredClient); security.IsSupportChangePassword = true; WebApplication.Instance.ApplicationName = "PermissionPolicyExample"; WebApplication.Instance.Security = security; WebApplication.Instance.DatabaseUpdateMode = DatabaseUpdateMode.Never; WebApplication.Instance.CreateCustomObjectSpaceProvider += delegate(object sender2, CreateCustomObjectSpaceProviderEventArgs e2) { e2.ObjectSpaceProvider = new MiddleTierServerObjectSpaceProvider(wcfSecuredClient); }; WebApplication.Instance.Setup(); WebApplication.Instance.Start(); }