Thursday, March 17, 2011

Liferay Twitter portlet

https://code.google.com/p/liferay-twitter-portlet/

Friday, February 18, 2011

Liferay 6: Deployment/Undeployment with Ext plugins environment

I have always liked the concept of plug-in in Liferay but using the ext environment as plug-in in Liferay 6 seems to be a little bit painful and time taking. It will need you to restart tomcat a couple of times if you are working in service files. The original  post which i used here for reference documents everything.  I am copying it here so that i can recall it in future. However i am listing below the major steps followed in the original post.
  1. Stop the tomcat.
  2. Remove ext plug-in related jars in @temp folder of your tomcat instance @temp\liferay\com\liferay\portal\deploy\dependencies
  3. Remove ext plug-in related jars from ROOT/WEB-INF/lib/
  4. Remove xml for ext plug-in from ROOT/WEB-INF/
  5. Remove service jar from @tomcat/lib/ext related to plug-in
  6. Start tomcat  and deploy updated plug-in war while tomcat is running, You will see a message like  "You must reboot the server and redeploy all other plugin". 
  7. Now stop the tomcat and restart it again for the global jars to take effect. And you are ready to go
In the original post you will see the bat script which can be quite handy.

Saturday, February 12, 2011

Too Many open files in Alfresco

This is related to facing the situation where alfresco deployed in UNIX environment gives the error of "Too Many Opened Files". This is more often related to File handles and Lucene. UNIX systems is configured by default to allow users a maximum of only 1024 open file handles, which is often not sufficient for the file structure used by the indexes. Thus while setting up Alfresco on UNIX do the following check and configuration to get over this issue.

 Verify that the global settings for maximum number of file handles is large enough.
As a user used to run Alfresco run :
ulimit -n

You can check the number of open files allowed per user with the command

cat /proc/sys/fs/file-max

This gives the number of file handles that can be opened by user at a time.
To increase this number, go to/etc/security/limits.conf file in edit mode and the below lines
username soft nofile 4096
username hard nofile 65536

where username is the name of user to run Alfresco.

And finally restart your Alfresco for the changes to become active.

Check the original issue here.

Other references
http://www.xenoclast.org/doc/benchmark/HTTP-benchmarking-HOWTO/node7.html
http://ironman.darthgibus.net/?tag=too-many-open-files

Friday, November 26, 2010

Create Java SSL certificate


1 Create the SSL key for your machine using Java's keytool program. When asked to specify your first and last name, use the name of the machine running the CAS Tomcat server. For example, on my machine, I used localhost:
                 keytool -genkey -alias tomcat -keypass mycertificate -keyalg RSA
2. You now have a keystore in the current user's home directory. Now you need to add the certificate to your JRE's cacerts file. Export the certificate you just generated:
                 keytool -export -alias tomcat -keypass mycertificate -file server.crt
3. Now, add the exported certificate (server.crt) to your JRE's cacerts file again using Java's keytool program, as follows:
                keytool -import -file server.crt -keypass mycertificate -keystore ..\jre\lib\security\cacerts
4. The last step in setting up SSL is to tell Tomcat about the keystore. Edit the server.xml file again. Modify the SSL connector definition with the lines           highlighted below. Note that the keystoreFile is the full path to the current user's home directory where the keystore resides:
                                <Connector port="8443" maxHttpHeaderSize="8192"
                                maxThreads="150" minSpareThreads="25"
                                maxSpareThreads="75"
                                enableLookups="false" disableUploadTimeout="true"
                                acceptCount="100" scheme="https" secure="true"
                                clientAuth="false" sslProtocol="TLS"
                                keystoreFile="/root/.keystore"
                                keystorePass="mycertificate"
                                truststoreFile="/usr/lib/jvm/java-1.5.0-sun/jre/lib/
                                security/cacerts" />

Thursday, November 25, 2010

Alfresco and CAS Integration


