public static boolean isHiddenOrReadOnly(SecurityState securityState, String attributeName) { if (securityState == null) { return false; } return securityState.getHiddenAttributes().contains(attributeName) || securityState.getReadonlyAttributes().contains(attributeName); }
jsonObject.put(READ_ONLY_ATTRIBUTES_KEY, securityState.getReadonlyAttributes()); if (!securityState.getHiddenAttributes().isEmpty()) { jsonObject.put(HIDDEN_ATTRIBUTES_KEY, securityState.getHiddenAttributes());
@Override public void visit(Entity entity, MetaProperty property) { MetaClass metaClass = metadata.getClassNN(entity.getClass()); if (!security.isEntityAttrReadPermitted(metaClass, property.getName())) { addInaccessibleAttribute(entity, property.getName()); if (!metadataTools.isSystem(property) && !property.isReadOnly()) { setNullPropertyValue(entity, property); } } SecurityState securityState = BaseEntityInternalAccess.getSecurityState(entity); if (securityState != null && securityState.getHiddenAttributes().contains(property.getName())) { addInaccessibleAttribute(entity, property.getName()); if (!metadataTools.isSystem(property)) { setNullPropertyValue(entity, property); } } } }
@Override public void visit(Entity entity, MetaProperty property) { MetaClass metaClass = metadata.getClassNN(entity.getClass()); String propertyName = property.getName(); if (!security.isEntityAttrReadPermitted(metaClass, propertyName)) { addInaccessibleAttribute(entity, propertyName); if (!metadataTools.isSystem(property) && !property.isReadOnly()) { setNullPropertyValue(entity, property); } } SecurityState securityState = BaseEntityInternalAccess.getSecurityState(entity); if (securityState != null && securityState.getHiddenAttributes().contains(property.getName())) { addInaccessibleAttribute(entity, property.getName()); if (!metadataTools.isSystem(property)) { setNullPropertyValue(entity, property); } } } }
@Override public void visit(Entity entity, MetaProperty property) { MetaClass metaClass = metadata.getClassNN(entity.getClass()); if (!security.isEntityAttrReadPermitted(metaClass, property.getName())) { addInaccessibleAttribute((BaseGenericIdEntity) entity, property.getName()); if (!metadataTools.isSystem(property) && !property.isReadOnly()) { // Using reflective access to field because the attribute can be unfetched if loading not partial entities, // which is the case when in-memory constraints exist BaseEntityInternalAccess.setValue(entity, property.getName(), null); } } SecurityState securityState = BaseEntityInternalAccess.getSecurityState(entity); if (securityState != null && securityState.getHiddenAttributes().contains(property.getName())) { if (!metadataTools.isSystem(property)) { // Using reflective access to field because the attribute can be unfetched if loading not partial entities, // which is the case when in-memory constraints exist BaseEntityInternalAccess.setValue(entity, property.getName(), null); } } } }
protected ComponentState calculateComponentState(Entity entity, MetaPropertyPath propertyPath) { MetaProperty[] metaProperties = propertyPath.getMetaProperties(); ComponentState componentState = new ComponentState(); for (int i = 0; i < metaProperties.length; i++) { MetaProperty metaProperty = metaProperties[i]; String name = metaProperty.getName(); SecurityState securityState = getSecurityState(entity); if (securityState != null) { componentState.hidden = test(componentState.hidden, securityState.getHiddenAttributes(), name); componentState.readOnly = test(componentState.readOnly, securityState.getReadonlyAttributes(), name); if (i == metaProperties.length - 1) { componentState.required = test(componentState.required, securityState.getRequiredAttributes(), name); } } if (i != metaProperties.length - 1) { entity = entity.getValue(name); if (entity == null) { break; } } } return componentState; }