Skip to main content

Creating OSGi Modules and Sharing Packages

  Overview This guide walks through creating two OSGi modules in Liferay 7.4 and sharing a Java package between them using the standard API + Implementation pattern. This is the most common and correct approach for exposing reusable services in a Liferay-based architecture. In OSGi, a bundle (module) does not expose its internal packages by default — everything is private unless explicitly exported. To share code between modules, the standard practice is to split functionality into: · An API module — contains interfaces/DTOs and exports the package · A Service (Implementation) module — implements the interface, imports the package, and registers the implementation as an OSGi component/service The consuming module then simply imports the API package and looks up the service using @Reference injection. Step 1: Create the API Module Using Liferay Workspace + Blade CLI, generate a new API module: blade create -t api -p com.sgc.greeting greeting-api This generates a Gradle module unde...

Configure Keycloak 15 as the Identity Provider (IdP) with Liferay 7.4

 

1. Configure Keycloak 15 as the Identity Provider (IdP)  Liferay 7.4

Keycloak will manage your users and issue SAML assertions.

·        Create a SAML Client:

1.     Log in to the Keycloak Admin Console and go to Clients > Create.

2.     Client ID: Use a unique identifier (e.g., liferay-saml-sp).

3.     Client Protocol: Select saml.

4.     Client SAML Endpoint: Use Liferay's ACS URL: https://[your-domain]/c/portal/saml/acs.

·        Adjust Client Settings:

1.     Valid Redirect URIs: Set to https://[your-domain]/*.

2.     Name ID Format: Set to email or username based on your Liferay user mapping.

3.     Force Name ID Format: Set to On.

4.     Client Signature Required: Set to Off for initial testing, though recommended On for production once certificates are exchanged.

·        Export Metadata: Go to Realm Settings > General and click on SAML 2.0 Identity Provider Metadata. Save this XML file; you will need it for Liferay.

2. Configure Liferay 7.4 EE as the Service Provider (SP) 

In Liferay 7.4, SAML is built-in and configured via the SAML Admin panel. [1]

·        General Setup:

1.     Navigate to Global MenuControl PanelSecuritySAML Admin.

2.     Set SAML Role to Service Provider.

3.     Entity ID: Enter the same Client ID used in Keycloak (e.g., liferay-saml-sp).

4.     Click Create Certificate and provide the required details (Common Name, Organization, etc.).

·        Identity Provider Connection:

1.     Go to the Identity Provider Connections tab and click Add Identity Provider.

2.     Name: Enter Keycloak.

3.     Entity ID: This is found in the Keycloak metadata XML (usually the realm URL).

4.     Metadata: Select Upload Metadata XML and upload the file you saved from Keycloak.

5.     Name Identifier Format: Ensure this matches Keycloak (e.g., Email Address).

6.     Check Enabled and Save

3. Map Attributes (Optional but Recommended)

To ensure Liferay automatically creates/updates users with the correct data, map Keycloak attributes to Liferay fields in the Identity Provider Connection settings: [1]

·        emailAddressemail

Comments

Popular posts from this blog

service builder with crud operation in liferay

   Crud and Search opration in Liferay:      ->  Liferay use service builder techniq for Crud opration.    ->  Service builder purform by  Service.xml file.    ->  Service.xml file create table in database and also create class and diffrent method.   1)      Create service.xml file.             ->Create service.xml file in WEB-INF and write below code.             ->CODE:        < service-builder package-path = "com.test" >         < namespace > qr </ namespace >           < entity name = "Searchclass" local-service = "true"                     ...

How to create new site programmaticly in liferay with validation

Create site in liferay <%@page import="javax.portlet.PortletPreferences"%> <%@page import="com.liferay.portal.kernel.util.ParamUtil"%> <%@page import="com.liferay.portal.kernel.util.HtmlUtil"%> <%@page import="com.liferay.portal.kernel.util.StringPool"%> <%@page import="com.liferay.portal.kernel.util.UnicodeProperties"%> <%@page import="com.liferay.portal.service.LayoutSetPrototypeServiceUtil"%> <%@page import="com.liferay.portal.model.LayoutSetPrototype"%> <%@page import="com.liferay.portal.service.GroupLocalServiceUtil"%> <%@page import="java.util.List"%> <%@page import="com.liferay.portal.kernel.bean.BeanParamUtil"%> <%@page import="com.liferay.portal.theme.ThemeDisplay"%> <%@page import="com.liferay.portal.model.Group"%> <%@page import="com.liferay.portal.kernel.util.WebK...

The Ultimate Guide to Liferay DXP Performance Tuning: Speed Up Your Portal

The Ultimate Guide to Liferay DXP Performance Tuning: Speed Up Your Portal In the enterprise web space, milliseconds equal millions. Whether you are running a B2B commerce storefront, a customer support portal, or an employee intranet on Liferay DXP, slow load times will devastate your user experience and destroy your SEO rankings. Out of the box, Liferay is configured to run on almost any machine. This means its default settings are highly conservative to ensure compatibility, not maximum performance. If you are launching a production environment without tuning your server, you are leaving massive amounts of speed and scalability on the table. In this comprehensive, deep-dive guide, we are going to explore the critical layers of Liferay performance tuning. We will cover backend Java Virtual Machine (JVM) configuration, Database Connection Pooling, Elasticsearch optimization, and Frontend caching strategies. By the end of this guide, you will have a blazing-fast, enterprise-grade...