public Action getRevokeAction() { return actionFactory.createAction(Action.REVOKE); }
protected void initData() { EntityFeatures.deactivateInterceptor(); Company company = new Company(); company.setUserLevelEnabled(true); company.setFieldLevelEnabled(true); company.setGroupHierarchyEnabled(true); company.setObjectLevelEnabled(true); persist(company); user1 = new User("User 1"); user1.setCompany(company); persist(user1); user2 = new User("User 2"); user2.setCompany(company); persist(user2); userGroupA = new UserGroup("Usergroup A"); persist(userGroupA); userGroupB = new UserGroup("Usergroup B"); persist(userGroupB); userGroupC = new UserGroup("Usergroup C"); persist(userGroupC); userGroupD = new UserGroup("Usergroup D"); persist(userGroupD); // create actions createAction = actionFactory.createAction(Action.CREATE); deleteAction = actionFactory.createAction(Action.DELETE); updateAction = actionFactory.createAction(Action.UPDATE); grantAction = actionFactory.createAction(Action.GRANT); revokeAction = actionFactory.createAction(Action.REVOKE); readAction = actionFactory.createAction(Action.READ); // create some resources userEntity = (EntityResource) entityResourceFactory.createResource(User.class); groupEntity = (EntityResource) entityResourceFactory.createResource(UserGroup.class); documentEntity = (EntityResource) entityResourceFactory.createResource(Document.class); documentEntityTitleField = (EntityResource) entityResourceFactory.createResource(Document.class, Title_Field); documentEntityContentField = (EntityResource) entityResourceFactory.createResource(Document.class, Content_Field); emailEntity = (EntityResource) entityResourceFactory.createResource(Email.class); user1Entity = (EntityDataResource) entityResourceFactory.createResource(user1.getClass(), user1.getId()); user2Entity = (EntityDataResource) entityResourceFactory.createResource(user2.getClass(), user2.getId()); document1Entity = (EntityDataResource) entityResourceFactory.createResource(Document.class, 1); document2Entity = (EntityDataResource) entityResourceFactory.createResource(Document.class, 2); document1EntityTitleField = (EntityDataResource) entityResourceFactory.createResource(Document.class, Title_Field, 1); document1EntityContentField = (EntityDataResource) entityResourceFactory.createResource(Document.class, Content_Field, 1); // create admin admin = new User("Admin"); admin.setCompany(company); persist(admin); // add permissions to admin // admin can grant and revoke any action permissionManager.save( permissionFactory.create( admin, grantAction, resourceFactory.createResource(getAddAction()))); permissionManager.save( permissionFactory.create( admin, grantAction, resourceFactory.createResource(getCreateAction()))); permissionManager.save( permissionFactory.create( admin, grantAction, resourceFactory.createResource(getDeleteAction()))); permissionManager.save( permissionFactory.create( admin, grantAction, resourceFactory.createResource(getGrantAction()))); permissionManager.save( permissionFactory.create( admin, grantAction, resourceFactory.createResource(getReadAction()))); permissionManager.save( permissionFactory.create( admin, grantAction, resourceFactory.createResource(getRemoveAction()))); permissionManager.save( permissionFactory.create( admin, grantAction, resourceFactory.createResource(getRevokeAction()))); permissionManager.save( permissionFactory.create( admin, grantAction, resourceFactory.createResource(getUpdateAction()))); permissionManager.save( permissionFactory.create( admin, revokeAction, resourceFactory.createResource(getAddAction()))); permissionManager.save( permissionFactory.create( admin, revokeAction, resourceFactory.createResource(getCreateAction()))); permissionManager.save( permissionFactory.create( admin, revokeAction, resourceFactory.createResource(getDeleteAction()))); permissionManager.save( permissionFactory.create( admin, revokeAction, resourceFactory.createResource(getGrantAction()))); permissionManager.save( permissionFactory.create( admin, revokeAction, resourceFactory.createResource(getReadAction()))); permissionManager.save( permissionFactory.create( admin, revokeAction, resourceFactory.createResource(getRemoveAction()))); permissionManager.save( permissionFactory.create( admin, revokeAction, resourceFactory.createResource(getRevokeAction()))); permissionManager.save( permissionFactory.create( admin, revokeAction, resourceFactory.createResource(getUpdateAction()))); // admin can grant to users and usergroups permissionManager.save(permissionFactory.create(admin, grantAction, userEntity)); permissionManager.save(permissionFactory.create(admin, revokeAction, userEntity)); // admin can change user properties permissionManager.save(permissionFactory.create(admin, updateAction, userEntity)); permissionManager.save(permissionFactory.create(admin, grantAction, groupEntity)); permissionManager.save(permissionFactory.create(admin, revokeAction, groupEntity)); // admin can change group properties permissionManager.save(permissionFactory.create(admin, updateAction, groupEntity)); // TODO not needed anymore because isGranted service method does not check action resource // permissionManager.save(permissionFactory.create(admin, revokeAction, // resourceFactory.createResource(grantAction))); // permissionManager.save(permissionFactory.create(admin, grantAction, // resourceFactory.createResource(revokeAction))); // permissionManager.save(permissionFactory.create(admin, grantAction, // resourceFactory.createResource(grantAction))); // permissionManager.save(permissionFactory.create(admin, revokeAction, // resourceFactory.createResource(revokeAction))); // // permissionManager.save(permissionFactory.create(admin, grantAction, // resourceFactory.createResource(deleteAction))); // permissionManager.save(permissionFactory.create(admin, grantAction, // resourceFactory.createResource(createAction))); // permissionManager.save(permissionFactory.create(admin, grantAction, // resourceFactory.createResource(updateAction))); // permissionManager.save(permissionFactory.create(admin, grantAction, // resourceFactory.createResource(readAction))); // // permissionManager.save(permissionFactory.create(admin, revokeAction, // resourceFactory.createResource(deleteAction))); // permissionManager.save(permissionFactory.create(admin, revokeAction, // resourceFactory.createResource(createAction))); // permissionManager.save(permissionFactory.create(admin, revokeAction, // resourceFactory.createResource(updateAction))); // permissionManager.save(permissionFactory.create(admin, revokeAction, // resourceFactory.createResource(readAction))); // admin change user_level, field_level, etc permissionManager.save( permissionFactory.create( admin, updateAction, entityResourceFactory.createResource(Company.class))); // admin can grant the sample entities permissionManager.save( permissionFactory.create( admin, grantAction, entityResourceFactory.createResource(TestCarrier.class))); permissionManager.save( permissionFactory.create( admin, grantAction, entityResourceFactory.createResource(Carrier.class))); permissionManager.save( permissionFactory.create( admin, grantAction, entityResourceFactory.createResource(Party.class))); permissionManager.save( permissionFactory.create( admin, grantAction, entityResourceFactory.createResource(Contact.class))); permissionManager.save( permissionFactory.create( admin, grantAction, entityResourceFactory.createResource(CarrierGroup.class))); permissionManager.save( permissionFactory.create( admin, grantAction, entityResourceFactory.createResource(CarrierTeam.class))); permissionManager.save( permissionFactory.create( admin, grantAction, entityResourceFactory.createResource(CarrierContactEntry.class))); permissionManager.save( permissionFactory.create( admin, grantAction, entityResourceFactory.createResource(Document.class))); permissionManager.save( permissionFactory.create( admin, grantAction, entityResourceFactory.createResource(Email.class))); permissionManager.save( permissionFactory.create( admin, grantAction, entityResourceFactory.createResource(Comment.class))); // admin can revoke the sample entities permissionManager.save( permissionFactory.create( admin, revokeAction, entityResourceFactory.createResource(Carrier.class))); permissionManager.save( permissionFactory.create( admin, revokeAction, entityResourceFactory.createResource(Party.class))); permissionManager.save( permissionFactory.create( admin, revokeAction, entityResourceFactory.createResource(Contact.class))); permissionManager.save( permissionFactory.create( admin, revokeAction, entityResourceFactory.createResource(CarrierGroup.class))); permissionManager.save( permissionFactory.create( admin, revokeAction, entityResourceFactory.createResource(CarrierTeam.class))); permissionManager.save( permissionFactory.create( admin, revokeAction, entityResourceFactory.createResource(Document.class))); permissionManager.save( permissionFactory.create( admin, revokeAction, entityResourceFactory.createResource(Email.class))); permissionManager.save( permissionFactory.create( admin, revokeAction, entityResourceFactory.createResource(Comment.class))); }
public Action getReadAction() { return actionFactory.createAction(Action.READ); }
public Action getGrantAction() { return actionFactory.createAction(Action.GRANT); }
public Action getDeleteAction() { return actionFactory.createAction(Action.DELETE); }
public Action getRemoveAction() { return actionFactory.createAction(Action.REMOVE); }
public Action getAddAction() { return actionFactory.createAction(Action.ADD); }
public Action getCreateAction() { return actionFactory.createAction(Action.CREATE); }
public Action getUpdateAction() { return actionFactory.createAction(Action.UPDATE); }