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

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


    @Transactional
    public void assignUserToRole(AssignUserToRoleCommand aCommand) {

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

        User user =
                this.userRepository()
                    .userWithUsername(
                            tenantId,
                            aCommand.getUsername());
View Full Code Here


    public boolean isUserInRole(
            String aTenantId,
            String aUsername,
            String aRoleName) {

        User user = this.userInRole(aTenantId, aUsername, aRoleName);

        return user != null;
    }
View Full Code Here

    public User userInRole(
            String aTenantId,
            String aUsername,
            String aRoleName) {

        User userInRole = null;

        TenantId tenantId = new TenantId(aTenantId);

        User user =
                this.userRepository()
                    .userWithUsername(
                            tenantId,
                            aUsername);
View Full Code Here

    public AccessApplicationServiceTest() {
        super();
    }

    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

    }

    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);
View Full Code Here

    }

    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

        assertTrue(role.isInRole(user, DomainRegistry.groupMemberService()));
    }

    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

                            user.username(),
                            role.name()));
    }

    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 UserResourceTest() {
        super();
    }

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

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

        System.out.println(">>> GET: " + url);
        ClientRequest request = new ClientRequest(url);
        request.pathParameter("tenantId", user.tenantId().id());
        request.pathParameter("username", user.username());
        request.pathParameter("password", FIXTURE_PASSWORD);

        String output = request.getTarget(String.class);
        System.out.println(output);

        RepresentationReader reader = new RepresentationReader(output);

        assertEquals(user.tenantId().id(), reader.stringValue("tenantId.id"));
        assertEquals(user.username(), reader.stringValue("username"));
        assertEquals(user.person().emailAddress().address(), reader.stringValue("emailAddress"));
    }
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

TOP

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

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.