Search in sources :

Example 1 with LDAPPermissionCalculator

use of password.pwm.util.LDAPPermissionCalculator in project pwm by pwm-project.

the class ConfigGuideUtils method forwardToJSP.

static void forwardToJSP(final PwmRequest pwmRequest) throws IOException, ServletException, PwmUnrecoverableException {
    final ConfigGuideBean configGuideBean = pwmRequest.getPwmApplication().getSessionStateService().getBean(pwmRequest, ConfigGuideBean.class);
    if (configGuideBean.getStep() == GuideStep.LDAP_PERMISSIONS) {
        final LDAPPermissionCalculator ldapPermissionCalculator = new LDAPPermissionCalculator(ConfigGuideForm.generateStoredConfig(configGuideBean));
        pwmRequest.setAttribute(PwmRequestAttribute.LdapPermissionItems, ldapPermissionCalculator);
    }
    final HttpServletRequest req = pwmRequest.getHttpServletRequest();
    final ServletContext servletContext = req.getSession().getServletContext();
    String destURL = '/' + PwmConstants.URL_JSP_CONFIG_GUIDE;
    destURL = destURL.replace("%1%", configGuideBean.getStep().toString().toLowerCase());
    servletContext.getRequestDispatcher(destURL).forward(req, pwmRequest.getPwmResponse().getHttpServletResponse());
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ConfigGuideBean(password.pwm.http.bean.ConfigGuideBean) LDAPPermissionCalculator(password.pwm.util.LDAPPermissionCalculator) ServletContext(javax.servlet.ServletContext)

Example 2 with LDAPPermissionCalculator

use of password.pwm.util.LDAPPermissionCalculator 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 3 with LDAPPermissionCalculator

use of password.pwm.util.LDAPPermissionCalculator 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)

Aggregations

LDAPPermissionCalculator (password.pwm.util.LDAPPermissionCalculator)3 StoredConfigurationImpl (password.pwm.config.stored.StoredConfigurationImpl)2 ChaiUnavailableException (com.novell.ldapchai.exception.ChaiUnavailableException)1 IOException (java.io.IOException)1 ServletContext (javax.servlet.ServletContext)1 ServletException (javax.servlet.ServletException)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 CSVPrinter (org.apache.commons.csv.CSVPrinter)1 ErrorInformation (password.pwm.error.ErrorInformation)1 PwmException (password.pwm.error.PwmException)1 PwmUnrecoverableException (password.pwm.error.PwmUnrecoverableException)1 ConfigGuideBean (password.pwm.http.bean.ConfigGuideBean)1