use of org.activiti.engine.identity.User in project Activiti by Activiti.
the class IdentityTest method testMembership.
public void testMembership() {
Group sales = identityService.newGroup("sales");
identityService.saveGroup(sales);
Group development = identityService.newGroup("development");
identityService.saveGroup(development);
User johndoe = identityService.newUser("johndoe");
identityService.saveUser(johndoe);
User joesmoe = identityService.newUser("joesmoe");
identityService.saveUser(joesmoe);
User jackblack = identityService.newUser("jackblack");
identityService.saveUser(jackblack);
identityService.createMembership("johndoe", "sales");
identityService.createMembership("joesmoe", "sales");
identityService.createMembership("joesmoe", "development");
identityService.createMembership("jackblack", "development");
List<Group> groups = identityService.createGroupQuery().groupMember("johndoe").list();
assertEquals(createStringSet("sales"), getGroupIds(groups));
groups = identityService.createGroupQuery().groupMember("joesmoe").list();
assertEquals(createStringSet("sales", "development"), getGroupIds(groups));
groups = identityService.createGroupQuery().groupMember("jackblack").list();
assertEquals(createStringSet("development"), getGroupIds(groups));
List<User> users = identityService.createUserQuery().memberOfGroup("sales").list();
assertEquals(createStringSet("johndoe", "joesmoe"), getUserIds(users));
users = identityService.createUserQuery().memberOfGroup("development").list();
assertEquals(createStringSet("joesmoe", "jackblack"), getUserIds(users));
identityService.deleteGroup("sales");
identityService.deleteGroup("development");
identityService.deleteUser("jackblack");
identityService.deleteUser("joesmoe");
identityService.deleteUser("johndoe");
}
use of org.activiti.engine.identity.User in project Activiti by Activiti.
the class IdentityTest method testUser.
public void testUser() {
User user = identityService.newUser("johndoe");
user.setFirstName("John");
user.setLastName("Doe");
user.setEmail("johndoe@alfresco.com");
identityService.saveUser(user);
user = identityService.createUserQuery().userId("johndoe").singleResult();
assertEquals("johndoe", user.getId());
assertEquals("John", user.getFirstName());
assertEquals("Doe", user.getLastName());
assertEquals("johndoe@alfresco.com", user.getEmail());
identityService.deleteUser("johndoe");
}
use of org.activiti.engine.identity.User in project Activiti by Activiti.
the class IdentityTest method testAuthentication.
public void testAuthentication() {
User user = identityService.newUser("johndoe");
user.setPassword("xxx");
identityService.saveUser(user);
assertTrue(identityService.checkPassword("johndoe", "xxx"));
assertFalse(identityService.checkPassword("johndoe", "invalid pwd"));
identityService.deleteUser("johndoe");
}
use of org.activiti.engine.identity.User in project Activiti by Activiti.
the class BaseJPARestTestCase method createUsers.
protected void createUsers() {
User user = identityService.newUser("kermit");
user.setFirstName("Kermit");
user.setLastName("the Frog");
user.setPassword("kermit");
identityService.saveUser(user);
Group group = identityService.newGroup("admin");
group.setName("Administrators");
identityService.saveGroup(group);
identityService.createMembership(user.getId(), group.getId());
}
use of org.activiti.engine.identity.User in project Activiti by Activiti.
the class UserInfoCollectionResource method setUserInfo.
@RequestMapping(value = "/identity/users/{userId}/info", method = RequestMethod.POST, produces = "application/json")
public UserInfoResponse setUserInfo(@PathVariable String userId, @RequestBody UserInfoRequest userRequest, HttpServletRequest request, HttpServletResponse response) {
User user = getUserFromRequest(userId);
if (userRequest.getKey() == null) {
throw new ActivitiIllegalArgumentException("The key cannot be null.");
}
if (userRequest.getValue() == null) {
throw new ActivitiIllegalArgumentException("The value cannot be null.");
}
String existingValue = identityService.getUserInfo(user.getId(), userRequest.getKey());
if (existingValue != null) {
throw new ActivitiConflictException("User info with key '" + userRequest.getKey() + "' already exists for this user.");
}
identityService.setUserInfo(user.getId(), userRequest.getKey(), userRequest.getValue());
response.setStatus(HttpStatus.CREATED.value());
return restResponseFactory.createUserInfoResponse(userRequest.getKey(), userRequest.getValue(), user.getId());
}
Aggregations