Skip to main content

Posts

Liferay session before and after login

Liferay session before and after login is different By default, liferay comes with the configuration that while doing the login invalidate the current session and generate the new session. And following configuration in the portal.properties is the responsible for it. # # Set this to true to invalidate the session when a user logs into the # portal. This helps prevents phishing. Set this to false if you need the # guest user and the authenticated user to have the same session. # session.enable.phishing.protection=true To keep the same session between the guest pages and the private pages after login. we will have turn this flag this off. set this flag to false in the portal-ext.properties file # Set this to true to invalidate the session when a user logs into the # portal. This helps prevents phishing. Set this to false if you need the # guest user and the authenticated user to have the same session. # session.enable.phishing.protection=false Th...

Liferay Permission System

Liferay Permission System 1. Liferay’s permission system uses a flexible mechanism that defines the actions that a given user can perform within the context of the portal or a specific portlet. 2. Portal and portlet developers break down the operations that can be performed in the portal or portlet into distinct actions. 3. The act of granting the ability to perform an action to a specific role is the act of granting a permission. 4. In Liferay, permissions are not granted to directly to users. Instead, permissions are granted to roles. Roles, in turn, can be assigned to specific users, sites, organizations, or user groups. Action: An operation that can be performed by a portal user. For example, actions that be performed on the Offer Portlet include ADD_TO_PAGE, CONFIGURATION, and VIEW. Actions that can be performed on a Offer entity include ADD_ENTRY, DELETE, PERMISSIONS, UPDATE, and VIEW. Resource: A generic representation of any portlet or entity in the portal on which ...

JSR 286 PORTLET Security

Using Portal Roles in a Portlet-: Roles in Liferay Portal are the primary means for granting or restricting access to content. When a role is assigned to a user, the user is granted the permissions that have been defined for the role. JSR 286 PORTLET Security The JSR 286 portlet specification defines a means to specify roles used by portlets in their docroot/WEB-INF/portlet.xml descriptors. The role names themselves, however, are not standardized. When these portlets run in Liferay, you’ll recognize familiar role names. Noticed that the portlet which we have been using in our examples Offer Portlet references the roles <security-role-ref> <role-name>administrator</role-name> </security-role-ref> <security-role-ref> <role-name>guest</role-name> </security-role-ref> <security-role-ref> <role-name>power-user</role-name> </security-role-ref> <security-role-ref> <role-name>user</...

Application Start Up Hook for Creating Layout, addingPortlet on Layout , Creating SitePages, Site, CustomField, Roles, Layout on Application StartUp

Step 1-: Create a Hook and it would be an Event Bundle HOOK (application.startup.events )               In portal.properties add this line               application.startup.events=com.test.event.MyPortalStartUpAction Step 2-: First we need to create a class were we will define pages that we will need in our site package com.test.pageutil public class MyPageUtil { public static Map<String, String> getPrivatePageList() {    Map<String, String> pages = new LinkedHashMap<String, String>(); pages.put("pageOne", "PageOne"); pages.put("pageTwo", "PageTwo"); pages.put("pageThree", "PageThree"); return pages; } Step 3-: This hook class will extend SimpleAction public class MyPortalStartUpAction extends SimpleAction{ @Override public void run(String[] ids) throws ActionException { try { for (int i = 0; i < ids.length; i++) { _log.inf...

Upload File and maintain folder structure for specific category wise files in Liferay 6.2

Step 1-: Create a portlet - FileUpload-Portlet Step 2-: Create init.jsp and add these line-: <%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%> <%@ taglib uri="http://liferay.com/tld/aui" prefix="aui"%> <%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui"%> <%@ page import="com.liferay.portal.kernel.util.ParamUtil"%> <%@ page import="com.liferay.portal.kernel.util.Validator"%> <%@ page import="javax.portlet.PortletPreferences"%> <%@ page import="com.liferay.util.PwdGenerator"%> Step 3-: On view.jsp add these lines <%@ include file="/html/fileuploadprog/init.jsp" %> <portlet:actionURL var="redirectUploadURL" name="redirectUpload"></portlet:actionURL> <aui:form action="<%= redirectUploadURL %>">   <aui:button name="UploadFile...

Liferay JSP Hook Development

In this article I am going customize Liferay sign in Portlet to demonstrate Liferay JSP Hook Step1-:  Consider that we have created Liferay Plugin Project of type hook and the name of the project is loginIn-hook. Inside of this project open liferay-hook.xml and add the below contents  <?xml version="1.0"?> <!DOCTYPE hook PUBLIC "-//Liferay//DTD Hook 6.2.0//EN" "http://www.liferay.com/dtd/liferay-hook_6_2_0.dtd"> <hook>     <portal-properties>portal.properties</portal-properties>     <custom-jsp-dir>/custom_jsps</custom-jsp-dir> </hook> Step2-:  We need to customize liferay original jsp file in the path  {TOMCAT_HOME}\docroot\html\portlet\login\login.jsp. Step3-:  Open the login.jsp file and add this line before aui button row just as shown below Your IP:<%=com.liferay.portal.util.PortalUtil.getHttpServletRequest(renderRequest).getRemoteAddr()%> <aui:button-row...

Basic Hook

Basic Hook and its type Liferay portal comes with a bundle where all the default built in portlets exist. Typically if any customization required in terms of JSP (UI) and portal properties. We need to go by Hook implementation. Hook is supported by hot deployment. Liferay documentation suggests that - Whenever possible, hooks should be used in place of Ext plugins, as they are hot-deployable and more forward compatible. Some common scenarios that require the use of a hook are     When you have to perform a custom action on portal startup     When you have to perform a custom action on user login     When you need to overwrite or extend portal JSPs     When you need to modify portal properties     When you need to replace a portal service with your own implementation. Types of HOOK 1. Event Handlers -:    Liferay has a few event handler connection points throughout its lifecycle, which are desgined to handle e...