Beispiel #1
0
        public SecurityToken CreateToken(User principalUser, Tenant owningTenant, Group owningGroup, User owningUser, IEnumerable <AbstractRoleDefinition> abstractRoleDefinitions)
        {
            ArgumentUtility.CheckNotNull("principalUser", principalUser);
            var abstractRoles = new List <IDomainObjectHandle <AbstractRoleDefinition> > ();

            if (abstractRoleDefinitions != null)
            {
                abstractRoles.AddRange(abstractRoleDefinitions.Select(abstractRole => abstractRole.GetHandle()));
            }

            Principal principal = PrincipalTestHelper.Create(principalUser.Tenant, principalUser, principalUser.Roles);

            return(SecurityToken.Create(principal, owningTenant, owningGroup, owningUser, abstractRoles));
        }
Beispiel #2
0
        public void AccessControlList_GetAccessTypes2()
        {
            var user = User3;
            var acl  = TestHelper.CreateStatefulAcl(Ace3);

            Assert.That(Ace3.Validate().IsValid);
            Principal     principal     = PrincipalTestHelper.Create(user.Tenant, user, user.Roles);
            SecurityToken securityToken = SecurityToken.Create(
                principal,
                user.Tenant,
                null,
                null,
                Enumerable.Empty <IDomainObjectHandle <AbstractRoleDefinition> >());
            AccessInformation accessInformation = acl.GetAccessTypes(securityToken);

            Assert.That(accessInformation.AllowedAccessTypes, Is.EquivalentTo(new[] { ReadAccessType, WriteAccessType }));
        }
Beispiel #3
0
        public void AccessControlList_GetAccessTypes_AceWithPosition_GroupSelectionAll()
        {
            var ace = TestHelper.CreateAceWithPositionAndGroupCondition(Position, GroupCondition.None);

            AttachAccessTypeReadWriteDelete(ace, true, null, true);
            Assert.That(ace.Validate().IsValid);
            var           acl           = TestHelper.CreateStatefulAcl(ace);
            Principal     principal     = PrincipalTestHelper.Create(User.Tenant, User, User.Roles);
            SecurityToken securityToken = SecurityToken.Create(
                principal,
                User.Tenant,
                null,
                null,
                Enumerable.Empty <IDomainObjectHandle <AbstractRoleDefinition> >());
            AccessInformation accessInformation = acl.GetAccessTypes(securityToken);

            Assert.That(accessInformation.AllowedAccessTypes, Is.EquivalentTo(new[] { ReadAccessType, DeleteAccessType }));
        }
Beispiel #4
0
        public SecurityToken CreateTokenWithAbstractRole(params AbstractRoleDefinition[] roleDefinitions)
        {
            Principal principal = PrincipalTestHelper.Create(CreateTenant("AnyTenant"), null, new Role[0]);

            return(SecurityToken.Create(principal, null, null, null, roleDefinitions.Select(abstractRole => abstractRole.GetHandle())));
        }
Beispiel #5
0
        public SecurityToken CreateTokenWithoutUser()
        {
            Principal principal = PrincipalTestHelper.Create(CreateTenant("AnyTenant"), null, new Role[0]);

            return(SecurityToken.Create(principal, null, null, null, Enumerable.Empty <IDomainObjectHandle <AbstractRoleDefinition> >()));
        }