@Test public void deleteAccessNotGrantedForEditCollaborator() throws ComponentLookupException { when(this.access1.getGrantedRight()).thenReturn(Right.ILLEGAL); when(this.access2.getGrantedRight()).thenReturn(Right.EDIT); Assert.assertNull(this.mocker.getComponentUnderTest().hasAccess(this.user, Right.DELETE, this.doc)); }
@Override public Boolean hasAccess(User user, Right access, EntityReference entity) { if (!ObjectUtils.allNotNull(user, access, entity) || !(access == Right.VIEW || access == Right.EDIT)) { return null; } Family family = this.familyRepository.get(entity.toString()); if (family == null) { return null; } for (Patient member : family.getMembers()) { AccessLevel grantedAccess = this.manager.getAccessLevel(member, user.getProfileDocument()); Right grantedRight = grantedAccess.getGrantedRight(); if (grantedRight != null && (grantedRight.equals(access) || (grantedRight.getImpliedRights() != null && grantedRight.getImpliedRights().contains(access)))) { return true; } } return null; }
AccessThroughFamilyMemberAuthorisationModule implements AuthorizationModule { @Override public Boolean hasAccess(User user, Right access, EntityReference entity) { if (!ObjectUtils.allNotNull(user, access, entity) || !(access == Right.VIEW || access == Right.EDIT)) { return null; } Family family = this.familyRepository.get(entity.toString()); if (family == null) { return null; } for (Patient member : family.getMembers()) { AccessLevel grantedAccess = this.manager.getAccessLevel(member, user.getProfileDocument()); Right grantedRight = grantedAccess.getGrantedRight(); if (grantedRight != null && (grantedRight.equals(access) || (grantedRight.getImpliedRights() != null && grantedRight.getImpliedRights().contains(access)))) { return true; } } return null; } }
AccessThroughFamilyMemberAuthorisationModule implements AuthorizationModule { @Override public Boolean hasAccess(User user, Right access, EntityReference entity) { if (!ObjectUtils.allNotNull(user, access, entity) || !(access == Right.VIEW || access == Right.EDIT)) { return null; } Family family = this.familyRepository.get(entity.toString()); if (family == null) { return null; } for (Patient member : family.getMembers()) { AccessLevel grantedAccess = this.manager.getAccessLevel(member, user.getProfileDocument()); Right grantedRight = grantedAccess.getGrantedRight(); if (grantedRight != null && (grantedRight.equals(access) || (grantedRight.getImpliedRights() != null && grantedRight.getImpliedRights().contains(access)))) { return true; } } return null; }  }
AccessThroughFamilyMemberAuthorisationModule implements AuthorizationModule { @Override public Boolean hasAccess(User user, Right access, EntityReference entity) { if (!ObjectUtils.allNotNull(user, access, entity) || !(access == Right.VIEW || access == Right.EDIT)) { return null; } Family family = this.familyRepository.get(entity.toString()); if (family == null) { return null; } for (Patient member : family.getMembers()) { AccessLevel grantedAccess = this.manager.getAccessLevel(member, user.getProfileDocument()); Right grantedRight = grantedAccess.getGrantedRight(); if (grantedRight != null && (grantedRight.equals(access) || (grantedRight.getImpliedRights() != null && grantedRight.getImpliedRights().contains(access)))) { return true; } } return null; }  @Override int getPriority(); @Override Boolean hasAccess(User user, Right access, EntityReference entity); }
AccessThroughFamilyMemberAuthorisationModule implements AuthorizationModule { @Override public Boolean hasAccess(User user, Right access, EntityReference entity) { if (!ObjectUtils.allNotNull(user, access, entity) || !(access == Right.VIEW || access == Right.EDIT)) { return null; } Family family = this.familyRepository.get(entity.toString()); if (family == null) { return null; } for (Patient member : family.getMembers()) { AccessLevel grantedAccess = this.manager.getAccessLevel(member, user.getProfileDocument()); Right grantedRight = grantedAccess.getGrantedRight(); if (grantedRight != null && (grantedRight.equals(access) || (grantedRight.getImpliedRights() != null && grantedRight.getImpliedRights().contains(access)))) { return true; } } return null; }  @Override int getPriority(); @Override Boolean hasAccess(User user, Right access, EntityReference entity);  }