git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portal/portal-manager@134210 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
6e1dd2d46d
commit
e6bbddf015
|
@ -24,8 +24,7 @@ public class ContextUserUtil {
|
||||||
* @param httpServletRequest
|
* @param httpServletRequest
|
||||||
* @returnthe current user LR id
|
* @returnthe current user LR id
|
||||||
*/
|
*/
|
||||||
protected static Long getCurrentUserId(HttpServletRequest httpServletRequest) {
|
protected static Long getCurrentUserId(HttpServletRequest httpServletRequest) {
|
||||||
|
|
||||||
Cookie[] cookies = httpServletRequest.getCookies();
|
Cookie[] cookies = httpServletRequest.getCookies();
|
||||||
String userId = null;
|
String userId = null;
|
||||||
String companyId = null;
|
String companyId = null;
|
||||||
|
@ -46,18 +45,27 @@ public class ContextUserUtil {
|
||||||
|
|
||||||
} catch (Exception pException) {
|
} catch (Exception pException) {
|
||||||
_log.warn("Exception while getting current user from cookie, returning current user from http header");
|
_log.warn("Exception while getting current user from cookie, returning current user from http header");
|
||||||
String userHeaderIdString = httpServletRequest.getHeader(PortalContext.USER_ID_ATTR_NAME);
|
return getUserFromHeader(httpServletRequest);
|
||||||
long userIdToReturn = -1;
|
|
||||||
try {
|
|
||||||
userIdToReturn = Long.parseLong(userHeaderIdString);
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
_log.error("The userId is not a number -> " + userHeaderIdString);
|
|
||||||
}
|
|
||||||
return userIdToReturn;
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
_log.debug("Something wrong with cookies, returning current user from http header");
|
||||||
|
return getUserFromHeader(httpServletRequest);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
return null;
|
_log.warn("Cookies are not present, returning current user from http header");
|
||||||
|
return getUserFromHeader(httpServletRequest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static long getUserFromHeader(HttpServletRequest httpServletRequest) {
|
||||||
|
String userHeaderIdString = httpServletRequest.getHeader(PortalContext.USER_ID_ATTR_NAME);
|
||||||
|
long userIdToReturn = -1;
|
||||||
|
try {
|
||||||
|
userIdToReturn = Long.parseLong(userHeaderIdString);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
_log.error("The userId is not a number -> " + userHeaderIdString);
|
||||||
|
}
|
||||||
|
return userIdToReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String hexStringToStringByAscii(String hexString) {
|
private static String hexStringToStringByAscii(String hexString) {
|
||||||
|
|
Loading…
Reference in New Issue