ServiceNow connector deployment guide 1.0.0.0

Liferay Service Builder – Connect to External/Seperate Database

  • Create a  Liferay plugin project
  • Create a service.xml , ex like below.


<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE service-builder PUBLIC “-//Liferay//DTD Service Builder 6.2.0//EN” “http://www.liferay.com/dtd/liferay-service-builder_6_2_0.dtd”>
<service-builder package-path=”com.dinacs” auto-namespace-tables=”false”>
<author>vishnu</author>
<namespace>dinacs</namespace>
<entity name=”Feedback” local-service=”true” remote-service=”true”>

<column name=”feedbackId” type=”long” primary=”true” />

<column name=”feedbackTitle” type=”String” />
<column name=”feedbackText” type=”String” />
</entity>
</service-builder>

  • Build the service
  • Add your separate database details in portal-ext.properties ex like below.

# liferay default db
jdbc.default.driverClassName=com.mysql.jdbc.Driver
jdbc.default.url=jdbc:mysql://localhost/lportal?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
jdbc.default.username=root
jdbc.default.password=root

# seperate database
jdbc.dinacs.driverClassName=com.mysql.jdbc.Driver
jdbc.dinacs.url=jdbc:mysql://localhost/dinacsdb?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
jdbc.dinacs.username=root
jdbc.dinacs.password=root

  • Create ext-spring.xml file under docroot/WEB-INF/src/META-INF
  • Place the content like below in ext-spring.xml

<?xml version=”1.0″?>

<beans xmlns=”http://www.springframework.org/schema/beans”
xmlns:aop=”http://www.springframework.org/schema/aop” xmlns:context=”http://www.springframework.org/schema/context”
xmlns:tx=”http://www.springframework.org/schema/tx” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=”http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd”>

<bean id=”basePersistence” abstract=”true”>
<property name=”dataSource” ref=”dinacsDS” />
<property name=”sessionFactory” ref=”dinacsSessionFactory” />
</bean>

<bean id=”dinacsHibernateSessionFactory”
class=”com.liferay.portal.spring.hibernate.PortletHibernateConfiguration”
lazy-init=”true”>
<property name=”dataSource” ref=”dinacsDS” />
</bean>

<bean id=”dinacsSessionFactory” class=”com.liferay.portal.dao.orm.hibernate.SessionFactoryImpl”
lazy-init=”true”>
<property name=”sessionFactoryImplementor” ref=”dinacsHibernateSessionFactory” />
</bean>

<bean id=”dinacsDS”
class=”org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy”>
<property name=”targetDataSource”>
<bean class=”com.liferay.portal.dao.jdbc.util.DataSourceFactoryBean”>
<property name=”propertyPrefix” value=”jdbc.dinacs.” />
</bean>
</property>
</bean>
</beans>

  • Edit the service.xml and add data-source , session-factory and tx-manager attributes to the entity tag.
  • Ex like below.

<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE service-builder PUBLIC “-//Liferay//DTD Service Builder 6.2.0//EN” “http://www.liferay.com/dtd/liferay-service-builder_6_2_0.dtd”>
<service-builder package-path=”com.dinacs” auto-namespace-tables=”false”>
<author>vishnu</author>
<namespace>dinacs</namespace>
<entity name=”Feedback” local-service=”true” remote-service=”true” data-source=”dinacsDS” session-factory=”dinacsSessionFactory” tx-manager=”dinacsTransactionManager” >

<column name=”feedbackId” type=”long” primary=”true” />

<column name=”feedbackTitle” type=”String” />
<column name=”feedbackText” type=”String” />
</entity>
</service-builder>

  • Build the service again.
  • Deploy the portlet.


Note : tables will be created in the liferay default database only , need to manually create the tables in separate database.

ServiceNow connector deployment guide 1.0.0.0

Integrating Solr Search Engine with Liferay portal

Step 1: Setting up Solr server

