Few productive days in a dreamy vacation

Well, not hoping to write about my dreamy vacation, so will just tip off the few productive days. 🙂 Yeah so i was doing some work for Archmage last few days, gave life to a dead project, played with joomla, wordpress and osCommerce.

After much research and hacking me and few of my friends at Archmage thought of using Joomla and WordPress as core CMSes for our web development tasks, to make the work more rapid and easy. So yeah am hacking and looking for plugins and modules that i can use on joomla. Since last two weeks i was working on a real estate project and an e-commerce one. i was looking for resources on them. so yeah if you are looking for something similar try Estate Agent Improved for real estate and Virtuemart for E-Commerce. both are nicely made, Joomla plugins. With a little bit of customization they can be used like a charm.

OH and yeah today i gave a new look to my blog. 🙂 last night i updated to WordPress 2.5.1 ( yeah I know FINALLY!! 🙂 ) Edit: I updated it again today (16th June) to WP 2.6 🙂 .  Many thanks goes to Andrayogi for a pretty neat template. Added some plugins, had some problems with the DIGG IT icon. My firebug started giving a javascript error “unterminated string literal” and finally found a fix.. well its simple just edit the plugin and add

digg_bodytext = '<?php echo trim(preg_replace('/s/', ' ', get_the_excerpt())); ?>';

instead of

digg_bodytext = '<?php get_the_excerpt(); ?>';

That will fix the error. yeah so the site looks pretty neat. am sure many over the net uses this theme. even tried some different colors and combinations but thought this is the best combination so kept it in original.

Soo yeah will write some thing with more value soon.

cheers !

Advertisement

Joomla Hack! Automated Joomla user registration via JSF form

Well this post is some what continuation of my last post.
What is the use of single sign on if you have to register in two different sites ? yeah this is the solution for that… What i wanted to do is, when a user registers in my java web application i wanted to register the same user in the PHP app. Since these two applications have different user data-tables (well in my project i cannot merge these tables or use one database. if that is your case just ignore this post.)

When a new user registers in my JAVA web app am taking that user form data and insert those to the joomla database. 🙂 (Yup I know.. What is there to blog about this ?)
But what went wrong is joomla use some extra data from 2 other different tables other than jos_users (in joomla database).

those tables are jos_core_acl_aro and jos_core_acl_groups_aro_map so when you are inserting the data to the jos_users table.. also save the data in to the other two tables as well.
there are foreign key constrains over these tables. so

1- Insert the user to the jos_users
2– take the user id from a select query and insert that user to the jos_core_acl_aro
3- takes jos_core_acl_aro id from a select query and insert it in to the jos_core_acl_groups_aro_map

take a look at the three tables then you will realize what you should do.

The other task is password encryption. well Joomla 1.5 uses md5 encryption mechanism to hash the passwords. When a password is created, it is hashed with a 32 character salt that is appended to the end of the password string. The password is stored as {TOTAL HASH}:{ORIGINAL SALT}.

you can see this method at plugins/authentication/joomla.php lines 80-116.

So what you have to do is take your password and make a {TOTAL HASH}:{ORIGINAL SALT} from it and save the created string. I found this information also in a discussion forum. which had shown a java class to do this task.. so yeah it was quite useful..

so that’s all about behind the seen registration 🙂

Have fun !

Single Sign-On between Joomla (PHP) and a custom JSF / JSP login (JAVA)

Single sign-on (SSO) is a method of access control, that enables a user to authenticate once, and gain access to the resources of multiple software systems. Well in my case, the task i have given is to authenticate a user in a PHP and a JAVA (Web) system simultaneously.

My PHP web application is the well known Joomla CMS, and my JAVA web application is based on JSF and custom built. After some thinking and research I found several resources which are worth reading (JOSSO, OneSign ), but i couldn’t take any help from them, mostly those SSO frameworks are complex ( yeah 🙂 I couldn’t understand ) and aimed on a general pourpose and most of them are not for free.

So yeah I thought of doing some Hack to joomla and also make some changes in my Java web app’s authentication method. After talking with some of my geeky Friends (Sandaruwan and Anjana). I came up with two approaches. both are involved in handling the cookies manually up to certain extent.

The 1st approach is (Which i didn’t try and had to give up due to the reason that I am using JSF as the web application framework) to log-in to the Joomla site and after loged in to Joomla create a random named temp file in the server (possibly in /home/secrets with 777) with the user-name (if a valid log in) and set a cookie using set_cookie(“name”,$filename) and direct to a jsp page to do the java side authentication.

in this JSP, page read the secret file name from the cookie and read the file from the http server in-order to take the username of the loged-in user. By passing this to the authentication method of the java web app, the java side also can be authenticated.

yup it is pretty simple, but i had to give it up mainly because I use JSF. if I do the user authentication in the above way in the java side. I cannot add the user object to the FacesContext which will be used by my other java side components. so even though i log in. later on in other jsf pages my loged user cannot be found. (Shortly my java login process is not happening according to the JSF implementation procedures.) and secondly i had to give up this method because my Project manger didn’t like the idea of saving temp files in the server. 🙂

So the Second and the method which i have implemented is, automating the Joomla log-in process by making an http request to the http server from my JSF backing bean. and set the PHP cookie manually via Http Servlet response.

before i explain this method more broadly i have to mention about two nice tools which helped me to monitor the http requests and response.
Apache TCP Monitor
Live Http headers (FireFox ad-on)

Architecture

Implementation

There are two different scenarios.
1. User can visit teh home page of the joomla site 1st and the PHP Cookie is already set.
2. User visit the Java site PHP Cookie is not available.

Continue reading Single Sign-On between Joomla (PHP) and a custom JSF / JSP login (JAVA)