Integrated cas with liferay

Integrated cas with liferay

借花献佛:
We found some way that somehow, solves the liferay integration with cas. The solution is this when you login in to liferay just in the try to call the login page of cas manually

1) Change the view.jsp page. make the form method to get
2) change touch_protected.jsp. Add
<% String query=request.getQueryString();%>

3) change touch_protected.jsp again. Add
<body onLoad=”self.location=’<%= CTX_PATH%>/portal/protected?<%=query%>$mode=portal’;”>
We will use this mode later on CAS login page

3) Change top_bar.jsp and add

<c:if test="<%= signedIn %>">
<a href="<%= Http.getProtocol(request) %>://<%= request.getServerName() %>:<%=request.getServerPort()%>/html/common/logout2.jsp" class="bg" ><bean:message key="sign-out" /></a>

</c:if>

4) Change web.xml and add:
<filter>
<filter-name>CAS Filter</filter-name>
<filter-class>edu.yale.its.tp.cas.client.filter.CASFilter</filter-class>
<init-param>
<param-name>edu.yale.its.tp.cas.client.filter.loginUrl</param-name>
<param-value>https://casserver:8443/cas/login</param-value>
</init-param>
<init-param>
<param-name>edu.yale.its.tp.cas.client.filter.validateUrl</param-name>
<param-value>https://casserver:8443/cas/proxyValidate</param-value>
</init-param>
<init-param>
<param-name>edu.yale.its.tp.cas.client.filter.logout</param-name>
<param-value>https://casserver:8443/cas/logout</param-value>
</init-param>
<init-param>
<param-name>edu.yale.its.tp.cas.client.filter.serverName</param-name>
<param-value>casserver</param-value>
</init-param>
</filter>

<filter-mapping>
<filter-name>CAS Filter</filter-name>
<url-pattern>/c/portal/protected/*</url-pattern>
</filter-mapping>

6) We should define a logout2.jsp which calls the cas logout url not liferay logout.

NOW WE SHOULD GO TO CAS-SERVER. We should use the mode paramater here to do some tricks. Remmeber there are other applications that want to use the normal login page, only we(liferay users) need to make a hidden view of this page.

5) change the the login.jsp and header.jsp. You must configure the CAS login page to view itself in while it login page is loaded in liferay. just add this on the header.jsp
String mode="standard";
String username="";
String password="";
String url = request.getParameter("service");
if (!url.equals(null)){
int pos=url.lastIndexOf('?');
int pos1=url.indexOf("mode=portal",pos);
if (pos1!=-1)
{
mode="portal";
}

now use the mode parameter to create a login form which all hidden filed

<%
if (mode.equals("portal"))
{
%>
<script language="JavaScript">
function submitForm() {
document.login_form.username.value ="<%=username%>";
document.login_form.password.value ="<%=password%>";
document.login_form.submit();
}
</script>

<body onLoad="submitForm()" >
<form method="post" name="login_form">
<input type="hidden" name="username" maxlength="20" size="12" dir="ltr">
<input type="hidden" name="password" maxlength="20" size="14" dir="ltr">
<input type="hidden" name="lt" value="<%= request.getAttribute("edu.yale.its.tp.cas.lt") %>" />
</form>

<%
}
else{
//rest of the page

你可能感兴趣的:(Integrated cas with liferay)