2

I am creating a custom Java servlet inside of Maximo. I want to piggyback off of Maximo's authentication and as a part of that I need some way of retrieving the user info (user name, display name, etc.) from the HttpServletRequest object. I am able to access the JSESSIONID from the request cookies (which as I understand it is how Maximo/WebSphere keeps track of your user session), but I have not been able to find a way to use that to retrieve the UserInfo object.

I have scoured the Javadocs trying to figure something out but have had no luck. It seems like Java customizations in Maximo are pretty rare nowadays so there are not many resources to figure this one out.

Jesse Williams
  • 140
  • 1
  • 8

2 Answers2

2

Have you tried psdi.webclient.system.session.WebClientSessionManager.getWebClientSessionManager(javax.servlet.http.HttpSession session).getWebClientSession(javax.servlet.http.HttpServletRequest request) ?

Preacher
  • 2,127
  • 1
  • 11
  • 25
  • Thanks, that works, but only if there is an active WebClientSession. I got it figured out for my use case, see my answer below. – Jesse Williams Aug 25 '20 at 18:51
2

Got this figured out after some digging in the Javadocs. Turns out I can pull the MXSession off of the request session object as follows:

Enumeration e = req.getSession().getAttributeNames();
String username = null;
while (e.hasMoreElements()) {
String attrName = (String) e.nextElement();
if (attrName.equals("MXSession")) {
  MXSession session = (MXSession) req
    .getSession()
    .getAttribute("MXSession");
  UserInfo user = session.getUserInfo();
  if (user != null) {
    username = user.getUserName().toLowerCase();
  }
}

Preacher's example also works, but only if there is an active WebclientSession, and for my particular use case, I want it to also work if there is only an OslcSession, which doesn't always have an associated WebclientSession. This solution works in either case, since the MXSession is always available.

Jesse Williams
  • 140
  • 1
  • 8