Search in sources :

Example 16 with User

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");
}
Also used : Group(org.activiti.engine.identity.Group) User(org.activiti.engine.identity.User)

Example 17 with User

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");
}
Also used : User(org.activiti.engine.identity.User)

Example 18 with User

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");
}
Also used : User(org.activiti.engine.identity.User)

Example 19 with User

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());
}
Also used : Group(org.activiti.engine.identity.Group) User(org.activiti.engine.identity.User)

Example 20 with User

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());
}
Also used : User(org.activiti.engine.identity.User) ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) ActivitiConflictException(org.activiti.rest.exception.ActivitiConflictException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

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