Class RemoteFieldReadAccess
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final recordThe rules a field of a node is checked against: its type, the node itself when it has rules of its own, and the fields those rules are set on. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate final Map<org.alfresco.service.namespace.QName, RemoteFieldReadAccess.RuleTarget> private static final Stringprivate static final org.apache.commons.logging.Logprivate final org.alfresco.service.namespace.NamespaceServiceprivate final Map<org.alfresco.service.cmr.repository.NodeRef, RemoteFieldReadAccess.RuleTarget> private final SecurityServiceprivate final org.alfresco.service.cmr.repository.NodeService -
Constructor Summary
ConstructorsConstructorDescriptionRemoteFieldReadAccess(SecurityService securityService, org.alfresco.service.cmr.repository.NodeService unsecuredNodeService, org.alfresco.service.namespace.NamespaceService namespaceService) Constructor for RemoteFieldReadAccess. -
Method Summary
Modifier and TypeMethodDescriptionprivate booleancanRead(RemoteFieldReadAccess.RuleTarget ruleTarget, org.alfresco.service.namespace.QName fieldName) booleancanRead(org.alfresco.service.cmr.repository.NodeRef nodeRef, org.alfresco.service.namespace.QName fieldName) Whether the current user may read a field of a node.booleancanReadOnType(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.private booleancomputeReadAccess(RemoteFieldReadAccess.RuleTarget ruleTarget, org.alfresco.service.namespace.QName fieldName) private RemoteFieldReadAccess.RuleTargetcreateRuleTarget(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.private booleanhasOwnRules(org.alfresco.service.cmr.repository.NodeRef nodeRef) private RemoteFieldReadAccess.RuleTargetresolveRuleTarget(org.alfresco.service.cmr.repository.NodeRef nodeRef) private Set<org.alfresco.service.namespace.QName> toFieldQNames(Set<String> prefixedFieldNames) Rules also name entries that are not fields, such asView-documents, or fields of a model no longer deployed: those never match a field and are left out.
-
Field Details
-
logger
private static final org.apache.commons.logging.Log logger -
GLOBAL_SCOPE
- See Also:
-
KEY_SEPARATOR
- See Also:
-
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
-
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 rulesunsecuredNodeService- the node service used to read the type and aspects of a nodenamespaceService- 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 fieldfieldName- 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 tofieldName- 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
Rules also name entries that are not fields, such asView-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)
-