do not overwrite PW with random PW

pull/402/head
Michael Peter Christen 4 years ago
parent 3e6a1e0a49
commit 907f121d0c

@ -97,14 +97,7 @@ public class ConfigAccounts_p {
if (inputerror == 0) {
if (localhostAccess) {
sb.setConfig(SwitchboardConstants.ADMIN_ACCOUNT_FOR_LOCALHOST, true);
// if an localhost access is configured, check if a local password is given
// if not, set a random password
if (env.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, "").isEmpty()) {
// make a 'random' password
env.setConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, "0000" + sb.genRandomPassword());
}
} else {
sb.setConfig(SwitchboardConstants.ADMIN_ACCOUNT_FOR_LOCALHOST, false);
if (env.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, "").startsWith("0000")) {

@ -2620,13 +2620,6 @@ public final class Switchboard extends serverSwitch {
GuiHandler.clear();
}
// set a random password if no password is configured
if ( getConfigBool(SwitchboardConstants.ADMIN_ACCOUNT_FOR_LOCALHOST, false)
&& getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, "").isEmpty() ) {
// make a 'random' password, this will keep the ability to log in from localhost without password
setConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, "0000" + this.genRandomPassword());
}
// stop greedylearning if limit is reached
if (getConfigBool(SwitchboardConstants.GREEDYLEARNING_ACTIVE, false)) {
long cs = this.index.fulltext().collectionSize();

@ -38,13 +38,11 @@ import java.util.LinkedHashSet;
import java.util.Map;
import java.util.NavigableMap;
import java.util.Properties;
import java.util.Random;
import java.util.Set;
import java.util.TreeMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import net.yacy.cora.order.Digest;
import net.yacy.cora.protocol.ClientIdentification;
import net.yacy.cora.protocol.Domains;
import net.yacy.cora.protocol.HeaderFramework;
@ -737,30 +735,6 @@ public class serverSwitch {
throw new FileNotFoundException(f.toString());
}
private static Random pwGenerator = new Random();
/**
* Generates a random password.
*
* @return random password which is 20 characters long.
*/
public String genRandomPassword() {
return genRandomPassword(20);
}
/**
* Generates a random password of a given length.
*
* @param length
* length o password
* @return password of given length
*/
public String genRandomPassword(final int length) {
byte[] bytes = new byte[length];
pwGenerator.nextBytes(bytes);
return Digest.encodeMD5Hex(bytes);
}
/**
* set/remember jetty server
*

Loading…
Cancel
Save