Search in sources :

Example 1 with SpecProvider

use of org.apache.solr.api.SpecProvider 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;
}
Also used : ReqHandlerToApi(org.apache.solr.api.ApiBag.ReqHandlerToApi) ArrayList(java.util.ArrayList) AuthenticationPlugin(org.apache.solr.security.AuthenticationPlugin) AuthorizationPlugin(org.apache.solr.security.AuthorizationPlugin) ApiBag(org.apache.solr.api.ApiBag) SpecProvider(org.apache.solr.api.SpecProvider) ReqHandlerToApi(org.apache.solr.api.ApiBag.ReqHandlerToApi) Api(org.apache.solr.api.Api) ReqHandlerToApi(org.apache.solr.api.ApiBag.ReqHandlerToApi) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Aggregations

ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 Api (org.apache.solr.api.Api)1 ApiBag (org.apache.solr.api.ApiBag)1 ReqHandlerToApi (org.apache.solr.api.ApiBag.ReqHandlerToApi)1 SpecProvider (org.apache.solr.api.SpecProvider)1 AuthenticationPlugin (org.apache.solr.security.AuthenticationPlugin)1 AuthorizationPlugin (org.apache.solr.security.AuthorizationPlugin)1