• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Security.WindowsGroupPermission类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Dev2.Services.Security.WindowsGroupPermission的典型用法代码示例。如果您正苦于以下问题:C# WindowsGroupPermission类的具体用法?C# WindowsGroupPermission怎么用?C# WindowsGroupPermission使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



WindowsGroupPermission类属于Dev2.Services.Security命名空间,在下文中一共展示了WindowsGroupPermission类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Remove

        public void Remove(Guid resourceId)
        {
            LogStart();
            _permissionsLock.EnterWriteLock();
            try
            {
                var oldPermissions = new WindowsGroupPermission[_permissions.Count];
                _permissions.CopyTo(oldPermissions);

                var removedCount = _permissions.RemoveAll(p => !p.IsServer && p.ResourceID == resourceId);

                if(removedCount > 0)
                {
                    RaisePermissionsModified(oldPermissions, _permissions);

                    // This will trigger a FileSystemWatcher file changed event
                    // which in turn will cause the permissions to be re-read.
                    WritePermissions(_permissions);
                }
            }
            finally
            {
                _permissionsLock.ExitWriteLock();
            }
            LogEnd();
        }
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:26,代码来源:SecurityServiceBase.cs


示例2: GivenItHasWith

        public void GivenItHasWith(string groupName, string groupRights)
        {
            var groupPermssions = new WindowsGroupPermission
            {
                WindowsGroup = groupName,
                ResourceID = Guid.Empty,
                IsServer = true
            };
            var permissionsStrings = groupRights.Split(new[] { ", " }, StringSplitOptions.RemoveEmptyEntries);
            foreach(var permissionsString in permissionsStrings)
            {
                SecPermissions permission;
                if(Enum.TryParse(permissionsString.Replace(" ", ""), true, out permission))
                {
                    groupPermssions.Permissions |= permission;
                }
            }
            Data.Settings.Settings settings = new Data.Settings.Settings
            {
                Security = new SecuritySettingsTO(new List<WindowsGroupPermission> { groupPermssions })
            };

            var environmentModel = ScenarioContext.Current.Get<IEnvironmentModel>("environment");
            EnsureEnvironmentConnected(environmentModel);
            environmentModel.ResourceRepository.WriteSettings(environmentModel, settings);
            environmentModel.Disconnect();
        }
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:27,代码来源:SettingsPermissionsSteps.cs


示例3: AuthorizationHelpers_Matches_SecurityPermissionIsServer_True

        public void AuthorizationHelpers_Matches_SecurityPermissionIsServer_True()
        {
            //------------Setup for test--------------------------
            var securityPermission = new WindowsGroupPermission { IsServer = true };

            //------------Execute Test---------------------------
            var authorized = securityPermission.Matches(null);

            //------------Assert Results-------------------------
            Assert.IsTrue(authorized);
        }
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:11,代码来源:AuthorizationHelpersTests.cs


