use of com.haulmont.cuba.web.auth.WebAuthConfig in project cuba by cuba-platform.
the class ControllerUtils method getUserSession.
public static UserSession getUserSession(HttpServletRequest req) {
String s = req.getParameter("s");
if (s != null) {
try {
UUID id = UUID.fromString(s);
WebAuthConfig webAuthConfig = AppBeans.get(Configuration.class).getConfig(WebAuthConfig.class);
TrustedClientService trustedClientService = AppBeans.get(TrustedClientService.NAME);
UserSession session = trustedClientService.findSession(webAuthConfig.getTrustedClientPassword(), id);
if (session != null) {
req.getSession().setAttribute(App.USER_SESSION_ATTR, session);
return session;
} else {
return null;
}
} catch (Exception e) {
log.warn("Unable to get session from Login Service", e);
return null;
}
} else {
// noinspection UnnecessaryLocalVariable
UserSession userSession = (UserSession) req.getSession().getAttribute(App.USER_SESSION_ATTR);
return userSession;
}
}
Aggregations