Thursday, March 4, 2010

liferay 5.1.1-send ONLY login information vis HTTPS

1. Apply patch code to liferay-poratl-src/portal-impl/com/liferay/portal/util/PortalImpl.java [change method body : public String getPortalURL(String serverName, int serverPort, boolean secure)](Replace attached file here with PortalImpl-5.1.1Patch.java)

2. change your working directory to : liferay-poratl-src/portal-impl/

3. execute command : ant clean jar

4. delete portal-impl.jar in ext/modules and copy new portal-impl.jar (created in step 3) to ext/modules [ext = extension home directory]

5. add following property to ext/ext-impl/src/portal-ext.properties file.

company.security.auth.requires.https=true
web.server.http.port=8080
web.server.https.port=8443
session.enable.phishing.protection=false

6. stop your running tomcat instance and delete tomcat_home/temp and tomcat_home/work directories.

8. change your working directory to country portal home and execute command : ant clean deploy

9. start your tomcat.

10. delete your current server certificate installed in firefox. (edit > preferences > advanced > encryption > view certificates > servers ) and check.

Patch Code :

public String getPortalURL(
String serverName, int serverPort, boolean secure) {

StringBuilder sb = new StringBuilder();

if (secure || Http.HTTPS.equals(PropsValues.WEB_SERVER_PROTOCOL)) {
sb.append(Http.HTTPS_WITH_SLASH);
}
else {
sb.append(Http.HTTP_WITH_SLASH);
}

if (Validator.isNull(PropsValues.WEB_SERVER_HOST)) {
sb.append(serverName);
}
else {
sb.append(PropsValues.WEB_SERVER_HOST);
}
// enable login through HTTPS start. :add by rangalal: 02-03-2010

/*//comment by rangalal

if (!secure) {
if (PropsValues.WEB_SERVER_HTTP_PORT == -1) {
if ((serverPort != Http.HTTP_PORT) &&
(serverPort != Http.HTTPS_PORT)) {

sb.append(StringPool.COLON);
sb.append(serverPort);
}
}
else {
if ((PropsValues.WEB_SERVER_HTTP_PORT != serverPort) &&
(PropsValues.WEB_SERVER_HTTP_PORT != Http.HTTP_PORT)) {

sb.append(StringPool.COLON);
sb.append(PropsValues.WEB_SERVER_HTTP_PORT);
}
}
}

if (secure) {
if (PropsValues.WEB_SERVER_HTTPS_PORT == -1) {
if ((serverPort != Http.HTTP_PORT) &&
(serverPort != Http.HTTPS_PORT)) {

sb.append(StringPool.COLON);
sb.append(serverPort);
}
}
else {
if ((PropsValues.WEB_SERVER_HTTPS_PORT != serverPort) &&
(PropsValues.WEB_SERVER_HTTPS_PORT != Http.HTTPS_PORT)) {

sb.append(StringPool.COLON);
sb.append(PropsValues.WEB_SERVER_HTTPS_PORT);
}
}
}
*/
// add by rangalal

if ((serverPort != Http.HTTP_PORT) && (serverPort != Http.HTTPS_PORT)) {
sb.append(StringPool.COLON);
sb.append(secure?PropsValues.WEB_SERVER_HTTPS_PORT:PropsValues.WEB_SERVER_HTTP_PORT);
}

// enable login through HTTPS end.

//_log.info("URL : "+sb.toString());

return sb.toString();
}

see : http://issues.liferay.com/browse/LPS-3291

No comments: