public void policyTestDatabasePermissionGrants() throws IOException {
final DatabasePermission[] relDirPathPerms
= new DatabasePermission[relDirPaths.length];
for (int i = 0; i < relDirPaths.length; i++) {
relDirPathPerms[i]
= new DatabasePermission(relDirPaths[i],
DatabasePermission.CREATE);
}
// test DatabasePermission for unauthorized, authorized, and
// all-authorized users
final int[] singleLocPaths = { 2, 3, 6, 7 };
final SystemPrincipal authorizedUser
= new SystemPrincipal("authorizedSystemUser");
final SystemPrincipal unAuthorizedUser
= new SystemPrincipal("unAuthorizedSystemUser");
final SystemPrincipal superUser
= new SystemPrincipal("superUser");
for (int i = 0; i < singleLocPaths.length; i++) {
final int j = singleLocPaths[i];
execute(unAuthorizedUser,
new CreateDatabaseAction(relDirPathPerms[j]), false);
execute(authorizedUser,
new CreateDatabaseAction(relDirPathPerms[j]), (j != 6));
execute(superUser,
new CreateDatabaseAction(relDirPathPerms[j]), true);
}
// test DatabasePermission for any user
final SystemPrincipal anyUser
= new SystemPrincipal("anyUser");
final DatabasePermission dbPerm
= new DatabasePermission("directory:dir",
DatabasePermission.CREATE);
execute(anyUser,
new CreateDatabaseAction(dbPerm), true);
}