static Map getCollectionsForAdminOp()

in plugin-solr/src/main/java/org/apache/ranger/authorization/solr/authorizer/SolrAuthzUtil.java [109:190]


    static Map<String, RangerSolrConstants.AccessType> getCollectionsForAdminOp(AuthorizationContext ctx) {
        String           actionName = ctx.getParams().get(CoreAdminParams.ACTION);
        CollectionAction action     = CollectionAction.get(actionName);

        if (action != null) {
            switch (action) {
                case LISTSNAPSHOTS:
                case BACKUP: {
                    String name = ctx.getParams().get(CollectionAdminParams.COLLECTION);

                    return (name != null) ? Collections.singletonMap(name, RangerSolrConstants.AccessType.QUERY) : Collections.emptyMap();
                }

                case MIGRATE: {
                    Map<String, RangerSolrConstants.AccessType> result = new HashMap<>();
                    String                                      source = ctx.getParams().get(CollectionAdminParams.COLLECTION);
                    String                                      target = ctx.getParams().get("target." + CollectionAdminParams.COLLECTION);

                    if (source != null) {
                        result.put(source, RangerSolrConstants.AccessType.QUERY);
                    }

                    if (target != null) {
                        result.put(source, RangerSolrConstants.AccessType.UPDATE);
                    }

                    return result;
                }

                case DELETE:
                case CREATEALIAS:
                case DELETEALIAS:
                case CREATESHARD:
                case DELETESHARD:
                case SPLITSHARD:
                case RELOAD:
                case CREATE: {
                    String name = ctx.getParams().get(CommonParams.NAME);

                    return (name != null) ? Collections.singletonMap(name, RangerSolrConstants.AccessType.UPDATE) : Collections.emptyMap();
                }

                case DELETESNAPSHOT:
                case CREATESNAPSHOT:
                case SYNCSHARD:
                case MOVEREPLICA:
                case RESTORE:
                case MIGRATESTATEFORMAT:
                case FORCELEADER:
                case REBALANCELEADERS:
                case BALANCESHARDUNIQUE:
                case ADDREPLICAPROP:
                case DELETEREPLICAPROP:
                case ADDREPLICA:
                case DELETEREPLICA:
                case MODIFYCOLLECTION: {
                    String name = ctx.getParams().get(CollectionAdminParams.COLLECTION);

                    return (name != null) ? Collections.singletonMap(name, RangerSolrConstants.AccessType.UPDATE) : Collections.emptyMap();
                }

                case MOCK_COLL_TASK:
                case MOCK_REPLICA_TASK:
                case MOCK_SHARD_TASK:
                case REPLACENODE:
                case DELETENODE:
                case ADDROLE:
                case REMOVEROLE:
                case REQUESTSTATUS:
                case DELETESTATUS:
                case LIST:
                case LISTALIASES:
                case CLUSTERPROP:
                case OVERSEERSTATUS:
                case CLUSTERSTATUS: {
                    return Collections.emptyMap();
                }
            }
        }

        return Collections.emptyMap();
    }