You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2018/04/20 14:03:44 UTC
tinkerpop git commit: TINKERPOP-1946 Removed old version of
Credentials DSL
Repository: tinkerpop
Updated Branches:
refs/heads/TINKERPOP-1946 [created] 9458641c7
TINKERPOP-1946 Removed old version of Credentials DSL
This was deprecated on 3.3.3 - it can be removed for 3.4.0
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/9458641c
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/9458641c
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/9458641c
Branch: refs/heads/TINKERPOP-1946
Commit: 9458641c77605a9518bf885eadb6716646ce4006
Parents: e2fce7b
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Apr 20 10:02:54 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Apr 20 10:02:54 2018 -0400
----------------------------------------------------------------------
CHANGELOG.asciidoc | 1 +
.../jsr223/dsl/credential/CredentialGraph.java | 123 -------------------
.../CredentialGraphGremlinPlugin.java | 2 -
.../dsl/credential/CredentialGraphTest.java | 122 ------------------
4 files changed, 1 insertion(+), 247 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9458641c/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 5a3f1aa..d903000 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -30,6 +30,7 @@ This release also includes changes from <<release-3-3-3, 3.3.3>>.
* `hadoop-gremlin` no longer generates a test artifact.
* Fixed a bug in `ReducingBarrierStep`, that returned the provided seed value despite no elements being available.
* Changed the order of `select()` scopes. The order is now: maps, side-effects, paths.
+* Removed previously deprecated Credentials DSL infrastructure.
* Moved `TraversalEngine` to `gremlin-test` as it has long been only used in testing infrastructure.
* Removed previously deprecated `rebindings` options from the Java driver API.
* Removed support for Giraph.
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9458641c/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraph.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraph.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraph.java
deleted file mode 100644
index 0ae8e00..0000000
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraph.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * 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.tinkerpop.gremlin.groovy.jsr223.dsl.credential;
-
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.T;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.mindrot.jbcrypt.BCrypt;
-
-import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.drop;
-
-/**
- * A DSL for managing a "credentials graph" used by Gremlin Server for simple authentication functions. If the
- * {@link Graph} is transactional, new transactions will be started for each method call.
- *
- * @author Stephen Mallette (http://stephen.genoprime.com)
- * @deprecated As of release 3.3.3, replaced by {@link CredentialTraversalDsl}.
- */
-@Deprecated
-public class CredentialGraph {
-
- private final int BCRYPT_ROUNDS = 4;
- private final Graph graph;
- private final GraphTraversalSource g;
- private final boolean supportsTransactions;
-
- public CredentialGraph(final Graph graph) {
- this.graph = graph;
- g = graph.traversal();
- supportsTransactions = graph.features().graph().supportsTransactions();
- }
-
- /**
- * Finds a user by username and return {@code null} if one could not be found.
- *
- * @throws IllegalStateException if there is more than one user with a particular username.
- */
- public Vertex findUser(final String username) {
- if (supportsTransactions) g.tx().rollback();
- final GraphTraversal<Vertex,Vertex> t = g.V().has(CredentialGraphTokens.PROPERTY_USERNAME, username);
- final Vertex v = t.hasNext() ? t.next() : null;
- if (t.hasNext()) throw new IllegalStateException(String.format("Multiple users with username %s", username));
- return v;
- }
-
- /**
- * Creates a new user.
- *
- * @return the newly created user vertex
- */
- public Vertex createUser(final String username, final String password) {
- if (findUser(username) != null) throw new IllegalStateException("User with this name already exists");
- if (supportsTransactions) graph.tx().rollback();
-
- try {
- final Vertex v = graph.addVertex(T.label, CredentialGraphTokens.VERTEX_LABEL_USER,
- CredentialGraphTokens.PROPERTY_USERNAME, username,
- CredentialGraphTokens.PROPERTY_PASSWORD, BCrypt.hashpw(password, BCrypt.gensalt(BCRYPT_ROUNDS)));
- if (supportsTransactions) graph.tx().commit();
- return v;
- } catch (Exception ex) {
- if (supportsTransactions) graph.tx().rollback();
- throw new RuntimeException(ex);
- }
- }
-
- /**
- * Removes a user by name.
- *
- * @return the number of users removed (which should be one or zero)
- */
- public long removeUser(final String username) {
- if (supportsTransactions) graph.tx().rollback();
- try {
- final long count = g.V().has(CredentialGraphTokens.PROPERTY_USERNAME, username).sideEffect(drop()).count().next();
- if (supportsTransactions) graph.tx().commit();
- return count;
- } catch (Exception ex) {
- if (supportsTransactions) graph.tx().rollback();
- throw new RuntimeException(ex);
- }
- }
-
- /**
- * Get a count of the number of users in the database.
- */
- public long countUsers() {
- if (supportsTransactions) graph.tx().rollback();
- return g.V().hasLabel(CredentialGraphTokens.VERTEX_LABEL_USER).count().next();
- }
-
- @Override
- public String toString() {
- return "CredentialGraph{" +
- "graph=" + graph +
- '}';
- }
-
- /**
- * Wrap up any {@link Graph} instance in the {@code CredentialGraph} DSL.
- */
- public static CredentialGraph credentials(final Graph graph) {
- return new CredentialGraph(graph);
- }
-}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9458641c/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraphGremlinPlugin.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraphGremlinPlugin.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraphGremlinPlugin.java
index e36dff9..1bafbee 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraphGremlinPlugin.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraphGremlinPlugin.java
@@ -38,11 +38,9 @@ public class CredentialGraphGremlinPlugin extends AbstractGremlinPlugin {
static {
try {
imports = DefaultImportCustomizer.build()
- .addClassImports(CredentialGraph.class)
.addClassImports(CredentialTraversalDsl.class)
.addClassImports(CredentialTraversal.class)
.addClassImports(CredentialTraversalSource.class)
- .addMethodImports(CredentialGraph.class.getMethod("credentials", Graph.class))
.create();
} catch (Exception ex) {
throw new RuntimeException(ex);
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9458641c/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraphTest.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraphTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraphTest.java
deleted file mode 100644
index 7e054ce..0000000
--- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraphTest.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * 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.tinkerpop.gremlin.groovy.jsr223.dsl.credential;
-
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
-import org.hamcrest.MatcherAssert;
-import org.junit.Test;
-
-import static org.apache.tinkerpop.gremlin.groovy.jsr223.dsl.credential.CredentialGraph.credentials;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.greaterThan;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNull;
-
-/**
- * These tests cover old functionality prior to the new method for DSL implementation.
- *
- * @author Stephen Mallette (http://stephen.genoprime.com)
- * @deprecated As for release 3.3.3, replaced by {@link CredentialTraversalDslTest}.
- */
-@Deprecated
-public class CredentialGraphTest {
-
- @Test
- public void shouldCreateUser() {
- final Graph graph = TinkerGraph.open();
- final Vertex v = credentials(graph).createUser("stephen", "secret");
- assertEquals("stephen", v.value("username"));
- assertEquals("user", v.label());
- assertNotEquals("secret", v.value("password")); // hashed to something
- assertThat(v.value("password").toString().length(), greaterThan(0));
- }
-
- @Test
- public void shouldRemoveUser() {
- final Graph graph = TinkerGraph.open();
- MatcherAssert.assertThat(graph.vertices().hasNext(), is(false));
- credentials(graph).createUser("stephen", "secret");
- MatcherAssert.assertThat(graph.vertices().hasNext(), is(true));
-
- assertEquals(1, credentials(graph).removeUser("stephen"));
- MatcherAssert.assertThat(graph.vertices().hasNext(), is(false));
- }
-
- @Test
- public void shouldNotRemoveUser() {
- final Graph graph = TinkerGraph.open();
- MatcherAssert.assertThat(graph.vertices().hasNext(), is(false));
- credentials(graph).createUser("stephen", "secret");
- MatcherAssert.assertThat(graph.vertices().hasNext(), is(true));
-
- assertEquals(0, credentials(graph).removeUser("stephanie"));
- MatcherAssert.assertThat(graph.vertices().hasNext(), is(true));
- }
-
- @Test
- public void shouldFindUser() {
- final Graph graph = TinkerGraph.open();
- MatcherAssert.assertThat(graph.vertices().hasNext(), is(false));
- credentials(graph).createUser("marko", "secret");
- final Vertex stephen = credentials(graph).createUser("stephen", "secret");
- credentials(graph).createUser("daniel", "secret");
- MatcherAssert.assertThat(graph.vertices().hasNext(), is(true));
-
- assertEquals(stephen, credentials(graph).findUser("stephen"));
- }
-
- @Test
- public void shouldNotFindUser() {
- final Graph graph = TinkerGraph.open();
- MatcherAssert.assertThat(graph.vertices().hasNext(), is(false));
- credentials(graph).createUser("marko", "secret");
- credentials(graph).createUser("stephen", "secret");
- credentials(graph).createUser("daniel", "secret");
- MatcherAssert.assertThat(graph.vertices().hasNext(), is(true));
-
- assertNull(credentials(graph).findUser("stephanie"));
- }
-
- @Test
- public void shouldCountUsers() {
- final Graph graph = TinkerGraph.open();
- MatcherAssert.assertThat(graph.vertices().hasNext(), is(false));
- credentials(graph).createUser("marko", "secret");
- credentials(graph).createUser("stephen", "secret");
- credentials(graph).createUser("daniel", "secret");
- MatcherAssert.assertThat(graph.vertices().hasNext(), is(true));
-
- assertEquals(3, credentials(graph).countUsers());
- }
-
- @Test(expected = IllegalStateException.class)
- public void shouldThrowIfFindingMultipleUsers() {
- final Graph graph = TinkerGraph.open();
- MatcherAssert.assertThat(graph.vertices().hasNext(), is(false));
- credentials(graph).createUser("stephen", "secret");
- credentials(graph).createUser("stephen", "secret");
- MatcherAssert.assertThat(graph.vertices().hasNext(), is(true));
-
- assertNull(credentials(graph).findUser("stephen"));
- }
-}