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.

No comments: