Skip to content

Commit 425f231

Browse files
author
michele
committed
VST authentication
1 parent 19edcda commit 425f231

File tree

6 files changed

+66
-8
lines changed

6 files changed

+66
-8
lines changed

src/main/java/com/arangodb/internal/velocypack/VPackDriverModule.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import com.arangodb.entity.arangosearch.ConsolidationPolicy;
2727
import com.arangodb.entity.arangosearch.ConsolidationType;
2828
import com.arangodb.internal.velocystream.internal.AuthenticationRequest;
29+
import com.arangodb.internal.velocystream.internal.GssAuthenticationRequest;
2930
import com.arangodb.model.TraversalOptions;
3031
import com.arangodb.model.arangosearch.ArangoSearchPropertiesOptions;
3132
import com.arangodb.velocypack.VPackModule;
@@ -54,6 +55,7 @@ public <C extends VPackSetupContext<C>> void setup(final C context) {
5455
});
5556
context.registerSerializer(Request.class, VPackSerializers.REQUEST);
5657
context.registerSerializer(AuthenticationRequest.class, VPackSerializers.AUTH_REQUEST);
58+
context.registerSerializer(GssAuthenticationRequest.class, VPackSerializers.GSS_AUTH_REQUEST);
5759
context.registerSerializer(CollectionType.class, VPackSerializers.COLLECTION_TYPE);
5860
context.registerSerializer(BaseDocument.class, VPackSerializers.BASE_DOCUMENT);
5961
context.registerSerializer(BaseEdgeDocument.class, VPackSerializers.BASE_EDGE_DOCUMENT);

src/main/java/com/arangodb/internal/velocypack/VPackSerializers.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.arangodb.entity.*;
2424
import com.arangodb.entity.arangosearch.*;
2525
import com.arangodb.internal.velocystream.internal.AuthenticationRequest;
26+
import com.arangodb.internal.velocystream.internal.GssAuthenticationRequest;
2627
import com.arangodb.model.TraversalOptions;
2728
import com.arangodb.model.TraversalOptions.Order;
2829
import com.arangodb.model.arangosearch.ArangoSearchPropertiesOptions;
@@ -71,6 +72,15 @@ public class VPackSerializers {
7172
builder.close();
7273
};
7374

75+
public static final VPackSerializer<GssAuthenticationRequest> GSS_AUTH_REQUEST = (builder, attribute, value, context) -> {
76+
builder.add(attribute, ValueType.ARRAY);
77+
builder.add(value.getVersion());
78+
builder.add(value.getType());
79+
builder.add(value.getEncryption());
80+
builder.add(value.getToken());
81+
builder.close();
82+
};
83+
7484
public static final VPackSerializer<CollectionType> COLLECTION_TYPE = (builder, attribute, value, context) -> builder.add(attribute, value.getType());
7585

7686
public static final VPackSerializer<BaseDocument> BASE_DOCUMENT = (builder, attribute, value, context) -> {

src/main/java/com/arangodb/internal/velocystream/VstCommunication.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
public abstract class VstCommunication<R, C extends VstConnection> implements Closeable {
5252

5353
protected static final String ENCRYPTION_PLAIN = "plain";
54+
protected static final String ENCRYPTION_NEGOTIATE = "negotiate";
5455
private static final Logger LOGGER = LoggerFactory.getLogger(VstCommunication.class);
5556

5657
protected static final AtomicLong mId = new AtomicLong(0L);

src/main/java/com/arangodb/internal/velocystream/VstCommunicationSync.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
import com.arangodb.ArangoDBException;
2424
import com.arangodb.internal.net.HostHandler;
25-
import com.arangodb.internal.velocystream.internal.AuthenticationRequest;
25+
import com.arangodb.internal.velocystream.internal.GssAuthenticationRequest;
2626
import com.arangodb.internal.velocystream.internal.Message;
2727
import com.arangodb.internal.velocystream.internal.VstConnectionSync;
2828
import com.arangodb.util.ArangoSerialization;
@@ -36,7 +36,6 @@
3636

3737
/**
3838
* @author Mark Vollmary
39-
*
4039
*/
4140
public class VstCommunicationSync extends VstCommunication<Response, VstConnectionSync> {
4241

@@ -71,11 +70,9 @@ private Message send(final Message message, final VstConnectionSync connection)
7170

7271
@Override
7372
protected void authenticate(final VstConnectionSync connection) {
74-
String token = "Negotiate YIICyAYGKwYBBQUCoIICvDCCArigDTALBgkqhkiG9xIBAgKiggKlBIICoWCCAp0GCSqGSIb3EgECAgEAboICjDCCAoigAwIBBaEDAgEOogcDBQAgAAAAo4IBkWGCAY0wggGJoAMCAQWhGhsYQlJVRUNLTElOVVguQVJBTkdPREIuQklaoiswKaADAgEBoSIwIBsESFRUUBsYYnJ1ZWNrbGludXguYXJhbmdvZGIuYml6o4IBNzCCATOgAwIBEqEDAgEBooIBJQSCASF4bHwiBfl70XzaMPPeOQRzY63S5PLwslzzxZArabFKF8s67531vAGmyMcjTPNvClIwew63bCMN4xtjJx+7G2oo+AnlQ+rNMBO5eKHJDsVbFo44P3tiz4Z8lGvK/gJuwCaA/25BaNachJT6RlhkS+x/ZsglKU6y0Okbiz42viSyC3mFpJx5gmcK2xMS6CAp6498JXlevR9F3EqQ67xlWIjWKntqPWK+gj4jU85AXD9ylJpOUm9/Wu82sUIUgT3+kg1x26DvD/5SkzqHLRTJvTRMaSglpqoUMcvSKhK0LRBzcqIxneo1egbg74Jvq/Pu/yZJUfkfBrXHuqQTecT2b8kboSuOp+FYc1J0Uw3xRpZu5peLBSfvIvmkj29uNzlalJQ/pIHdMIHaoAMCARKigdIEgc9/TWh3OUUKFBaXABytmHD8rNvUyBbZRYf8UuXsdi1coZUJRGBT0D53hMLLb1XoveJbci9S5L1xzpWbK3YDmMwH0EMwxSgNGPdZfblEXY9/XeKMA54tNJLnZxyWO0hdwNdN839uJd7hISamV6JxBSZjuKYbxW5sahgeBdJZvFxWxp0PFnSAnfX5yQwFn8AGSB0jHRFkgwNwTwfpIoFNsInd3lZXzSABVHqdcpGXD4uixd6yErtNjFjdQvPpo9m0lzypkwDImxA2Dvd1Tb3OF7k=";
75-
// Request request = new Request(null,null,null);
76-
// request.putHeaderParam("Authorization", token);
77-
// request.setType(1000);
78-
AuthenticationRequest request = new AuthenticationRequest(user, password != null ? password : "", ENCRYPTION_PLAIN);
73+
String token = "YIICyAYGKwYBBQUCoIICvDCCArigDTALBgkqhkiG9xIBAgKiggKlBIICoWCCAp0GCSqGSIb3EgECAgEAboICjDCCAoigAwIBBaEDAgEOogcDBQAgAAAAo4IBkWGCAY0wggGJoAMCAQWhGhsYQlJVRUNLTElOVVguQVJBTkdPREIuQklaoiswKaADAgEBoSIwIBsESFRUUBsYYnJ1ZWNrbGludXguYXJhbmdvZGIuYml6o4IBNzCCATOgAwIBEqEDAgEBooIBJQSCASF4bHwiBfl70XzaMPPeOQRzY63S5PLwslzzxZArabFKF8s67531vAGmyMcjTPNvClIwew63bCMN4xtjJx+7G2oo+AnlQ+rNMBO5eKHJDsVbFo44P3tiz4Z8lGvK/gJuwCaA/25BaNachJT6RlhkS+x/ZsglKU6y0Okbiz42viSyC3mFpJx5gmcK2xMS6CAp6498JXlevR9F3EqQ67xlWIjWKntqPWK+gj4jU85AXD9ylJpOUm9/Wu82sUIUgT3+kg1x26DvD/5SkzqHLRTJvTRMaSglpqoUMcvSKhK0LRBzcqIxneo1egbg74Jvq/Pu/yZJUfkfBrXHuqQTecT2b8kboSuOp+FYc1J0Uw3xRpZu5peLBSfvIvmkj29uNzlalJQ/pIHdMIHaoAMCARKigdIEgc87aa9g09YlnOr5fNth5MRxf7MIbPbxwlG3E1ag9y4cRN/C1DIZRG1kP0e8qRmPsBfr7ogLqD1mO5ByxD7Q3BaBMte7yuFG1sKO/wboG4S8R9kOT8bf+b+SO40v9k3Z7Iw1jCPUSaUPji1S2cHM1/6g9JTbaiaGCB3SSa1XUoFVf17/h40aXaejtzA+dQM8zJfphy0vMkU+WaOA+ZJeflDL96WUvZIR6qz3JFcK6Xi+kKTm45zXYXenyVyoc2A2brL5fOz4efksBdB96SEOvbw=";
74+
GssAuthenticationRequest request = new GssAuthenticationRequest(token, ENCRYPTION_NEGOTIATE);
75+
// AuthenticationRequest request = new AuthenticationRequest(user, password != null ? password : "", ENCRYPTION_PLAIN);
7976
final Response response = execute(request, connection);
8077
checkError(response);
8178
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* DISCLAIMER
3+
*
4+
* Copyright 2016 ArangoDB GmbH, Cologne, Germany
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
*/
20+
21+
package com.arangodb.internal.velocystream.internal;
22+
23+
import com.arangodb.velocystream.Request;
24+
25+
/**
26+
* @author Michele Rastelli
27+
*/
28+
public class GssAuthenticationRequest extends Request {
29+
30+
private final String token;
31+
private final String encryption;// "negotiate"
32+
33+
public GssAuthenticationRequest(final String token, final String encryption) {
34+
super(null, null, null);
35+
this.token = token;
36+
this.encryption = encryption;
37+
setType(1000);
38+
}
39+
40+
public String getToken() {
41+
return token;
42+
}
43+
44+
public String getEncryption() {
45+
return encryption;
46+
}
47+
48+
}

src/test/java/com/arangodb/KerberosVST.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public static void main(String[] args) throws InterruptedException, GSSException
4545

4646
while (true) {
4747
System.out.println(arangoDB.getVersion().getVersion());
48-
Thread.sleep(60000);
48+
Thread.sleep(5000);
4949
}
5050
}
5151

0 commit comments

Comments
 (0)