Class CommonPluginUtils
- java.lang.Object
-
- com.identityworksllc.iiq.common.plugin.CommonPluginUtils
-
public class CommonPluginUtils extends Object
Some utilities to avoid boilerplate
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
CommonPluginUtils.SingleServerExecute
The executor passed tosingleServerExecute(SailPointContext, ServiceDefinition, SingleServerExecute)
mainly so that we can extend it with those default methods and throw an exception from run().
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Optional<String>
getClientIP(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.static Map<String,Object>
getExceptionMapping(Throwable t, boolean includeStackTrace)
Gets the exception mappingstatic void
singleServerExecute(sailpoint.api.SailPointContext context, sailpoint.object.ServiceDefinition self, CommonPluginUtils.SingleServerExecute executor)
Executes the task given by the functionalCommonPluginUtils.SingleServerExecute
if this server is the alphabetically lowest active server on which this Service is allowed to run.static Map<String,String>
toStatusResponse(String message)
Gets a map / JSON object indicating a status responsestatic Map<String,String>
toStatusResponse(String message, Throwable error)
Gets a map / JSON object indicating a status response with an optional error
-
-
-
Method Detail
-
getClientIP
public static Optional<String> getClientIP(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
- TheHttpServletRequest
object- Returns:
- The client IP in an
Optional
, if it’s available
-
getExceptionMapping
public static Map<String,Object> getExceptionMapping(Throwable t, boolean includeStackTrace)
Gets the exception mapping- Parameters:
t
- The exception to convert into a MapincludeStackTrace
- 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 functionalCommonPluginUtils.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 contextself
- The current ServiceDefinitionexecutor
- The executor to run- Throws:
sailpoint.tools.GeneralException
- if any failures occur
-
toStatusResponse
public static Map<String,String> toStatusResponse(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,String> toStatusResponse(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 responseerror
- The error to associate with the response- Returns:
- The response object
-
-