@Test public void editAccessGrantedForOwner() throws ComponentLookupException { Assert.assertTrue(this.mocker.getComponentUnderTest().hasAccess(this.user, Right.EDIT, this.doc)); }
@Override public Boolean hasAccess(User user, Right access, EntityReference entity) { if (!ObjectUtils.allNotNull(access, entity) || access.getTargetedEntityType() == null || !access.getTargetedEntityType().contains(EntityType.DOCUMENT)) { return null; } Patient patient = this.patientRepository.get(entity.toString()); if (patient == null) { return null; } AccessLevel grantedAccess = this.manager.getEntityAccess(patient).getAccessLevel(user != null ? user.getProfileDocument() : null); if (this.ownerAccess.compareTo(grantedAccess) <= 0) { return true; } return null; }
OwnerAccessAuthorizationModule implements AuthorizationModule { @Override public Boolean hasAccess(User user, Right access, EntityReference entity) { if (!ObjectUtils.allNotNull(access, entity) || access.getTargetedEntityType() == null || !access.getTargetedEntityType().contains(EntityType.DOCUMENT)) { return null; } Patient patient = this.patientRepository.get(entity.toString()); if (patient == null) { return null; } AccessLevel grantedAccess = this.manager.getEntityAccess(patient).getAccessLevel(user != null ? user.getProfileDocument() : null); if (this.ownerAccess.compareTo(grantedAccess) <= 0) { return true; } return null; } }
OwnerAccessAuthorizationModule implements AuthorizationModule { @Override public Boolean hasAccess(User user, Right access, EntityReference entity) { if (!ObjectUtils.allNotNull(access, entity) || access.getTargetedEntityType() == null || !access.getTargetedEntityType().contains(EntityType.DOCUMENT)) { return null; } Patient patient = this.patientRepository.get(entity.toString()); if (patient == null) { return null; } AccessLevel grantedAccess = this.manager.getEntityAccess(patient).getAccessLevel(user != null ? user.getProfileDocument() : null); if (this.ownerAccess.compareTo(grantedAccess) <= 0) { return true; } return null; }  }
OwnerAccessAuthorizationModule implements AuthorizationModule { @Override public Boolean hasAccess(User user, Right access, EntityReference entity) { if (!ObjectUtils.allNotNull(access, entity) || access.getTargetedEntityType() == null || !access.getTargetedEntityType().contains(EntityType.DOCUMENT)) { return null; } Patient patient = this.patientRepository.get(entity.toString()); if (patient == null) { return null; } AccessLevel grantedAccess = this.manager.getEntityAccess(patient).getAccessLevel(user != null ? user.getProfileDocument() : null); if (this.ownerAccess.compareTo(grantedAccess) <= 0) { return true; } return null; }  @Override int getPriority(); @Override Boolean hasAccess(User user, Right access, EntityReference entity); }
OwnerAccessAuthorizationModule implements AuthorizationModule { @Override public Boolean hasAccess(User user, Right access, EntityReference entity) { if (!ObjectUtils.allNotNull(access, entity) || access.getTargetedEntityType() == null || !access.getTargetedEntityType().contains(EntityType.DOCUMENT)) { return null; } Patient patient = this.patientRepository.get(entity.toString()); if (patient == null) { return null; } AccessLevel grantedAccess = this.manager.getEntityAccess(patient).getAccessLevel(user != null ? user.getProfileDocument() : null); if (this.ownerAccess.compareTo(grantedAccess) <= 0) { return true; } return null; }  @Override int getPriority(); @Override Boolean hasAccess(User user, Right access, EntityReference entity);  }