Line data Source code
1 : // Copyright (C) 2016 The Android Open Source Project 2 : // 3 : // Licensed under the Apache License, Version 2.0 (the "License"); 4 : // you may not use this file except in compliance with the License. 5 : // You may obtain a copy of the License at 6 : // 7 : // http://www.apache.org/licenses/LICENSE-2.0 8 : // 9 : // Unless required by applicable law or agreed to in writing, software 10 : // distributed under the License is distributed on an "AS IS" BASIS, 11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 : // See the License for the specific language governing permissions and 13 : // limitations under the License. 14 : 15 : package com.google.gerrit.server.config; 16 : 17 : import com.google.gerrit.server.securestore.SecureStore; 18 : import org.eclipse.jgit.lib.Config; 19 : 20 : /** Plugin configuration in etc/$PLUGIN.config and etc/$PLUGIN.secure.config. */ 21 : public class GlobalPluginConfig extends Config { 22 : private final SecureStore secureStore; 23 : private final String pluginName; 24 : 25 : GlobalPluginConfig(String pluginName, Config baseConfig, SecureStore secureStore) { 26 1 : super(baseConfig); 27 1 : this.pluginName = pluginName; 28 1 : this.secureStore = secureStore; 29 1 : } 30 : 31 : @Override 32 : public String getString(String section, String subsection, String name) { 33 1 : String secure = secureStore.getForPlugin(pluginName, section, subsection, name); 34 1 : if (secure != null) { 35 0 : return secure; 36 : } 37 1 : return super.getString(section, subsection, name); 38 : } 39 : 40 : @Override 41 : public String[] getStringList(String section, String subsection, String name) { 42 1 : String[] secure = secureStore.getListForPlugin(pluginName, section, subsection, name); 43 1 : if (secure != null && secure.length > 0) { 44 0 : return secure; 45 : } 46 1 : return super.getStringList(section, subsection, name); 47 : } 48 : }