Search in sources :

Example 76 with User

use of org.activiti.engine.identity.User in project Activiti by Activiti.

the class IdentityServiceTest method testDeleteMembership.

public void testDeleteMembership() {
    Group sales = identityService.newGroup("sales");
    identityService.saveGroup(sales);
    User johndoe = identityService.newUser("johndoe");
    identityService.saveUser(johndoe);
    // Add membership
    identityService.createMembership(johndoe.getId(), sales.getId());
    List<Group> groups = identityService.createGroupQuery().groupMember(johndoe.getId()).list();
    assertTrue(groups.size() == 1);
    assertEquals("sales", groups.get(0).getId());
    // Delete the membership and check members of sales group
    identityService.deleteMembership(johndoe.getId(), sales.getId());
    groups = identityService.createGroupQuery().groupMember(johndoe.getId()).list();
    assertTrue(groups.isEmpty());
    identityService.deleteGroup("sales");
    identityService.deleteUser("johndoe");
}
Also used : Group(org.activiti.engine.identity.Group) User(org.activiti.engine.identity.User)

Example 77 with User

use of org.activiti.engine.identity.User in project Activiti by Activiti.

the class IdentityServiceTest method testUserInfo.

public void testUserInfo() {
    User user = identityService.newUser("testuser");
    identityService.saveUser(user);
    identityService.setUserInfo("testuser", "myinfo", "myvalue");
    assertEquals("myvalue", identityService.getUserInfo("testuser", "myinfo"));
    identityService.setUserInfo("testuser", "myinfo", "myvalue2");
    assertEquals("myvalue2", identityService.getUserInfo("testuser", "myinfo"));
    identityService.deleteUserInfo("testuser", "myinfo");
    assertNull(identityService.getUserInfo("testuser", "myinfo"));
    identityService.deleteUser(user.getId());
}
Also used : User(org.activiti.engine.identity.User)

Example 78 with User

use of org.activiti.engine.identity.User in project Activiti by Activiti.

the class IdentityServiceTest method testDeleteMembershipWhenUserIsNoMember.

public void testDeleteMembershipWhenUserIsNoMember() {
    Group sales = identityService.newGroup("sales");
    identityService.saveGroup(sales);
    User johndoe = identityService.newUser("johndoe");
    identityService.saveUser(johndoe);
    // Delete the membership when the user is no member
    identityService.deleteMembership(johndoe.getId(), sales.getId());
    identityService.deleteGroup("sales");
    identityService.deleteUser("johndoe");
}
Also used : Group(org.activiti.engine.identity.Group) User(org.activiti.engine.identity.User)

Example 79 with User

use of org.activiti.engine.identity.User in project Activiti by Activiti.

the class UserListQuery method loadItems.

public List<Item> loadItems(int start, int count) {
    List<User> users = identityService.createUserQuery().orderByUserFirstName().asc().orderByUserLastName().asc().orderByUserId().asc().listPage(start, count);
    List<Item> userListItems = new ArrayList<Item>();
    for (User user : users) {
        userListItems.add(new UserListItem(user));
    }
    return userListItems;
}
Also used : PropertysetItem(com.vaadin.data.util.PropertysetItem) Item(com.vaadin.data.Item) User(org.activiti.engine.identity.User) ArrayList(java.util.ArrayList)

Example 80 with User

use of org.activiti.engine.identity.User in project Activiti by Activiti.

the class DefaultLoginHandler method authenticate.

public LoggedInUserImpl authenticate(String userName, String password) {
    LoggedInUserImpl loggedInUser = null;
    try {
        if (identityService.checkPassword(userName, password)) {
            User user = identityService.createUserQuery().userId(userName).singleResult();
            // Fetch and cache user data
            loggedInUser = new LoggedInUserImpl(user, password);
            List<Group> groups = identityService.createGroupQuery().groupMember(user.getId()).list();
            for (Group group : groups) {
                if (Constants.SECURITY_ROLE.equals(group.getType())) {
                    loggedInUser.addSecurityRoleGroup(group);
                    if (Constants.SECURITY_ROLE_USER.equals(group.getId())) {
                        loggedInUser.setUser(true);
                    }
                    if (Constants.SECURITY_ROLE_ADMIN.equals(group.getId())) {
                        loggedInUser.setAdmin(true);
                    }
                } else if (ExplorerApp.get().getAdminGroups() != null && ExplorerApp.get().getAdminGroups().contains(group.getId())) {
                    loggedInUser.addSecurityRoleGroup(group);
                    loggedInUser.setAdmin(true);
                } else if (ExplorerApp.get().getUserGroups() != null && ExplorerApp.get().getUserGroups().contains(group.getId())) {
                    loggedInUser.addSecurityRoleGroup(group);
                    loggedInUser.setUser(true);
                } else {
                    loggedInUser.addGroup(group);
                }
            }
        }
    } catch (Exception e) {
    // Do nothing, returning null should be enough
    }
    return loggedInUser;
}
Also used : Group(org.activiti.engine.identity.Group) LoggedInUser(org.activiti.explorer.identity.LoggedInUser) User(org.activiti.engine.identity.User) LoggedInUserImpl(org.activiti.explorer.identity.LoggedInUserImpl)

Aggregations

User (org.activiti.engine.identity.User)94 Group (org.activiti.engine.identity.Group)22 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)12 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)10 Task (org.activiti.engine.task.Task)10 JsonNode (com.fasterxml.jackson.databind.JsonNode)9 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)9 Picture (org.activiti.engine.identity.Picture)9 StringEntity (org.apache.http.entity.StringEntity)9 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)9 ArrayList (java.util.ArrayList)7 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)7 HttpPut (org.apache.http.client.methods.HttpPut)7 HttpGet (org.apache.http.client.methods.HttpGet)6 UserQuery (org.activiti.engine.identity.UserQuery)5 HttpDelete (org.apache.http.client.methods.HttpDelete)5 HttpPost (org.apache.http.client.methods.HttpPost)4 Item (com.vaadin.data.Item)3 ActivitiException (org.activiti.engine.ActivitiException)3 IdentityService (org.activiti.engine.IdentityService)3