laminelam commented on code in PR #857: URL: https://github.com/apache/solr/pull/857#discussion_r930273100
########## solr/solrj/src/java/org/apache/solr/common/cloud/DigestZkACLProvider.java: ########## @@ -0,0 +1,102 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.solr.common.cloud; + +import static org.apache.zookeeper.server.auth.DigestAuthenticationProvider.generateDigest; + +import java.lang.invoke.MethodHandles; +import java.security.NoSuchAlgorithmException; +import java.util.ArrayList; +import java.util.List; +import org.apache.solr.common.SolrException; +import org.apache.solr.common.StringUtils; +import org.apache.solr.common.cloud.ZkCredentialsInjector.ZkCredential; +import org.apache.zookeeper.ZooDefs; +import org.apache.zookeeper.data.ACL; +import org.apache.zookeeper.data.Id; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * A class that expects a {@link ZkCredentialsInjector} to create Zookeeper ACLs using digest scheme + */ +public class DigestZkACLProvider extends SecurityAwareZkACLProvider { + + private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + + /** Called by reflective instantiation */ + public DigestZkACLProvider() {} + + public DigestZkACLProvider(ZkCredentialsInjector zkCredentialsInjector) { + super(zkCredentialsInjector); + } + + /** + * @return Set of ACLs to return for non-security related znodes + */ + @Override + protected List<ACL> createNonSecurityACLsToAdd() { + return createACLsToAdd(true); + } + + /** + * Provider ACL Credential + * + * @return Set of ACLs to return security-related znodes + */ + @Override + protected List<ACL> createSecurityACLsToAdd() { + return createACLsToAdd(false); + } + + protected List<ACL> createACLsToAdd(boolean includeReadOnly) { + List<ACL> result = new ArrayList<>(); Review Comment: This is exactly what I did in the first version of the code but ended up removing it for sack of readability as this small piece of code is only called once at server start-up and has almost zero impact in term of performance. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For additional commands, e-mail: issues-h...@solr.apache.org