Как корректно переопределить SecurityImpl?

В дополнение к стандартной логике проверки прав, для пары сущностный требуется реализовать кстомную логику проверки прав на редактирование нескольких атрибутов.
На данном этапе мы можем “пока обойтись” setEnable(false) в контроллере экрана для соответсвующих контролов, но в перспективе потребуется REST API.
Поэтому, пытаюсь сразу воткнуться в SecurityImpl, переопределить его метод isEntityAttrUpdatePermitted и добавив в дополнительную проверку.

Создал тестовый проект, в нем создан новый класс ExtSecurityImpl:

package com.company.testcustonsecur.core;

import com.haulmont.chile.core.model.MetaClass;
import com.haulmont.cuba.core.sys.SecurityImpl;

public class ExtSecurityImpl extends SecurityImpl{
    
    @Override
    public boolean isEntityAttrUpdatePermitted(MetaClass metaClass, String propertyPath) {
        return super.isEntityAttrUpdatePermitted(metaClass, propertyPath);
    }

}

Зарегистрировал класс ExtSecurityImpl в spring.xml модуля core проекта:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd">

    <!-- Annotation-based beans -->
    <context:component-scan base-package="com.company.testcustonsecur"/>
    <bean id="cuba_Security" class="com.company.testcustonsecur.core.ExtSecurityImpl"/>

</beans>

Уже на этом этапе, при попытке запуска приложения сыпятся ошибки:

<....>
22:34:06.550 WARN  c.h.c.c.s.CubaCoreApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cuba_UserManagementService': Unsatisfied dependency expressed through field 'security'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cuba_Security': Unsatisfied dependency expressed through field 'security'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.haulmont.cuba.core.PersistenceSecurity' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@javax.inject.Inject()}
22:34:06.571 ERROR c.h.c.c.s.AbstractWebAppContextLoader - Error initializing application
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cuba_UserManagementService': Unsatisfied dependency expressed through field 'security'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cuba_Security': Unsatisfied dependency expressed through field 'security'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.haulmont.cuba.core.PersistenceSecurity' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@javax.inject.Inject()}
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:588) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
        at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
<....>

К сожалению, в документации информации о возможностях и тонкостях переопределения SecurityImpl не нашел.
Может есть сампл, в котором можно подсмотреть реализацию подобной задачи с SecurityImpl??

С учетом появившегося функционала контроля доступа к атрибутам сущностей, вопрос рассосался сам собой.

Если кому-то тоже требуется дополнительно ограничивать доступ к отдельным атрибутам сущности в зависимости от значений атрибутов сущности, причем железно из кода - маленький тестовый проект с единственным экраном в приложении.

Если под Admin в field1 вводим HIDE, то field2 скрывается с формы на лету.
Если в field1 вводим READ, то то field2 на лету становится доступным только для чтения.
В Entity manager поведение аналогичное, за исключением применения ограничений на лету в процессе заполнения атрибутов.

testAttrAccess.zip (85,4 КБ)

1 симпатия

При переопределение Security необходимо наследоваться от класса com.haulmont.cuba.core.sys.PersistenceSecurityImpl.

Далее зарегистрировать бин в spiring.xml core модуля в виде:

<bean id="cuba_Security" name="cuba_PersistenceSecurity"
          class="com.company.ExtPersistenceSecurityImpl"/>