removed ASL Session, ported to gCube Client Context
git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portal/portal-manager@134195 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
d034412bbe
commit
6e1dd2d46d
|
@ -6,6 +6,9 @@ import java.security.Key;
|
||||||
import javax.servlet.http.Cookie;
|
import javax.servlet.http.Cookie;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.liferay.portal.model.Company;
|
import com.liferay.portal.model.Company;
|
||||||
import com.liferay.portal.service.CompanyLocalServiceUtil;
|
import com.liferay.portal.service.CompanyLocalServiceUtil;
|
||||||
import com.liferay.util.Encryptor;
|
import com.liferay.util.Encryptor;
|
||||||
|
@ -15,12 +18,14 @@ import com.liferay.util.Encryptor;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ContextUserUtil {
|
public class ContextUserUtil {
|
||||||
|
private static final Logger _log = LoggerFactory.getLogger(PortalContext.class);
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @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;
|
||||||
|
@ -40,7 +45,15 @@ public class ContextUserUtil {
|
||||||
return Long.valueOf(userIdPlain);
|
return Long.valueOf(userIdPlain);
|
||||||
|
|
||||||
} catch (Exception pException) {
|
} catch (Exception pException) {
|
||||||
throw new RuntimeException(pException);
|
_log.warn("Exception while getting current user from cookie, returning current user from http header");
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue