TINKERPOP-1562 Deprecated the CredentialGraph and moved it to a new home so tht the "plugin" package can go away completely.
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/6439d709 Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/6439d709 Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/6439d709 Branch: refs/heads/master Commit: 6439d709c60a107b3e6a3b79231344f8a2ce2e7a Parents: 39e3965 Author: Stephen Mallette <sp...@genoprime.com> Authored: Tue Nov 29 10:13:04 2016 -0500 Committer: Stephen Mallette <sp...@genoprime.com> Committed: Fri Dec 2 06:31:50 2016 -0500 ---------------------------------------------------------------------- .../dsl/credential/CredentialGraphTest.java | 121 +++++++++++++++++++ .../dsl/credential/CredentialGraphTest.java | 2 +- .../groovy/util/DependencyGrabber.groovy | 14 +++ .../jsr223/dsl/credential/CredentialGraph.java | 121 +++++++++++++++++++ .../CredentialGraphGremlinPlugin.java | 51 ++++++++ .../dsl/credential/CredentialGraphTokens.java | 31 +++++ .../plugin/dsl/credential/CredentialGraph.java | 2 + .../dsl/credential/CredentialGraphTokens.java | 2 + .../jsr223/CredentialGraphGremlinPlugin.java | 55 --------- ...pache.tinkerpop.gremlin.jsr223.GremlinPlugin | 2 +- 10 files changed, 344 insertions(+), 57 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6439d709/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraphTest.java ---------------------------------------------------------------------- diff --git a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraphTest.java b/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraphTest.java new file mode 100644 index 0000000..e3a713d --- /dev/null +++ b/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraphTest.java @@ -0,0 +1,121 @@ +/* + * 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.AbstractGremlinTest; +import org.apache.tinkerpop.gremlin.FeatureRequirement; +import org.apache.tinkerpop.gremlin.FeatureRequirementSet; +import org.apache.tinkerpop.gremlin.structure.Graph; +import org.apache.tinkerpop.gremlin.structure.Vertex; +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; + +/** + * @author Stephen Mallette (http://stephen.genoprime.com) + */ +public class CredentialGraphTest extends AbstractGremlinTest { + + @Test + @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) + public void shouldCreateUser() { + 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 + @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) + @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_REMOVE_VERTICES) + public void shouldRemoveUser() { + 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 + @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) + public void shouldNotRemoveUser() { + 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 + @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) + public void shouldFindUser() { + 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 + @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) + public void shouldNotFindUser() { + 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 + @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) + public void shouldCountUsers() { + 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) + @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY) + public void shouldThrowIfFindingMultipleUsers() { + 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")); + } +} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6439d709/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraphTest.java ---------------------------------------------------------------------- diff --git a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraphTest.java b/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraphTest.java index d7d7f9d..7cdf329 100644 --- a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraphTest.java +++ b/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraphTest.java @@ -26,7 +26,7 @@ import org.apache.tinkerpop.gremlin.structure.Vertex; import org.hamcrest.MatcherAssert; import org.junit.Test; -import static org.apache.tinkerpop.gremlin.groovy.plugin.dsl.credential.CredentialGraph.*; +import static org.apache.tinkerpop.gremlin.groovy.plugin.dsl.credential.CredentialGraph.credentials; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.greaterThan; http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6439d709/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabber.groovy ---------------------------------------------------------------------- diff --git a/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabber.groovy b/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabber.groovy index f2bfe5c..4f895c8 100644 --- a/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabber.groovy +++ b/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabber.groovy @@ -50,6 +50,13 @@ class DependencyGrabber { this.extensionDirectory = extensionDirectory } + /** + * @deprecated As of release 3.2.4, replaced by {@link #deleteDependenciesFromPath(Artifact)} + */ + def String deleteDependenciesFromPath(final org.apache.tinkerpop.gremlin.groovy.plugin.Artifact artifact) { + deleteDependenciesFromPath(new Artifact(artifact.group, artifact.artifact, artifact.version)) + } + def String deleteDependenciesFromPath(final Artifact artifact) { final def dep = makeDepsMap(artifact) final String extClassPath = getPathFromDependency(dep) @@ -63,6 +70,13 @@ class DependencyGrabber { } } + /** + * @deprecated As of release 3.2.4, replaced by {@link #copyDependenciesToPath(Artifact)} + */ + def String copyDependenciesToPath(final org.apache.tinkerpop.gremlin.groovy.plugin.Artifact artifact) { + copyDependenciesToPath(new Artifact(artifact.group, artifact.artifact, artifact.version)) + } + def Set<String> copyDependenciesToPath(final Artifact artifact) { final def dep = makeDepsMap(artifact) final String extClassPath = getPathFromDependency(dep) http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6439d709/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 new file mode 100644 index 0000000..707e816 --- /dev/null +++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraph.java @@ -0,0 +1,121 @@ +/* + * 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.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) + */ +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/6439d709/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 new file mode 100644 index 0000000..7b6bd64 --- /dev/null +++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraphGremlinPlugin.java @@ -0,0 +1,51 @@ +/* + * 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.jsr223.AbstractGremlinPlugin; +import org.apache.tinkerpop.gremlin.jsr223.DefaultImportCustomizer; +import org.apache.tinkerpop.gremlin.jsr223.ImportCustomizer; +import org.apache.tinkerpop.gremlin.structure.Graph; + +/** + * Plugin for the "credentials graph". This plugin imports the {@link CredentialGraph} to its environment. + * + * @author Stephen Mallette (http://stephen.genoprime.com) + */ +public class CredentialGraphGremlinPlugin extends AbstractGremlinPlugin { + + private static final String NAME = "tinkerpop.credentials"; + + private static final ImportCustomizer imports; + + static { + try { + imports = DefaultImportCustomizer.build() + .addClassImports(CredentialGraph.class) + .addMethodImports(CredentialGraph.class.getMethod("credentials", Graph.class)) + .create(); + } catch (Exception ex) { + throw new RuntimeException(ex); + } + } + + public CredentialGraphGremlinPlugin() { + super(NAME, imports); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6439d709/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraphTokens.java ---------------------------------------------------------------------- diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraphTokens.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraphTokens.java new file mode 100644 index 0000000..ac16302 --- /dev/null +++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/dsl/credential/CredentialGraphTokens.java @@ -0,0 +1,31 @@ +/* + * 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; + +/** + * @author Stephen Mallette (http://stephen.genoprime.com) + */ +public final class CredentialGraphTokens { + public static final String PROPERTY_USERNAME = "username"; + public static final String PROPERTY_PASSWORD = "password"; + + public static final String VERTEX_LABEL_USER = "user"; + + private CredentialGraphTokens() {} +} http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6439d709/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraph.java ---------------------------------------------------------------------- diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraph.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraph.java index 8c0277c..6a90587 100644 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraph.java +++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraph.java @@ -32,7 +32,9 @@ import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.drop; * {@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.2.4, replaced by {@link org.apache.tinkerpop.gremlin.groovy.jsr223.dsl.credential.CredentialGraph}. */ +@Deprecated public class CredentialGraph { private final int BCRYPT_ROUNDS = 4; http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6439d709/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraphTokens.java ---------------------------------------------------------------------- diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraphTokens.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraphTokens.java index 0cb2543..1f0d8cf 100644 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraphTokens.java +++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/CredentialGraphTokens.java @@ -20,7 +20,9 @@ package org.apache.tinkerpop.gremlin.groovy.plugin.dsl.credential; /** * @author Stephen Mallette (http://stephen.genoprime.com) + * @deprecated As of release 3.2.4, replaced by {@link org.apache.tinkerpop.gremlin.groovy.jsr223.dsl.credential.CredentialGraphTokens}. */ +@Deprecated public final class CredentialGraphTokens { public static final String PROPERTY_USERNAME = "username"; public static final String PROPERTY_PASSWORD = "password"; http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6439d709/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/jsr223/CredentialGraphGremlinPlugin.java ---------------------------------------------------------------------- diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/jsr223/CredentialGraphGremlinPlugin.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/jsr223/CredentialGraphGremlinPlugin.java deleted file mode 100644 index 761567b..0000000 --- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/plugin/dsl/credential/jsr223/CredentialGraphGremlinPlugin.java +++ /dev/null @@ -1,55 +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.plugin.dsl.credential.jsr223; - -import org.apache.tinkerpop.gremlin.groovy.plugin.dsl.credential.CredentialGraph; -import org.apache.tinkerpop.gremlin.jsr223.AbstractGremlinPlugin; -import org.apache.tinkerpop.gremlin.jsr223.DefaultImportCustomizer; -import org.apache.tinkerpop.gremlin.jsr223.ImportCustomizer; -import org.apache.tinkerpop.gremlin.structure.Graph; - -import java.util.HashSet; -import java.util.Set; - -/** - * Plugin for the "credentials graph". This plugin imports the {@link CredentialGraph} to its environment. - * - * @author Stephen Mallette (http://stephen.genoprime.com) - */ -public class CredentialGraphGremlinPlugin extends AbstractGremlinPlugin { - - private static final String NAME = "tinkerpop.credentials"; - - private static final ImportCustomizer imports; - - static { - try { - imports = DefaultImportCustomizer.build() - .addClassImports(CredentialGraph.class) - .addMethodImports(CredentialGraph.class.getMethod("credentials", Graph.class)) - .create(); - } catch (Exception ex) { - throw new RuntimeException(ex); - } - } - - public CredentialGraphGremlinPlugin() { - super(NAME, imports); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6439d709/gremlin-groovy/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin ---------------------------------------------------------------------- diff --git a/gremlin-groovy/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin b/gremlin-groovy/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin index 0004a80..251250b 100644 --- a/gremlin-groovy/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin +++ b/gremlin-groovy/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin @@ -1,2 +1,2 @@ org.apache.tinkerpop.gremlin.groovy.jsr223.SugarGremlinPlugin -org.apache.tinkerpop.gremlin.groovy.plugin.dsl.credential.jsr223.CredentialGraphGremlinPlugin \ No newline at end of file +org.apache.tinkerpop.gremlin.groovy.jsr223.dsl.credential.CredentialGraphGremlinPlugin \ No newline at end of file