Class RemoteFieldReadAccess

java.lang.Object
fr.becpg.repo.entity.remote.extractor.RemoteFieldReadAccess

public class RemoteFieldReadAccess extends Object
Field level read access of the remote export: whether a security rule hides a field from the current user.

SecurityService.computeAccessMode(NodeRef, QName, QName) resolves the rules of a node on every call, and an export reads dozens of fields on hundreds of nodes that share a handful of types. The answer depends on the rules in force, the node type and the field only, so it is computed once per such triple and kept for the request. A field no rule mentions is readable whoever asks: the ruled fields of a type are read once per request, and the full evaluation, which starts by resolving the authorities of the user, is only paid for those few fields.

The rules in force are the global ones, except on a node carrying a local rule (sec:securityRef) or on an entity template, which the service treats apart: those nodes get a scope of their own. The node level restrictions of the security plugins are left out on purpose: whether the node itself may be read is a question for its ACL, already answered by the search or by the visitor.

Not thread safe: one instance per visitor, that is per request.

Author:
matthieu
  • Field Details

    • logger

      private static final org.apache.commons.logging.Log logger
    • GLOBAL_SCOPE

      private static final String GLOBAL_SCOPE
      See Also:
    • KEY_SEPARATOR

      private static final String KEY_SEPARATOR
      See Also:
    • securityService

      private final SecurityService securityService
    • unsecuredNodeService

      private final org.alfresco.service.cmr.repository.NodeService unsecuredNodeService
    • namespaceService

      private final org.alfresco.service.namespace.NamespaceService namespaceService
    • ruleTargetByNode

      private final Map<org.alfresco.service.cmr.repository.NodeRef,RemoteFieldReadAccess.RuleTarget> ruleTargetByNode
    • globalRuleTargetByType

      private final Map<org.alfresco.service.namespace.QName,RemoteFieldReadAccess.RuleTarget> globalRuleTargetByType
    • fieldsWithRulesByType

      private final Map<String,Set<org.alfresco.service.namespace.QName>> fieldsWithRulesByType
    • readAccessByField

      private final Map<String,Boolean> readAccessByField
  • Constructor Details

    • RemoteFieldReadAccess

      public RemoteFieldReadAccess(SecurityService securityService, org.alfresco.service.cmr.repository.NodeService unsecuredNodeService, org.alfresco.service.namespace.NamespaceService namespaceService)

      Constructor for RemoteFieldReadAccess.

      Parameters:
      securityService - the service evaluating the security rules
      unsecuredNodeService - the node service used to read the type and aspects of a node
      namespaceService - the namespace service used to name a field as the rules do
  • Method Details

    • canRead

      public boolean canRead(org.alfresco.service.cmr.repository.NodeRef nodeRef, org.alfresco.service.namespace.QName fieldName)
      Whether the current user may read a field of a node.
      Parameters:
      nodeRef - the node holding the field
      fieldName - the property or association
      Returns:
      false when a security rule hides the field from the current user
    • canReadOnType

      public boolean canReadOnType(org.alfresco.service.namespace.QName nodeType, org.alfresco.service.namespace.QName fieldName)
      Whether the current user may read a field of a type under the global rules, for a node that is no longer in the repository, such as an entity serialized in a version archive.
      Parameters:
      nodeType - the type the field belongs to
      fieldName - the property or association
      Returns:
      false when a security rule hides the field from the current user
    • canRead

      private boolean canRead(RemoteFieldReadAccess.RuleTarget ruleTarget, org.alfresco.service.namespace.QName fieldName)
    • createRuleTarget

      private RemoteFieldReadAccess.RuleTarget createRuleTarget(org.alfresco.service.namespace.QName nodeType, Optional<org.alfresco.service.cmr.repository.NodeRef> ruleScope)
      Without a rule entry on the field, the access mode is read or write, never none: a default read only group gives read access and the security plugins never go below it.
    • toFieldQNames

      private Set<org.alfresco.service.namespace.QName> toFieldQNames(Set<String> prefixedFieldNames)
      Rules also name entries that are not fields, such as View-documents, or fields of a model no longer deployed: those never match a field and are left out.
    • computeReadAccess

      private boolean computeReadAccess(RemoteFieldReadAccess.RuleTarget ruleTarget, org.alfresco.service.namespace.QName fieldName)
    • resolveRuleTarget

      private RemoteFieldReadAccess.RuleTarget resolveRuleTarget(org.alfresco.service.cmr.repository.NodeRef nodeRef)
    • hasOwnRules

      private boolean hasOwnRules(org.alfresco.service.cmr.repository.NodeRef nodeRef)