Package org.activiti.engine.identity

Examples of org.activiti.engine.identity.User


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


    identityService.deleteGroup("sales");
    identityService.deleteUser("johndoe");
  }
 
  public void testDeleteMembershipUnexistingGroup() {
    User johndoe = identityService.newUser("johndoe");
    identityService.saveUser(johndoe);
    // No exception should be thrown when group doesn't exist
    identityService.deleteMembership(johndoe.getId(), "unexistinggroup");
    identityService.deleteUser(johndoe.getId());
  }
View Full Code Here

    assertFalse(identityService.checkPassword(null, "passwd"));
    assertFalse(identityService.checkPassword(null, null));
  }
 
  public void testUserOptimisticLockingException() {
    User user = identityService.newUser("kermit");
    identityService.saveUser(user);
   
    User user1 = identityService.createUserQuery().singleResult();
    User user2 = identityService.createUserQuery().singleResult();
   
    user1.setFirstName("name one");
    identityService.saveUser(user1);

    try {
     
      user2.setFirstName("name two");
      identityService.saveUser(user2);
     
      fail("Expected an exception");
    } catch (ActivitiOptimisticLockingException e) {
      // Expected an exception
View Full Code Here

  public void execute(DelegateExecution execution) throws Exception {

    IdentityService identityService = execution.getEngineServices().getIdentityService();
   
    String username = "Kermit";
    User user = identityService.newUser(username);
    user.setPassword("123");
    user.setFirstName("Manually");
    user.setLastName("created");
    identityService.saveUser(user);
   
    // Add admin group
    Group group = identityService.newGroup("admin");
    identityService.saveGroup(group);
View Full Code Here

  @Deployment
  public void testMultipleServiceInvocationsFromDelegate() {
    runtimeService.startProcessInstanceByKey("multipleServiceInvocations");
   
    // The service task should have created a user which is part of the admin group
    User user = identityService.createUserQuery().singleResult();
    assertEquals("Kermit", user.getId());
    Group group = identityService.createGroupQuery().groupMember(user.getId()).singleResult();
    assertNotNull(group);
    assertEquals("admin", group.getId());
   
    // Cleanup
    identityService.deleteUser("Kermit");
View Full Code Here

    }

    @Override
    public UserDetails loadUserByUsername(String userId)
            throws UsernameNotFoundException {
        User user = null;
        try {
            user = this.identityService.createUserQuery()
                    .userId(userId)
                    .singleResult();
        } catch (ActivitiException ex) {
            // don't care
        }

        if (null == user) {
            throw new UsernameNotFoundException(
                    String.format("user (%s) could not be found", userId));
        }

        // if the results not null then its active...
        boolean active = true;

        // get the granted authorities
        List<GrantedAuthority> grantedAuthorityList = new ArrayList<GrantedAuthority>();
        List<Group> groupsForUser = identityService
                .createGroupQuery()
                .groupMember(user.getId())
                .list();

        for (Group g : groupsForUser) {
            grantedAuthorityList.add(new GroupGrantedAuthority(g));
        }

        return new org.springframework.security.core.userdetails.User(
                user.getId(),
                user.getPassword() ,
                active, active, active, active,
                grantedAuthorityList);
    }
View Full Code Here

    this.i18nManager = ExplorerApp.get().getI18nManager();
  }
 
  public Label resolveText(Event event) {
    IdentityService identityService = ProcessEngines.getDefaultProcessEngine().getIdentityService();
    User user = identityService.createUserQuery().userId(event.getUserId()).singleResult();
    String eventAuthor = "<span class='" + ExplorerLayout.STYLE_TASK_EVENT_AUTHOR + "'>"
          + user.getFirstName() + " " + user.getLastName() + "</span> ";
   
    String text = null;
    if (Event.ACTION_ADD_USER_LINK.equals(event.getAction())) {
      User involvedUser = identityService.createUserQuery().userId(event.getMessageParts().get(0)).singleResult();
      text = i18nManager.getMessage(Messages.EVENT_ADD_USER_LINK,
              eventAuthor,
              involvedUser.getFirstName() + " " + involvedUser.getLastName(),
              event.getMessageParts().get(1)); // second msg part = role
    } else if (Event.ACTION_DELETE_USER_LINK.equals(event.getAction())) {
      User involvedUser = identityService.createUserQuery().userId(event.getMessageParts().get(0)).singleResult();
      text = i18nManager.getMessage(Messages.EVENT_DELETE_USER_LINK,
              eventAuthor,
              involvedUser.getFirstName() + " " + involvedUser.getLastName(),
              event.getMessageParts().get(1));
    } else if (Event.ACTION_ADD_GROUP_LINK.equals(event.getAction())) {
      text = i18nManager.getMessage(Messages.EVENT_ADD_GROUP_LINK,
              eventAuthor,
              event.getMessageParts().get(0),
View Full Code Here

  @Autowired
  protected IdentityService identityService;
 
  @RequestMapping(value="/identity/users/{userId}/info/{key}", method = RequestMethod.GET, produces = "application/json")
  public UserInfoResponse getUserInfo(@PathVariable("userId") String userId, @PathVariable("key") String key, HttpServletRequest request) {
    User user = getUserFromRequest(userId);
   
    String existingValue = identityService.getUserInfo(user.getId(), key);
    if (existingValue == null) {
      throw new ActivitiObjectNotFoundException("User info with key '" + key + "' does not exists for user '" + user.getId() + "'.", null);
    }
   
    String serverRootUrl = request.getRequestURL().toString();
    serverRootUrl = serverRootUrl.substring(0, serverRootUrl.indexOf("/identity/users/"));
    return restResponseFactory.createUserInfoResponse(key, existingValue, user.getId(), serverRootUrl);
  }
View Full Code Here

 
  @RequestMapping(value="/identity/users/{userId}/info/{key}", method = RequestMethod.PUT, produces = "application/json")
  public UserInfoResponse setUserInfo(@PathVariable("userId") String userId, @PathVariable("key") String key,
      @RequestBody UserInfoRequest userRequest, HttpServletRequest request) {
   
    User user = getUserFromRequest(userId);
    String validKey = getValidKeyFromRequest(user, key);
   
    if (userRequest.getValue() == null) {
      throw new ActivitiIllegalArgumentException("The value cannot be null.");
    }
   
    if (userRequest.getKey() == null || validKey.equals(userRequest.getKey())) {
      identityService.setUserInfo(user.getId(), key, userRequest.getValue());
    } else {
      throw new ActivitiIllegalArgumentException("Key provided in request body doesn't match the key in the resource URL.");
    }
   
    String serverRootUrl = request.getRequestURL().toString();
    serverRootUrl = serverRootUrl.substring(0, serverRootUrl.indexOf("/identity/users/"));
    return restResponseFactory.createUserInfoResponse(key, userRequest.getValue(), user.getId(), serverRootUrl);
  }
View Full Code Here

    return restResponseFactory.createUserInfoResponse(key, userRequest.getValue(), user.getId(), serverRootUrl);
  }
 
  @RequestMapping(value="/identity/users/{userId}/info/{key}", method = RequestMethod.DELETE)
  public void deleteUserInfo(@PathVariable("userId") String userId, @PathVariable("key") String key, HttpServletResponse response) {
    User user = getUserFromRequest(userId);
    String validKey = getValidKeyFromRequest(user, key);
   
    identityService.setUserInfo(user.getId(), validKey, null);
   
    response.setStatus(HttpStatus.NO_CONTENT.value());
  }
View Full Code Here

TOP

Related Classes of org.activiti.engine.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.