1

How can i define custom permisssion to custom portlet for specific user in liferay I used enviroment liferay 6.1.2 ga3 with jboss In my custom portlet deploy/undeploy button but how can i give specific permission to that only admin person can access that function any other can not use that

check this link https://i.stack.imgur.com/FFQy9.png

Can you please elaborate.

I also check this link for reference

and in jsp page for rendering all the datagrid data render through jeasyui and rest API

Removing Custom Permissions/Actions from a Portlet http://liferayzone.wordpress.com/2013/09/01/liferay-permission-on-custom-portlet/

Community
  • 1
  • 1

2 Answers2

2

Liferay allows assigning permissions to roles only, you just cannot do it for single users. You have either define a new role or implement this functionality on your own (not using Liferay's permission system).

Just in case if you would come up with this idea, avoid using creating roles for every user - it is a performance killer. People sometimes try do do this in order to get around the limitations of Liferay's permission system - it is a very bad idea!

  • Actually i want to do same as i describe just for test purpose rather the issue of this performance.Can you elaborate the way and how can i implemet – user3595542 Jul 21 '14 at 06:38
  • We have also option about that in one jsp portlet rendering page we have to check its admin or not if admin then we show the button else not.So is there any util file in bundle to check that for admin login or not.?? – user3595542 Jul 21 '14 at 07:37
  • You can obtain `PermissionChecker` object from ThemeDisplay and then check `isOmniadmin()` method which will tell you if user is an administrator. But it is not a good solution, as this is not configurable (you hardcode *administrator* role in your code). In the following article, it is described how this should be done properly: https://www.liferay.com/web/guest/community/wiki/-/wiki/Main/Using+Liferay's+Permission+System+from+a+portlet – Krzysztof Gołębiowski Jul 21 '14 at 18:20
  • Ext Js is not natively supported. Why don't you use Vaadin? – Krzysztof Gołębiowski Jul 22 '14 at 05:33
  • its good and work for just jsp but in our jsp datagrid content render through jEasyUi so all the code in java script for rendering. – user3595542 Jul 22 '14 at 08:00
1

This tutorial can help you:

  1. You need to create a resource-action-mapping XML file, and add a new action-key (plain string)
  2. Put it into /src/main/resources/resource-action (name it as default.xml)
  3. Create a portlet.properties file under /src/main/resources
  4. Add the following line: resource.actions.configs=resource-actions/default.xml

Deploy your portlet, and check your new permission under Roles -> Select role -> Define permissions tab

You can check the user permissions with the permissionChecker on your JSP

  1. You need this import: <%@ taglib prefix="theme" uri="http://liferay.com/tld/theme" %>
  2. Define objects: <theme:defineObjects />
  3. Now you can use the permissionchecker object:

    permissionChecker.hasPermission(scopeGroupId, portletName, scopeGroupId,    permissionName)
    
krstf
  • 627
  • 7
  • 25