Michael Jennings wrote:
>
> Hi everyone,
>
> Does anyone have an idea of how I could go about implementing
> realms/authentication on a per-context basis?
> Ideally, what I would like to do is have each context control
> their users and roles. Where should I look to get a clue?
Make a simple realm implementation that simply gets the real realm
config information from the context passed with the request, e.g.
authenticate(Req)
{
Context ctx = req.getContext();
// Now you have all the context config available
..
}
I have a JAAS realm which has context specific realm config using the
<context-param>
<param-name>Name</param-name>
<param-value>Value</param-value>
</context-param>
attributes in web.xml to provide context specific control.
In the realm, just so
String ctxNameValue = ctx.getInitParameter("Name");
or similar. With JAAS this is easy, because JAAS allows for different
JAAS configurations to be used, you just specify a different config name
to the JAAS context.
Antony