More servicesWindows Live
HomeHotmailSpacesOneCare
 
MSN
Sign in
 
 
Spaces home  Patrice SecheressePhotosProfileFriendsBlog Tools Explore the Spaces community

Blog

November 24

Stable version of VolunteerBase

This version 0.6 of volunteerbase contains fixes and minor improvements, the project is now in a stable phase. The Wiki user guide has a comprehensive coverage of all the functions. The package has been upgraded to Tomcat 6.0 and the distribution can use Java 5.0 or 6.0.

October 19

Volunteerbase project specifications completed

With the release 0.5, the project is now covering the initial specifications. The next big steps will be the functional tests, acceptance test and the documentation. The test by the new SPW Australia team should add some new ideas and further evolutions.

October 04

Release 0.4 of VolunteerBase project

After a long iteration, finally the 0.4 is published.

The biggest challenge was to include a reporting capability without using heavy weight framework. After some issues with JPA and iReport, I have decided to choose a simpler and well known solution with Apache Fop. The idea of xsl-format looks good. It uses the css style and is able to generate many output (html, pdf, png, RTF etc...). It's really handful to separate the content of the presentation and it gives the possibility to customize easily the report. However it's not very efficient to create rapid report with complex structure. Associated with a lack of tools and the future css3, I not sure of the future of this product.

The release contains also a bunch of bug fixes.

The new function is the volunteer contribution management. The features are:

  • A schedule to define the payment plan for a year, depending of the month of selection
  • Book keeping of the volunteer contributions

The next feature in 0.5 will be an individual report to give a situation of the volunteer contributions.

August 22

Volunteer Base release 0.3

This release is mainly focused on usability improvements. The iterations will deliver alternatively new functions and defect fixes. The goal is to move from a prototype (release 0.1) to a production ready software with all the functions required in version 1.0.

This release includes work from Sean Melody, a new active and motivated contributor.

August 08

Programmatic Login from a Stand-Alone Client

This blog follow the previous one "Secured EJB 3.0 Web Start Application Client".

Now, we want to access the same EJB without Java Web Start and we want to provide a user/login programmatically. We can use a class provided with GlassFish : ProgrammaticLogin.

I assume you have done and deployed the previous project. The client part of the previous Enterprise Application is not necessary, you can skip it if you have not already done the demo. We will create a totally independent project.

Create the project

Create a new project, select Java, Projects -> Java Application and click Next. Name the project ProgrammaticLogin and click finish.

Add the libraries

We need few libraries from Glassfish in order to run the project. Right click on Libraries -> Add JAR/Folder, image and add the following jar files from the <GLASSFISH_INSTALL_DIR>/lib directory of your GlassFish serveur :  appserv-rt.jar, j2ee.jar, appserv-ext.jar, appserv-admin.jar. These jar contain all you need to run the client.

Right click again on Libraries -> Add Project and add the EJB project Login-ejb.

image

Login code

You can now open the Main class and input the following code inside the main method:

ProgrammaticLogin pm = new ProgrammaticLogin();
pm.login("demo", "demo"); //user and password of a user mapped to admin role

InitialContext ctx;
try {
    ctx = new InitialContext();
    Object ref = ctx.lookup("demo.CalculatorRemote");
    CalculatorRemote calc = (CalculatorRemote) PortableRemoteObject.narrow(ref,CalculatorRemote.class);
    javax.swing.JOptionPane.showMessageDialog(null, "2 + 2 = " + calc.add(2, 2));
    javax.swing.JOptionPane.showMessageDialog(null, calc.hello("Mr Demo"));
} catch (Exception ex) {
    ex.printStackTrace();
}

Resolve the imports (Ctrl+Maj+F with NB 5, Ctrl+Maj+I with NB 6).

Run the demo

Start the application server.

Before running the client, we must set the configuration in order to obtain the correct login module. We must give the JAAS config file.

Right click on the project, select Properties -> Run.

In VM Options, add : -Djava.security.auth.login.config=D:/JavaServers/glassfish-v2-b53/lib/appclient/appclientlogin.conf

Replace D:/JavaServers/glassfish-v2-b53/ by the directory of your GlassFish serveur. Note: don't forget the - at the beginning of -Djava.sec...image

Click Run, you will see the 2 messages, including the message from restricted method hello().

Note

The programmatic login can be used with Java Web Start. Just add the 2 lines in bold in the code to the previous demo and add the required libraries.

August 05

Secured EJB 3.0 and Web Start Application Client

One option of the Glassfish Server is the ability to launch a desktop client application from the server with Java Web Start. Associated with NetBeans, it's easy to create a secured application easy to distribute.

First, with NetBeans, ensure you have GlassFish server registered (see Tools -> Server Manager and add your server GlassFish or Sun Java System Application Server version 9  included in the JavaEE 5 SDK).

Create the project

Create a new project, select Enterprise, Projects -> Enterprise Application and click Next.

image

In window 'Name and Location', fill in the project name with Login, your GlasFish server as Sun Java System Application Server, Java version as Java EE 5 and select Create EJB Module, deselect Create Web Application Module, select Create Application Client Module. Leave the default values for the module names and press Finish.

image

Create the EJB

Right click on Login-ejb -> New -> Session Bean.

Set the EJB name with Calculator, package with demo, check Remote and uncheck Local. Leave stateless checked.

Create method add

In the CalculatorBean.java source, right click -> EJB Methods -> Add Business Method. Name the method 'add' with int as return type and 2 parameters a and b as int.

image

Replace return 0 by return a + b

Create the method hello

