users@glassfish.java.net

Re: JACC and PolicyConfigurationImpl

From: Kumar Jayanti <v.b.kumar.jayanti_at_oracle.com>
Date: Mon, 4 Jul 2011 15:57:29 +0530

On 02-Jul-2011, at 1:35 AM, Laird Nelson wrote:

> Can someone shed light on how the default Policy installed by Glassfish 3.1 actually reads granted.policy and excluded.policy files?
>
> I can see how it generates them, but I don't actually see the files being read. Correction: I see the excluded.policy files being read, but not the granted.policy ones.

At the time of deployment the of an App the policies will be put into service as well as written to the filesystem during commit(). The policy files will be read during a restart of the server. And that code is in getPolicyConfigurationImplFromDirectory()

>
> If I create a new instance of PolicyConfigurationFactoryImpl and ask it to get a PolicyConfigurationImpl for a given known context, I can see from the log output that the policy configuration finds the directory, discovers the files, and apparently processes them with no problem. This all happens in PolicyConfigurationImpl#initialize().
>
> But when I investigate the internal Policy object housed by PolicyConfiguraitonImpl (its "policy" member variable using setAccessible(true)), it is empty even after initialize() is called when there are granted.policy files present in The Right Place.
>
> Refreshing the BasePolicyWrapper does not appear to cause the context policy to be refreshed.
>
> I'm doing all this in a unit test as part of writing a JACC implementation. I am trying to understand how the default Policy provider implementation works.
>
> I'm worried that perhaps it regenerates the granted.policy file every single time,

You mean the Default Policy Provider is doing this ?.

regards,
kumar
> even though you're supposed to be able to pre-create the granted.policy file and copy it into the right directory. Maybe there isn't a test case to see if this is the case?
>
> Thanks,
> Laird