Skip to content
Permalink
Browse files
Add an option 'token' for authentication (#46)
Change-Id: Id2d748f83ce3c52dc961ba32b044dff6e40b6615
  • Loading branch information
Linary authored and javeme committed Mar 22, 2019
1 parent 69dd2c8 commit 9e9fb45011c66c749d21acc030b274e057b3ec2d
Showing 4 changed files with 15 additions and 4 deletions.
@@ -8,7 +8,7 @@
"format": "CSV",
"header": ["name", "age", "city"],
"charset": "UTF-8",
"comment_symbols": ["#"]
"skipped_line_regex": "(^#|^//).*"
},
"null_values": ["NULL", "null", ""]
},
@@ -8,7 +8,7 @@
"format": "CSV",
"header": ["name", "age", "city"],
"charset": "UTF-8",
"comment_symbols": ["#"]
"skipped_line_regex": "(^#|^//).*"
},
"null_values": ["NULL", "null", ""]
},
@@ -25,7 +25,7 @@
import com.beust.jcommander.Parameter;
import com.beust.jcommander.ParameterException;

public class LoadOptions {
public final class LoadOptions {

@Parameter(names = {"-f", "--file"}, required = true, arity = 1,
validateWith = {FileValidator.class},
@@ -51,6 +51,10 @@ public class LoadOptions {
description = "The port of HugeGraphServer")
public int port = 8080;

@Parameter(names = {"--token"}, arity = 1,
description = "The token of graph for authentication")
public String token = null;

@Parameter(names = {"--num-threads"}, arity = 1,
validateWith = {PositiveValidator.class},
description = "The number of threads to use")
@@ -41,6 +41,13 @@ private HugeClientWrapper() {}

private static HugeClient newHugeClient(LoadOptions options) {
String address = options.host + ":" + options.port;
return new HugeClient(address, options.graph, options.timeout);
if (options.token == null) {
return new HugeClient(address, options.graph, options.timeout);
} else {
// The username is same as graph name
return new HugeClient(address, options.graph,
options.graph, options.token,
options.timeout);
}
}
}

0 comments on commit 9e9fb45

Please sign in to comment.