public static boolean isRequired(SecurityState securityState, String attributeName) { if (securityState == null) { return false; } return securityState.getRequiredAttributes().contains(attributeName); }
jsonObject.put(HIDDEN_ATTRIBUTES_KEY, securityState.getHiddenAttributes()); if (!securityState.getRequiredAttributes().isEmpty()) { jsonObject.put(REQUIRED_ATTRIBUTES_KEY, securityState.getRequiredAttributes());
protected void checkRequiredAttributes(Entity entity) { SecurityState securityState = getSecurityState(entity); if (securityState != null && !securityState.getRequiredAttributes().isEmpty()) { for (MetaProperty metaProperty : entity.getMetaClass().getProperties()) { String propertyName = metaProperty.getName(); if (BaseEntityInternalAccess.isRequired(securityState, propertyName) && entity.getValue(propertyName) == null) { throw new RowLevelSecurityException(format("Attribute [%s] is required for entity %s", propertyName, entity), entity.getMetaClass().getName()); } } } }
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; }