enhanced ability to debug the code

pull/402/head
Michael Peter Christen 4 years ago
parent eea2d71851
commit e0f4e3fd9a

@ -65,11 +65,12 @@ public class YaCyLegacyCredential extends Credential {
public boolean check(Object credentials) { public boolean check(Object credentials) {
if (credentials instanceof Credential) { // for DIGEST auth if (credentials instanceof Credential) { // for DIGEST auth
if(this.c == null) { if (this.c == null) {
/* credential may be null after switching from BASIC to DIGEST authentication without re-encoding the password */ /* credential may be null after switching from BASIC to DIGEST authentication without re-encoding the password */
return false; return false;
} }
return ((Credential) credentials).check(this.c); Credential credential = (Credential) credentials;
return credential.check(this.c);
} }
if (credentials instanceof String) { // for BASIC auth if (credentials instanceof String) { // for BASIC auth
final String pw = (String) credentials; final String pw = (String) credentials;
@ -88,7 +89,8 @@ public class YaCyLegacyCredential extends Credential {
// normal users (and new admin pwd) for BASIC auth // normal users (and new admin pwd) for BASIC auth
if (hash.startsWith("MD5:") && hash != null) { if (hash.startsWith("MD5:") && hash != null) {
boolean success = (Digest.encodeMD5Hex(foruser + ":" + Switchboard.getSwitchboard().getConfig(SwitchboardConstants.ADMIN_REALM,"YaCy")+":" + pw).equals(hash.substring(4))); String realm = Switchboard.getSwitchboard().getConfig(SwitchboardConstants.ADMIN_REALM, "");
boolean success = Digest.encodeMD5Hex(foruser + ":" + realm + ":" + pw).equals(hash.substring(4));
// exception: allow the hash as pwd (used in bin/apicall.sh) // exception: allow the hash as pwd (used in bin/apicall.sh)
if (!success && foruser.equals(Switchboard.getSwitchboard().getConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, "admin"))) { if (!success && foruser.equals(Switchboard.getSwitchboard().getConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, "admin"))) {
if (pw.equals(hash)) { if (pw.equals(hash)) {

Loading…
Cancel
Save