Permissions in Liferay are very flexible but very complex to understand. In this recipe, we will show you only the basic use of permissions, but we hope this tutorial will be a start-up to implement more complex permissions. Let's assume that our goal is extending the previous portlet to display a secret message only for the users who have a specific permission. This permission should be configurable in the portlet permissions.
We assume that you have a ready-to-use Maven portlet generated from Maven archetypes. In Chapter 1, Installation and Basic Configuration, we described how to achieve this.
To achieve our goal, we have to define and add a specific permission to our portlet from the previous recipe. Next, we should register our list of permissions. At the end, we will use those permissions to display the secret area in our portlet. Perform these steps:
Create the
src/main/resources/resource-actions
folder.Create a file...