Created
May 4, 2017 06:36
-
-
Save cmaggiulli/b83179d74b484844e281e9d68c3a3242 to your computer and use it in GitHub Desktop.
Impersonate User script to run in Liferay 6.2 Script Console
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.liferay.portal.util.PortalUtil; | |
import com.liferay.portal.theme.ThemeDisplay; | |
import com.liferay.util.Encryptor; | |
import javax.servlet.http.HttpServletRequest; | |
String key = "23410447"; | |
String uid = ""; | |
ThemeDisplay themeDisplay = null; | |
HttpServletRequest request = null; | |
try { | |
request = PortalUtil.getHttpServletRequest(actionRequest); | |
themeDisplay = (ThemeDisplay) request.getAttribute("themeDisplay"); | |
uid = Encryptor.encrypt(PortalUtil.getCompany(request).getKeyObj(), key); | |
themeDisplay.setDoAsUserId(uid); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment