RequestHandler and IMendixRequest

1
Hello all, I've been trying to get some information from the user's HTTP request (IP, auth user name, etc). The most straightforward way seemed to be the RequestHandler functionality. Registering a handler is easy as pie, but getting information from the IMendixRequest object is not. In fact, I can't seem to pull any information from it whatsoever. I hope someone can help me out. Sidenote: There seems to be no source information or javadoc available for this class, and I can't find any sort of documentation in the API description. This makes it difficult to work with. Am I overlooking something? Here's what I've tried so far: My first source was the slightly old but excellent RequestHandlers at your service article, that led me to try the following @Override public void processRequest(IMxRuntimeRequest iMxRuntimeRequest, IMxRuntimeResponse iMxRuntimeResponse, String s) throws Exception { Core.getLogger("RequestHandlerTest").info("process request: " + s + ", " + iMxRuntimeRequest.getRequestString()); } However, the log always gives "process request , ". No path, no RequestString content. I did some further reading on the forums and found a suggestion to cast the IMendixRequest object to a HttpServletRequest, and then work from there. HttpServletRequest request = (HttpServletRequest) iMxRuntimeRequest.getOriginalRequest(); In addition to the 'getOriginalRequest' message being deprecated now, this line of code gives a cast exception (cannot cast to HttpServletRequest). Same if I remove the getOriginalRequest and try a straight cast from IMendixRequest. I then decided to try and adept some existing code that should work. I browsed through the WinSSO Module java and copied the head of its request handler: @Override public void processRequest(IMxRuntimeRequest arg0, IMxRuntimeResponse arg1, String arg2) throws Exception { this.doGet(arg0, arg1, false); } protected void doGet(IMxRuntimeRequest request, IMxRuntimeResponse response, boolean retry) throws IOException { String auth = request.getHeader("Authorization"); The result is (again) an empty string. I've tried the above ideas both from a local deployment and from a Windows Server running IIS 7. The results were the same. So, I've kinda run out of ideas. It feels as if this should be easy and straightforward, since it seems to be working for everyone. What am I overlooking?
asked
2 answers
2

@ Jason Braswell: Thanks for the response. I'm afraid that I've already tried that angle, without success.

@ Reinout van Schouwen: Thank you! That was what I was looking for.

    HttpServletRequest servletRequest = request.getHttpServletRequest();

yields a standard ServletRequest object that then allows

String userRemote = servletRequest.getRemoteUser();
String userPrincipal = servletRequest.getUserPrincipal()

Problem solved!

answered
0

I don't use other custom request handlers but I have overrided my login request handler.
This is how I get my ip information:

String ipAddress = request.getHeader("X-Forwarded-For");
String remoteAddress = request.getRemoteAddr();


I would assume, but have not tested, that you can get the session id as well from the headers. For example, request.getHeader("currentSessionId")

EDIT: Updated key for session id from headers

answered