use of password.pwm.http.bean.ConfigGuideBean in project pwm by pwm-project.
the class ConfigGuideServlet method restGotoStep.
@ActionHandler(action = "gotoStep")
private ProcessStatus restGotoStep(final PwmRequest pwmRequest) throws PwmUnrecoverableException, IOException, ServletException {
final ConfigGuideBean configGuideBean = getBean(pwmRequest);
final String requestedStep = pwmRequest.readParameterAsString("step");
GuideStep step = GuideStep.START;
if (requestedStep != null && requestedStep.length() > 0) {
try {
step = GuideStep.valueOf(requestedStep);
} catch (IllegalArgumentException e) {
final String errorMsg = "unknown goto step request: " + requestedStep;
LOGGER.error(pwmRequest, errorMsg);
}
}
if (step == GuideStep.START) {
configGuideBean.getFormData().clear();
configGuideBean.getFormData().putAll(ConfigGuideForm.defaultForm());
} else if (step == GuideStep.NEXT) {
step = configGuideBean.getStep().next();
while (step != GuideStep.FINISH && !step.visible(configGuideBean)) {
step = step.next();
}
} else if (step == GuideStep.PREVIOUS) {
step = configGuideBean.getStep().previous();
while (step != GuideStep.START && !step.visible(configGuideBean)) {
step = step.previous();
}
}
if (step == GuideStep.FINISH) {
final ContextManager contextManager = ContextManager.getContextManager(pwmRequest);
try {
ConfigGuideUtils.writeConfig(contextManager, configGuideBean);
pwmRequest.getPwmSession().getSessionStateBean().setTheme(null);
} catch (PwmException e) {
final RestResultBean restResultBean = RestResultBean.fromError(e.getErrorInformation(), pwmRequest);
pwmRequest.outputJsonResult(restResultBean);
return ProcessStatus.Halt;
} catch (Exception e) {
final RestResultBean restResultBean = RestResultBean.fromError(new ErrorInformation(PwmError.ERROR_UNKNOWN, "error during save: " + e.getMessage()), pwmRequest);
pwmRequest.outputJsonResult(restResultBean);
return ProcessStatus.Halt;
}
final HashMap<String, String> resultData = new HashMap<>();
resultData.put("serverRestart", "true");
pwmRequest.outputJsonResult(RestResultBean.withData(resultData));
pwmRequest.invalidateSession();
} else {
configGuideBean.setStep(step);
pwmRequest.outputJsonResult(RestResultBean.forSuccessMessage(pwmRequest, Message.Success_Unknown));
LOGGER.trace("setting current step to: " + step);
}
return ProcessStatus.Continue;
}
use of password.pwm.http.bean.ConfigGuideBean in project pwm by pwm-project.
the class ConfigGuideServlet method restUseConfiguredCerts.
@ActionHandler(action = "useConfiguredCerts")
private ProcessStatus restUseConfiguredCerts(final PwmRequest pwmRequest) throws PwmUnrecoverableException, IOException {
final ConfigGuideBean configGuideBean = getBean(pwmRequest);
final boolean value = Boolean.parseBoolean(pwmRequest.readParameterAsString("value"));
configGuideBean.setUseConfiguredCerts(value);
pwmRequest.outputJsonResult(RestResultBean.forSuccessMessage(pwmRequest, Message.Success_Unknown));
return ProcessStatus.Halt;
}
use of password.pwm.http.bean.ConfigGuideBean in project pwm by pwm-project.
the class ConfigGuideServlet method restBrowseLdap.
@ActionHandler(action = "browseLdap")
private ProcessStatus restBrowseLdap(final PwmRequest pwmRequest) throws IOException, PwmUnrecoverableException {
final ConfigGuideBean configGuideBean = getBean(pwmRequest);
final StoredConfigurationImpl storedConfiguration = ConfigGuideForm.generateStoredConfig(configGuideBean);
if (configGuideBean.getStep() == GuideStep.LDAP_PROXY) {
storedConfiguration.resetSetting(PwmSetting.LDAP_PROXY_USER_DN, LDAP_PROFILE_KEY, null);
storedConfiguration.resetSetting(PwmSetting.LDAP_PROXY_USER_PASSWORD, LDAP_PROFILE_KEY, null);
}
final Instant startTime = Instant.now();
final Map<String, String> inputMap = pwmRequest.readBodyAsJsonStringMap(PwmHttpRequestWrapper.Flag.BypassValidation);
final String profile = inputMap.get("profile");
final String dn = inputMap.getOrDefault("dn", "");
final LdapBrowser ldapBrowser = new LdapBrowser(pwmRequest.getPwmApplication().getLdapConnectionService().getChaiProviderFactory(), storedConfiguration);
final LdapBrowser.LdapBrowseResult result = ldapBrowser.doBrowse(profile, dn);
ldapBrowser.close();
LOGGER.trace(pwmRequest, "performed ldapBrowse operation in " + TimeDuration.fromCurrent(startTime).asCompactString() + ", result=" + JsonUtil.serialize(result));
pwmRequest.outputJsonResult(RestResultBean.withData(result));
return ProcessStatus.Halt;
}
Aggregations