blob: 8d1d4f58e374c445b995b500573be9666a77742a (
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
36
37
38
39
40
41
42
43
44
45
|
// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.server.rpc.security;
import com.google.inject.Inject;
import com.yahoo.cloud.config.ConfigserverConfig;
import com.yahoo.config.provision.security.NodeIdentifier;
import com.yahoo.container.di.componentgraph.Provider;
import com.yahoo.security.tls.TransportSecurityUtils;
import com.yahoo.vespa.config.server.host.HostRegistries;
import com.yahoo.vespa.config.server.rpc.RequestHandlerProvider;
/**
* A provider for {@link RpcAuthorizer}. The instance provided is dependent on the configuration of the configserver.
*
* @author bjorncs
*/
public class DefaultRpcAuthorizerProvider implements Provider<RpcAuthorizer> {
private final RpcAuthorizer rpcAuthorizer;
@Inject
public DefaultRpcAuthorizerProvider(ConfigserverConfig config,
NodeIdentifier nodeIdentifier,
HostRegistries hostRegistries,
RequestHandlerProvider handlerProvider) {
boolean useMultiTenantAuthorizer =
TransportSecurityUtils.isTransportSecurityEnabled() && config.multitenant() && config.hostedVespa();
this.rpcAuthorizer =
useMultiTenantAuthorizer
? new MultiTenantRpcAuthorizer(nodeIdentifier, hostRegistries, handlerProvider, getThreadPoolSize(config))
: new NoopRpcAuthorizer();
}
private static int getThreadPoolSize(ConfigserverConfig config) {
return config.numRpcThreads() != 0 ? config.numRpcThreads() : 8;
}
@Override
public RpcAuthorizer get() {
return rpcAuthorizer;
}
@Override
public void deconstruct() {}
}
|