How Servlet Filter Plugin Module communicate with JIRA software(Not Cloud)


   I am confused about communcation mechanism between JIAR software(Not Cloud) and  Plugin Module.

 For example:

   I intend to utilize Servlet Filter Plugin to monitor user behaviors by checking some urls. During that process, I need to some information, such as projects, roles and so on. I  could achive that by calling rest api, but it means http been used  between Plugin and JIAR software, is it correct?

    Somebody could please give me more information?

 Thanks in advance.


1 answer

This widget could not be displayed.
Aleksandr Zuevich Community Champion Jun 07, 2017


you can inject the dependencies or use static ComponentAccessor methods to get ProjectManager, UserManager and so on.

Could you please give me more info about  communcation mechanism between JIAR software(Not Cloud) and  Plugin Module?

Aleksandr Zuevich Community Champion Jun 07, 2017

You register your servlet-filter in atlassian-plugin.xml, then implements javax.servlet.Filter interface. So now you have access to servletRequest (HttpServletRequest), servletResponse and filterChain objects. E.g. you can also get current user by 

ApplicationUser loggedUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();

It is very crucial clue, thank you very much.


Could you please give me more inforamtion, such as sample code?

thanks for your support.

Aleksandr Zuevich Community Champion Jun 19, 2017

Please take a look:

public class SprintServletFilter implements Filter {

public void init(FilterConfig filterConfig) throws ServletException {


public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest;
RequestWrapper requestWrapper = new RequestWrapper(httpServletRequest);
ApplicationUser loggedUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
filterChain.doFilter(requestWrapper, servletResponse);
String requestBody = new String(requestWrapper.getRawData());
JsonObject jsonObject = new JsonParser().parse(requestBody).getAsJsonObject();
JsonElement jsonElement = jsonObject.get("sprintId");
if (!jsonElement.isJsonNull()) {
Long sprintId = jsonElement.getAsLong();

public void destroy() {



 ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()  the result is null, and I tried isLoggedInUser() return false , getUser() return null

I don't know how to deal it, :(.

Aleksandr Zuevich Community Champion Jun 21, 2017

What do you have inside atlassian-plugin.xml?


<servlet-filter name="Sprint Servlet" key="sprintServlet"
location="before-decoration" weight="200">
<description>Tackle sprint events</description>

thanks , I have fixed this issue by changing  location="after-encoding" to  location="before-decoration" .

Maybe the user info not been injected on the top of chain, I guess

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Thursday in United States

Local Atlassian Research Workshop opportunity on Sep. 28th

We're looking for participants for another workshop at Atlassian! We need Jira admins who have interesting custom workflows, issue views, or boards. Think you have a story to sh...

47 views 0 0
View post

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