Package com.liferay.portal.security.permission

Examples of com.liferay.portal.security.permission.PermissionChecker


    throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay)actionRequest.getAttribute(
      WebKeys.THEME_DISPLAY);

    PermissionChecker permissionChecker =
      themeDisplay.getPermissionChecker();

    if (!permissionChecker.isCompanyAdmin()) {
      return;
    }

    long meetupsEntryId = ParamUtil.getLong(
      actionRequest, "meetupsEntryId");
View Full Code Here


      actionRequest);

    ThemeDisplay themeDisplay = (ThemeDisplay)uploadRequest.getAttribute(
      WebKeys.THEME_DISPLAY);

    PermissionChecker permissionChecker =
      themeDisplay.getPermissionChecker();

    if (!permissionChecker.isCompanyAdmin()) {
      return;
    }

    long meetupsEntryId = ParamUtil.getLong(
      uploadRequest, "meetupsEntryId");
View Full Code Here

  @Override
  protected Collection<UserData> getUsers() {

    try {
      final PermissionChecker oldChecker = PermissionThreadLocal.getPermissionChecker();
      try {
        PermissionThreadLocal.setPermissionChecker(new PermissionChecker() { //TODO not the best way to do it?
          @Override
          public long getCompanyId() {
            return oldChecker.getCompanyId();
          }

          @Override
          public long getOwnerRoleId() {
            return oldChecker.getOwnerRoleId();
          }

          @Override
          public long[] getRoleIds(long userId, long groupId) {
            return oldChecker.getRoleIds(userId, groupId);
          }

          @Override
          public long getUserId() {
            return oldChecker.getUserId();
          }

          @Override
          public boolean hasOwnerPermission(long companyId, String name, long primKey, long ownerId, String actionId) {
            return true;
          }

          @Override
          public boolean hasOwnerPermission(long companyId, String name, String primKey, long ownerId, String actionId) {
            return true;
          }

          @Override
          public boolean hasPermission(long groupId, String name, long primKey, String actionId) {
            return true;
          }

          @Override
          public boolean hasPermission(long groupId, String name, String primKey, String actionId) {
            return true;
          }

          @Override
          public boolean hasUserPermission(long groupId, String name, String primKey, String actionId, boolean checkAdmin) {
            return true;
          }

          @Override
          public void init(User user, boolean checkGuest) {
            oldChecker.init(user, checkGuest);
          }

          @Override
          public boolean isCommunityAdmin(long groupId) {
            return true;
          }

          @Override
          public boolean isCommunityOwner(long groupId) {
            return true;
          }

          @Override
          public boolean isCompanyAdmin() {
            return true;
          }

          @Override
          public boolean isCompanyAdmin(long companyId) {
            return true;
          }

          @Override
          public boolean isOmniadmin() {
            return true;
          }

          @Override
          public void resetValues() {
            oldChecker.resetValues();
          }

          @Override
          public void setCheckGuest(boolean checkGuest) {
            oldChecker.setCheckGuest(true);
          }

          @Override
          public void setValues(PortletRequest portletRequest) {
            oldChecker.setValues(portletRequest);
          }
        });
        Role role = RoleServiceUtil.getRole(PortalUtil.getDefaultCompanyId(), liferayRoleName);
        if (role == null) return new HashSet<UserData>();
        long[] roleUserIds = UserServiceUtil.getRoleUserIds(role.getRoleId());
View Full Code Here

*/
public class SetupBrazilianRegionsStartupAction extends SimpleAction {

  public void run(String[] companyIds) throws ActionException {

    PermissionChecker permissionChecker = PermissionThreadLocal.getPermissionChecker();

    try {

      PermissionThreadLocal.setPermissionChecker(new OminAdminPermissionChecker());

View Full Code Here

   *
   * @throws  SystemException
   * @throws  PortalException
   */
  protected void setupPermissionChecker(long companyId) throws PortalException, SystemException {
    PermissionChecker permissionChecker = PermissionThreadLocal.getPermissionChecker();

    if (permissionChecker == null) {
      Role administratorRole = RoleLocalServiceUtil.getRole(companyId, RoleConstants.ADMINISTRATOR);
      User administratorUser = UserLocalServiceUtil.getRoleUsers(administratorRole.getRoleId()).get(0);

View Full Code Here

    }
  }

  public boolean userHasPortletPermission(String actionId) {
    ThemeDisplay themeDisplay = getThemeDisplay();
    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();
    String portletId = themeDisplay.getPortletDisplay().getId();
    boolean hasPermission = false;

    try {
      hasPermission = PortletPermissionUtil.contains(permissionChecker, themeDisplay.getPlid(), portletId,
View Full Code Here

  private static void updateExpandos(long companyId, Registrant registrant) throws PortalException, SystemException {

    // Set the expando column (custom field) values. Note that since the registration portlet is being used
    // by a "Guest" user, we have to trick the Liferay permissionChecker into thinking that the current
    // user is the Administrator user (someone who has the permission to set expando column values).
    PermissionChecker permissionCheckerBackup = PermissionThreadLocal.getPermissionChecker();
    PermissionThreadLocal.setPermissionChecker(getAdministratorPermissionChecker(companyId));

    ExpandoBridge expandoBridge = registrant.getExpandoBridge();
    expandoBridge.setAttribute(UserExpando.COMPANY_NAME.getName(), registrant.getCompanyName());
    expandoBridge.setAttribute(UserExpando.FAVORITE_COLOR.getName(), registrant.getFavoriteColor());
View Full Code Here

        phone.setNumber(mobilePhone);
        phone.setPrimary(true);
        phone.setTypeId(getMobilePhoneTypeId());
        phones.add(phone);

        PermissionChecker permissionCheckerBackup = PermissionThreadLocal.getPermissionChecker();
        PermissionThreadLocal.setPermissionChecker(getAdministratorPermissionChecker(companyId));

        // Note: Exception will be thrown if we don't set the PrinicpalThreadLocal name.
        String principalNameBackup = PrincipalThreadLocal.getName();
        PrincipalThreadLocal.setName(creatorUserId);
View Full Code Here

    }
  }

  private static PermissionChecker getAdministratorPermissionChecker(long companyId) throws PortalException,
    SystemException {
    PermissionChecker administratorPermissionChecker = null;
    Role administratorRole = RoleLocalServiceUtil.getRole(companyId, RoleConstants.ADMINISTRATOR);
    List<User> administratorUsers = UserLocalServiceUtil.getRoleUsers(administratorRole.getRoleId());

    if ((administratorUsers != null) && (administratorUsers.size() > 0)) {
View Full Code Here

TOP

Related Classes of com.liferay.portal.security.permission.PermissionChecker

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.