private static boolean isRestrictionProperty(String propertyName) { return !AccessControlConstants.ACE_PROPERTY_NAMES.contains(propertyName) && !NamespaceRegistry.PREFIX_JCR.equals(Text.getNamespacePrefix(propertyName)); } }
/** * Returns {@code false} if the specified attribute name doesn't have * a 'jcr' or 'rep' namespace prefix; {@code true} otherwise. This is * a lazy evaluation in order to avoid testing the defining node type of * the associated jcr property. * * @param attributeName The attribute name. * @return {@code true} if the specified property name doesn't seem * to represent repository internal information. */ static boolean isInfoAttribute(String attributeName) { String prefix = Text.getNamespacePrefix(attributeName); return !RESERVED_PREFIXES.contains(prefix); }
/** * Returns {@code false} if the specified attribute name doesn't have * a 'jcr' or 'rep' namespace prefix; {@code true} otherwise. This is * a lazy evaluation in order to avoid testing the defining node type of * the associated jcr property. * * @param attributeName The attribute name. * @return {@code true} if the specified property name doesn't seem * to represent repository internal information. */ static boolean isInfoAttribute(String attributeName) { String prefix = Text.getNamespacePrefix(attributeName); return !RESERVED_PREFIXES.contains(prefix); }
private static boolean isRestrictionProperty(String propertyName) { return !AccessControlConstants.ACE_PROPERTY_NAMES.contains(propertyName) && !NamespaceRegistry.PREFIX_JCR.equals(Text.getNamespacePrefix(propertyName)); } }
/** * Returns <code>false</code> if the specified attribute name doesn't have * a 'jcr' or 'rep' namespace prefix; <code>true</code> otherwise. This is * a lazy evaluation in order to avoid testing the defining node type of * the associated jcr property. * * @param propertyName * @return <code>true</code> if the specified property name doesn't seem * to represent repository internal information. */ private static boolean isInfoAttribute(String propertyName) { String prefix = Text.getNamespacePrefix(propertyName); return !Name.NS_JCR_PREFIX.equals(prefix) && !Name.NS_REP_PREFIX.equals(prefix); }
/** * Returns <code>false</code> if the specified attribute name doesn't have * a 'jcr' or 'rep' namespace prefix; <code>true</code> otherwise. This is * a lazy evaluation in order to avoid testing the defining node type of * the associated jcr property. * * @param propertyName * @return <code>true</code> if the specified property name doesn't seem * to represent repository internal information. */ private static boolean isInfoAttribute(String propertyName) { String prefix = Text.getNamespacePrefix(propertyName); return !Name.NS_JCR_PREFIX.equals(prefix) && !Name.NS_REP_PREFIX.equals(prefix); }
/** * Returns {@code false} if the specified attribute name doesn't have * a 'jcr' or 'rep' namespace prefix; {@code true} otherwise. This is * a lazy evaluation in order to avoid testing the defining node type of * the associated jcr property. * * @param attributeName The attribute name. * @return {@code true} if the specified property name doesn't seem * to represent repository internal information. */ private boolean isInfoAttribute(@NotNull String attributeName) { String prefix = Text.getNamespacePrefix(attributeName); return !NamespaceConstants.RESERVED_PREFIXES.contains(prefix); } }
/** * Returns {@code false} if the specified attribute name doesn't have * a 'jcr' or 'rep' namespace prefix; {@code true} otherwise. This is * a lazy evaluation in order to avoid testing the defining node type of * the associated jcr property. * * @param attributeName The attribute name. * @return {@code true} if the specified property name doesn't seem * to represent repository internal information. */ private boolean isInfoAttribute(@Nonnull String attributeName) { String prefix = Text.getNamespacePrefix(attributeName); return !NamespaceConstants.RESERVED_PREFIXES.contains(prefix); } }
/** * Returns {@code false} if the specified attribute name doesn't have * a 'jcr' or 'rep' namespace prefix; {@code true} otherwise. This is * a lazy evaluation in order to avoid testing the defining node type of * the associated jcr property. * * @param attributeName The attribute name. * @return {@code true} if the specified property name doesn't seem * to represent repository internal information. */ private boolean isInfoAttribute(@NotNull String attributeName) { String prefix = Text.getNamespacePrefix(attributeName); return !NamespaceConstants.RESERVED_PREFIXES.contains(prefix); } }
@Override public boolean matches(@NotNull Tree tree, @Nullable PropertyState property) { String name = (property != null) ? property.getName() : tree.getName(); String prefix = Text.getNamespacePrefix(name); if (!prefix.isEmpty()) { for (String p : prefixes) { if (prefix.equals(p)) { return true; } } } return false; }
private Name getName(String jcrName, Map<String,String> namespaces) { String prefix = Text.getNamespacePrefix(jcrName); String uri = (Name.NS_EMPTY_PREFIX.equals(prefix)) ? Name.NS_DEFAULT_URI : namespaces.get(prefix); return NAME_FACTORY.create(uri, Text.getLocalName(jcrName)); }
private Name getName(String jcrName, Map<String,String> namespaces) { String prefix = Text.getNamespacePrefix(jcrName); String uri = (Name.NS_EMPTY_PREFIX.equals(prefix)) ? Name.NS_DEFAULT_URI : namespaces.get(prefix); return NAME_FACTORY.create(uri, Text.getLocalName(jcrName)); }
@Override public boolean matches(@NotNull Tree tree, @Nullable PropertyState property) { String name = (property != null) ? property.getName() : tree.getName(); String prefix = Text.getNamespacePrefix(name); if (!prefix.isEmpty()) { for (String p : prefixes) { if (prefix.equals(p)) { return true; } } } return false; }
@Override public boolean matches(@Nonnull Tree tree, @Nullable PropertyState property) { String name = (property != null) ? property.getName() : tree.getName(); String prefix = Text.getNamespacePrefix(name); if (!prefix.isEmpty()) { for (String p : prefixes) { if (prefix.equals(p)) { return true; } } } return false; }
public CurrentUserPrivilegeSetProperty asDavProperty() throws RepositoryException { List<Privilege> davPrivs = new ArrayList<Privilege>(); for (javax.jcr.security.Privilege privilege : session.getAccessControlManager().getPrivileges(absPath)) { String privilegeName = privilege.getName(); String prefix = Text.getNamespacePrefix(privilegeName); Namespace ns = (prefix.isEmpty()) ? Namespace.EMPTY_NAMESPACE : Namespace.getNamespace(prefix, session.getNamespaceURI(prefix)); davPrivs.add(Privilege.getPrivilege(Text.getLocalName(privilegeName), ns)); } return new CurrentUserPrivilegeSetProperty(davPrivs.toArray(new Privilege[davPrivs.size()])); } }
private SupportedPrivilege createSupportedPrivilege(Privilege privilege) throws RepositoryException { String privilegeName = privilege.getName(); String localName = Text.getLocalName(privilegeName); String prefix = Text.getNamespacePrefix(privilegeName); Namespace ns = (prefix.isEmpty()) ? Namespace.EMPTY_NAMESPACE : Namespace.getNamespace(prefix, session.getNamespaceURI(prefix)); org.apache.jackrabbit.webdav.security.Privilege davPrivilege = org.apache.jackrabbit.webdav.security.Privilege.getPrivilege(localName, ns); SupportedPrivilege[] aggregates = (privilege.isAggregate()) ? getDeclaredAggregates(privilege) : null; SupportedPrivilege sp = new SupportedPrivilege(davPrivilege, null, null, privilege.isAbstract(), aggregates); if (!aggregated.contains(privilegeName)) { supportedPrivileges.put(privilegeName, sp); } return sp; }
@Override public Validator childNodeAdded(String name, NodeState after) throws CommitFailedException { if (isPrivilegeDefinition(after)) { // make sure privileges have been initialized before Tree parent = getPrivilegesTree(rootBefore); // the following characteristics are expected to be validated elsewhere: // - permission to allow privilege registration -> permission validator. // - name collisions (-> delegated to NodeTypeValidator since sms are not allowed) // - name must be valid (-> delegated to NameValidator) // name may not contain reserved namespace prefix if (NamespaceConstants.RESERVED_PREFIXES.contains(Text.getNamespacePrefix(name))) { String msg = "Failed to register custom privilege: Definition uses reserved namespace: " + name; throw new CommitFailedException("Privilege", 1, msg); } // validate the definition Tree tree = treeProvider.createReadOnlyTree(parent, name, after); validateDefinition(tree); } // privilege definitions may not have child nodes (or another type of nodes // that is not handled by this validator anyway). return null; }
@Override public Validator childNodeAdded(String name, NodeState after) throws CommitFailedException { if (isPrivilegeDefinition(after)) { // make sure privileges have been initialized before getPrivilegesTree(rootBefore); // the following characteristics are expected to be validated elsewhere: // - permission to allow privilege registration -> permission validator. // - name collisions (-> delegated to NodeTypeValidator since sms are not allowed) // - name must be valid (-> delegated to NameValidator) // name may not contain reserved namespace prefix if (NamespaceConstants.RESERVED_PREFIXES.contains(Text.getNamespacePrefix(name))) { String msg = "Failed to register custom privilege: Definition uses reserved namespace: " + name; throw new CommitFailedException("Privilege", 1, msg); } // validate the definition Tree tree = new ImmutableTree(ImmutableTree.ParentProvider.UNSUPPORTED, name, after); validateDefinition(tree); } // privilege definitions may not have child nodes (or another type of nodes // that is not handled by this validator anyway). return null; }
@Override public Validator childNodeAdded(String name, NodeState after) throws CommitFailedException { if (isPrivilegeDefinition(after)) { // make sure privileges have been initialized before Tree parent = getPrivilegesTree(rootBefore); // the following characteristics are expected to be validated elsewhere: // - permission to allow privilege registration -> permission validator. // - name collisions (-> delegated to NodeTypeValidator since sms are not allowed) // - name must be valid (-> delegated to NameValidator) // name may not contain reserved namespace prefix if (NamespaceConstants.RESERVED_PREFIXES.contains(Text.getNamespacePrefix(name))) { String msg = "Failed to register custom privilege: Definition uses reserved namespace: " + name; throw new CommitFailedException("Privilege", 1, msg); } // validate the definition Tree tree = treeProvider.createReadOnlyTree(parent, name, after); validateDefinition(tree); } // privilege definitions may not have child nodes (or another type of nodes // that is not handled by this validator anyway). return null; }
/** * Builds a webdav property name from the given jcrName. In case the jcrName * contains a namespace prefix that would conflict with any of the predefined * webdav namespaces a new prefix is assigned.<br> * Please note, that the local part of the jcrName is checked for XML * compatibility by calling {@link ISO9075#encode(String)} * * @param jcrName name of the jcr property * @param session session * @return a <code>DavPropertyName</code> for the given jcr name. * @throws RepositoryException if an error during repository access occurs. */ private DavPropertyName getDavName(String jcrName, Session session) throws RepositoryException { // make sure the local name is xml compliant String localName = ISO9075.encode(Text.getLocalName(jcrName)); String prefix = Text.getNamespacePrefix(jcrName); String uri = session.getNamespaceURI(prefix); Namespace namespace = Namespace.getNamespace(prefix, uri); DavPropertyName name = DavPropertyName.create(localName, namespace); return name; }