You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by no...@apache.org on 2016/03/21 11:00:13 UTC

lucene-solr:apiv2: SOLR-8029: security api spec should be lazily loaded because it can change with the implementation

Repository: lucene-solr
Updated Branches:
  refs/heads/apiv2 0412be5d6 -> 6aedeb9c4


SOLR-8029: security api spec should be lazily loaded because it can change with the implementation


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/6aedeb9c
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/6aedeb9c
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/6aedeb9c

Branch: refs/heads/apiv2
Commit: 6aedeb9c44f7725addfefb7eb4dfa4484e826a05
Parents: 0412be5
Author: Noble Paul <no...@apache.org>
Authored: Mon Mar 21 15:29:56 2016 +0530
Committer: Noble Paul <no...@apache.org>
Committed: Mon Mar 21 15:29:56 2016 +0530

----------------------------------------------------------------------
 .../apache/solr/handler/SolrConfigHandler.java  |  1 -
 .../solr/handler/admin/SecurityConfHandler.java | 25 +++++++++++++++-----
 2 files changed, 19 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6aedeb9c/solr/core/src/java/org/apache/solr/handler/SolrConfigHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/SolrConfigHandler.java b/solr/core/src/java/org/apache/solr/handler/SolrConfigHandler.java
index 42239dd..4182f4d 100644
--- a/solr/core/src/java/org/apache/solr/handler/SolrConfigHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/SolrConfigHandler.java
@@ -72,7 +72,6 @@ import org.apache.solr.response.SolrQueryResponse;
 import org.apache.solr.schema.SchemaManager;
 import org.apache.solr.security.AuthorizationContext;
 import org.apache.solr.security.PermissionNameProvider;
-import org.apache.solr.security.PermissionNameProvider.Name;
 import org.apache.solr.util.CommandOperation;
 import org.apache.solr.util.DefaultSolrThreadFactory;
 import org.apache.solr.util.RTimer;

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/6aedeb9c/solr/core/src/java/org/apache/solr/handler/admin/SecurityConfHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/SecurityConfHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/SecurityConfHandler.java
index eb63410..b06a017 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/SecurityConfHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/SecurityConfHandler.java
@@ -29,7 +29,6 @@ import com.google.common.collect.ImmutableList;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.cloud.ZkStateReader.ConfigData;
 import org.apache.solr.common.params.CommonParams;
-import org.apache.solr.common.util.Map2;
 import org.apache.solr.common.util.Utils;
 import org.apache.solr.core.CoreContainer;
 import org.apache.solr.handler.RequestHandlerBase;
@@ -44,7 +43,6 @@ import org.apache.solr.security.PermissionNameProvider;
 import org.apache.solr.util.CommandOperation;
 import org.apache.solr.api.Api;
 import org.apache.solr.api.ApiBag;
-import org.apache.solr.api.ApiSupport;
 import org.apache.solr.api.SpecProvider;
 import org.apache.zookeeper.KeeperException;
 
@@ -196,15 +194,30 @@ public class SecurityConfHandler extends RequestHandlerBase implements Permissio
           final SpecProvider authzCommands = ApiBag.getSpec("cluster.security.authorization.Commands");
           apis.add(ApiBag.wrapRequestHandler(this, ApiBag.getSpec("cluster.security.authentication")));
           apis.add(ApiBag.wrapRequestHandler(this, ApiBag.getSpec("cluster.security.authorization")));
-          AuthenticationPlugin authcPlugin = cores.getAuthenticationPlugin();
-          apis.add(ApiBag.wrapRequestHandler(this, authcPlugin != null && authcPlugin instanceof SpecProvider ? ((SpecProvider) authcPlugin) : authcCommands));
-          AuthorizationPlugin authzPlugin = cores.getAuthorizationPlugin();
-          apis.add(ApiBag.wrapRequestHandler(this, authzPlugin != null && authzPlugin instanceof SpecProvider ? ((SpecProvider) authzPlugin) : authzCommands));
+          apis.add(ApiBag.wrapRequestHandler(this, () -> {
+            AuthenticationPlugin authcPlugin = cores.getAuthenticationPlugin();
+            return authcPlugin != null && authcPlugin instanceof SpecProvider ?
+                ((SpecProvider) authcPlugin).getSpec() :
+                ApiBag.getSpec("cluster.security.authentication.Commands").getSpec();
+          }));
+
+//          AuthorizationPlugin authzPlugin = cores.getAuthorizationPlugin();
+//          apis.add(ApiBag.wrapRequestHandler(this, authzPlugin != null && authzPlugin instanceof SpecProvider ? ((SpecProvider) authzPlugin) : authzCommands));
+
+          apis.add(ApiBag.wrapRequestHandler(this, () -> {
+            AuthorizationPlugin authzPlugin = cores.getAuthorizationPlugin();
+            return authzPlugin != null && authzPlugin instanceof SpecProvider ?
+                ((SpecProvider) authzPlugin).getSpec() :
+                ApiBag.getSpec("cluster.security.authorization.Commands").getSpec();
+          }));
+
+
           this.apis = ImmutableList.copyOf(apis);
         }
       }
     }
     return this.apis;
   }
+
 }