List of usage examples for com.liferay.portal.kernel.security.permission ActionKeys ADD_USER_GROUP
String ADD_USER_GROUP
To view the source code for com.liferay.portal.kernel.security.permission ActionKeys ADD_USER_GROUP.
Click Source Link
From source file:eu.gerhards.liferay.services.angular.service.impl.AngularUserGroupServiceImpl.java
License:Open Source License
@Override public com.liferay.portal.kernel.model.UserGroup createUserGroup(long userId, long companyId, String name, String description) throws PortalException { _log.info("Creating new user group ..."); _log.debug(" ... security check ... "); this.crossCompanyCheck(companyId); this.checkPersonalPermission(ActionKeys.ADD_USER_GROUP); return UserGroupLocalServiceUtil.addUserGroup(userId, companyId, name, description, new ServiceContext()); }
From source file:eu.gerhards.liferay.services.angular.service.impl.AngularUserServiceImpl.java
License:Open Source License
protected void checkUpdateUserPermission(long updateUserId, long userId, long companyId, long[] groupIds, long[] organizationIds, long[] roleIds, long[] userGroupIds, ServiceContext serviceContext) throws PortalException { Company company = CompanyLocalServiceUtil.getCompany(companyId); // Adding user must be member of everything he adds long[] userIds = new long[] { updateUserId }; // Check if creator / updater is also part in the groups ServicePermissionUtil.checkMembership(userIds, groupIds, organizationIds, roleIds, userGroupIds); if (groupIds != null && groupIds.length > 0) { PortalPermissionUtil.check(getPermissionChecker(), ActionKeys.ADD_USER); angularGroupService.checkGroups(userId, groupIds); }/*from w w w . j a v a 2 s. c o m*/ if (organizationIds != null && organizationIds.length > 0) { PortalPermissionUtil.check(getPermissionChecker(), ActionKeys.ADD_ORGANIZATION); angularOrganizationService.checkOrganizations(userId, organizationIds); } if (roleIds != null && roleIds.length > 0) { PortalPermissionUtil.check(getPermissionChecker(), ActionKeys.ADD_ROLE); angularRoleService.checkRoles(userId, roleIds); } if (userGroupIds != null && userGroupIds.length > 0) { PortalPermissionUtil.check(getPermissionChecker(), ActionKeys.ADD_USER_GROUP); angularUserGroupService.checkUserGroupIds(userId, userGroupIds); } if (serviceContext == null) { serviceContext = new ServiceContext(); } boolean anonymousUser = ParamUtil.getBoolean(serviceContext, "anonymousUser"); long defaultUserId = userLocalService.getDefaultUserId(companyId); if (((updateUserId != 0) && (updateUserId != defaultUserId)) || (!company.isStrangers() && !anonymousUser)) { UserPermissionUtil.check(getPermissionChecker(), updateUserId, ActionKeys.UPDATE_USER); UserPermissionUtil.check(getPermissionChecker(), userId, organizationIds, ActionKeys.UPDATE); } }
From source file:eu.gerhards.liferay.services.angular.service.impl.AngularUserServiceImpl.java
License:Open Source License
protected void checkAddUserPermission(long creatorUserId, long companyId, String emailAddress, long[] groupIds, long[] organizationIds, long[] roleIds, long[] userGroupIds, ServiceContext serviceContext) throws PortalException { Company company = CompanyLocalServiceUtil.getCompany(companyId); // Check if user has an according right assigned with add user permission; Either he owns the right itself, by his roles or by his user roles User creator = this.getGuestOrUser(); long[] userIds = new long[] { creatorUserId }; // Adding user must be member of everything he adds ServicePermissionUtil.checkMembership(userIds, groupIds, organizationIds, roleIds, userGroupIds); if (groupIds != null && groupIds.length > 0) { PortalPermissionUtil.check(getPermissionChecker(), ActionKeys.ADD_TO_PAGE); angularGroupService.checkGroups(0, groupIds); }/* w w w . j av a 2s . c o m*/ if (organizationIds != null && organizationIds.length > 0) { PortalPermissionUtil.check(getPermissionChecker(), ActionKeys.ADD_ORGANIZATION); angularOrganizationService.checkOrganizations(0, organizationIds); } if (roleIds != null && roleIds.length > 0) { PortalPermissionUtil.check(getPermissionChecker(), ActionKeys.ADD_ROLE); angularRoleService.checkRoles(0, roleIds); } if (userGroupIds != null && userGroupIds.length > 0) { PortalPermissionUtil.check(getPermissionChecker(), ActionKeys.ADD_USER_GROUP); angularUserGroupService.checkUserGroupIds(0, userGroupIds); } boolean anonymousUser = ParamUtil.getBoolean(serviceContext, "anonymousUser"); long defaultUserId = userLocalService.getDefaultUserId(companyId); if (((creatorUserId != 0) && (creatorUserId != defaultUserId)) || (!company.isStrangers() && !anonymousUser)) { ServicePermissionUtil.checkAllPersonalPermissions(creator, ActionKeys.ADD_USER, companyId, getPermissionChecker(), User.class.getName()); } if ((creatorUserId == 0) || (creatorUserId == defaultUserId)) { if (!company.isStrangersWithMx() && company.hasCompanyMx(emailAddress)) { throw new UserEmailAddressException.MustNotUseCompanyMx(emailAddress); } } }