Class RequestHandler
- java.lang.Object
-
- com.mendix.externalinterface.connector.RequestHandler
-
- All Implemented Interfaces:
IRequestHandler
public abstract class RequestHandler extends java.lang.Object implements IRequestHandler
Implementation ofIRequestHandlerthat provides some access to the Mendix Runtime. Most importantly, it lets you access session information of requests.
-
-
Field Summary
Fields Modifier and Type Field Description protected ILogNodelogger-
Fields inherited from interface com.mendix.externalinterface.connector.IRequestHandler
APPLICATION_OCTET_STREAM_TYPE, CSRF_TOKEN_HEADER, CSRF_TOKEN_PARAMETER, EXPIRES
-
-
Constructor Summary
Constructors Constructor Description RequestHandler()Creates a new request handler.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected java.lang.StringbuildUserInfo(IContext context)voiddoProcessRequest(IMxRuntimeRequest request, IMxRuntimeResponse response, java.lang.String path)Method that is called when a new request is to be processed.protected java.lang.StringformatDate(java.util.Date date)protected longgetExpiresTimeStamp(int addYears)protected java.lang.StringgetSessionCookieName()protected ISessiongetSessionFromRequest(IMxRuntimeRequest request)Get the session using the cookie.protected ISessiongetSessionFromRequest(IMxRuntimeRequest request, boolean performCSRFCheck)Get the session using the cookie.protected booleanisSessionKilledByNewLogin(IMxRuntimeRequest request)Returns whether the specified session has expired.protected java.util.DateparseDate(java.lang.String date)protected abstract voidprocessRequest(IMxRuntimeRequest request, IMxRuntimeResponse response, java.lang.String path)Method that is called when a new request is to be processed.
-
-
-
Field Detail
-
logger
protected ILogNode logger
-
-
Method Detail
-
doProcessRequest
public void doProcessRequest(IMxRuntimeRequest request, IMxRuntimeResponse response, java.lang.String path) throws java.lang.Exception
Description copied from interface:IRequestHandlerMethod that is called when a new request is to be processed.- Specified by:
doProcessRequestin interfaceIRequestHandler- Parameters:
request- the request to handlerresponse- the response to update for the requestpath- the request path after the handler type (e.g. for "/xas/commit" the handler type is "xas/" and the path is "commit")- Throws:
java.lang.Exception
-
processRequest
protected abstract void processRequest(IMxRuntimeRequest request, IMxRuntimeResponse response, java.lang.String path) throws java.lang.Exception
Method that is called when a new request is to be processed. Implement this method instead of overridingdoProcessRequest(com.mendix.m2ee.api.IMxRuntimeRequest, com.mendix.m2ee.api.IMxRuntimeResponse, java.lang.String).- Parameters:
request- the request to handlerresponse- the response to update for the requestpath- the request path- Throws:
java.lang.Exception
-
getSessionFromRequest
protected ISession getSessionFromRequest(IMxRuntimeRequest request) throws CoreException
Get the session using the cookie. No csrf check will be performed.- Parameters:
request- the request from which to get the session- Returns:
- the session
- Throws:
CoreException- if the session cannot be retrieved
-
getSessionFromRequest
protected ISession getSessionFromRequest(IMxRuntimeRequest request, boolean performCSRFCheck) throws CoreException
Get the session using the cookie.- Parameters:
request- the request from which to get the sessionperformCSRFCheck- whether a csrf check will be performed using the request headers- Returns:
- the session
- Throws:
CoreException- if the session cannot be retrieved
-
isSessionKilledByNewLogin
protected boolean isSessionKilledByNewLogin(IMxRuntimeRequest request)
Returns whether the specified session has expired.- Parameters:
request- the request from which to get the session- Returns:
- true if the session expired, false otherwise
-
buildUserInfo
protected java.lang.String buildUserInfo(IContext context)
-
getExpiresTimeStamp
protected long getExpiresTimeStamp(int addYears)
-
formatDate
protected java.lang.String formatDate(java.util.Date date)
-
parseDate
protected java.util.Date parseDate(java.lang.String date) throws java.text.ParseException- Throws:
java.text.ParseException
-
getSessionCookieName
protected java.lang.String getSessionCookieName()
-
-