1.            You can set up CAS on separate tomcat or same tomcat running alfresco. you need to make couple of changes to tomcat's conf/server.xml file for separate tomcat regarding SSL/AJP/server port:
                                ...
                                <Server port="8006" shutdown="SHUTDOWN">
                                ...
                                <Connector port="8081" maxHttpHeaderSize="8192"
                                maxThreads="150" minSpareThreads="25"
                                maxSpareThreads="75"
                                enableLookups="false" redirectPort="8444"
                                acceptCount="100"
                                connectionTimeout="20000" disableUploadTimeout="tru
                                e" />
                                ...
                                <!-- Define a SSL HTTP/1.1 Connector on port 8443 -->
                                <Connector port="8443" maxHttpHeaderSize="8192"
                                maxThreads="150" minSpareThreads="25"
                                maxSpareThreads="75"
                                enableLookups="false" disableUploadTimeout="true"
                                acceptCount="100" scheme="https" secure="true"
                                clientAuth="false" sslProtocol="TLS"
                                ...
                                <!-- Define an AJP 1.3 Connector on port 8010 -->
                                <Connector port="8010"
                                enableLookups="false" redirectPort="8443"
                                protocol="AJP/1.3" />
                2. Start up new Tomcat instance. and it should run smoothly along with alfresco tomcat.
                3. Download the CAS server from JA-SIG at http://www.ja-sig.org/products/cas/.
                4. CAS-protected URL redirects, the browser to the CAS authentication page. For security reasons, the CAS URLs are protected with SSL. Creating the certificate and adding it to the JRE's keystore requires below steps.
                5. Use Java's keytool program to create the SSL key for your machine. When asked to specify your first and last name, use the name of the machine running the CAS Tomcat server. For example, I used localhost:
                 keytool -genkey -alias tomcat -keypass changeit -keyalg RSA
                6. We have a keystore in the user's home directory. Now need to add the certificate to your JRE's cacerts file. Export the certificate generated:
                 keytool -export -alias tomcat -keypass changeit -file server.crt
                7. Adding the exported certificate (server.crt) to JRE's cacerts file, as follows:
                keytool -import -file server.crt -keypass changeit -keystore ..\jre\lib\security\cacerts
                8. The last step in setting up SSL is to tell Tomcat about the keystore. Edit the server.xml file again. :
                                <Connector port="8443" maxHttpHeaderSize="8192"
                                maxThreads="150" minSpareThreads="25"
                                maxSpareThreads="75"
                                enableLookups="false" disableUploadTimeout="true"
                                acceptCount="100" scheme="https" secure="true"
                                clientAuth="false" sslProtocol="TLS"
                                keystoreFile="/root/.keystore"
                                keystorePass="changeit"
                                truststoreFile="/usr/lib/jvm/java-1.5.0-sun/jre/lib/
                                security/cacerts" />
                9. Copy the CAS webapp WAR to the webapps directory of Tomcat instance. The          CAS webapp WAR is in the directory where you expanded CAS under "modules". The file is called cas-server-webapp-3.3.3.war.
                10. Start CAS Tomcat. CAS screen can be seen at https://[machine name]:8443/cas. Add the following entry to the Alfresco web.xml
                                <!-- cas client filter -->
                                <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://localhost:8443/cas/login</param-value>
                                </init-param>
                                <init-param>
                                <param-name>
                                edu.yale.its.tp.cas.client.filter.validateUrl</param-name>
                                <param-value>https://localhost:8443/cas/serviceValidate</param-value>
                                </init-param>
                                <init-param>
                                <param-name>edu.yale.its.tp.cas.client.filter.serverName</param-name>
                                <param-value>localhost:8080</param-value>
                                </init-param>
                                </filter>
                11.          Next, add the filter mapping.This will cause Tomcat to redirect the browser to the CAS login if anyone without a valid ticket attempts to run. For Alfresco, the                 URL pattern should be:
                                <filter-mapping>
                                <filter-name>CAS Filter</filter-name>
                                <url-pattern>/faces/*</url-pattern>
                                </filter-mapping>
                12.          Save the web.xml file. At this point, you could restart Alfresco Tomcat and open the web client and you'd be redirected to the CAS login page. But Alfresco                 doesn't yet know how to extract the credentials from CAS to use to start an Alfresco session. To do that, you have to write an AuthenticationFilter. Look at Alfresco Wiki at http://wiki.alfresco.com/wiki/Central_Authentication_Service_Configuration for same.
                13.          You need to tell Alfresco to use the new Authentication Filter in place of the out of the box Authentication Filter. Do that by editing web.xml and modifying               the Authentication Filter filter as follows:
                                <filter>
                                <filter-name>Authentication Filter</filter-name>
                                <!--
                                <filter-class>
                                org.alfresco.web.app.servlet.AuthenticationFilter
                                </filter-class>
                                -->
                                <filter-class>
                                com.someco.servlets.AuthenticationFilter</filter-class>
                                <init-param>
                                <param-name>cas.user.label</param-name>
                                <param-value>
                                edu.yale.its.tp.cas.client.filter.user</param-value>
                                </init-param>
                                </filter>
                15.          Start Alfresco. You should now be able to log in to Alfresco . Remember that at this point, CAS is still using its default adapter, which grants successful logins when the username and password match.