From 3d913558aba476c6a94b892b24f97b66f34cc2d0 Mon Sep 17 00:00:00 2001 From: reger Date: Fri, 27 Dec 2013 21:04:14 +0100 Subject: [PATCH] display configured adminUserName in ConfigAccounts_p - fix read default username in in loginservice --- htroot/ConfigAccounts_p.java | 2 +- source/net/yacy/http/YaCyLoginService.java | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/htroot/ConfigAccounts_p.java b/htroot/ConfigAccounts_p.java index 533dfc81f..a80176cbc 100644 --- a/htroot/ConfigAccounts_p.java +++ b/htroot/ConfigAccounts_p.java @@ -96,7 +96,7 @@ public class ConfigAccounts_p { prop.put("localhost.checked", (localhostAccess) ? 1 : 0); prop.put("account.checked", (localhostAccess) ? 0 : 1); prop.put("statusPassword", localhostAccess ? "0" : "1"); - prop.put("defaultUser", "admin"); + prop.put("defaultUser", env.getConfig("adminAccountUserName", "admin")); //default values prop.put("current_user", "newuser"); diff --git a/source/net/yacy/http/YaCyLoginService.java b/source/net/yacy/http/YaCyLoginService.java index e60ec2245..bc0d798ae 100644 --- a/source/net/yacy/http/YaCyLoginService.java +++ b/source/net/yacy/http/YaCyLoginService.java @@ -49,7 +49,7 @@ public class YaCyLoginService extends MappedLoginService { // TODO: implement legacy credentials final Switchboard sb = Switchboard.getSwitchboard(); - String adminuser = sb.getConfig("adminAccount", "admin"); + String adminuser = sb.getConfig("adminAccountUserName", "admin"); if (username.equals(adminuser)) { final String adminAccountBase64MD5 = sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, ""); // in YaCy the credential hash is composed of username:pwd so the username is needed to create valid credential @@ -69,9 +69,8 @@ public class YaCyLoginService extends MappedLoginService { } else { // get user data from UserDB Entry user = sb.userDB.getEntry(username); if (user != null) { - String[] role; if (user.hasRight(AccessRight.ADMIN_RIGHT)) { - role = new String[]{AccessRight.ADMIN_RIGHT.toString()}; + String[] role = new String[]{AccessRight.ADMIN_RIGHT.toString()}; Credential credential = YaCyLegacyCredential.getCredentials(username, user.getMD5EncodedUserPwd()); Principal userPrincipal = new MappedLoginService.KnownUser(username, credential);