protected boolean isEditingPermitted() { if (propertyPath != null) { MetaClass metaClass = propertyPath.getMetaClass(); return owner.security.isEntityAttrUpdatePermitted(metaClass, propertyPath.toString()); } return true; }
protected void applyPermissions(com.haulmont.cuba.gui.components.Component columnComponent) { if (columnComponent instanceof HasValueSource && columnComponent instanceof com.haulmont.cuba.gui.components.Component.Editable) { HasValueSource component = (HasValueSource) columnComponent; MetaPropertyPath propertyPath = ((EntityValueSource) component.getValueSource()).getMetaPropertyPath(); if (propertyPath != null) { com.haulmont.cuba.gui.components.Component.Editable editable = (com.haulmont.cuba.gui.components.Component.Editable) component; editable.setEditable(editable.isEditable() && security.isEntityAttrUpdatePermitted(propertyPath)); } } }
protected void enableEditableColumns(EntityTableItems<E> entityTableSource, Collection<MetaPropertyPath> propertyIds) { MetaClass metaClass = entityTableSource.getEntityMetaClass(); List<MetaPropertyPath> editableColumns = new ArrayList<>(propertyIds.size()); for (MetaPropertyPath propertyId : propertyIds) { if (!security.isEntityAttrUpdatePermitted(metaClass, propertyId.toString())) { continue; } Column column = getColumn(propertyId.toString()); if (BooleanUtils.isTrue(column.isEditable())) { com.vaadin.v7.ui.Table.ColumnGenerator generator = component.getColumnGenerator(column.getId()); if (generator != null) { if (generator instanceof SystemTableColumnGenerator) { // remove default generator component.removeGeneratedColumn(propertyId); } else { // do not edit generated columns continue; } } editableColumns.add(propertyId); } } setEditableColumns(editableColumns); }
Class<?> propertyType = metaProperty.getJavaType(); if (propertyRange.isDatatype() || propertyRange.isEnum()) { if (security.isEntityAttrUpdatePermitted(metaClass, propertyName)) view.addLocalProperty(propertyName); } else if (propertyRange.isClass()) { if (security.isEntityAttrUpdatePermitted(metaClass, propertyName)) { EntityImportView propertyImportView = buildFromJsonObject(propertyJsonObject.getAsJsonObject(), propertyMetaClass); view.addEmbeddedProperty(propertyName, propertyImportView); if (metaProperty.getType() == MetaProperty.Type.COMPOSITION) { JsonElement propertyJsonObject = entry.getValue(); if (security.isEntityAttrUpdatePermitted(metaClass, propertyName)) { if (propertyJsonObject.isJsonNull()) { if (security.isEntityAttrUpdatePermitted(metaClass, propertyName)) if (metaProperty.getRange().getCardinality() == Range.Cardinality.MANY_TO_ONE) { view.addManyToOneProperty(propertyName, ReferenceImportBehaviour.ERROR_ON_MISSING); switch (metaProperty.getRange().getCardinality()) { case MANY_TO_MANY: if (security.isEntityAttrUpdatePermitted(metaClass, propertyName)) view.addManyToManyProperty(propertyName, ReferenceImportBehaviour.ERROR_ON_MISSING, CollectionImportPolicy.REMOVE_ABSENT_ITEMS); break; if (security.isEntityAttrUpdatePermitted(metaClass, propertyName)) view.addOneToManyProperty(propertyName, propertyImportView, CollectionImportPolicy.REMOVE_ABSENT_ITEMS);
protected void loadEditable(FieldGroup resultComponent, FieldGroup.FieldConfig field) { Element element = field.getXmlDescriptor(); if (element != null) { String editable = element.attributeValue("editable"); if (StringUtils.isNotEmpty(editable)) { field.setEditable(Boolean.parseBoolean(editable)); } } if (!field.isCustom() && BooleanUtils.isNotFalse(field.isEditable())) { MetaClass metaClass = getMetaClass(resultComponent, field); MetaPropertyPath propertyPath = getMetadataTools().resolveMetaPropertyPath(metaClass, field.getProperty()); checkNotNullArgument(propertyPath, "Could not resolve property path '%s' in '%s'", field.getId(), metaClass); if (!getSecurity().isEntityAttrUpdatePermitted(metaClass, propertyPath.toString())) { field.setEditable(false); } } }
if (column.isEditable() && (columnId instanceof MetaPropertyPath)) { MetaPropertyPath propertyPath = ((MetaPropertyPath) columnId); if (security.isEntityAttrUpdatePermitted(metaClass, propertyPath.toString())) { if (editableColumns.isEmpty()) { editableColumns = new ArrayList<>();
protected void applyPermissions(Component fieldComponent) { if (fieldComponent instanceof DatasourceComponent) { DatasourceComponent dsComponent = (DatasourceComponent) fieldComponent; MetaPropertyPath propertyPath = dsComponent.getMetaPropertyPath(); Datasource datasource = dsComponent.getDatasource(); if (datasource != null && propertyPath != null) { MetaClass metaClass = datasource.getMetaClass(); Security security = getSecurity(); if (!security.isEntityAttrUpdatePermitted(metaClass, propertyPath.toString()) && dsComponent instanceof Component.Editable) { ((Component.Editable) dsComponent).setEditable(false); } if (!security.isEntityAttrReadPermitted(metaClass, propertyPath.toString())) { dsComponent.setVisible(false); } } } }
protected void createTimeZoneField() { FieldGroup.FieldConfig timeZoneFc = fieldGroupRight.getFieldNN("timeZone"); HBoxLayout hbox = uiComponents.create(HBoxLayout.class); hbox.setSpacing(true); timeZoneLookup = uiComponents.create(LookupField.TYPE_STRING); timeZoneLookup.setDatasource(timeZoneFc.getTargetDatasource(), timeZoneFc.getProperty()); timeZoneLookup.setRequired(false); MetaClass userMetaClass = userDs.getMetaClass(); timeZoneLookup.setEditable(fieldGroupRight.isEditable() && security.isEntityAttrUpdatePermitted(userMetaClass, timeZoneFc.getProperty())); Map<String, String> options = new TreeMap<>(); for (String id : TimeZone.getAvailableIDs()) { TimeZone timeZone = TimeZone.getTimeZone(id); options.put(timeZones.getDisplayNameLong(timeZone), id); } timeZoneLookup.setOptionsMap(options); hbox.add(timeZoneLookup); CheckBox autoDetectField = uiComponents.create(CheckBox.class); autoDetectField.setDatasource(timeZoneFc.getTargetDatasource(), "timeZoneAuto"); autoDetectField.setCaption(messages.getMainMessage("timeZone.auto")); autoDetectField.setDescription(messages.getMainMessage("timeZone.auto.descr")); autoDetectField.setAlignment(Alignment.MIDDLE_RIGHT); autoDetectField.setEditable(fieldGroupRight.isEditable() && security.isEntityAttrUpdatePermitted(userMetaClass, "timeZoneAuto")); hbox.add(autoDetectField); hbox.expand(timeZoneLookup); timeZoneFc.setComponent(hbox); }
protected void loadEditable(FieldGroup fieldGroup, FieldGroup.FieldConfig field) { if (fieldGroup.isEditable()) { MetaClass metaClass = rds.resolveCategorizedEntityClass(); MetaPropertyPath propertyPath = dynamicAttributesTools.getMetaPropertyPath(metaClass, field.getProperty()); checkNotNullArgument(propertyPath, "Could not resolve property path '%s' in '%s'", field.getId(), metaClass); boolean editableFromPermissions = security.isEntityAttrUpdatePermitted(metaClass, propertyPath.toString()); if (!editableFromPermissions) { field.setEditable(false); } boolean visibleFromPermissions = security.isEntityAttrReadPermitted(metaClass, propertyPath.toString()); if (!visibleFromPermissions) { field.setVisible(false); } } }
protected boolean checkRemovePermission() { ContainerDataUnit containerDataUnit = (ContainerDataUnit) target.getItems(); MetaClass metaClass = containerDataUnit.getEntityMetaClass(); if (metaClass == null) { return false; } boolean entityOpPermitted = security.isEntityOpPermitted(metaClass, EntityOp.DELETE); if (!entityOpPermitted) { return false; } if (containerDataUnit.getContainer() instanceof Nested) { Nested nestedContainer = (Nested) containerDataUnit.getContainer(); MetaClass masterMetaClass = nestedContainer.getMaster().getEntityMetaClass(); MetaProperty metaProperty = masterMetaClass.getPropertyNN(nestedContainer.getProperty()); boolean attrPermitted = security.isEntityAttrUpdatePermitted(masterMetaClass, metaProperty.getName()); if (!attrPermitted) { return false; } } return true; }
@Override protected boolean isPermitted() { if (target == null || !(target.getItems() instanceof ContainerDataUnit)) { return false; } ContainerDataUnit containerDataUnit = (ContainerDataUnit) target.getItems(); MetaClass metaClass = containerDataUnit.getEntityMetaClass(); if (metaClass == null) { return false; } if (containerDataUnit.getContainer() instanceof Nested) { Nested nestedContainer = (Nested) containerDataUnit.getContainer(); MetaClass masterMetaClass = nestedContainer.getMaster().getEntityMetaClass(); MetaProperty metaProperty = masterMetaClass.getPropertyNN(nestedContainer.getProperty()); boolean attrPermitted = security.isEntityAttrUpdatePermitted(masterMetaClass, metaProperty.getName()); if (!attrPermitted) { return false; } } return super.isPermitted(); }
@Override protected boolean isPermitted() { if (target == null || !(target.getItems() instanceof ContainerDataUnit)) { return false; } ContainerDataUnit containerDataUnit = (ContainerDataUnit) target.getItems(); MetaClass metaClass = containerDataUnit.getEntityMetaClass(); if (metaClass == null) { return false; } if (containerDataUnit.getContainer() instanceof Nested) { Nested nestedContainer = (Nested) containerDataUnit.getContainer(); MetaClass masterMetaClass = nestedContainer.getMaster().getEntityMetaClass(); MetaProperty metaProperty = masterMetaClass.getPropertyNN(nestedContainer.getProperty()); boolean attrPermitted = security.isEntityAttrUpdatePermitted(masterMetaClass, metaProperty.getName()); if (!attrPermitted) { return false; } } return super.isPermitted(); }
&& security.isEntityAttrUpdatePermitted(reportTemplate.getMetaClass(), "content");
if (!security.isEntityAttrUpdatePermitted(metaPropertyPath)) { ((Component.Editable) component).setEditable(false);
moveConstraintToGroup(constraintsTable.getSingleSelected()) ); if (!security.isEntityAttrUpdatePermitted(metadata.getClass(Constraint.class), "group")) { moveToGroupAction.setEnabled(false);
((Editable) component).setEditable(security.isEntityAttrUpdatePermitted(entityValueSource.getEntityMetaClass(), propertyPath.toString()));