@Test void testGrantPermissions() { groupValue = GroupValueFactoryTest.getTestGroupValue(); groupService.grantDefaultPermissions(groupValue); verify(permissionService) .createPermission( Permission.create( new PackageIdentity("bbmri_eric"), createRoleSid("bbmri_eric_MANAGER"), WRITEMETA)); verify(aclService).createAcl(new GroupIdentity("bbmri_eric")); verify(permissionService) .createPermission( Permission.create( new GroupIdentity("bbmri_eric"), createRoleSid("bbmri_eric_MANAGER"), WRITEMETA)); }
public void grantDefaultPermissions(GroupValue groupValue) { PackageIdentity packageIdentity = new PackageIdentity(groupValue.getRootPackage().getName()); GroupIdentity groupIdentity = new GroupIdentity(groupValue.getName()); aclService.createAcl(groupIdentity); groupValue .getRoles() .forEach( roleValue -> { PermissionSet permissionSet = PERMISSION_SETS_PER_ROLE.get(roleValue.getLabel()); Sid roleSid = createRoleSid(roleValue.getName()); permissionService.createPermission( Permission.create(packageIdentity, roleSid, permissionSet)); permissionService.createPermission( Permission.create(groupIdentity, roleSid, permissionSet)); }); if (groupValue.isPublic()) { permissionService.createPermission( Permission.create(groupIdentity, createAuthoritySid(AUTHORITY_USER), READ)); } }
GroupService { public void grantDefaultPermissions(GroupValue groupValue) { PackageIdentity packageIdentity = new PackageIdentity(groupValue.getRootPackage().getName()); GroupIdentity groupIdentity = new GroupIdentity(groupValue.getName()); aclService.createAcl(groupIdentity); groupValue .getRoles() .forEach( roleValue -> { PermissionSet permissionSet = PERMISSION_SETS_PER_ROLE.get(roleValue.getLabel()); Sid roleSid = createRoleSid(roleValue.getName()); permissionService.createPermission( Permission.create(packageIdentity, roleSid, permissionSet)); permissionService.createPermission( Permission.create(groupIdentity, roleSid, permissionSet)); }); if (groupValue.isPublic()) { permissionService.createPermission( Permission.create(groupIdentity, createAuthoritySid(AUTHORITY_USER), READ)); } } }
GroupService { public void grantDefaultPermissions(GroupValue groupValue) { PackageIdentity packageIdentity = new PackageIdentity(groupValue.getRootPackage().getName()); GroupIdentity groupIdentity = new GroupIdentity(groupValue.getName()); aclService.createAcl(groupIdentity); groupValue .getRoles() .forEach( roleValue -> { PermissionSet permissionSet = PERMISSION_SETS_PER_ROLE.get(roleValue.getLabel()); Sid roleSid = createRoleSid(roleValue.getName()); permissionService.createPermission( Permission.create(packageIdentity, roleSid, permissionSet)); permissionService.createPermission( Permission.create(groupIdentity, roleSid, permissionSet)); }); if (groupValue.isPublic()) { permissionService.createPermission( Permission.create(groupIdentity, createAuthoritySid(AUTHORITY_USER), READ)); } } @SuppressWarnings("java:S107")  GroupService(
      PackageFactory packageFactory,
      DataService dataService,
      GroupMetadata groupMetadata,
      RoleMembershipService roleMembershipService,
      RoleMembershipMetadata roleMembershipMetadata,
      MutableAclService aclService,
      PermissionService permissionService); }
GroupService { public void grantDefaultPermissions(GroupValue groupValue) { PackageIdentity packageIdentity = new PackageIdentity(groupValue.getRootPackage().getName()); GroupIdentity groupIdentity = new GroupIdentity(groupValue.getName()); aclService.createAcl(groupIdentity); groupValue .getRoles() .forEach( roleValue -> { PermissionSet permissionSet = PERMISSION_SETS_PER_ROLE.get(roleValue.getLabel()); Sid roleSid = createRoleSid(roleValue.getName()); permissionService.createPermission( Permission.create(packageIdentity, roleSid, permissionSet)); permissionService.createPermission( Permission.create(groupIdentity, roleSid, permissionSet)); }); if (groupValue.isPublic()) { permissionService.createPermission( Permission.create(groupIdentity, createAuthoritySid(AUTHORITY_USER), READ)); } } @SuppressWarnings("java:S107")  GroupService(
      PackageFactory packageFactory,
      DataService dataService,
      GroupMetadata groupMetadata,
      RoleMembershipService roleMembershipService,
      RoleMembershipMetadata roleMembershipMetadata,
      MutableAclService aclService,
      PermissionService permissionService); @Transactional void persist(GroupValue groupValue); @RunAsSystem Collection<Group> getGroups(); @RunAsSystem Group getGroup(String groupName); @RunAsSystem void addMember(final Group group, final User user, final Role role); @RunAsSystem void removeMember(final Group group, final User user); @RunAsSystem void updateMemberRole(final Group group, final User member, final Role newRole); @RunAsSystem boolean isGroupNameAvailable(final GroupValue groupValue); void deleteGroup(String groupName); void updateExtendsRole(Group group, Role groupRole, Role memberRole); void removeExtendsRole(Group group, Role memberRole); void grantDefaultPermissions(GroupValue groupValue); }
GroupService { public void grantDefaultPermissions(GroupValue groupValue) { PackageIdentity packageIdentity = new PackageIdentity(groupValue.getRootPackage().getName()); GroupIdentity groupIdentity = new GroupIdentity(groupValue.getName()); aclService.createAcl(groupIdentity); groupValue .getRoles() .forEach( roleValue -> { PermissionSet permissionSet = PERMISSION_SETS_PER_ROLE.get(roleValue.getLabel()); Sid roleSid = createRoleSid(roleValue.getName()); permissionService.createPermission( Permission.create(packageIdentity, roleSid, permissionSet)); permissionService.createPermission( Permission.create(groupIdentity, roleSid, permissionSet)); }); if (groupValue.isPublic()) { permissionService.createPermission( Permission.create(groupIdentity, createAuthoritySid(AUTHORITY_USER), READ)); } } @SuppressWarnings("java:S107")  GroupService(
      PackageFactory packageFactory,
      DataService dataService,
      GroupMetadata groupMetadata,
      RoleMembershipService roleMembershipService,
      RoleMembershipMetadata roleMembershipMetadata,
      MutableAclService aclService,
      PermissionService permissionService); @Transactional void persist(GroupValue groupValue); @RunAsSystem Collection<Group> getGroups(); @RunAsSystem Group getGroup(String groupName); @RunAsSystem void addMember(final Group group, final User user, final Role role); @RunAsSystem void removeMember(final Group group, final User user); @RunAsSystem void updateMemberRole(final Group group, final User member, final Role newRole); @RunAsSystem boolean isGroupNameAvailable(final GroupValue groupValue); void deleteGroup(String groupName); void updateExtendsRole(Group group, Role groupRole, Role memberRole); void removeExtendsRole(Group group, Role memberRole); void grantDefaultPermissions(GroupValue groupValue); static final String MANAGER; static final String EDITOR; static final String VIEWER; static final String AUTHORITY_MANAGER; static final String AUTHORITY_EDITOR; static final String AUTHORITY_VIEWER; static final Set<String> DEFAULT_ROLES; }