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");
}
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());
}
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");
}
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;
}
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;
}
Aggregations