Class CommonPluginUtils

    • Method Detail

      • getClientIP

        public static Optional<StringgetClientIP​(javax.servlet.http.HttpServletRequest request)
        Attempts to find the Client IP, either via the request header X-FORWARDED-FOR (set by load balancers and reverse proxies), or via the request itself.
        Parameters:
        request - The HttpServletRequest object
        Returns:
        The client IP in an Optional, if it’s available
      • getExceptionMapping

        public static Map<String,​ObjectgetExceptionMapping​(Throwable t,
                                                                   boolean includeStackTrace)
        Gets the exception mapping
        Parameters:
        t - The exception to convert into a Map
        includeStackTrace - True if we should include the stack trace in the response
        Returns:
        The exception transformed into a mapping
      • singleServerExecute

        public static void singleServerExecute​(sailpoint.api.SailPointContext context,
                                               sailpoint.object.ServiceDefinition self,
                                               CommonPluginUtils.SingleServerExecute executor)
                                        throws sailpoint.tools.GeneralException
        Executes the task given by the functional CommonPluginUtils.SingleServerExecute if this server is the alphabetically lowest active server on which this Service is allowed to run.

        Server names are sorted by the database using an ‘order by’ on query.

        This is intended to be used as the bulk of the execute() method of a Service class. You can either pass a lambda/closure to this method or implement the SingleServerExecute interface in your Service class (in which case you’d simply pass ‘this’).

        Parameters:
        context - The context
        self - The current ServiceDefinition
        executor - The executor to run
        Throws:
        sailpoint.tools.GeneralException - if any failures occur
      • toStatusResponse

        public static Map<String,​StringtoStatusResponse​(String message)
        Gets a map / JSON object indicating a status response
        Parameters:
        message - The message to associate with the response
        Returns:
        The response object
      • toStatusResponse

        public static Map<String,​StringtoStatusResponse​(String message,
                                                                Throwable error)
        Gets a map / JSON object indicating a status response with an optional error
        Parameters:
        message - The message to associate with the response
        error - The error to associate with the response
        Returns:
        The response object