use of org.motechproject.config.domain.MotechSettings in project motech by motech.
the class SettingServiceImpl method getPasswordValidator.
@Override
public PasswordValidator getPasswordValidator() {
MotechSettings motechSettings = configurationService.getPlatformSettings();
String validatorName = motechSettings.getPasswordValidator();
PasswordValidator validator = null;
if (StringUtils.isNotBlank(validatorName)) {
LOGGER.debug("No password validator configured");
validator = passwordValidatorManager.getValidator(validatorName);
}
if (validator == null) {
validator = passwordValidatorManager.noneValidator();
}
// if min pass length configured, then decorate the validator
int minPassLength = getMinPasswordLength();
if (minPassLength > 0) {
validator = new MinLengthValidatorDecorator(validator, minPassLength);
}
return validator;
}
use of org.motechproject.config.domain.MotechSettings in project motech by motech.
the class PasswordRecoveryServiceTest method shouldSendRecoveryEmail.
@Test
public void shouldSendRecoveryEmail() {
motechSettings = mock(MotechSettings.class);
when(settingsFacade.getPlatformSettings()).thenReturn(motechSettings);
when(motechSettings.getServerHost()).thenReturn("serverurl");
when(motechSettings.getServerUrl()).thenReturn("http://serverurl");
when(motechSettings.getLoginMode()).thenReturn(LoginMode.REPOSITORY);
PasswordRecovery newRecovery = new PasswordRecovery();
newRecovery.setUsername(USERNAME);
newRecovery.setEmail(EMAIL);
newRecovery.setToken(TOKEN);
newRecovery.setExpirationDate(DateTime.now().plusHours(1));
newRecovery.setLocale(Locale.ENGLISH);
emailSenderInjected.sendRecoveryEmail(newRecovery);
verify(eventRelay).sendEventMessage(any(emailEvent.getClass()));
}
use of org.motechproject.config.domain.MotechSettings in project motech by motech.
the class StartupController method submitForm.
@RequestMapping(value = "/startup", method = RequestMethod.POST)
@ResponseBody
public List<String> submitForm(@RequestBody StartupForm startupSettings) throws IOException {
ConfigSource configSource = (configurationService.loadBootstrapConfig() != null) ? configurationService.loadBootstrapConfig().getConfigSource() : ConfigSource.UI;
StartupFormValidator startupFormValidator = startupFormValidatorFactory.getStartupFormValidator(startupSettings, userService);
List<String> errors = startupFormValidator.validate(startupSettings, configurationService.getConfigSource());
if (!errors.isEmpty()) {
return errors;
} else if (!startupManager.canLaunchBundles()) {
if (ConfigSource.UI.equals(configSource)) {
MotechSettings settings = startupManager.getDefaultSettings();
settings.setLanguage(startupSettings.getLanguage());
settings.setLoginModeValue(startupSettings.getLoginMode());
settings.setProviderName(startupSettings.getProviderName());
settings.setProviderUrl(startupSettings.getProviderUrl());
configurationService.savePlatformSettings(settings);
if (LoginMode.REPOSITORY.equals(LoginMode.valueOf(startupSettings.getLoginMode()))) {
registerMotechAdmin(startupSettings);
}
} else {
registerMotechAdmin(startupSettings);
}
startupManager.startup();
}
return errors;
}
Aggregations