Sunday, February 10, 2008

ACEGI Authorization

Hi,in my previous blog i have talked about authentication.Here i am going to talk about authorization.Let me tell u first what it is.
Say for an application you want some users to use some feautres and you do not want that feautre to accessible by othere users.This blocking you can achieve through ACEGI
what you have to do is to create roles for each uses and giving priviles to each roles so that roles having certain privileges can access their feautres.Like in an web application we can have roles like Admin,Manager,Quest etc.So each roles can access feautres that others cannot.
You can use the code as i have given in authentication only you have to add some extra tags
which is shown below.

Here URLInterceptor is a filter which gets invoked for each url and sees whether the current user with a given role has the privilege to acess the url if yes then he can go to the page defined by this url else he is redirected to acess denied page.

The filter code goes here



Let me explain a bit of the code the method lookupAttributes gets called for each url
with parameter as the url of the current page.Here in this method we do some login inorder to find the all the roles for the current role from the database.
and bind that url to the ConfigAttributeEditor object and return to the caller that is the browser.If the user has role that is present in the this object than he can access the current page else not.

Wednesday, February 6, 2008

Memory leakage

What is memory leakage?
It is nothing but if your jvm cannot provide heap size that your application requires at runtime then memory leakage takes place.
Todays industry are facing a great problem with this the reason basically for this is creating unnessary objects.And also care has not been taken while creating session object which pays a high penalty.Imagine a web application where a 1000 user hits persecond and we have created session objects without having any thought so imagine what is going to happen.
To avoid this lets create only one session per user.For that you have to create session like this
HttpSession session =request.getSession(false);
what it will do if a session object is already there it wont create a new one as regard to true or void arguement of getSession method of request object.

How to give an alias name for a web application?

Well one day a need arised that we have to maintain versioning for our application i.e a war and ear
So the problem happpened with me was how to keep the context root of the war which i have used in my Apps for page redirection.
As i was using Jboss server for development.It has a capability of adding an alias name for context root.We just have to create a file called jboss-web.xml and put inside our web-inf folder of our application the tag we have to put inside the file is

thats all.So now if your war file name is project-1.0.war
you can just acess your application from brower as http://host:portno/yourroot/ thats all.