Extend SecureStore interface
Since initial implementation of SecureStore interface was introduced new data types were used to store and retrieve sensitive data. Therefore getList and setList methods needs to be added to it. Change-Id: I678171df406e6f9cd19c18fc7c0d546bd8dba973 Signed-off-by: Dariusz Luksza <dariusz@luksza.org>
This commit is contained in:
@@ -15,7 +15,6 @@
|
||||
package com.google.gerrit.server.securestore;
|
||||
|
||||
import com.google.gerrit.common.FileUtil;
|
||||
import com.google.gerrit.extensions.annotations.Export;
|
||||
import com.google.gerrit.server.config.SitePaths;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
@@ -27,12 +26,10 @@ import org.eclipse.jgit.util.FS;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@Singleton
|
||||
@Export(DefaultSecureStore.NAME)
|
||||
public class DefaultSecureStore implements SecureStore {
|
||||
public static final String NAME = "default";
|
||||
|
||||
private final FileBasedConfig sec;
|
||||
|
||||
@Inject
|
||||
@@ -51,6 +48,11 @@ public class DefaultSecureStore implements SecureStore {
|
||||
return sec.getString(section, subsection, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getList(String section, String subsection, String name) {
|
||||
return sec.getStringList(section, subsection, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(String section, String subsection, String name, String value) {
|
||||
if (value != null) {
|
||||
@@ -61,6 +63,17 @@ public class DefaultSecureStore implements SecureStore {
|
||||
save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setList(String section, String subsection, String name,
|
||||
List<String> values) {
|
||||
if (values != null) {
|
||||
sec.setStringList(section, subsection, name, values);
|
||||
} else {
|
||||
sec.unset(section, subsection, name);
|
||||
}
|
||||
save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unset(String section, String subsection, String name) {
|
||||
sec.unset(section, subsection, name);
|
||||
|
||||
@@ -16,12 +16,18 @@ package com.google.gerrit.server.securestore;
|
||||
|
||||
import com.google.gerrit.extensions.annotations.ExtensionPoint;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ExtensionPoint
|
||||
public interface SecureStore {
|
||||
|
||||
String get(String section, String subsection, String name);
|
||||
|
||||
String[] getList(String section, String subsection, String name);
|
||||
|
||||
void set(String section, String subsection, String name, String value);
|
||||
|
||||
void setList(String section, String subsection, String name, List<String> values);
|
||||
|
||||
void unset(String section, String subsection, String name);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user