Search in sources :

Example 26 with StoredConfigurationImpl

use of password.pwm.config.stored.StoredConfigurationImpl 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;
}
Also used : ConfigGuideBean(password.pwm.http.bean.ConfigGuideBean) StoredConfigurationImpl(password.pwm.config.stored.StoredConfigurationImpl) Instant(java.time.Instant) LdapBrowser(password.pwm.ldap.LdapBrowser)

Example 27 with StoredConfigurationImpl

use of password.pwm.config.stored.StoredConfigurationImpl in project pwm by pwm-project.

the class ConfigManagerServlet method showPermissions.

private void showPermissions(final PwmRequest pwmRequest) throws IOException, ServletException, PwmUnrecoverableException {
    final StoredConfigurationImpl storedConfiguration = readCurrentConfiguration(pwmRequest);
    final LDAPPermissionCalculator ldapPermissionCalculator = new LDAPPermissionCalculator(storedConfiguration);
    pwmRequest.setAttribute(PwmRequestAttribute.LdapPermissionItems, ldapPermissionCalculator);
    pwmRequest.forwardToJsp(JspUrl.CONFIG_MANAGER_PERMISSIONS);
}
Also used : StoredConfigurationImpl(password.pwm.config.stored.StoredConfigurationImpl) LDAPPermissionCalculator(password.pwm.util.LDAPPermissionCalculator)

Example 28 with StoredConfigurationImpl

use of password.pwm.config.stored.StoredConfigurationImpl in project pwm by pwm-project.

the class ConfigManagerServlet method downloadPermissionReportCsv.

private void downloadPermissionReportCsv(final PwmRequest pwmRequest) throws PwmUnrecoverableException, IOException, ChaiUnavailableException, ServletException {
    pwmRequest.getPwmResponse().markAsDownload(HttpContentType.csv, pwmRequest.getConfig().readAppProperty(AppProperty.DOWNLOAD_FILENAME_LDAP_PERMISSION_CSV));
    final CSVPrinter csvPrinter = JavaHelper.makeCsvPrinter(pwmRequest.getPwmResponse().getOutputStream());
    try {
        final StoredConfigurationImpl storedConfiguration = readCurrentConfiguration(pwmRequest);
        final LDAPPermissionCalculator ldapPermissionCalculator = new LDAPPermissionCalculator(storedConfiguration);
        for (final LDAPPermissionCalculator.PermissionRecord permissionRecord : ldapPermissionCalculator.getPermissionRecords()) {
            final String settingTxt = permissionRecord.getPwmSetting() == null ? LocaleHelper.getLocalizedMessage(Display.Value_NotApplicable, pwmRequest) : permissionRecord.getPwmSetting().toMenuLocationDebug(permissionRecord.getProfile(), pwmRequest.getLocale());
            csvPrinter.printRecord(permissionRecord.getActor().getLabel(pwmRequest.getLocale(), pwmRequest.getConfig()), permissionRecord.getAttribute(), permissionRecord.getAccess().toString(), settingTxt);
        }
    } catch (Exception e) {
        final ErrorInformation errorInformation = new ErrorInformation(PwmError.ERROR_UNKNOWN, e.getMessage());
        LOGGER.error(pwmRequest, errorInformation);
        pwmRequest.respondWithError(errorInformation);
    } finally {
        IOUtils.closeQuietly(csvPrinter);
    }
}
Also used : CSVPrinter(org.apache.commons.csv.CSVPrinter) ErrorInformation(password.pwm.error.ErrorInformation) StoredConfigurationImpl(password.pwm.config.stored.StoredConfigurationImpl) LDAPPermissionCalculator(password.pwm.util.LDAPPermissionCalculator) ServletException(javax.servlet.ServletException) PwmUnrecoverableException(password.pwm.error.PwmUnrecoverableException) ChaiUnavailableException(com.novell.ldapchai.exception.ChaiUnavailableException) PwmException(password.pwm.error.PwmException) IOException(java.io.IOException)

Example 29 with StoredConfigurationImpl

use of password.pwm.config.stored.StoredConfigurationImpl in project pwm by pwm-project.

the class ConfigManagerServlet method showSummary.

private void showSummary(final PwmRequest pwmRequest) throws IOException, ServletException, PwmUnrecoverableException {
    final StoredConfigurationImpl storedConfiguration = readCurrentConfiguration(pwmRequest);
    final LinkedHashMap<String, Object> outputMap = new LinkedHashMap<>(storedConfiguration.toOutputMap(pwmRequest.getLocale()));
    pwmRequest.setAttribute(PwmRequestAttribute.ConfigurationSummaryOutput, outputMap);
    pwmRequest.forwardToJsp(JspUrl.CONFIG_MANAGER_EDITOR_SUMMARY);
}
Also used : StoredConfigurationImpl(password.pwm.config.stored.StoredConfigurationImpl) LinkedHashMap(java.util.LinkedHashMap)

Example 30 with StoredConfigurationImpl

use of password.pwm.config.stored.StoredConfigurationImpl in project pwm by pwm-project.

the class ConfigManagerServlet method readCurrentConfiguration.

public static StoredConfigurationImpl readCurrentConfiguration(final PwmRequest pwmRequest) throws PwmUnrecoverableException {
    final ContextManager contextManager = ContextManager.getContextManager(pwmRequest.getHttpServletRequest().getSession());
    final ConfigurationReader runningConfigReader = contextManager.getConfigReader();
    final StoredConfigurationImpl runningConfig = runningConfigReader.getStoredConfiguration();
    return StoredConfigurationImpl.copy(runningConfig);
}
Also used : StoredConfigurationImpl(password.pwm.config.stored.StoredConfigurationImpl) ContextManager(password.pwm.http.ContextManager) ConfigurationReader(password.pwm.config.stored.ConfigurationReader)

Aggregations

StoredConfigurationImpl (password.pwm.config.stored.StoredConfigurationImpl)34 PwmException (password.pwm.error.PwmException)11 PwmUnrecoverableException (password.pwm.error.PwmUnrecoverableException)11 IOException (java.io.IOException)9 ServletException (javax.servlet.ServletException)9 PwmSetting (password.pwm.config.PwmSetting)9 ChaiUnavailableException (com.novell.ldapchai.exception.ChaiUnavailableException)8 LinkedHashMap (java.util.LinkedHashMap)8 ConfigurationReader (password.pwm.config.stored.ConfigurationReader)7 ErrorInformation (password.pwm.error.ErrorInformation)7 PwmOperationalException (password.pwm.error.PwmOperationalException)7 ConfigManagerBean (password.pwm.http.bean.ConfigManagerBean)7 ConfigGuideBean (password.pwm.http.bean.ConfigGuideBean)6 ArrayList (java.util.ArrayList)5 PwmApplication (password.pwm.PwmApplication)5 StoredValue (password.pwm.config.StoredValue)5 PwmLocaleBundle (password.pwm.i18n.PwmLocaleBundle)5 RestResultBean (password.pwm.ws.server.RestResultBean)5 Instant (java.time.Instant)4 List (java.util.List)4