Total Pageviews

Sunday, May 12, 2013

Creating Self Signed Certificate using Keytool

Prerequsites: For using the keytool utility, we have to ensure that our environment is configured to use the bin directory of JDK, otherwise the full path to the utility must be present on the command line. Which can be ensured by typing java or javac on command prompt.

There are basically three steps:
1. Generate the certificate in the keystore file


Here tomcat is an unique alias of certificate. change is the default password, you can change it. You now have a .keystore in the current user's home directory

2. Now export the certificate you just generated:

Now the certificate has been exported to server.crt file.

3. Now, add the exported certificate (server.crt) to your JRE's cacerts file

 Yes, now its done.

Sunday, April 28, 2013

Creating Roles in Liferay with Portal-ext.properties

Need of user role is a very common in live scenario. One way is quite easy, just sign in as administrator, go to control panel and add one. But there is a drawback of this approach. If you are working on staging environment, you have to create this role in production environment when the code is deployed there. It means this is database specific and it will not move to production when the build is deployed on the server.

Liferay has provided us a better solution for the same. We can create role by using certain properties in portal-ext.properties file. We have to add the following properties in our portal-ext properties file.
Just restart the box after adding them, and go to the Roles section in Control Panel, you will be able to see both the roles added there.

Now if we want to access these roles in our code programmatically because this is basic need of creating role. So it can be done as following:
For getting users we can use the following methods:
Some other properties of portal-ext.properties that you can work on are:
Hope this will be helpful.

Wednesday, April 17, 2013

Liferay: Uploading User Portrait via Custom Portlet

The following code can be integreate with any MVC portlet extending MVCPortlet in controller class.

view.jsp
Controller class