Repeat the same process to add a business method hello with a String a return type and a String as parameter with 'name' as parameter name.

image

Replace return null by return "Hello " + name;

Add security annotations

Before @Stateless, add an annotation to declare the role admin. Insert the line :

@DeclareRoles("admin")

Before the method hello, add an annotation to restrict the access of the method to the role "admin":

@RolesAllowed("admin")

The source of the EJB must look like this

package demo;

import javax.annotation.security.DeclareRoles;
import javax.annotation.security.RolesAllowed;
import javax.ejb.Stateless;

/**
 *
 * @author PSe
 */
@DeclareRoles("admin")
@Stateless
public class CalculatorBean implements CalculatorRemote {
    /** Creates a new instance of CalculatorBean */
    public CalculatorBean() {
    }

    public int add(final int a, final int b) {
        return a + b;
    }

    @RolesAllowed("admin")
    public String hello(final String name) {
        return "Hello " + name;
    }
}

Client code

Open the project nodes Login-app-client -> Source Package, login and double click on Main.java.

Right click in the source select Entreprise Resources -> Call Enterprise Bean and select CalculatorBean. Press OK. The line to reference the bean is automatically inserted:

@EJB
private static CalculatorRemote calculatorBean;

Add the lines below to call the methods:

javax.swing.JOptionPane.showMessageDialog(null, "2 + 2 = " + calculatorBean.add(2, 2));
javax.swing.JOptionPane.showMessageDialog(null, calculatorBean.hello("Mr admin"));

Press Alt+Maj+F to resolve the import. The source must look like:

package login;

import demo.CalculatorRemote;
import java.rmi.RemoteException;
import javax.ejb.EJB;

/**
 *
 * @author PSe
 */
public class Main {
    @EJB
    private static CalculatorRemote calculatorBean;
    /** Creates a new instance of Main */
    public Main() {
    }
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        javax.swing.JOptionPane.showMessageDialog(null, "2 + 2 = " + calculatorBean.add(2, 2));
        javax.swing.JOptionPane.showMessageDialog(null, calculatorBean.hello("Mr admin"));
    }
}

Run the application

Press the Run button image , the project is deployed and the client is launched. You will see the login window: image

Enter any name and password, the application will fail because we need to create the users and map the role admin.

Create the users

In the Runtime tab (service with NetBeans 6), open the Servers node and right click on Sun Java System Application Server and select View Admin Console: image

Your browser will open a window to log on the server. Put the admin name and password you give when installing the application server.

image

Select Configuration -> Security -> Realms -> file and click Manage Users. Click New to create two user, one in the group user, the other in the group admin. In my example, the user demo is in the group admin and the user user is in the group user.

Roles mapping

To map the roles, open in the project tab the Login project -> Configuration Files and double click on sun-application.xml. Click on Edit As XML and replace <sun-application/> by :

<sun-application>
  <security-role-mapping>
    <role-name>user</role-name>
    <group-name>user</group-name>
  </security-role-mapping>
  <security-role-mapping>
    <role-name>admin</role-name>
    <group-name>admin</group-name>
  </security-role-mapping>
</sun-application>

Run again the application, enter the user demo and the password, you will see two windows:

image

image

If you try again with a user outside the admin group, you will see only the first message and the application will throw an error.

Note : with NetBeans 5.5.1, I must kill the Login process after the execution. To do this, select the Runtime tab, open the Processes node, right click on Login (Run) and select Terminate Process.

Java Web Start the application

If you open the browser and use the address http://localhost:8080/Login/Login-app-client

the application will start automatically.

This conclude the demo and give a glimpse of the power of NetBeans and GlassFish. These products are easy to use, well designed, efficient and designed for enterprise solution.  Associated with the power of Java EE 5 annotations, you can construct a solution without headache.

July 29

English vocabulary

Thank you Sandy for your message to notify some mistakes but I can not respond as a result of your security setting which prevent it.
I must admit that my English is still weak after seven months in Australia. Unfortunately, it could not be as good as my computer skills and my native French (Sandy guess was right, I'm French). I try to go ahead but sometimes errors happen, it is part of the learning process. I know it's important to improve my English level so I am student in night courses.
Furthermore, I can't ask people to check my writing, I'm working alone and my wife is also French. If you are ready to give me a hand, you are welcome Smile
Last point, I agree that  the missing 's' of adds was an ugly fault and I can't argue about the plural of functionality but if you look up in the Macquarie (Australia's national dictionary): functionality 1. the purpose designed to be fulfilled by a device, tool, machine, etc. 2. Computers the range of functions which an application has. Not so ugly, isn't it?

Volunteerbase project release 0.2

This version adds new functions to the product :
- new search filters and advanced search criterias
- export to merge mail / emailer to send e-mails
- reminder and actions to be completed

It also includes some code improvements and minor bug fixes.
July 09

Release 0.1 of Volunteerbase

The first release is ready. This is a typical front end system without any extra functionalities. It gives all you need to add, modify, delete, search any information, including documents. The next release is intended to add a mailer with merge capabilities, reminders, actions to be conducted, etc...
June 06

Volunteer Base project hosted on SourceForge

The volunteer project (about volunteering) wich I am developing is new hosted on SourceForge. Feel free to look the site http://volunteerbase.sourceforge.net/
March 17

First blog

Welcome to this blog.

If you are looking for an exellent project manager or/and analyst programmer, I fit the bill.
If you are looking for a free lancer or volunteer for your Information System with latest technology, stop here, I can help you.


You can find some examples of my work on www.microcode.fr or www.habitersurlacote.com