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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.container.http;
import com.yahoo.config.provision.DataplaneToken;
import java.security.cert.X509Certificate;
import java.util.List;
/**
* Represents a client. The client is identified by one of the provided certificates and have a set of permissions.
*
* @author mortent
*/
public class Client {
private final String id;
private final List<String> permissions;
private final List<X509Certificate> certificates;
private final List<DataplaneToken> tokens;
private final boolean internal;
public Client(String id, List<String> permissions, List<X509Certificate> certificates, List<DataplaneToken> tokens) {
this(id, permissions, certificates, tokens, false);
}
private Client(String id, List<String> permissions, List<X509Certificate> certificates, List<DataplaneToken> tokens,
boolean internal) {
this.id = id;
this.permissions = List.copyOf(permissions);
this.certificates = List.copyOf(certificates);
this.tokens = List.copyOf(tokens);
this.internal = internal;
}
public String id() {
return id;
}
public List<String> permissions() {
return permissions;
}
public List<X509Certificate> certificates() {
return certificates;
}
public List<DataplaneToken> tokens() { return tokens; }
public boolean internal() {
return internal;
}
public static Client internalClient(List<X509Certificate> certificates) {
return new Client("_internal", List.of("read","write"), certificates, List.of(), true);
}
}
|