@Test public void openVisibilityAllowsEdit() throws ComponentLookupException { when(this.helper.getVisibility(this.primaryEntity)).thenReturn(this.openVisibility); 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; } PrimaryEntity primaryEntity = this.resolver.resolveEntity(entity.toString()); if (primaryEntity == null) { return null; } Visibility visibility = this.helper.getVisibility(primaryEntity); if (visibility == null) { return null; } Right grantedRight = visibility.getDefaultAccessLevel().getGrantedRight(); if (user != null && user.getProfileDocument() != null && (grantedRight.equals(access) || (grantedRight.getImpliedRights() != null && grantedRight.getImpliedRights().contains(access)))) { return true; } return null; }
VisibilityAccessAuthorizationModule 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; } PrimaryEntity primaryEntity = this.resolver.resolveEntity(entity.toString()); if (primaryEntity == null) { return null; } Visibility visibility = this.helper.getVisibility(primaryEntity); if (visibility == null) { return null; } Right grantedRight = visibility.getDefaultAccessLevel().getGrantedRight(); if (user != null && user.getProfileDocument() != null && (grantedRight.equals(access) || (grantedRight.getImpliedRights() != null && grantedRight.getImpliedRights().contains(access)))) { return true; } return null; } }
VisibilityAccessAuthorizationModule 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; } PrimaryEntity primaryEntity = this.resolver.resolveEntity(entity.toString()); if (primaryEntity == null) { return null; } Visibility visibility = this.helper.getVisibility(primaryEntity); if (visibility == null) { return null; } Right grantedRight = visibility.getDefaultAccessLevel().getGrantedRight(); if (user != null && user.getProfileDocument() != null && (grantedRight.equals(access) || (grantedRight.getImpliedRights() != null && grantedRight.getImpliedRights().contains(access)))) { return true; } return null; }  }
VisibilityAccessAuthorizationModule 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; } PrimaryEntity primaryEntity = this.resolver.resolveEntity(entity.toString()); if (primaryEntity == null) { return null; } Visibility visibility = this.helper.getVisibility(primaryEntity); if (visibility == null) { return null; } Right grantedRight = visibility.getDefaultAccessLevel().getGrantedRight(); if (user != null && user.getProfileDocument() != 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); }
VisibilityAccessAuthorizationModule 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; } PrimaryEntity primaryEntity = this.resolver.resolveEntity(entity.toString()); if (primaryEntity == null) { return null; } Visibility visibility = this.helper.getVisibility(primaryEntity); if (visibility == null) { return null; } Right grantedRight = visibility.getDefaultAccessLevel().getGrantedRight(); if (user != null && user.getProfileDocument() != 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);  }