Wednesday, April 30, 2008

An interesting difference between Oracle and MySQL

This is a very interesting and important difference between the Default settings of oracle and mysql isolation levels.

Default Isolation Level for Oracle = READ COMMITED
Defautl for MySQL = REPEATABLE READ

J2EE Container Security in Applications

Introduction

Using J2EE Container security is the first step towards designing a secure and portable J2EE application.

The integration of Container security with an application is easy but requires some amount of knowledge and research. The main reason for this is various J2EE application server providers gives us only a limited amount of login modules by default.
For example an Active Directory authentication is a standard requirement but not all J2EE Server vendors provide this.But many major vendors provide this login module . The bottomline is we may be required to write our own login modules for many standard services. Writing our own login module is not difficult .Writing a custom login module will not be covered in this post.This post is about integrating a DB login module to an application deployed in JBoss Server.
In this post i am only giving the steps without eloborating on each of the steps.

5 Steps
  1. Identify the EJB that you want to secure.
  2. Add the annotation @Securitydomain and give the name of the domain which will provide the security.
  3. Add @RolesAllowed annotation and define which roles can access the EJB methods
  4. In the jboss login-config xml add a security domain entry
  5. Configure the DatabaseServerLoginModule as the liogin module. This will allow us to use authenticate and authorise the user and roles from a database. This module is provided by JBoss , so only thing left is to tell this module the tables to be used.
That's all. Now try invoking the ejb methods without providing a user and password in the JNDI properties. You should get an authentication exception.Now provide a valid user and password and if that user is mapped to a role then the ejb invocation will be successful.