Package com.saasovation.identityaccess.domain.model.identity

Examples of com.saasovation.identityaccess.domain.model.identity.Tenant


    @Transactional
    public void provisionRole(ProvisionRoleCommand aCommand) {

        TenantId tenantId = new TenantId(aCommand.getTenantId());

        Tenant tenant = this.tenantRepository().tenantOfId(tenantId);

        Role role =
                tenant.provisionRole(
                        aCommand.getRoleName(),
                        aCommand.getDescription(),
                        aCommand.isSupportsNesting());

        this.roleRepository().add(role);
View Full Code Here


        super();
    }

    public void testUserInRoleAuthorization() throws Exception {

        Tenant tenant = this.tenantAggregate();
        User user = this.userAggregate();
        DomainRegistry.userRepository().add(user);
        Role managerRole = tenant.provisionRole("Manager", "A manager role.", true);

        managerRole.assignUser(user);

        DomainRegistry
            .roleRepository()
View Full Code Here

        assertFalse(authorized);
    }

    public void testUsernameInRoleAuthorization() throws Exception {

        Tenant tenant = this.tenantAggregate();
        User user = this.userAggregate();
        DomainRegistry.userRepository().add(user);
        Role managerRole = tenant.provisionRole("Manager", "A manager role.", true);

        managerRole.assignUser(user);

        DomainRegistry
            .roleRepository()
            .add(managerRole);

        boolean authorized =
                DomainRegistry
                    .authorizationService()
                    .isUserInRole(tenant.tenantId(), user.username(), "Manager");

        assertTrue(authorized);

        authorized =
                DomainRegistry
                    .authorizationService()
                    .isUserInRole(tenant.tenantId(), user.username(), "Director");

        assertFalse(authorized);
    }
View Full Code Here

    public RoleTest() {
        super();
    }

    public void testProvisionRole() throws Exception {
        Tenant tenant = this.tenantAggregate();
        Role role = tenant.provisionRole("Manager", "A manager role.");
        DomainRegistry.roleRepository().add(role);
        assertEquals(1, DomainRegistry.roleRepository().allRoles(tenant.tenantId()).size());
    }
View Full Code Here

        DomainRegistry.roleRepository().add(role);
        assertEquals(1, DomainRegistry.roleRepository().allRoles(tenant.tenantId()).size());
    }

    public void testRoleUniqueness() throws Exception {
        Tenant tenant = this.tenantAggregate();
        Role role1 = tenant.provisionRole("Manager", "A manager role.");
        DomainRegistry.roleRepository().add(role1);

        boolean nonUnique = false;

        try {
            Role role2 = tenant.provisionRole("Manager", "A manager role.");
            DomainRegistry.roleRepository().add(role2);

            fail("Should have thrown exception for nonuniqueness.");

        } catch (IllegalStateException e) {
View Full Code Here

        assertTrue(nonUnique);
    }

    public void testUserIsInRole() throws Exception {
        Tenant tenant = this.tenantAggregate();
        User user = this.userAggregate();
        DomainRegistry.userRepository().add(user);
        Role managerRole = tenant.provisionRole("Manager", "A manager role.", true);
        Group group = new Group(user.tenantId(), "Managers", "A group of managers.");
        DomainRegistry.groupRepository().add(group);
        managerRole.assignGroup(group, DomainRegistry.groupMemberService());
        DomainRegistry.roleRepository().add(managerRole);
        group.addUser(user);
View Full Code Here

        assertTrue(group.isMember(user, DomainRegistry.groupMemberService()));
        assertTrue(managerRole.isInRole(user, DomainRegistry.groupMemberService()));
    }

    public void testUserIsNotInRole() throws Exception {
        Tenant tenant = this.tenantAggregate();
        User user = this.userAggregate();
        DomainRegistry.userRepository().add(user);
        Role managerRole = tenant.provisionRole("Manager", "A manager role.", true);
        Group group = tenant.provisionGroup("Managers", "A group of managers.");
        DomainRegistry.groupRepository().add(group);
        managerRole.assignGroup(group, DomainRegistry.groupMemberService());
        DomainRegistry.roleRepository().add(managerRole);
        Role accountantRole = new Role(user.tenantId(), "Accountant", "An accountant role.");
        DomainRegistry.roleRepository().add(accountantRole);
View Full Code Here

        assertFalse(managerRole.isInRole(user, DomainRegistry.groupMemberService()));
        assertFalse(accountantRole.isInRole(user, DomainRegistry.groupMemberService()));
    }

    public void testNoRoleInternalGroupsInFindGroupByName() throws Exception {
        Tenant tenant = this.tenantAggregate();
        Role roleA = tenant.provisionRole("RoleA", "A role of A.");
        DomainRegistry.roleRepository().add(roleA);

        boolean error = false;

        try {

            System.out.println("GROUP REPOSITORY: " + DomainRegistry.groupRepository());

            DomainRegistry
                .groupRepository()
                .groupNamed(
                        tenant.tenantId(),
                        roleA.group().name());

            fail("Should have thrown exception for invalid group name.");

        } catch (Exception e) {
View Full Code Here

            public Class<GroupUserAdded> subscribedToEventType() {
                return GroupUserAdded.class;
            }
        });

        Tenant tenant = this.tenantAggregate();
        User user = this.userAggregate();
        DomainRegistry.userRepository().add(user);
        Role managerRole = tenant.provisionRole("Manager", "A manager role.", true);
        Group group = new Group(user.tenantId(), "Managers", "A group of managers.");
        DomainRegistry.groupRepository().add(group);
        managerRole.assignGroup(group, DomainRegistry.groupMemberService());
        managerRole.assignUser(user);
        DomainRegistry.roleRepository().add(managerRole);
View Full Code Here

            public Class<GroupUserRemoved> subscribedToEventType() {
                return GroupUserRemoved.class;
            }
        });

        Tenant tenant = this.tenantAggregate();
        User user = this.userAggregate();
        DomainRegistry.userRepository().add(user);
        Role managerRole = tenant.provisionRole("Manager", "A manager role.", true);
        Group group = new Group(user.tenantId(), "Managers", "A group of managers.");
        DomainRegistry.groupRepository().add(group);
        managerRole.assignUser(user);
        managerRole.assignGroup(group, DomainRegistry.groupMemberService());
        DomainRegistry.roleRepository().add(managerRole);
View Full Code Here

TOP

Related Classes of com.saasovation.identityaccess.domain.model.identity.Tenant

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.