[Liferay] liferay implements single-point logon-cas

Source: Internet
Author: User
Tags ldap openldap

Last article: single-point logon using liferay-OpenLDAP


This article does not introduce concepts, but focuses on implementation.


Liferay : 6.1.1 CE GA2  OpenLdap for Windows :openldap-2.4.38-x86  Apache Directory Studio : Apache Directory Studio 2.0.0-M3  CAS : cas-server-3.5.2  Windows : 7 x64  

Chapter 2 CAS Configuration
Download installation: https://www.apereo.org/cas/download
The version used in this article is cas-server-3.5.2-release
Decompress and copy the cas-server-3.5.2-release in the cas-server-3.5.2 \ cas-server-webapp-3.5.2.war \ modules directory and paste it to $ {liferay. home} \ webapps, and rename it to any name you want, such as CAS-server, and then restart liferay server.
Note that all the configuration tutorials on the Internet refer to SSL configuration. CAS server is used only after SSL is configured. In fact, there is no need between the two, this article uses CAS server without configuring SSL.
After liferay is restarted, enter the URL http: // localhost: 8080/CAS-server/login. Enter a string of the same user name and password. Click "Log On". If the logon is successful, the initial configuration of CAS server is successful.
But note! It's just a preliminary step. Many tutorials are very irresponsible and end at this point, leaving a semi-finished product for unknown readers.

CAS sever and liferay Integration

Modify authenticationhandlers to modify the CAS authentication conditions, as long as the user name and password are equivalent strings, the login successfully found directory cas-server-3.5.2-release \ cas-server-3.5.2 \ cas-server-webapp \ SRC \ main \ webapp \ WEB-INF, open deployerconfigcontext. XML file, locate the following content and comment or delete it

<property name="authenticationHandlers">…</property>

Add original

<property name="authenticationHandlers"><list><bean class="org.jasig.cas.adaptors.ldap.BindLdapAuthenticationHandler"p:filter="uid=%u"p:searchBase="dc=example,dc=com"          p:contextSource-ref="contextSource" /></list></property>


P: Filter = "uid = % u"-note that uid is used for filtering, and SN can also be used. This depends on the rdn when the user is created, as shown in figure



P: searchbase = "DC = example, Dc = com"-corresponds to the root entry of the dit. For more information about the DIT, see the previous article.


Add contextsource before </beans> at the end of the file

<bean id="contextSource" class="org.springframework.ldap.core.support.LdapContextSource">      <property name="pooled" value="true"/>      <property name="urls">        <list>          <value>ldap://localhost:389</value>        </list>      </property>      <!-- <property name="userDn" value="cn=jimbob, dc=example, dc=com"/> -->      <property name="userDn" value="cn=jimbob,dc=example,dc=com"/>      <property name="password" value="dirtysecret"/>      <property name="baseEnvironmentProperties">        <map>          <!-- Three seconds is an eternity to users. -->          <entry key="com.sun.jndi.ldap.connect.timeout" value="3000" />          <entry key="com.sun.jndi.ldap.read.timeout" value="3000" />          <entry key="java.naming.security.authentication" value="simple" />        </map>      </property></bean>

Modify the Pom. xml of Maven and compile it in the cas-server-3.5.2-release \ cas-server-3.5.2 \ cas-server-webapp directory find and open Pom. XML, add the following before the first dependency, and compile

<dependency>      <groupId>${project.groupId}</groupId>      <artifactId>cas-server-support-ldap</artifactId>      <version>${project.version}</version></dependency>

Use the MVN install command to compile the war file, find the compiled war file in the following directory, copy and paste it to $ {liferay. Home} \ webapps, and restart the liferay server.



If you do not have a Maven environment, or the compilation fails, you can find the cas-server-3.5.2-release directly in the cas-server-3.5.2 \ cas-server-support-ldap-3.5.2.jar \ modules and copy and paste it to $ {liferay. home} \ webapps \ cas-Server \ WEB-INF \ Lib, the same effect, I do not understand why I have to compile it again.
If you use CAS server directly after completing the previous step, it will include, because there is still one less package, spring-ldap-core-1.3.2.RELEASE.jar, download one on the Internet, and agree to paste it to $ {liferay. home} \ webapps \ cas-Server \ WEB-INF \ Lib.

Configure CAS server in liferay



So far, the integration of CAS server and liferay is complete.

[Liferay] liferay implements single-point logon-cas

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.