Liferay provides two ways to check permissions. The first mechanism implements the Java Portlet Specification 2.0 (JSR 286) and provides an XML definition to map a Liferay role and portlet role. The second mechanism uses the Liferay permission checker to verify users and the actions that they perform. In this recipe, we will show you how the Java Portlet Specification and Liferay work together.
Generate or create an empty portlet using the Maven archetype generator. We described it in Chapter 1, Installation and Basic Configuration. It is not important which PortletBridge
will be used. We will decide to use a simple one called MVCPortlet
.
Let's assume that our goal is to write a greeting portlet that can recognize whether the current user is logged in as a user or a guest. In every situation, our portlet should display the greeting, Welcome Guest! or Welcome User.