1.1 download solr 4.3.1 from http://archive.apache.org/dist/lucene/solr/4.3.1/
1.2 Unzip it and navigate to solr-4.3.1\example and double click on start.jar
1.3 browse localhost:8983 and verify solr is up and running

Step 2: Install Solr 4 search Engine plugin on Liferay  Portal

2.1 Copy solr plugin war file to deploy folder (liferay.home/deploy)

Step 3 : Integrating Liferay Portal With Solr

Change the solr url as follows in solr-spring.xml which is located in liferay.home/tomcat/webapps/solr-web/WEB-INF/classes/META-INF/
Set the value of constructor-arg from

<bean id=”solrServer”
class=”com.liferay.portal.search.solr.server.BasicAuthSolrServer”>
<constructor-arg type=”java.lang.String” value=”” />
</bean>
to this :
<bean id=”solrServer”
class=”com.liferay.portal.search.solr.server.BasicAuthSolrServer”>
<constructor-arg type=”java.lang.String” value=” http://${solr.host.domain}:${solr.port.number}/solr” /> </bean>
</bean>

Step 4: Restart Liferay and solr servers.

ServiceNow connector deployment guide 1.0.0.0

Integrating OKTA SSO With Liferay Portal Using SAML

1 : Installing SAML Plugin on Liferay Portal.

1.1 Download and Copy saml plugin war file to deploy folder (liferay.home/deploy)

If you do not have saml plugin war file.

1.1 Login to the Liferay portal as admin and go to the control panel
1.2 Click on apps and then purchased tab.
1.3 In purchased tab click on EE.
1.4 Search for SAML 2.0 and click on install.

2 : Creating Chicklet in OKTA For Liferay , We can create developer okta account for this trial.

2.1 Get the service provider url (liferay sp) . ex http://your domain or ip /c/portal/saml/acs
2.2  Create Okta Chicklet with following details
service provider url ex: http://your domain or ip /c/portal/saml/acs
Audience restriction ex : Liferay
Okta Metadata file : save it in xml and put it in the liferay.home/data/ directory

3: Creating keystore

Create keystore in the liferay.home/data/ directory using below command
keytool -genkey -keyalg RSA -alias Dinacs -keystore keystore.jks -storepass dinacs-validity 360           -keysize 2048

Enter the details and keep alias password as same as the keystore password.
It creates keystore.jks file in the liferay.home/data directory.

4:  Modify portal-ext.properties file

Navigate to liferay.home and open portal-ext.properties file .
Add below entries to the file and save it.

##
## SAML
##
# Enable SAML Plugin
saml.enabled=true
# Set the role to sp on the Service Provider side
saml.role=sp
# Set the SAML entity id, it matches the alias we used to setup the keystore
saml.entity.id=Dinacs
# The metadata location for Identity Provider
saml.metadata.paths=${liferay.home}/data/OktaMetadata.xml
#
# Keystore
#
# keystore type
saml.keystore.type=jks
# location of the keystore
saml.keystore.path=${liferay.home}/data/keystore.jks
# pwd for accessing the keystore
saml.keystore.password=dinacs
# pwd for accessing the certificate of the entity in the keystore
saml.keystore.credential.password[dinacs]=dinacs
#
# Service Provider
# the chicklet url from okta
saml.sp.default.idp.entity.id=http://www.okta.com/ – your idp url
saml.sp.sign.authn.request=true
saml.sp.assertion.signature.required=false
saml.sp.clock.skew=3000
saml.sp.session.keepalive.url=http://your ip or domain :8080/c/portal/saml/idp/keepalive
# Service Provider user attribute mappings
saml.sp.user.attribute.mappings=UserName=emailAddress\nFirstName=firstName\nLastName=lastName
#Set this to true to enable reminder queries that are used to help reset a user’s password.
users.reminder.queries.enabled=false
# auto generate screen names
users.screen.name.always.autogenerate=true

Step 5: Restart Server and Test SSO

Hit your liferay url and if you are not logged in then it will redirect you to the okta login page , after entering login credentials , Okta will redirect back to the liferay . User will be created in the liferay portal and will see it logged in.