List of usage examples for com.liferay.portal.kernel.security.permission ActionKeys DELETE_USER
String DELETE_USER
To view the source code for com.liferay.portal.kernel.security.permission ActionKeys DELETE_USER.
Click Source Link
From source file:eu.gerhards.liferay.services.angular.service.impl.AngularUserServiceImpl.java
License:Open Source License
@Override public User deleteUserByEmail(String emailAddress) throws PortalException { _log.info("Deleteing user by email address ..."); _log.debug(" ... security check ... "); PortalPermissionUtil.check(getPermissionChecker(), ActionKeys.DELETE_USER); _log.debug(" ... deleting ..."); User user = getGuestOrUser();/*from w w w .ja v a 2 s. c o m*/ User existingUser = UserLocalServiceUtil.fetchUserByEmailAddress(user.getCompanyId(), emailAddress); return this.deleteUser(user, existingUser); }
From source file:eu.gerhards.liferay.services.angular.service.impl.AngularUserServiceImpl.java
License:Open Source License
@Override public User deleteUserById(long userId) throws PortalException { _log.info("Deleteing user by id ..."); _log.debug(" ... security check ... "); PortalPermissionUtil.check(getPermissionChecker(), ActionKeys.DELETE_USER); _log.debug(" ... deleting ..."); User user = getGuestOrUser();/* w w w . ja v a2 s .co m*/ User existingUser = UserLocalServiceUtil.getUserById(user.getCompanyId(), userId); return this.deleteUser(user, existingUser); }
From source file:eu.gerhards.liferay.services.angular.service.impl.AngularUserServiceImpl.java
License:Open Source License
protected void checkDeleteUserPermission(long deleteUserId, long companyId, long userId, ServiceContext serviceContext) throws PortalException { Company company = CompanyLocalServiceUtil.getCompany(companyId); boolean anonymousUser = ParamUtil.getBoolean(serviceContext, "anonymousUser"); long defaultUserId = userLocalService.getDefaultUserId(companyId); if (((deleteUserId != 0) && (deleteUserId != defaultUserId)) || (!company.isStrangers() && !anonymousUser)) { PermissionChecker permissionChecker = getPermissionChecker(); // Check if user has an according group added with assign members User creator = this.getUser(deleteUserId); long[] creatorUserGroupIds = creator.getGroupIds(); boolean hasGroupRight = false; // Either group needs right ADD_USER if (creatorUserGroupIds != null && creatorUserGroupIds.length > 0) { int index = 0; while (!hasGroupRight && index < creatorUserGroupIds.length) { hasGroupRight = UserGroupPermissionUtil.contains(getPermissionChecker(), creatorUserGroupIds[index++], ActionKeys.DELETE_USER); }/*from w w w . j a va2 s. com*/ } // or the user itself if (!hasGroupRight && !PortalPermissionUtil.contains(permissionChecker, ActionKeys.DELETE_USER)) { throw new PrincipalException.MustHavePermission(permissionChecker, Organization.class.getName(), 0, ActionKeys.UPDATE_USER, ActionKeys.ASSIGN_MEMBERS); } } }