String user = principals[i].getName();
if (user.equals("admin"))
{
// owner permissions
permissions.add(new FolderPermission("/", "view, edit"));
permissions.add(new PagePermission("/default-page.psml", "view, edit"));
}
else if (user.equals("user"))
{
// owner permissions
permissions.add(new FragmentPermission("/default-page.psml/some-app::SomePortlet", "view, edit"));
// granted permissions
permissions.add(new PagePermission("/user-page.psml", "view, edit"));
permissions.add(new FragmentPermission("/user-page.psml/*", "view"));
}
// public view permissions
permissions.add(new FolderPermission("/", "view"));
permissions.add(new PagePermission("/default-page.psml", "view"));
permissions.add(new PagePermission("/page.security", "view"));
permissions.add(new FragmentPermission("security::*", "view"));
}
else if (principals[i] instanceof RolePrincipal)
{
// get permissions for roles
String role = principals[i].getName();
if (role.equals("admin"))
{
// global permissions
permissions.add(new FolderPermission("<<ALL FILES>>", "view, edit"));
permissions.add(new FragmentPermission("<<ALL FRAGMENTS>>", "view, edit"));
}
else if (role.equals("manager"))
{
// granted permissions
permissions.add(new PagePermission("/default-page.psml", "edit"));
permissions.add(new PagePermission("/default.link", "edit"));
}
}
}
// check permission