December 27, 2010

Wicket with JEE6

From JEE6 we no longer need a deployment descriptor (web.xml). So how we will proceed to declare the necessary configurations of wicket?

Solution: Create an empty class that inherits from WicketFilter and annotated with the necessary config.

import javax.servlet.annotation.WebFilter;
import javax.servlet.annotation.WebInitParam;
import org.apache.wicket.protocol.http.WicketFilter;

@WebFilter(value = "/*",
           initParams = { @WebInitParam(name = "applicationClassName", value = ""),
                          @WebInitParam(name="wicket.configuration", value="deployment")}) public class MyFilter extends WicketFilter{ }

Note: You can add as many parameters as you want.

December 24, 2010

eHour Timesheet Management

This is a simple preface to eHour and not a tutorial for how to develop on eHour or how to use eHour.
eHour is an open source web based time tracking tool for companies and organizations who need accurate information on how much time is spend on projects by their people.
eHour makes the amount of time your people spend on projects visible and available as simple and user friendly as possible.

eHour is developed primarily by wicket, spring and hibernate. Can be used as DBMS MySQL or Postgres.
The current development version of eHour can be checked out from the SVN repo with:

svn co
To build from the source we need
- Maven: 
- JDK 1.5 or higher: 

To configure your eHour (mail, currency, hours...), you need some modification in the table configuration. For adding the users you can use the table users.

December 10, 2010

BRIX CMS : Apache Wicket based CMS framework

Based on Wicket ( and JCR, it is the best Wicket-based CMS framework available today. BRIX is simple yet powerful and extensible, allowing designers the highest degree of freedom in developing a rich user experience.
Using Apache Wicket as the technology to serve the content makes it very easy to embed custom, stateful Wicket components into any CMS page, allowing rich integration with any existing Wicket web application. Using Apache Jackrabbit ( allows Brix to easily integrate full text search, versioning, and WebDav access.
Brix is business-friendly, open sourced under the Apache Software License version 2.0.

To get and run the Brix demo you can follow these steps:
- svn checkout brix  (this will create a directory named brix)
go to directory brix and do:
- mvn install 

This will create a folder named brix-demo, go to brix-demo and do: 
- mvn jetty:run (this will start the demo, just go to your favorite browser and open the url : http://localhost:8080/brixdemo/  you will get the following page (just try it)

 You can access the admin page (back-office) by opening the url : 
http://localhost:8080/brixdemo/admin you will get the following page : 
That's all for the moment.


December 9, 2010

Securing a JEE application

Goal:Secure a JEE application in Glassfish using JAAS (Java Authentication and Authorization Service).

Used tools:
Server: Glassfish v3.1
IDE: NetBeans 6.9.1
Database: MySQL 5.1

Create a web application (JSF2) with netbeans. We will secure this application with JDBC Realm.
Create a database mysql "security" and a table user
`user_name` varchar(45) NOT NULL,
`password` varchar(45) NOT NULL,
`group_name` varchar(45) DEFAULT NULL,
PRIMARY KEY (`user_name`)
Insert two rows into the table:
INSERT INTO `user` (`user_name`,`password`,`group_name`) VALUES
INSERT INTO `user` (`user_name`,`password`,`group_name`) VALUES
Create a JNDI (JDBC resource) related to the database security, using the administration console tree under glassfish Resources / JDBC.
In the administrative console go under Security / Domains and create a new domain "jdbcRealmSecurity"
The propreties of jdbcRealmSecurity :

Now we have to go edit the file web.xml. We'll start with the Login module configuration
The login form is the following :
<form action="j_security_check" method="POST">
    <div><img src="/j_security_check/images/logo.jpg" width="40" height="40"/></div>
    <div>Username:&nbsp;<input type="text" name="j_username"></div>
    <div>Password:&nbsp;<input type="password" name="j_password"></div>
    <div><input type="submit" value="Login"></div>
After that you define the roles:
Finally you define the security constraints:
Do not forget to go changing the sun-web.xml and add the group name to the specified roles.

You can test the application now :)