Friday, September 15, 2006

Container Managed Security part 1 : authentication

It's no secret, J2EE webapps can (and should) rely on Container Managed Security (CMS) in order to perform authentication and authorization.

From anywhere in the application, you are able to retrieve the user name :

String userName = request.getRemoteUser();

In typical WebFacets applications, the user profiles are identified by the user's login name... see where we're coming to ? We could use this user name in order to use facets...
An utility class could be used to retrieve the current user's profile, something like :

public IProfile getCMSProfile(HttpServletRequest request) {
String userName = request.getRemoteUser();
if (userName==null)
return null;
else
return profileRepository.getProfileById(userName);
}

And we could also have a filter that automatically loads the profile, for each incoming request.

Here it is for the authentication part. Next to come : mapping the CMS roles to profiles...

No comments: