Interface CustomerContextService


@PublicApi public interface CustomerContextService
A service project customer context allows any "named user" access to Jira Service Management and Jira Platform services.

This service allows you to setup customer context, execute some code and have the special Jira Service Management permissions apply to that called code.

Normally on the Jira platform, only licensed users can login and get permission-ed access to services. Jira Service Management, however, allows exceptions to this. In Jira Service Management EVERY named user is considered a "customer" when they are asking for help. This service allows you to enter a "customer context" to run code in the name of that user (free or otherwise).

WARNING : It is a breach of the Jira and Jira Service Management licence agreements to use this mechanism to subvert the software's terms and conditions. You must only use these methods when you are calling code services on behalf of customers, where that work is related to Jira Service Management.

  • Method Details

    • initCustomerContext

      void initCustomerContext(boolean runInContext) throws IllegalAccessException
      To be executed in order to begin a customer context from a request. This must only be called by such a filter and should throw an error if it is called twice within the same thread, or after an existing customer context call.
      Parameters:
      runInContext - true if we want to run this in customer context, false if we want this to run out of customer context
      Throws:
      IllegalAccessException - if this is run in a thread where the customer context service has already been called - this method is expected to be used only by incoming REST requests, but as a public API method it can trivially be called by anyone else.
    • runInCustomerContext

      <T> T runInCustomerContext(NoExceptionsCallable<T> callable)
      Executes the code in a "customer context". The special Jira Service Management permissions will apply to this call context.

      This method is re-entrant and can be called multiple times within the same thread.

      Type Parameters:
      T - the return type
      Parameters:
      callable - the code to execute
      Returns:
      T the callable returned value
    • runInCustomerContext

      void runInCustomerContext(Runnable runnable)
      Executes the code in a "customer context". The special Jira Service Management permissions will apply to this call context.

      This method is re-entrant and can be called multiple times within the same thread.

      Parameters:
      runnable - the code to execute
    • runOutOfCustomerContext

      <T> T runOutOfCustomerContext(NoExceptionsCallable<T> callable)
      Executes the code out of a "customer context". The special Jira Service Management permissions will NOT apply to this call context.

      This method is re-entrant and can be called multiple times within the same thread.

      Type Parameters:
      T - the return type
      Parameters:
      callable - the code to execute
      Returns:
      T the callable returned value
    • runOutOfCustomerContext

      void runOutOfCustomerContext(Runnable runnable)
      Executes the code out of a "customer context". The special Jira Service Management permissions will NOT apply to this call context.

      This method is re-entrant and can be called multiple times within the same thread.

      Parameters:
      runnable - the code to execute
    • isInCustomerContext

      boolean isInCustomerContext()
      Returns:
      true if the running code is currently inside a customer context