@Override public List<Group> getGroupsForUser(String userId) { return identityService.createGroupQuery().groupMember(userId).list(); }
public Group getGroup(String groupId) { return identityService.createGroupQuery().groupId(groupId).singleResult(); }
@Override public List<Group> getGroups(String filter) { GroupQuery groupQuery = identityService.createGroupQuery(); if (StringUtils.isNotEmpty(filter)) { groupQuery.groupNameLikeIgnoreCase("%" + (filter != null ? filter : "") + "%"); } return groupQuery.orderByGroupName().asc().list(); }
query.groupId(allRequestParams.get("id")); query.groupName(allRequestParams.get("name")); query.groupNameLike(allRequestParams.get("nameLike")); query.groupType(allRequestParams.get("type")); query.groupMember(allRequestParams.get("member"));
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override public List<Group> execute(CommandContext commandContext) { ProcessDefinitionEntity processDefinition = CommandContextUtil.getProcessDefinitionEntityManager(commandContext).findById(processDefinitionId); if (processDefinition == null) { throw new FlowableObjectNotFoundException("Cannot find process definition with id " + processDefinitionId, ProcessDefinition.class); } IdentityService identityService = CommandContextUtil.getProcessEngineConfiguration(commandContext).getIdentityService(); List<String> groupIds = new ArrayList<>(); List<IdentityLink> identityLinks = (List) processDefinition.getIdentityLinks(); for (IdentityLink identityLink : identityLinks) { if (identityLink.getGroupId() != null && identityLink.getGroupId().length() > 0) { if (!groupIds.contains(identityLink.getGroupId())) { groupIds.add(identityLink.getGroupId()); } } } if (groupIds.size() > 0) { return identityService.createGroupQuery().groupIds(groupIds).list(); } else { return new ArrayList<>(); } }
protected void clearAllUsersAndGroups() { // Privileges List<Privilege> privileges = idmIdentityService.createPrivilegeQuery().list(); for (Privilege privilege : privileges) { idmIdentityService.deletePrivilege(privilege.getId()); } // Groups List<Group> groups = idmIdentityService.createGroupQuery().list(); for (Group group : groups) { List<User> members = idmIdentityService.createUserQuery().memberOfGroup(group.getId()).list(); for (User member : members) { idmIdentityService.deleteMembership(member.getId(), group.getId()); } idmIdentityService.deleteGroup(group.getId()); } // Users List<User> users = idmIdentityService.createUserQuery().list(); for (User user : users) { idmIdentityService.deleteUser(user.getId()); } }
@ApiOperation(value = "Create a group", tags = { "Groups" }) @ApiResponses(value = { @ApiResponse(code = 201, message = "Indicates the group was created."), @ApiResponse(code = 400, message = "Indicates the id of the group was missing.") }) @PostMapping(value = "/groups", produces = "application/json") public GroupResponse createGroup(@RequestBody GroupRequest groupRequest, HttpServletRequest httpRequest, HttpServletResponse response) { if (groupRequest.getId() == null) { throw new FlowableIllegalArgumentException("Id cannot be null."); } // Check if a user with the given ID already exists so we return a CONFLICT if (identityService.createGroupQuery().groupId(groupRequest.getId()).count() > 0) { throw new FlowableConflictException("A group with id '" + groupRequest.getId() + "' already exists."); } Group created = identityService.newGroup(groupRequest.getId()); created.setId(groupRequest.getId()); created.setName(groupRequest.getName()); created.setType(groupRequest.getType()); if (restApiInterceptor != null) { restApiInterceptor.createNewGroup(created); } identityService.saveGroup(created); response.setStatus(HttpStatus.CREATED.value()); return restResponseFactory.createGroupResponse(created); }
@Override public List<String> getGroupsForCandidateUser(String candidateUser) { IdmIdentityService identityService = cmmnEngineConfiguration.getIdmIdentityService(); List<Group> groups = identityService.createGroupQuery().groupMember(candidateUser).list(); List<String> groupIds = new ArrayList<>(); for (Group group : groups) { groupIds.add(group.getId()); } return groupIds; } }
protected Group getGroupFromRequest(String groupId) { Group group = identityService.createGroupQuery().groupId(groupId).singleResult(); if (group == null) { throw new FlowableObjectNotFoundException("Could not find a group with id '" + groupId + "'.", Group.class); } if (restApiInterceptor != null) { restApiInterceptor.accessGroupInfoById(group); } return group; }
@Override public List<String> getGroupsForCandidateUser(String candidateUser) { IdentityService identityService = getProcessEngineConfiguration().getIdentityService(); List<Group> groups = identityService.createGroupQuery().groupMember(candidateUser).list(); List<String> groupIds = new ArrayList<>(); for (Group group : groups) { groupIds.add(group.getId()); } return groupIds; } }
public void deleteGroup(String groupId) { Group group = identityService.createGroupQuery().groupId(groupId).singleResult(); if (group == null) { throw new NotFoundException(); } identityService.deleteGroup(groupId); }
protected List<String> getGroupsForCandidateUser(String candidateUser) { IdentityService identityService = Context.getProcessEngineConfiguration().getIdentityService(); List<Group> groups = identityService.createGroupQuery().groupMember(candidateUser).list(); List<String> groupIds = new ArrayList<>(); for (Group group : groups) { groupIds.add(group.getId()); } return groupIds; }
public Group updateGroupName(String groupId, String name) { if (StringUtils.isBlank(name)) { throw new BadRequestException("Group name required"); } Group group = identityService.createGroupQuery().groupId(groupId).singleResult(); if (group == null) { throw new NotFoundException(); } group.setName(name); identityService.saveGroup(group); return group; }
protected List<String> getGroupsForCandidateUser(String candidateUser) { List<String> groupIds = new ArrayList<>(); IdmIdentityService idmIdentityService = CommandContextUtil.getTaskServiceConfiguration().getIdmIdentityService(); if (idmIdentityService != null) { List<Group> groups = idmIdentityService.createGroupQuery().groupMember(candidateUser).list(); for (Group group : groups) { groupIds.add(group.getId()); } } return groupIds; }
protected boolean isGroupPrivilege(String privilegeId, String groupId) { Group group = identityService.createGroupQuery().groupId(groupId).singleResult(); if (group == null) { throw new IllegalArgumentException("Invalid group id"); } return identityService.createPrivilegeQuery().privilegeId(privilegeId).groupId(groupId).count() > 0; }
@Override public Authentication authenticate(Authentication authentication) throws AuthenticationException { String name = authentication.getName(); String password = authentication.getCredentials().toString(); boolean authenticated = identityService.checkPassword(name, password); if (authenticated) { List<Group> groups = identityService.createGroupQuery().groupMember(name).list(); Collection<GrantedAuthority> grantedAuthorities = new ArrayList<>(); for (Group group : groups) { grantedAuthorities.add(new SimpleGrantedAuthority(group.getId())); } return new UsernamePasswordAuthenticationToken(name, password, grantedAuthorities); } else { throw new BadCredentialsException("Authentication failed for this username and password"); } }
public void addGroupMember(String groupId, String userId) { verifyGroupMemberExists(groupId, userId); Group group = identityService.createGroupQuery().groupId(groupId).singleResult(); if (group == null) { throw new NotFoundException(); } User user = identityService.createUserQuery().userId(userId).singleResult(); if (user == null) { throw new NotFoundException(); } identityService.createMembership(userId, groupId); }
protected List<String> getGroupsForCandidateUser(String candidateUser) { IdentityService identityService = Context.getProcessEngineConfiguration().getIdentityService(); List<Group> groups = identityService.createGroupQuery().groupMember(candidateUser).list(); List<String> groupIds = new ArrayList<>(); for (Group group : groups) { groupIds.add(group.getId()); } return groupIds; }
protected void verifyGroupMemberExists(String groupId, String userId) { // Check existence Group group = identityService.createGroupQuery().groupId(groupId).singleResult(); User user = identityService.createUserQuery().userId(userId).singleResult(); for (User groupMember : identityService.createUserQuery().memberOfGroup(groupId).list()) { if (groupMember.getId().equals(userId)) { user = groupMember; } } if (group == null || user == null) { throw new NotFoundException(); } }
public List<String> getAuthorizationGroups() { // Similar behaviour as the TaskQuery.taskCandidateUser() which includes the groups the candidate user is part of if (authorizationUserId != null) { IdentityService identityService = Context.getProcessEngineConfiguration().getIdentityService(); List<Group> groups = identityService.createGroupQuery().groupMember(authorizationUserId).list(); List<String> groupIds = new ArrayList<>(); for (Group group : groups) { groupIds.add(group.getId()); } return groupIds; } return null; }