Skip to content

Commit

Permalink
[GEOS-9083] Added back missing default master password warning.
Browse files Browse the repository at this point in the history
  • Loading branch information
sikeoka committed Dec 31, 2018
1 parent 99b7da5 commit b7e2a34
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1714,15 +1714,26 @@ public void saveMasterPasswordConfig(MasterPasswordConfig config) throws IOExcep

/** Checks the specified password against the master password. */
public boolean checkMasterPassword(String passwd) {
return checkMasterPassword(passwd.toCharArray());
return checkMasterPassword(passwd.toCharArray(), true);
}

/** Checks the specified password against the master password. */
public boolean checkMasterPassword(String passwd, boolean forLogin) {
return checkMasterPassword(passwd.toCharArray(), forLogin);
}

/** Checks the specified password against the master password. */
public boolean checkMasterPassword(char[] passwd) {
return checkMasterPassword(passwd, true);
}

/** Checks the specified password against the master password. */
public boolean checkMasterPassword(char[] passwd, boolean forLogin) {
try {
if (!this.masterPasswordProviderHelper
.loadConfig(this.masterPasswordConfig.getProviderName())
.isLoginEnabled()) {
if (forLogin
&& !this.masterPasswordProviderHelper
.loadConfig(this.masterPasswordConfig.getProviderName())
.isLoginEnabled()) {
return false;
}
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public SecurityWarningsPanel(String id) {
}

// check for default master password
boolean visibility = manager.checkMasterPassword(DEFAULT_ADMIN_PASSWD);
boolean visibility = manager.checkMasterPassword(DEFAULT_ADMIN_PASSWD, false);

Label label =
new Label(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* (c) 2018 Open Source Geospatial Foundation - all rights reserved
* This code is licensed under the GPL 2.0 license, available at the root
* application directory.
*/
package org.geoserver.security.web;

import org.geoserver.security.password.MasterPasswordProviderConfig;
import org.junit.Test;

public class SecurityHomePageContentProviderTest extends AbstractSecurityWicketTestSupport {

@Test
public void testMasterPasswordMessageWithLoginDisabled() throws Exception {
checkMasterPasswordMessage(false);
}

@Test
public void testMasterPasswordMessageWithLoginEnabled() throws Exception {
checkMasterPasswordMessage(true);
}

private void checkMasterPasswordMessage(boolean loginEnabled) throws Exception {
MasterPasswordProviderConfig masterPasswordConfig =
getSecurityManager()
.loadMasterPassswordProviderConfig(
getSecurityManager().getMasterPasswordConfig().getProviderName());
masterPasswordConfig.setLoginEnabled(loginEnabled);
getSecurityManager().saveMasterPasswordProviderConfig(masterPasswordConfig);
tester.startComponentInPage(
new SecurityHomePageContentProvider().getPageBodyComponent("swp"));
tester.assertComponent("swp", SecurityHomePageContentProvider.SecurityWarningsPanel.class);
tester.assertVisible("swp:mpmessage");
tester.assertVisible("swp:mplink");
}
}

0 comments on commit b7e2a34

Please sign in to comment.