Move registerEmailPrivateKey to secure.config
This is the last column in the system_config table that is needed by the stand-alone daemon installation format. Later we can look into dropping the entire system_config table. Change-Id: I8448c79e959b465e370a10a7fa6751c200c1b1a0
This commit is contained in:
@@ -18,6 +18,7 @@ import static com.google.gerrit.pgm.init.InitUtil.dnOf;
|
||||
|
||||
import com.google.gerrit.pgm.util.ConsoleUI;
|
||||
import com.google.gerrit.reviewdb.AuthType;
|
||||
import com.google.gwtjsonrpc.server.SignedToken;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@@ -80,5 +81,9 @@ class InitAuth implements InitStep {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (auth.getSecure("registerEmailPrivateKey") == null) {
|
||||
auth.setSecure("registerEmailPrivateKey", SignedToken.generateRandomKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -126,7 +126,7 @@ class Section {
|
||||
}
|
||||
|
||||
String password(final String username, final String password) {
|
||||
final String ov = flags.sec.getString(section, null, password);
|
||||
final String ov = getSecure(password);
|
||||
|
||||
String user = flags.sec.getString(section, null, username);
|
||||
if (user == null) {
|
||||
@@ -149,15 +149,23 @@ class Section {
|
||||
|
||||
final String nv = ui.password("%s's password", user);
|
||||
if (!eq(ov, nv)) {
|
||||
if (nv != null) {
|
||||
flags.sec.setString(section, null, password, nv);
|
||||
} else {
|
||||
flags.sec.unset(section, null, password);
|
||||
}
|
||||
setSecure(password, nv);
|
||||
}
|
||||
return nv;
|
||||
}
|
||||
|
||||
String getSecure(String name) {
|
||||
return flags.sec.getString(section, null, name);
|
||||
}
|
||||
|
||||
void setSecure(String name, String value) {
|
||||
if (value != null) {
|
||||
flags.sec.setString(section, null, name, value);
|
||||
} else {
|
||||
flags.sec.unset(section, null, name);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean eq(final String a, final String b) {
|
||||
if (a == null && b == null) {
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user