当前位置: 首页>>代码示例>>C#>>正文


C# Security.WindowsGroupPermission类代码示例

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


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


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