Package com.saasovation.identityaccess.domain.model.access

Examples of com.saasovation.identityaccess.domain.model.access.Role


                    .userWithUsername(
                            tenantId,
                            aCommand.getUsername());

        if (user != null) {
            Role role =
                    this.roleRepository()
                        .roleNamed(
                                tenantId,
                                aCommand.getRoleName());

            if (role != null) {
                role.assignUser(user);
            }
        }
    }
View Full Code Here


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

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

        Role role =
                tenant.provisionRole(
                        aCommand.getRoleName(),
                        aCommand.getDescription(),
                        aCommand.isSupportsNesting());
View Full Code Here

                    .userWithUsername(
                            tenantId,
                            aUsername);

        if (user != null) {
            Role role =
                    this.roleRepository()
                        .roleNamed(tenantId, aRoleName);

            if (role != null) {
                GroupMemberService groupMemberService =
                        new GroupMemberService(
                                this.userRepository(),
                                this.groupRepository());

                if (role.isInRole(user, groupMemberService)) {
                    userInRole = user;
                }
            }
        }
View Full Code Here

    public void testIsUserInRole() throws Exception {
        User user = this.userAggregate();
        DomainRegistry.userRepository().add(user);

        Role role = this.roleAggregate();
        DomainRegistry.roleRepository().add(role);

        assertFalse(
                ApplicationServiceRegistry
                    .accessApplicationService()
                    .isUserInRole(
                            user.tenantId().id(),
                            user.username(),
                            role.name()));

        ApplicationServiceRegistry
            .accessApplicationService()
            .assignUserToRole(
                    new AssignUserToRoleCommand(
                            user.tenantId().id(),
                            user.username(),
                            role.name()));

        assertTrue(
                ApplicationServiceRegistry
                    .accessApplicationService()
                    .isUserInRole(
                            user.tenantId().id(),
                            user.username(),
                            role.name()));
    }
View Full Code Here

    public void testUserInRole() throws Exception {
        User user = this.userAggregate();
        DomainRegistry.userRepository().add(user);

        Role role = this.roleAggregate();
        DomainRegistry.roleRepository().add(role);


        User userNotInRole =
                ApplicationServiceRegistry
                    .accessApplicationService()
                    .userInRole(user.tenantId().id(), user.username(), role.name());

        assertNull(userNotInRole);

        ApplicationServiceRegistry
            .accessApplicationService()
            .assignUserToRole(
                    new AssignUserToRoleCommand(
                            user.tenantId().id(),
                            user.username(),
                            role.name()));

        User userInRole =
                ApplicationServiceRegistry
                    .accessApplicationService()
                    .userInRole(user.tenantId().id(), user.username(), role.name());

        assertNotNull(userInRole);
    }
View Full Code Here

    public void testNoRoleInternalGroupsInFindAllGroups() throws Exception {
        Tenant tenant = this.tenantAggregate();
        Group groupA = tenant.provisionGroup("GroupA", "A group named GroupA");
        DomainRegistry.groupRepository().add(groupA);

        Role roleA = tenant.provisionRole("RoleA", "A role of A.");
        DomainRegistry.roleRepository().add(roleA);
        Role roleB = tenant.provisionRole("RoleB", "A role of B.");
        DomainRegistry.roleRepository().add(roleB);
        Role roleC = tenant.provisionRole("RoleC", "A role of C.");
        DomainRegistry.roleRepository().add(roleC);

        Collection<Group> groups =
            DomainRegistry
                .groupRepository()
View Full Code Here

    public void testIsUserInRole() throws Exception {
        User user = this.userAggregate();
        DomainRegistry.userRepository().add(user);

        Role role = this.roleAggregate();
        role.assignUser(user);
        DomainRegistry.roleRepository().add(role);

        String url = "http://localhost:" + PORT + "/tenants/{tenantId}/users/{username}/inRole/{role}";

        System.out.println(">>> GET: " + url);
        ClientRequest request = new ClientRequest(url);
        request.pathParameter("tenantId", user.tenantId().id());
        request.pathParameter("username", user.username());
        request.pathParameter("role", role.name());
        ClientResponse<String> response = request.get(String.class);
        assertEquals(200, response.getStatus());
        String entity = response.getEntity();
        System.out.println(entity);
        RepresentationReader reader = new RepresentationReader(entity);
        assertEquals(user.username(),  reader.stringValue("username"));
        assertEquals(role.name(), reader.stringValue("role"));
    }
View Full Code Here

    public void testIsUserNotInRole() throws Exception {
        User user = this.userAggregate();
        DomainRegistry.userRepository().add(user);

        Role role = this.roleAggregate();
        DomainRegistry.roleRepository().add(role);

        String url = "http://localhost:" + PORT + "/tenants/{tenantId}/users/{username}/inRole/{role}";

        System.out.println(">>> GET: " + url);
        ClientRequest request = new ClientRequest(url);
        request.pathParameter("tenantId", user.tenantId().id());
        request.pathParameter("username", user.username());
        request.pathParameter("role", role.name());
        ClientResponse<String> response = request.get(String.class);
        assertEquals(204, response.getStatus());
    }
View Full Code Here

    public void testAssignUserToRole() throws Exception {
        User user = this.userAggregate();
        DomainRegistry.userRepository().add(user);

        Role role = this.roleAggregate();
        DomainRegistry.roleRepository().add(role);

        assertFalse(role.isInRole(user, DomainRegistry.groupMemberService()));

        ApplicationServiceRegistry
            .accessApplicationService()
            .assignUserToRole(
                    new AssignUserToRoleCommand(
                            user.tenantId().id(),
                            user.username(),
                            role.name()));

        assertTrue(role.isInRole(user, DomainRegistry.groupMemberService()));
    }
View Full Code Here

        aTenant.withdrawInvitation(invitation.invitationId());

        this.userRepository().add(admin);

        Role adminRole =
            aTenant.provisionRole(
                    "Administrator",
                    "Default " + aTenant.name() + " administrator.");

        adminRole.assignUser(admin);

        this.roleRepository().add(adminRole);

        DomainEventPublisher.instance().publish(
                new TenantAdministratorRegistered(
View Full Code Here

TOP

Related Classes of com.saasovation.identityaccess.domain.model.access.Role

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.