servlets - Java Login with SSO -


i have servlet saml , wo2 server working. after login, system gets user data ldap. library created application using jsf (faces context).

there class called loginutil makes user data available applications through static methods such as: getuserid(), getuseremail() etc... each of method gets http session via faces context retrive user data saved @ login.

now have new applications being using spring boot , because of that, loginutil class doesnt work anymore.

i want suggestions change loginutil class make available use in application. @ first idea remove faces context , use pure session object, method statics wont able use normal variable inside of it. , i cant use static variable because applications deployed in clustered server.

any ideas?

your first idea not crazy,

contextfaces, uses threadlocal request,

you can same thing, make threadlocal, every request, using servlet filter, put theadlocal in loginuser, work in every app

class loginutil {  private static final threadlocal<userinformation> userinfo = new threadlocal();  void setuserinfo(userinformation user){   userinfo.set(user);  }   }  class userinformation{  httpsession session;  userinformation(httpsession session){  this.session = session; } }  @webfilter() class filterfoo implements filter{  public void dofilter(servletrequest request, servletresponse response, filterchain chain) {   try{    loginutil.setuserinfo(new userinformation(request.)   chain.dofilter(((httpservletrequest)request).getsession(),response);   }finally{    loginutil.setuserinfo(null);   } }  

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -