Skip to content

Commit

Permalink
add ssl for auth user when scan data
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicole00 committed Jan 2, 2024
1 parent 13a0cb2 commit 3e64bd7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import com.vesoft.nebula.storage.ScanEdgeRequest;
import com.vesoft.nebula.storage.ScanVertexRequest;
import com.vesoft.nebula.storage.VertexProp;

import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
Expand All @@ -35,7 +34,6 @@
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -1207,10 +1205,17 @@ private void authUser() throws AuthFailedException, IOErrorException,
if (graphAddrAndPort.length != 2) {
throw new IllegalArgumentException("the graph address is invalid.");
}
graphConnection.open(new HostAddress(graphAddrAndPort[0].trim(),
Integer.valueOf(graphAddrAndPort[1].trim())), timeout, false,
new HashMap<>(),
version);
if (sslParam == null) {
graphConnection.open(new HostAddress(graphAddrAndPort[0].trim(),
Integer.valueOf(graphAddrAndPort[1].trim())), timeout, false,
new HashMap<>(),
version);
} else {
graphConnection.open(new HostAddress(graphAddrAndPort[0].trim(),
Integer.valueOf(graphAddrAndPort[1].trim())), timeout, sslParam, false,
new HashMap<>(),
version);
}
AuthResult authResult = graphConnection.authenticate(user, password);
long sessionId = authResult.getSessionId();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.vesoft.nebula.client.graph.data.CASignedSSLParam;
import com.vesoft.nebula.client.graph.data.HostAddress;
import com.vesoft.nebula.client.graph.data.SSLParam;
import com.vesoft.nebula.client.graph.data.SelfSignedSSLParam;
import com.vesoft.nebula.client.storage.data.EdgeRow;
import com.vesoft.nebula.client.storage.data.EdgeTableRow;
import com.vesoft.nebula.client.storage.data.VertexRow;
Expand All @@ -17,13 +16,9 @@
import com.vesoft.nebula.client.storage.scan.ScanEdgeResultIterator;
import com.vesoft.nebula.client.storage.scan.ScanVertexResult;
import com.vesoft.nebula.client.storage.scan.ScanVertexResultIterator;
import com.vesoft.nebula.client.util.ProcessUtil;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Arrays;
import java.util.List;

import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
Expand Down Expand Up @@ -428,6 +423,10 @@ public void testCASignedSSL() {
"src/test/resources/ssl/client.crt",
"src/test/resources/ssl/client.key");
sslClient = new StorageClient(address, 1000, 1, 1, true, sslParam);
sslClient.setGraphAddress("127.0.0.1:8669");
sslClient.setUser("root");
sslClient.setPassword("nebula");
sslClient.setVersion("3.0.0");
sslClient.connect();

ScanVertexResultIterator resultIterator = sslClient.scanVertex(
Expand Down

0 comments on commit 3e64bd7

Please sign in to comment.