示例4: WindowsGroupPermission_Permissions_SetExecute_CorrectlyApplied

        public void WindowsGroupPermission_Permissions_SetExecute_CorrectlyApplied()
        {
            //------------Setup for test--------------------------            

            //------------Execute Test---------------------------
            var p = new WindowsGroupPermission { Permissions = Permissions.Execute };

            //------------Assert Results-------------------------
            Assert.IsFalse(p.View);
            Assert.IsTrue(p.Execute);
            Assert.IsFalse(p.Contribute);
            Assert.IsFalse(p.DeployTo);
            Assert.IsFalse(p.DeployFrom);
            Assert.IsFalse(p.Administrator);
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:15,代码来源:WindowsGroupPermissionTests.cs


示例5: SecurityWrite_Execute_SecuritySettingsValuePassedValidJSON_ShouldWriteFile

 public void SecurityWrite_Execute_SecuritySettingsValuePassedValidJSON_ShouldWriteFile()
 {
     //------------Setup for test--------------------------
     var permission = new WindowsGroupPermission { Administrator = true, IsServer = true, WindowsGroup = Environment.UserName };
     var windowsGroupPermissions = new List<WindowsGroupPermission> { permission };
     var securitySettings = new SecuritySettingsTO(windowsGroupPermissions) { CacheTimeout = new TimeSpan(0, 2, 0) };
     var securitySettingsValue = JsonConvert.SerializeObject(securitySettings);
     var securityWrite = new SecurityWrite();
     //------------Execute Test---------------------------
     securityWrite.Execute(new Dictionary<string, StringBuilder> { { "SecuritySettings", new StringBuilder(securitySettingsValue) } }, null);
     //------------Assert Results-------------------------
     Assert.IsTrue(File.Exists("secure.config"));
     var fileData = File.ReadAllText("secure.config");
     Assert.IsFalse(fileData.StartsWith("{"));
     Assert.IsFalse(fileData.EndsWith("}"));
     Assert.IsFalse(fileData.Contains("IsServer"));
     File.Delete("secure.config");
 }
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:18,代码来源:SecurityWriteTests.cs


示例6: AuthorizationServiceBase_IsAuthorized_UserIsInResourceRoleAndResourceToBeVerifiedIsNull_False

        public void AuthorizationServiceBase_IsAuthorized_UserIsInResourceRoleAndResourceToBeVerifiedIsNull_False()
        {
            //------------Setup for test--------------------------
            var securityPermission = new WindowsGroupPermission { IsServer = false, ResourceName = "Category\\Test1", ResourceID = Guid.NewGuid() };

            var securityService = new Mock<ISecurityService>();
            securityService.SetupGet(p => p.Permissions).Returns(new List<WindowsGroupPermission> { securityPermission });

            var user = new Mock<IPrincipal>();
            user.Setup(u => u.IsInRole(It.IsAny<string>())).Returns(true);

            var authorizationService = new TestAuthorizationServiceBase(securityService.Object) { User = user.Object };

            //------------Execute Test---------------------------
            var authorized = authorizationService.IsAuthorized(AuthorizationContext.Contribute, null);

            //------------Assert Results-------------------------
            Assert.IsFalse(authorized);
        }
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:19,代码来源:AuthorizationServiceBaseTests.cs


示例7: Compare

 int Compare(WindowsGroupPermission px, WindowsGroupPermission py)
 {
     switch(_sortMemberPath)
     {
         case "ResourceName":
             return System.String.Compare(px.ResourceName, py.ResourceName, System.StringComparison.InvariantCulture);
         case "WindowsGroup":
             return System.String.Compare(px.WindowsGroup, py.WindowsGroup, System.StringComparison.InvariantCulture);
         case "View":
             return px.View.CompareTo(py.View);
         case "Execute":
             return px.Execute.CompareTo(py.Execute);
         case "Contribute":
             return px.Contribute.CompareTo(py.Contribute);
         case "DeployTo":
             return px.DeployTo.CompareTo(py.DeployTo);
         case "DeployFrom":
             return px.DeployFrom.CompareTo(py.DeployFrom);
         case "Administrator":
             return px.Administrator.CompareTo(py.Administrator);
     }
     return 0;
 }
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:23,代码来源:WindowsGroupPermissionComparer.cs


示例8: CreateNewPermission

 WindowsGroupPermission CreateNewPermission(bool isServer)
 {
     var permission = new WindowsGroupPermission { IsNew = true, IsServer = isServer };
     RegisterPropertyChanged(permission);
     return permission;
 }
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:6,代码来源:SecurityViewModel.cs


示例9: UpdateForAdministratorPermissions

 static void UpdateForAdministratorPermissions(WindowsGroupPermission windowsGroupPermission)
 {
     windowsGroupPermission.DeployFrom = true;
     windowsGroupPermission.DeployTo = true;
     windowsGroupPermission.Contribute = true;
 }
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:6,代码来源:SecurityViewModel.cs


示例10: UpdateForContributePermissions

 static void UpdateForContributePermissions(WindowsGroupPermission windowsGroupPermission)
 {
     windowsGroupPermission.View = true;
     windowsGroupPermission.Execute = true;
 }
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:5,代码来源:SecurityViewModel.cs


示例11: SwitchAdminPermissionsOff

 static void SwitchAdminPermissionsOff(WindowsGroupPermission windowsGroupPermission, string propertyName)
 {
     if(!windowsGroupPermission.DeployTo && propertyName == "DeployTo"
        || !windowsGroupPermission.DeployFrom && propertyName == "DeployFrom"
        || !windowsGroupPermission.Contribute && propertyName == "Contribute")
     {
         windowsGroupPermission.Administrator = false;
     }
 }
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:9,代码来源:SecurityViewModel.cs


示例12: SwitchContributePermissionsOff

 static void SwitchContributePermissionsOff(WindowsGroupPermission windowsGroupPermission, string propertyName)
 {
     if(!windowsGroupPermission.View && propertyName == "View"
        || !windowsGroupPermission.Execute && propertyName == "Execute")
     {
         windowsGroupPermission.Contribute = false;
     }
 }
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:8,代码来源:SecurityViewModel.cs


示例13: WindowsGroupPermissions_CanRemove_Server_True

 public void WindowsGroupPermissions_CanRemove_Server_True()
 {
     //------------Setup for test--------------------------
     var p = new WindowsGroupPermission { IsServer = true, WindowsGroup = "xxx" };
     //------------Execute Test---------------------------
     var canRemove = p.CanRemove;
     //------------Assert Results-------------------------
     Assert.IsTrue(canRemove);
 }
开发者ID:Robin--,项目名称:Warewolf,代码行数:9,代码来源:WindowsGroupPermissionTests.cs


示例14: Verify_IsAuthorized

        void Verify_IsAuthorized(Permissions configPermissions, TestAuthorizationRequest authorizationRequest, bool isServer)
        {
            var configPermission = new WindowsGroupPermission { WindowsGroup = TestAuthorizationRequest.UserRole, IsServer = isServer, Permissions = configPermissions };

            if(!isServer && !string.IsNullOrEmpty(authorizationRequest.Resource))
            {
                Guid resourceID;
                if(Guid.TryParse(authorizationRequest.Resource, out resourceID))
                {
                    configPermission.ResourceID = resourceID;
                    configPermission.ResourceName = "TestCategory\\";
                }
                else
                {
                    configPermission.ResourceID = Guid.NewGuid();
                    configPermission.ResourceName = string.Format("TestCategory\\{0}", authorizationRequest.Resource);
                }
            }

            authorizationRequest.UserIsInRole = false;
            Verify_IsAuthorized(configPermission, authorizationRequest);

            authorizationRequest.UserIsInRole = true;
            Verify_IsAuthorized(configPermission, authorizationRequest);
        }
开发者ID:ndubul,项目名称:Chillas,代码行数:25,代码来源:ServerAuthorizationServiceTests.cs


示例15: SettingsWrite_Execute_SettingsWriteValuePassedValidJSON_ShouldDoSecurityWrite

        public void SettingsWrite_Execute_SettingsWriteValuePassedValidJSON_ShouldDoSecurityWrite()
        {
            //------------Setup for test--------------------------
            var permission = new WindowsGroupPermission { Administrator = true, IsServer = true, WindowsGroup = Environment.UserName };
            var windowsGroupPermissions = new List<WindowsGroupPermission> { permission };
            var settings = new Settings { Security = new SecuritySettingsTO(windowsGroupPermissions) };
            var serializeObject = JsonConvert.SerializeObject(settings);
            var settingsWrite = new SettingsWrite();
            //------------Execute Test---------------------------
            StringBuilder execute = settingsWrite.Execute(new Dictionary<string, StringBuilder> { { "Settings", new StringBuilder(serializeObject) } }, null);
            //------------Assert Results-------------------------
            Assert.IsTrue(File.Exists("secure.config"));
            File.Delete("secure.config");

            var msg = ToMsg(execute);

            StringAssert.Contains(msg.Message.ToString(), "Success");
        }
开发者ID:NatashaSchutte,项目名称:Warewolf-ESB,代码行数:18,代码来源:SettingsWriteTests.cs


示例16: WindowsGroupPermission_IsValid_IsServerAndWindowsGroupIsEmpty_False

        public void WindowsGroupPermission_IsValid_IsServerAndWindowsGroupIsEmpty_False()
        {
            //------------Setup for test--------------------------            

            //------------Execute Test---------------------------
            var p = new WindowsGroupPermission { IsServer = true, WindowsGroup = string.Empty };

            //------------Assert Results-------------------------
            Assert.IsFalse(p.IsValid);
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:10,代码来源:WindowsGroupPermissionTests.cs


示例17: GivenResourceHasRights

        public void GivenResourceHasRights(string resourceName, string resourceRights, string groupName)
        {
            var environmentModel = ScenarioContext.Current.Get<IEnvironmentModel>("environment");
            EnsureEnvironmentConnected(environmentModel);
            var resourceRepository = environmentModel.ResourceRepository;
            var settings = resourceRepository.ReadSettings(environmentModel);
            environmentModel.ForceLoadResources();

            var resourceModel = resourceRepository.FindSingle(model => model.Category.Equals(resourceName, StringComparison.InvariantCultureIgnoreCase));
            Assert.IsNotNull(resourceModel, "Did not find: " + resourceName);
            SecPermissions resourcePermissions = SecPermissions.None;
            var permissionsStrings = resourceRights.Split(new[] { ", " }, StringSplitOptions.RemoveEmptyEntries);
            foreach(var permissionsString in permissionsStrings)
            {
                SecPermissions permission;
                if(Enum.TryParse(permissionsString.Replace(" ", ""), true, out permission))
                {
                    resourcePermissions |= permission;
                }
            }
            settings.Security.WindowsGroupPermissions.RemoveAll(permission => permission.ResourceID == resourceModel.ID);
            var windowsGroupPermission = new WindowsGroupPermission { WindowsGroup = groupName, ResourceID = resourceModel.ID, ResourceName = resourceName, IsServer = false, Permissions = resourcePermissions };
            settings.Security.WindowsGroupPermissions.Add(windowsGroupPermission);
            resourceRepository.WriteSettings(environmentModel, settings);
        }
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:25,代码来源:SettingsPermissionsSteps.cs


示例18: WindowsGroupPermission_IsValid_IsNotServerAndResourceNameIsEmpty_False

        public void WindowsGroupPermission_IsValid_IsNotServerAndResourceNameIsEmpty_False()
        {
            //------------Setup for test--------------------------            

            //------------Execute Test---------------------------
            var p = new WindowsGroupPermission { IsServer = false, WindowsGroup = "xxx", ResourceName = string.Empty };

            //------------Assert Results-------------------------
            Assert.IsFalse(p.IsValid);
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:10,代码来源:WindowsGroupPermissionTests.cs


示例19: WindowsGroup_RemoveRow_DeleteTrue_DeletefalseEnableCellEditingTrue

 public void WindowsGroup_RemoveRow_DeleteTrue_DeletefalseEnableCellEditingTrue()
 {
     //------------Setup for test--------------------------
     var p = new WindowsGroupPermission { IsDeleted = true };
     //------------Execute Test---------------------------
     p.RemoveRow.Execute(null);
     //------------Assert Results-------------------------
     Assert.IsFalse(p.IsDeleted);
     Assert.IsTrue(p.EnableCellEditing);
 }
开发者ID:Robin--,项目名称:Warewolf,代码行数:10,代码来源:WindowsGroupPermissionTests.cs


示例20: WindowsGroupPermissions_CanRemoveRow_WindowsGroupChanges_CanExecuteChangedFires

 public void WindowsGroupPermissions_CanRemoveRow_WindowsGroupChanges_CanExecuteChangedFires()
 {
     //------------Setup for test--------------------------
     var p = new WindowsGroupPermission { IsDeleted = false };
     var hitCount=0;
     p.RemoveRow.CanExecuteChanged += (sender, args) =>
     {
         hitCount++;
     };
     //------------Execute Test---------------------------
     p.WindowsGroup = "TestGroup";
     //------------Assert Results-------------------------
     Assert.AreEqual(1,hitCount);
 }
开发者ID:Robin--,项目名称:Warewolf,代码行数:14,代码来源:WindowsGroupPermissionTests.cs



注:本文中的Dev2.Services.Security.WindowsGroupPermission类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Interfaces.IntellisenseProviderContext类代码示例发布时间:2022-05-24
下一篇:
C# PathOperations.Dev2CRUDOperationTO类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap