blob: 81813335a6367908cba1077b879358f10bce385e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
// Copyright 2020 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package ai.vespa.hosted.api;
import javax.net.ssl.SSLContext;
import java.net.http.HttpRequest;
import java.security.NoSuchAlgorithmException;
import java.util.Optional;
/**
* Adds environment dependent authentication to HTTP request against Vespa deployments.
*
* An implementation typically needs to override either of the methods in this interface,
* and needs to run in different environments, e.g., local user testing and automatic testing
* in a deployment pipeline.
*
* @author jonmv
*/
public interface EndpointAuthenticator {
/** Returns an SSLContext which provides authentication against a Vespa endpoint. */
default SSLContext sslContext() {
try {
return SSLContext.getDefault();
}
catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
}
/** Adds necessary authentication data to the given HTTP request builder, to pass the data plane of a Vespa endpoint. */
default HttpRequest.Builder authenticated(HttpRequest.Builder request) {
return request;
}
}
|