/*
* Iterate over ProtectionDomains and and check implies().
*/
for (int i = 0; i < protectionDomains.length; i++) {
ProtectionDomain pd = protectionDomains[i];
if (pd == null) {
continue;
}
/*
* Get CodeSource for ProtectionDomain.
*/
CodeSource cs = protectionDomains[i].getCodeSource();
/*
* Call getPermissions() on PolicyFileProvider passing
* ProtectionDomain.
*/
PermissionCollection pcPD = policy.getPermissions(pd);
/*
* Call getPermissions() on PolicyFileProvider passing
* CodeSource.
*/
PermissionCollection pcCS = policy.getPermissions(cs);
/*
* Call implies() on returned PermissionCollections passing
* permissions that granted in the policy file. Verify that
* implies() returns true.
*/
checkImplies(pcPD, pma[IGRANTED], true);
checkImplies(pcCS, pma[IGRANTED], true);
/*
* Call implies() on returned PermissionCollections passing
* not granted permissions. Verify that implies()
* returns false.
*/
checkImplies(pcPD, pma[INOTGRANTED], false);
checkImplies(pcCS, pma[INOTGRANTED], false);
/*
* For ProtectionDomains that have
* PreferredClassLoader as ClassLoader
* call implies() on returned PermissionCollections passing
* permissions that granted to
* qa1-policy-provider.jar's codebase.
* Verify that implies() returns true.
*/
if (pd.getClassLoader() instanceof PreferredClassLoader) {
checkImplies(pcPD, pma[ICODEBASEGRANTED], true);
checkImplies(pcCS, pma[ICODEBASEGRANTED], true);
}
if (pma[ICODEBASENOTGRANTED] == null) {
continue;
}
/*
* For ProtectionDomains that have
* PreferredClassLoader as ClassLoader
* call implies() on returned PermissionCollections passing
* permissions that are not granted to
* qa1-policy-provider.jar's codebase.
* Verify that implies() returns false.
*/
if (pd.getClassLoader() instanceof PreferredClassLoader) {
checkImplies(pcPD, pma[ICODEBASENOTGRANTED], false);
checkImplies(pcCS, pma[ICODEBASENOTGRANTED], false);
}
}
}