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

kturner pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo-access.git


The following commit(s) were added to refs/heads/main by this push:
     new dc80f08  adds a getting started guide (#13)
dc80f08 is described below

commit dc80f08929326fed5f28027b478773d7d0a621e2
Author: Keith Turner <ktur...@apache.org>
AuthorDate: Fri Sep 22 15:09:01 2023 -0400

    adds a getting started guide (#13)
---
 README.md                                          |  2 +
 contrib/getting-started/.gitignore                 |  1 +
 contrib/getting-started/README.md                  | 98 ++++++++++++++++++++++
 contrib/getting-started/pom.xml                    | 46 ++++++++++
 contrib/getting-started/run.sh                     | 21 +++++
 .../src/main/java/gse/AccessExample.java           | 66 +++++++++++++++
 pom.xml                                            | 20 +++++
 7 files changed, 254 insertions(+)

diff --git a/README.md b/README.md
index cdedc01..30f313d 100644
--- a/README.md
+++ b/README.md
@@ -40,3 +40,5 @@ The following types constitute the public API of this 
library.  All other types
 For an example of using this library see the [unit 
test](src/test/java/org/apache/accumulo/access/AccessEvaluatorTest.java).
 
 See the [specification](SPECIFICATION.md) for details about access expressions.
+
+See the [getting started guide](contrib/getting-started/README.md) for a 
simple example of how to use this java library.
diff --git a/contrib/getting-started/.gitignore 
b/contrib/getting-started/.gitignore
new file mode 100644
index 0000000..eb5a316
--- /dev/null
+++ b/contrib/getting-started/.gitignore
@@ -0,0 +1 @@
+target
diff --git a/contrib/getting-started/README.md 
b/contrib/getting-started/README.md
new file mode 100644
index 0000000..bd9090d
--- /dev/null
+++ b/contrib/getting-started/README.md
@@ -0,0 +1,98 @@
+<!--
+
+    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
+
+      https://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.
+
+-->
+
+# Getting started with Accumulo Access
+
+This standalone Accumulo Access example has the following components.
+
+ * [AccessExample](src/main/java/gse/AccessExample.java) Example that shows 
how to evaluate if data is accessible.
+ * [pom.xml](pom.xml) Maven build file that shows how to use Accumulo Access 
as a dependency
+ * [run.sh](run.sh) Bash script that runs the example
+
+To run this example clone the Accumulo Access repository and then do the 
following.
+
+```bash
+cd accumulo-access
+# This step installs a snapshot version of the Accumulo Access library.
+# This step will not longer be needed once Accumulo Access is released.
+mvn install
+cd contrib/getting-started
+# Build the example.  If you change the example java code, run this step again.
+mvn clean package
+# Run the example
+./run.sh
+```
+
+## Example runs
+
+Running with the authorizations set `{BLUE,GREEN,PINK,RED}` shows the complete 
data set because all data is accessible with these authorizations.
+
+```
+$ ./run.sh BLUE GREEN PINK RED
+data1 : (RED&GREEN)|(BLUE&PINK)
+data2 : (RED&GREEN)|(BLUE&PINK)
+data3 : (RED|GREEN)&(BLUE|PINK)
+data4 : (RED&GREEN)|(BLUE&PINK)
+data5 : (RED|GREEN)&(BLUE|PINK)
+data6 : 
+data7 : PINK
+data8 : RED&BLUE&GREEN&PINK
+data9 : PINK|(BLUE&RED)
+```
+
+Running with the empty set of authorizations shows only `data6` which has an 
empty access expression and is always accessible with any authorization set.
+
+```
+$ ./run.sh 
+data6 : 
+```
+
+Running with the authorizations set `{BLUE,RED}`
+
+```
+$ ./run.sh BLUE RED
+data3 : (RED|GREEN)&(BLUE|PINK)
+data5 : (RED|GREEN)&(BLUE|PINK)
+data6 : 
+data9 : PINK|(BLUE&RED)
+```
+
+Running with the authorizations set `{GREEN,RED}`
+
+```
+$ ./run.sh GREEN RED
+data1 : (RED&GREEN)|(BLUE&PINK)
+data2 : (RED&GREEN)|(BLUE&PINK)
+data4 : (RED&GREEN)|(BLUE&PINK)
+data6 : 
+```
+
+Running with the authorizations set `{PINK}`
+
+```
+$ ./run.sh PINK
+data6 : 
+data7 : PINK
+data9 : PINK|(BLUE&RED)
+```
+
+
+
diff --git a/contrib/getting-started/pom.xml b/contrib/getting-started/pom.xml
new file mode 100644
index 0000000..e549711
--- /dev/null
+++ b/contrib/getting-started/pom.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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
+
+      https://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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.accumulo</groupId>
+  <artifactId>getting-started</artifactId>
+  <version>1.0-SNAPSHOT</version>
+
+  <name>Accumulo Access Getting Started</name>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <maven.compiler.source>11</maven.compiler.source>
+    <maven.compiler.target>11</maven.compiler.target>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.accumulo</groupId>
+      <artifactId>accumulo-access</artifactId>
+      <version>1.0.0-SNAPSHOT</version>
+    </dependency>
+  </dependencies>
+
+</project>
diff --git a/contrib/getting-started/run.sh b/contrib/getting-started/run.sh
new file mode 100755
index 0000000..8a9a71e
--- /dev/null
+++ b/contrib/getting-started/run.sh
@@ -0,0 +1,21 @@
+#!/usr/bin/env bash
+#
+# 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
+#
+#   https://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.
+#
+
+mvn -q exec:java -Dexec.mainClass=gse.AccessExample -Dexec.args="$*"
diff --git a/contrib/getting-started/src/main/java/gse/AccessExample.java 
b/contrib/getting-started/src/main/java/gse/AccessExample.java
new file mode 100644
index 0000000..8ab8209
--- /dev/null
+++ b/contrib/getting-started/src/main/java/gse/AccessExample.java
@@ -0,0 +1,66 @@
+/*
+ * 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
+ *
+ *   https://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 gse;
+
+import org.apache.accumulo.access.AccessEvaluator;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+public class AccessExample {
+
+    public static void main(String[] args) {
+        // Create an access evaluator using the all the arguments passed in on 
the command line as authorizations.
+        AccessEvaluator evaluator = 
AccessEvaluator.builder().authorizations(args).build();
+
+        // For each record use the access evaluator to determine if it can be 
accessed using the authorizations from
+        // the command line and the access expression associated with each 
record.
+        for (Record record : getData()) {
+            if (evaluator.canAccess(record.accessExpression)) {
+                System.out.printf("%s : %s\n", record.data, 
record.accessExpression);
+            }
+        }
+    }
+
+    public static Collection<Record> getData() {
+        Collection<Record> records = new ArrayList<>();
+
+        records.add(new Record("data1", "(RED&GREEN)|(BLUE&PINK)"));
+        records.add(new Record("data2", "(RED&GREEN)|(BLUE&PINK)"));
+        records.add(new Record("data3", "(RED|GREEN)&(BLUE|PINK)"));
+        records.add(new Record("data4", "(RED&GREEN)|(BLUE&PINK)"));
+        records.add(new Record("data5", "(RED|GREEN)&(BLUE|PINK)"));
+        records.add(new Record("data6", ""));
+        records.add(new Record("data7", "PINK"));
+        records.add(new Record("data8", "RED&BLUE&GREEN&PINK"));
+        records.add(new Record("data9", "PINK|(BLUE&RED)"));
+
+        return records;
+    }
+
+    public static class Record {
+        public final String data;
+        public final String accessExpression;
+
+        public Record(String data, String accessExpression) {
+            this.data = data;
+            this.accessExpression = accessExpression;
+        }
+    }
+}
diff --git a/pom.xml b/pom.xml
index 8e0bcff..e2147ce 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,4 +1,24 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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
+
+      https://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.
+
+-->
 <project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
   <modelVersion>4.0.0</modelVersion>
   <parent>

Reply via email to