List of usage examples for com.liferay.portal.kernel.service UserLocalServiceUtil hasRoleUser
public static boolean hasRoleUser(long roleId, long userId)
From source file:com.liferay.iframe.web.internal.util.IFrameUtil.java
License:Open Source License
public static boolean isPasswordTokenEnabled(PortletRequest portletRequest) throws PortalException { if (!PropsValues.SESSION_STORE_PASSWORD) { return false; }//from w ww . j a v a 2 s . c om ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); Layout layout = themeDisplay.getLayout(); String roleName = PropsValues.IFRAME_PASSWORD_PASSWORD_TOKEN_ROLE; if (layout.isPrivateLayout() && layout.getGroup().isUser() && (themeDisplay.getRealUserId() == layout.getGroup().getClassPK())) { return true; } if (Validator.isNull(roleName)) { return false; } try { Role role = RoleLocalServiceUtil.getRole(themeDisplay.getCompanyId(), roleName); if (UserLocalServiceUtil.hasRoleUser(role.getRoleId(), themeDisplay.getUserId())) { return true; } } catch (Exception e) { if (_log.isWarnEnabled()) { _log.warn("Error getting role " + roleName + ". The password token " + "will be disabled."); } } return false; }