@Test void findOneByIdUserPermissionDenied() { Package pack = mock(Package.class); when(pack.getId()).thenReturn("1"); when(delegateRepository.findOneById("1")).thenReturn(pack); when(userPermissionEvaluator.hasPermission(new PackageIdentity("1"), PackagePermission.VIEW)) .thenReturn(false); assertThrows(PackagePermissionDeniedException.class, () -> repo.findOneById("1")); }
@Override public Package findOneById(Object id) { Package pack = delegate().findOneById(id); if (pack != null && !isActionPermitted(id, READ)) { throwPermissionException(pack, READ); } return pack; }
PackageRepositorySecurityDecorator extends AbstractRowLevelSecurityRepositoryDecorator<Package> { @Override public Package findOneById(Object id) { Package pack = delegate().findOneById(id); if (pack != null && !isActionPermitted(id, READ)) { throwPermissionException(pack, READ); } return pack; } }
PackageRepositorySecurityDecorator extends AbstractRowLevelSecurityRepositoryDecorator<Package> { @Override public Package findOneById(Object id) { Package pack = delegate().findOneById(id); if (pack != null && !isActionPermitted(id, READ)) { throwPermissionException(pack, READ); } return pack; } PackageRepositorySecurityDecorator(
      Repository<Package> delegateRepository,
      MutableAclService mutableAclService,
      UserPermissionEvaluator userPermissionEvaluator); }
PackageRepositorySecurityDecorator extends AbstractRowLevelSecurityRepositoryDecorator<Package> { @Override public Package findOneById(Object id) { Package pack = delegate().findOneById(id); if (pack != null && !isActionPermitted(id, READ)) { throwPermissionException(pack, READ); } return pack; } PackageRepositorySecurityDecorator(
      Repository<Package> delegateRepository,
      MutableAclService mutableAclService,
      UserPermissionEvaluator userPermissionEvaluator); @Override boolean isActionPermitted(Package updatedPack, Action action); @Override boolean isActionPermitted(Object id, Action action); @Override void throwPermissionException(Package pack, Action action); @Override Package findOneById(Object id); @Override void add(Package pack); @Override void update(Package pack); @Override Integer add(Stream<Package> packages); @Override void createAcl(Package pack); @Override void deleteAcl(Object id); @Override void deleteAcl(Package pack); @Override void updateAcl(Package pack); }
PackageRepositorySecurityDecorator extends AbstractRowLevelSecurityRepositoryDecorator<Package> { @Override public Package findOneById(Object id) { Package pack = delegate().findOneById(id); if (pack != null && !isActionPermitted(id, READ)) { throwPermissionException(pack, READ); } return pack; } PackageRepositorySecurityDecorator(
      Repository<Package> delegateRepository,
      MutableAclService mutableAclService,
      UserPermissionEvaluator userPermissionEvaluator); @Override boolean isActionPermitted(Package updatedPack, Action action); @Override boolean isActionPermitted(Object id, Action action); @Override void throwPermissionException(Package pack, Action action); @Override Package findOneById(Object id); @Override void add(Package pack); @Override void update(Package pack); @Override Integer add(Stream<Package> packages); @Override void createAcl(Package pack); @Override void deleteAcl(Object id); @Override void deleteAcl(Package pack); @Override void updateAcl(Package pack);  }