List of usage examples for com.liferay.portal.kernel.security.auth PrincipalException PrincipalException
public PrincipalException(Throwable cause)
From source file:com.bemis.portal.fileuploader.service.impl.FileUploaderServiceImpl.java
License:Open Source License
public FileEntry uploadFile(long companyId, long groupId, File file, String fileDescription, String fileName, long fileTypeId, String changeLog, String[] assetTagNames) throws PortalException { PermissionChecker permissionChecker = getPermissionChecker(); if (!permissionChecker.isGroupMember(groupId)) { throw new PrincipalException("User is not member of group with id : " + groupId); }//from w w w . j a v a 2 s . c om long userId = getUserId(); return fileUploaderLocalService.uploadFile(companyId, groupId, userId, file, fileDescription, fileName, fileTypeId, changeLog, assetTagNames); }
From source file:com.bemis.portal.fileuploader.service.impl.FileUploaderServiceImpl.java
License:Open Source License
public void uploadFiles(long companyId, long groupId, File file, long fileTypeId, String[] assetTagNames) throws IOException, PortalException { PermissionChecker permissionChecker = getPermissionChecker(); if (!permissionChecker.isGroupMember(groupId)) { throw new PrincipalException("User is not member of group with id : " + groupId); }/*from w w w .j a v a 2 s. co m*/ long userId = getUserId(); fileUploaderLocalService.uploadFiles(companyId, groupId, userId, file, fileTypeId, assetTagNames); }
From source file:com.liferay.comment.taglib.internal.struts.EditDiscussionStrutsAction.java
License:Open Source License
private DiscussionPermission _getDiscussionPermission(ThemeDisplay themeDisplay) throws PrincipalException { DiscussionPermission discussionPermission = _commentManager .getDiscussionPermission(themeDisplay.getPermissionChecker()); if (discussionPermission == null) { throw new PrincipalException("Discussion permission is null"); }//from w w w . j av a2s .c o m return discussionPermission; }
From source file:com.liferay.layout.type.controller.control.panel.internal.model.ControlPanelLayoutTypeAccessPolicy.java
License:Open Source License
@Override public void checkAccessAllowedToPortlet(HttpServletRequest request, Layout layout, Portlet portlet) throws PortalException { PermissionChecker permissionChecker = PermissionThreadLocal.getPermissionChecker(); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); if (PortletPermissionUtil.hasControlPanelAccessPermission(permissionChecker, themeDisplay.getScopeGroupId(), portlet)) {/* www .ja v a 2 s . com*/ return; } if (isAccessGrantedByRuntimePortlet(request)) { return; } if (isAccessGrantedByPortletAuthenticationToken(request, layout, portlet)) { return; } throw new PrincipalException( "User does not have permission to access Control Panel portlet " + portlet.getPortletId()); }
From source file:com.liferay.login.web.internal.portlet.action.CreateAnonymousAccountMVCActionCommand.java
License:Open Source License
@Override protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); PortletConfig portletConfig = (PortletConfig) actionRequest .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG); String portletName = portletConfig.getPortletName(); if (!portletName.equals(LoginPortletKeys.FAST_LOGIN)) { throw new PrincipalException("Unable to create anonymous account"); }/* w ww. ja va 2s . c om*/ if (actionRequest.getRemoteUser() != null) { actionResponse.sendRedirect(themeDisplay.getPathMain()); return; } String cmd = ParamUtil.getString(actionRequest, Constants.CMD); String emailAddress = ParamUtil.getString(actionRequest, "emailAddress"); PortletURL portletURL = PortletURLFactoryUtil.create(actionRequest, LoginPortletKeys.FAST_LOGIN, PortletRequest.RENDER_PHASE); portletURL.setParameter("mvcRenderCommandName", "/login/login_redirect"); portletURL.setParameter("emailAddress", emailAddress); portletURL.setParameter("anonymousUser", Boolean.TRUE.toString()); portletURL.setWindowState(LiferayWindowState.POP_UP); JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); try { if (cmd.equals(Constants.ADD)) { addAnonymousUser(actionRequest, actionResponse); sendRedirect(actionRequest, actionResponse, portletURL.toString()); } else if (cmd.equals(Constants.UPDATE)) { Company company = themeDisplay.getCompany(); if (!company.isStrangers()) { throw new PrincipalException.MustBeEnabled(company.getCompanyId(), PropsKeys.COMPANY_SECURITY_STRANGERS); } jsonObject = updateIncompleteUser(actionRequest, actionResponse); JSONPortletResponseUtil.writeJSON(actionRequest, actionResponse, jsonObject); } } catch (Exception e) { if (cmd.equals(Constants.UPDATE)) { jsonObject.putException(e); JSONPortletResponseUtil.writeJSON(actionRequest, actionResponse, jsonObject); } else if (e instanceof UserEmailAddressException.MustNotBeDuplicate) { User user = _userLocalService.getUserByEmailAddress(themeDisplay.getCompanyId(), emailAddress); if (user.getStatus() != WorkflowConstants.STATUS_INCOMPLETE) { SessionErrors.add(actionRequest, e.getClass()); } else { sendRedirect(actionRequest, actionResponse, portletURL.toString()); } } else if (e instanceof CaptchaConfigurationException || e instanceof CaptchaTextException || e instanceof CompanyMaxUsersException || e instanceof ContactNameException || e instanceof EmailAddressException || e instanceof GroupFriendlyURLException || e instanceof UserEmailAddressException) { SessionErrors.add(actionRequest, e.getClass(), e); } else { _log.error("Unable to create anonymous account", e); _portal.sendError(e, actionRequest, actionResponse); } } }
From source file:com.liferay.message.boards.internal.service.MBDiscussionMBMessageServiceWrapper.java
License:Open Source License
private PermissionChecker _getPermissionChecker() throws PrincipalException { PermissionChecker permissionChecker = PermissionThreadLocal.getPermissionChecker(); if (permissionChecker == null) { throw new PrincipalException("PermissionChecker not initialized"); }//ww w . ja v a 2 s. c o m return permissionChecker; }
From source file:com.liferay.message.boards.internal.service.MBDiscussionMBMessageServiceWrapper.java
License:Open Source License
private long _getUserId() throws PrincipalException { String name = PrincipalThreadLocal.getName(); if (Validator.isNull(name)) { throw new PrincipalException("Principal is null"); } else {/* w w w .j ava2 s.c om*/ for (int i = 0; i < _ANONYMOUS_NAMES.length; i++) { if (StringUtil.equalsIgnoreCase(name, _ANONYMOUS_NAMES[i])) { throw new PrincipalException("Principal cannot be " + _ANONYMOUS_NAMES[i]); } } } return GetterUtil.getLong(name); }