static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); EditModelPermission.AlwaysGranted = System.Diagnostics.Debugger.IsAttached; SecuredExportExampleWindowsFormsApplication winApplication = new SecuredExportExampleWindowsFormsApplication(); #if EASYTEST DevExpress.ExpressApp.Win.EasyTest.EasyTestRemotingRegistration.Register(); #endif try { InMemoryDataStoreProvider.Register(); winApplication.ConnectionString = InMemoryDataStoreProvider.ConnectionString; ((SecurityStrategy)winApplication.Security).CustomizeRequestProcessors += delegate(object sender, CustomizeRequestProcessorsEventArgs e) { List <IOperationPermission> result = new List <IOperationPermission>(); SecurityStrategyComplex security = sender as SecurityStrategyComplex; if (security != null) { Employee user = security.User as Employee; if (user != null) { foreach (ExtendedSecurityRole role in user.Roles) { if (role.CanExport) { result.Add(new ExportPermission()); } } } } IPermissionDictionary permissionDictionary = new PermissionDictionary((IEnumerable <IOperationPermission>)result); e.Processors.Add(typeof(ExportPermissionRequest), new ExportPermissionRequestProcessor(permissionDictionary)); }; winApplication.Setup(); winApplication.Start(); } catch (Exception e) { winApplication.HandleException(e); } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); EditModelPermission.AlwaysGranted = System.Diagnostics.Debugger.IsAttached; SecuredExportExampleWindowsFormsApplication winApplication = new SecuredExportExampleWindowsFormsApplication(); #if EASYTEST DevExpress.ExpressApp.Win.EasyTest.EasyTestRemotingRegistration.Register(); var serverProcess = new System.Diagnostics.Process(); serverProcess.StartInfo.FileName = @"..\..\..\SecuredExportExample.MiddleTierSecurityServer\bin\EasyTest\SecuredExportExample.MiddleTierSecurityServer.exe"; serverProcess.Start(); System.Threading.Thread.Sleep(5000); #endif try { WcfDataServerHelper.AddKnownType(typeof(ExportPermissionRequest)); winApplication.ConnectionString = "net.tcp://127.0.0.1:1451/DataServer"; winApplication.DatabaseUpdateMode = DatabaseUpdateMode.Never; WcfSecuredClient wcfSecuredClient = new WcfSecuredClient(WcfDataServerHelper.CreateNetTcpBinding(), new EndpointAddress(winApplication.ConnectionString)); MiddleTierClientSecurity securityClient = new MiddleTierClientSecurity(wcfSecuredClient); securityClient.IsSupportChangePassword = true; winApplication.ApplicationName = "SecuredExportExample"; winApplication.Security = securityClient; winApplication.CreateCustomObjectSpaceProvider += (s, e) => { e.ObjectSpaceProvider = new MiddleTierServerObjectSpaceProvider(wcfSecuredClient); }; winApplication.Setup(); winApplication.Start(); wcfSecuredClient.Dispose(); } catch (Exception e) { winApplication.HandleException(e); } }