Jira JAVA API - get list of all JIRA users Edited

Does anybody have any experience getting a list of all of the users in their JIRA application?

I need to write a plugin for this. I currently have some code:

package com.bosch.plugin.user.list.api;

import com.atlassian.jira.user.ApplicationUser;
import com.atlassian.crowd.embedded.api.User;
import com.atlassian.jira.user;
import com.atlassian.jira.user.util.UserManager;
import com.atlassian.jira.api;
import com.bosch.jira.timeinstatus.AtlassianPluginsTestRunner;
import com.bosch.jira.timeinstatus.RunWith;
import com.bosch.plugin.user.list.impl.MyPluginComponentImpl;
import com.atlassian.jira.web.action.admin.user.UserBrowser;
import com.sun.istack.internal.Nullable;
import com.atlassian.jira.user.UserKeyService;

import java.lang.String;
import java.util.ArrayList;
import java.util.Collection;
import javax.annotation.*;

public class ListUsers implements User

private String name;
private String userName;
private long directoryId;
private String emailAddress;
private boolean isActive;
private int userCount;
private final JiraAuthenticationConext;
private final SearchRequest;

public void validator(String name, String userName, int userCount, long directoryId, String emailAddress, boolean isActive, final JiraAuthenticationContext authenticationContext, final SearchRequest searchRequest)
this.name = name;
this.userName = userName;
this.emailAddress = emailAddress;
this.isActive = isActive;
this.userCount = userCount;
this.JiraAuthenticationService = authenticationContext;
this.searchRequest = searchRequest;

public static void main(String[] args) {
System.out.println("entry point of app");

//compare user name
public int compareTo(User user){
return name.compareTo(user.getName());

//getter and setter for name
public String getName(){
return name;

//getter and setter for user name
public String getuserName(){
return userName;
//getter and setter for email
public String getEmailAddress(){
return emailAddress;
//getter and setter for directory ID in JIRA
public long getDirectoryId(){
return directoryId;
//getter and setter for checking if user is active
public boolean isActive(){
return isActive;

public int getUserCount(){
return userCount;

public Query retrieveOrMakeSearchRequest(User loggedInUser, Project currentProject){
loggedInUser = authenticationContext.getLoggedInUser();
SearchRequestManager searchRequestManager = ComponentManager.getInstance().getSearchRequestManager();
SearchRequest src=searchRequestManager.getSearchRequestById(loggedInUser);

return null;

public ArrayList<User> getAllUsers(){
// Query query = retrieveOrMakeSearchRequest(loggedInUser, currentProject);
ArrayList<User> all = new ArrayList<User>(getAllUsers());
return all;

public ArrayList<User> getAllUsersInGroups(Collection<String> arg0){
ArrayList<User> allUsersandGroups = new ArrayList<User>(getAllGroups());
return allUsersandGroups;

public ArrayList<User> getAllGroups(){
ArrayList<User> allGroups = new ArrayList<User>(getGroups());
return allGroups;


Is this the write way about getting all of my users in the JIRA application? Can somebody help or point me in the right direction?


1 answer

0 votes
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.bc.user.search.UserSearchService
import com.atlassian.jira.bc.user.search.UserSearchParams

def userSearchService = ComponentAccessor.getComponent(UserSearchService.class);
UserSearchParams userSearchParams = (new UserSearchParams.Builder()).allowEmptyQuery(true).includeActive(true).includeInactive(true).maxResults(100000).build();

userSearchService.findUsers("", userSearchParams).each{ it->

It is a groovy script. But I think you can convert it to Java. If not then tell me, I ll do it for you

Thanks, I haven't used Groovy before, would you mind showing me? 

 UserSearchService userSearchService = ComponentAccessor.getComponent(UserSearchService.class);
 UserSearchParams userSearchParams = (new UserSearchParams.Builder()).allowEmptyQuery(true).includeActive(true).includeInactive(true).maxResults(100000).build();

        for (ApplicationUser cuser : userSearchService.findUsers("", userSearchParams)) {
                // do your code here

Excellent. Thank you!

Hello Alexey, do you have the POM dependencies that would be required for this?

I do not think there must any special dependencies. If you have any problems to build the project, kindly provide the logs.

Hi Alexey Matveev 

I need help on making requests to JIRA from external application,

I followed Basic Authentication and OAuth, but here problem is I have to use username/password to make request on JIRA every time. 

And Basic Authentication is not what I need because the requests must be made in the name of the currently logged-in user (here logged-in user is from external app user).

And with OAuth: Here if user does some update on issue then we want to know who is performing the action (transitions and updations). And it will be difficult to ask individual users to register their own tokens. 


Here my expectation is to make requests on JIRA from external application who is logged-in.

Please give me a better solution to make requests. 

Thanks in Advance.


You need to use SSO. I had such experience with Kerberos

Thanks many for the quick reply, if possible can you please explore how can I use SSO to make requests on JIRA API.

You need to put all logic in your external application. You need to use api for the sso provider to recieve the authentication ticket from the sso provider. Then you send the ticket to Jira using the providers Api.

For example, let s say you use Kerberos. Then you have to install an add-on to Jira which can hanlde Kerberos authentication. then for example you use java application to make calls to Jira. You would need to use a java package for Kerberos authentication. Then you would make a call to Jira Rest Api using the java kerberos package. It would do everything for you.

Thank you so much, I will try this, and question is if I use Kerberos, do I need to provide any header information on making requests to JIRA. I mean username/password in the request header. 

No, you do not pass it.

That is the whole point of SSO. If you use Kerberos, you authenticate yourself while logging to your pc. That is all. After it you only get tickets from the key distribution server. 

@Harinath T I work for Kantega Single Sign-on.

With our add-on you can optionally enable Kerberos for REST.


With Kerberos you use the currently logged in users credentials and not a provided username/password.

Here are two examples using curl:

curl -D- --negotiate -u: -X GET -H "Content-Type: application/json" "https://bitbucket.example.com/rest/api/1.0/users/"

curl -D- -u mark.miller:MyNotSoSecretPassword -X GET -H "Content-Type: application/json" "https://bitbucket.example.com/rest/api/1.0/users/"



Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,516 views 15 20
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you