@Test public void noActionWithNonDocumentRight() throws ComponentLookupException { Assert.assertNull(this.mocker.getComponentUnderTest().hasAccess(this.user, Right.REGISTER, this.doc)); Assert.assertNull(this.mocker.getComponentUnderTest().hasAccess(this.user, Right.PROGRAM, 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; } Family family = this.familyRepository.get(entity.toString()); if (family == null) { return null; } String ownerStr = (String) this.dab.getProperty(family.getDocumentReference(), this.resolver.resolve(Owner.CLASS_REFERENCE), Owner.PROPERTY_NAME); DocumentReference owner = this.strResolver.resolve(ownerStr); if (isGuestOwner(ownerStr, user) || user != null && owner.equals(user.getProfileDocument())) { return true; } if (this.auth.hasAccess(user, Right.ADMIN, entity)) { 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; } Family family = this.familyRepository.get(entity.toString()); if (family == null) { return null; } String ownerStr = (String) this.dab.getProperty(family.getDocumentReference(), this.resolver.resolve(Owner.CLASS_REFERENCE), Owner.PROPERTY_NAME); DocumentReference owner = this.strResolver.resolve(ownerStr); if (isGuestOwner(ownerStr, user) || user != null && owner.equals(user.getProfileDocument())) { return true; } if (this.auth.hasAccess(user, Right.ADMIN, entity)) { 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; } Family family = this.familyRepository.get(entity.toString()); if (family == null) { return null; } String ownerStr = (String) this.dab.getProperty(family.getDocumentReference(), this.resolver.resolve(Owner.CLASS_REFERENCE), Owner.PROPERTY_NAME); DocumentReference owner = this.strResolver.resolve(ownerStr); if (isGuestOwner(ownerStr, user) || user != null && owner.equals(user.getProfileDocument())) { return true; } if (this.auth.hasAccess(user, Right.ADMIN, entity)) { 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; } Family family = this.familyRepository.get(entity.toString()); if (family == null) { return null; } String ownerStr = (String) this.dab.getProperty(family.getDocumentReference(), this.resolver.resolve(Owner.CLASS_REFERENCE), Owner.PROPERTY_NAME); DocumentReference owner = this.strResolver.resolve(ownerStr); if (isGuestOwner(ownerStr, user) || user != null && owner.equals(user.getProfileDocument())) { return true; } if (this.auth.hasAccess(user, Right.ADMIN, entity)) { 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; } Family family = this.familyRepository.get(entity.toString()); if (family == null) { return null; } String ownerStr = (String) this.dab.getProperty(family.getDocumentReference(), this.resolver.resolve(Owner.CLASS_REFERENCE), Owner.PROPERTY_NAME); DocumentReference owner = this.strResolver.resolve(ownerStr); if (isGuestOwner(ownerStr, user) || user != null && owner.equals(user.getProfileDocument())) { return true; } if (this.auth.hasAccess(user, Right.ADMIN, entity)) { return true; } return null; }  @Override int getPriority(); @Override Boolean hasAccess(User user, Right access, EntityReference entity);  }