use of org.apache.solr.api.ApiBag.ReqHandlerToApi in project lucene-solr by apache.
the class SecurityConfHandler method getApis.
@Override
public Collection<Api> getApis() {
if (apis == null) {
synchronized (this) {
if (apis == null) {
Collection<Api> apis = new ArrayList<>();
final SpecProvider authcCommands = ApiBag.getSpec("cluster.security.authentication.Commands");
final SpecProvider authzCommands = ApiBag.getSpec("cluster.security.authorization.Commands");
apis.add(new ReqHandlerToApi(this, ApiBag.getSpec("cluster.security.authentication")));
apis.add(new ReqHandlerToApi(this, ApiBag.getSpec("cluster.security.authorization")));
SpecProvider authcSpecProvider = () -> {
AuthenticationPlugin authcPlugin = cores.getAuthenticationPlugin();
return authcPlugin != null && authcPlugin instanceof SpecProvider ? ((SpecProvider) authcPlugin).getSpec() : authcCommands.getSpec();
};
apis.add(new ReqHandlerToApi(this, authcSpecProvider) {
@Override
public synchronized Map<String, JsonSchemaValidator> getCommandSchema() {
// the cached commandSchema
if (SecurityConfHandler.this.authcPlugin != cores.getAuthenticationPlugin())
commandSchema = null;
SecurityConfHandler.this.authcPlugin = cores.getAuthenticationPlugin();
return super.getCommandSchema();
}
});
SpecProvider authzSpecProvider = () -> {
AuthorizationPlugin authzPlugin = cores.getAuthorizationPlugin();
return authzPlugin != null && authzPlugin instanceof SpecProvider ? ((SpecProvider) authzPlugin).getSpec() : authzCommands.getSpec();
};
apis.add(new ApiBag.ReqHandlerToApi(this, authzSpecProvider) {
@Override
public synchronized Map<String, JsonSchemaValidator> getCommandSchema() {
// the cached commandSchema
if (SecurityConfHandler.this.authzPlugin != cores.getAuthorizationPlugin())
commandSchema = null;
SecurityConfHandler.this.authzPlugin = cores.getAuthorizationPlugin();
return super.getCommandSchema();
}
});
this.apis = ImmutableList.copyOf(apis);
}
}
}
return this.apis;
}
Aggregations