You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by kw...@apache.org on 2020/10/20 11:45:07 UTC

[jackrabbit-filevault] branch feature/JCRVLT-433-achandling-validator created (now 36614a4)

This is an automated email from the ASF dual-hosted git repository.

kwin pushed a change to branch feature/JCRVLT-433-achandling-validator
in repository https://gitbox.apache.org/repos/asf/jackrabbit-filevault.git.


      at 36614a4  JCRVLT-433 access control validator

This branch includes the following new commits:

     new 36614a4  JCRVLT-433 access control validator

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[jackrabbit-filevault] 01/01: JCRVLT-433 access control validator

Posted by kw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kwin pushed a commit to branch feature/JCRVLT-433-achandling-validator
in repository https://gitbox.apache.org/repos/asf/jackrabbit-filevault.git

commit 36614a4d9ec68760e3b96b52da1b1249ea5e179e
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Tue Oct 20 13:43:46 2020 +0200

    JCRVLT-433 access control validator
    
    validates that achandling != ignore in case an acl is found in the
    package
---
 .../spi/impl/AccessControlValidator.java           | 64 ++++++++++++++++++++++
 .../spi/impl/AccessControlValidatorFactory.java    | 52 ++++++++++++++++++
 2 files changed, 116 insertions(+)

diff --git a/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/impl/AccessControlValidator.java b/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/impl/AccessControlValidator.java
new file mode 100644
index 0000000..497f2c9
--- /dev/null
+++ b/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/impl/AccessControlValidator.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.vault.validation.spi.impl;
+
+import java.util.Collection;
+import java.util.Collections;
+
+import org.apache.jackrabbit.vault.fs.io.AccessControlHandling;
+import org.apache.jackrabbit.vault.fs.spi.impl.jcr20.JcrACLManagement;
+import org.apache.jackrabbit.vault.util.DocViewNode;
+import org.apache.jackrabbit.vault.validation.spi.DocumentViewXmlValidator;
+import org.apache.jackrabbit.vault.validation.spi.NodeContext;
+import org.apache.jackrabbit.vault.validation.spi.ValidationMessage;
+import org.apache.jackrabbit.vault.validation.spi.ValidationMessageSeverity;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * @see <a href="https://issues.apache.org/jira/browse/JCRVLT-255">JCRVLT-255</a>
+ */
+public class AccessControlValidator implements DocumentViewXmlValidator {
+
+    protected static final JcrACLManagement ACL_MANAGEMENT = new JcrACLManagement();
+    protected static final String MESSAGE_IGNORED_ACCESS_CONTROL_LIST = "Found an access control list, but it is never considered during installation as the property `acHandling` is set to `ignore`!";
+    private final ValidationMessageSeverity severity;
+    private final AccessControlHandling accessControlHandling;
+
+    public AccessControlValidator(ValidationMessageSeverity severity, AccessControlHandling accessControlHandling) {
+        super();
+        this.severity = severity;
+        this.accessControlHandling = accessControlHandling;
+    }
+
+    @Override
+    public Collection<ValidationMessage> done() {
+        return null;
+    }
+
+    
+    @Override
+    public @Nullable Collection<ValidationMessage> validate(@NotNull DocViewNode node, @NotNull NodeContext nodeContext,
+            boolean isRoot) {
+        // extract primary type
+        if (accessControlHandling == AccessControlHandling.IGNORE && ACL_MANAGEMENT.isACLNodeType(node.primary)) {
+            return Collections.singleton(new ValidationMessage(severity, MESSAGE_IGNORED_ACCESS_CONTROL_LIST));
+        }
+        return null;
+    }
+
+}
diff --git a/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/impl/AccessControlValidatorFactory.java b/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/impl/AccessControlValidatorFactory.java
new file mode 100644
index 0000000..65027b1
--- /dev/null
+++ b/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/impl/AccessControlValidatorFactory.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.vault.validation.spi.impl;
+
+import org.apache.jackrabbit.vault.fs.io.AccessControlHandling;
+import org.apache.jackrabbit.vault.validation.spi.ValidationContext;
+import org.apache.jackrabbit.vault.validation.spi.Validator;
+import org.apache.jackrabbit.vault.validation.spi.ValidatorFactory;
+import org.apache.jackrabbit.vault.validation.spi.ValidatorSettings;
+import org.jetbrains.annotations.NotNull;
+import org.kohsuke.MetaInfServices;
+
+@MetaInfServices
+public final class AccessControlValidatorFactory implements ValidatorFactory {
+
+    @Override
+    public Validator createValidator(@NotNull ValidationContext context, @NotNull ValidatorSettings settings) {
+        AccessControlHandling accessControlHandling = context.getProperties().getACHandling();
+        return new AccessControlValidator(settings.getDefaultSeverity(), accessControlHandling);
+    }
+
+    @Override
+    public boolean shouldValidateSubpackages() {
+        // necessary to call nested validators which should be called for subpackages
+        return false;
+    }
+
+    @Override
+    public @NotNull String getId() {
+        return ValidatorFactory.ID_PREFIX_JACKRABBIT + "accesscontrol";
+    }
+
+    @Override
+    public int getServiceRanking() {
+        return Integer.MAX_VALUE;
+    }
+
+}