Search in sources :

Example 1 with ReportColumnFilter

use of password.pwm.svc.report.ReportColumnFilter in project pwm by pwm-project.

the class AdminServlet method downloadUserReportCsv.

@ActionHandler(action = "downloadUserReportCsv")
private ProcessStatus downloadUserReportCsv(final PwmRequest pwmRequest) throws PwmUnrecoverableException, IOException, ChaiUnavailableException, ServletException {
    final PwmApplication pwmApplication = pwmRequest.getPwmApplication();
    pwmRequest.getPwmResponse().markAsDownload(HttpContentType.csv, pwmApplication.getConfig().readAppProperty(AppProperty.DOWNLOAD_FILENAME_USER_REPORT_RECORDS_CSV));
    final OutputStream outputStream = pwmRequest.getPwmResponse().getOutputStream();
    try {
        final String selectedColumns = pwmRequest.readParameterAsString("selectedColumns", "");
        final ReportColumnFilter columnFilter = ReportUtils.toReportColumnFilter(selectedColumns);
        final ReportCsvUtility reportCsvUtility = new ReportCsvUtility(pwmApplication);
        reportCsvUtility.outputToCsv(outputStream, true, pwmRequest.getLocale(), columnFilter);
    } catch (Exception e) {
        final ErrorInformation errorInformation = new ErrorInformation(PwmError.ERROR_UNKNOWN, e.getMessage());
        pwmRequest.respondWithError(errorInformation);
    } finally {
        outputStream.close();
    }
    return ProcessStatus.Halt;
}
Also used : ErrorInformation(password.pwm.error.ErrorInformation) PwmApplication(password.pwm.PwmApplication) OutputStream(java.io.OutputStream) ReportCsvUtility(password.pwm.svc.report.ReportCsvUtility) ReportColumnFilter(password.pwm.svc.report.ReportColumnFilter) LocalDBException(password.pwm.util.localdb.LocalDBException) ServletException(javax.servlet.ServletException) PwmUnrecoverableException(password.pwm.error.PwmUnrecoverableException) PwmOperationalException(password.pwm.error.PwmOperationalException) ChaiUnavailableException(com.novell.ldapchai.exception.ChaiUnavailableException) DatabaseException(password.pwm.util.db.DatabaseException) PwmException(password.pwm.error.PwmException) IOException(java.io.IOException)

Example 2 with ReportColumnFilter

use of password.pwm.svc.report.ReportColumnFilter in project pwm by pwm-project.

the class ReportUtilsTest method testToReportColumnFilter2.

@Test
public void testToReportColumnFilter2() {
    String desiredColumns = "username,email,passwordStatusExpired,passwordStatusPreExpired,passwordStatusViolatesPolicy,passwordStatusWarnPeriod";
    ReportColumnFilter reportColumnFilter = ReportUtils.toReportColumnFilter(desiredColumns);
    // Verify the column name string gets translated into a ReportColumnFilter correctly:
    assertThat(reportColumnFilter.isUsernameVisible()).isEqualTo(true);
    assertThat(reportColumnFilter.isEmailVisible()).isEqualTo(true);
    assertThat(reportColumnFilter.isPasswordStatusExpiredVisible()).isEqualTo(true);
    assertThat(reportColumnFilter.isPasswordStatusPreExpiredVisible()).isEqualTo(true);
    assertThat(reportColumnFilter.isPasswordStatusViolatesPolicyVisible()).isEqualTo(true);
    assertThat(reportColumnFilter.isPasswordStatusWarnPeriodVisible()).isEqualTo(true);
    assertThat(reportColumnFilter.isUserDnVisible()).isEqualTo(false);
    assertThat(reportColumnFilter.isLdapProfileVisible()).isEqualTo(false);
    assertThat(reportColumnFilter.isUserGuidVisible()).isEqualTo(false);
    assertThat(reportColumnFilter.isAccountExpirationTimeVisible()).isEqualTo(false);
    assertThat(reportColumnFilter.isLastLoginTimeVisible()).isEqualTo(false);
    assertThat(reportColumnFilter.isPasswordExpirationTimeVisible()).isEqualTo(false);
    assertThat(reportColumnFilter.isPasswordChangeTimeVisible()).isEqualTo(false);
    assertThat(reportColumnFilter.isResponseSetTimeVisible()).isEqualTo(false);
    assertThat(reportColumnFilter.isHasResponsesVisible()).isEqualTo(false);
    assertThat(reportColumnFilter.isHasHelpdeskResponsesVisible()).isEqualTo(false);
    assertThat(reportColumnFilter.isResponseStorageMethodVisible()).isEqualTo(false);
    assertThat(reportColumnFilter.isResponseFormatTypeVisible()).isEqualTo(false);
    assertThat(reportColumnFilter.isRequiresPasswordUpdateVisible()).isEqualTo(false);
    assertThat(reportColumnFilter.isRequiresResponseUpdateVisible()).isEqualTo(false);
    assertThat(reportColumnFilter.isRequiresProfileUpdateVisible()).isEqualTo(false);
    assertThat(reportColumnFilter.isCacheTimestampVisible()).isEqualTo(false);
}
Also used : ReportColumnFilter(password.pwm.svc.report.ReportColumnFilter) Test(org.junit.Test)

Example 3 with ReportColumnFilter

use of password.pwm.svc.report.ReportColumnFilter in project pwm by pwm-project.

the class ReportUtils method toReportColumnFilter.

public static ReportColumnFilter toReportColumnFilter(final String desiredColumnsStr) {
    final ReportColumnFilter reportColumnFilter = new ReportColumnFilter();
    if (desiredColumnsStr != null) {
        final String[] selectedColumnsArray = desiredColumnsStr.split(",");
        final Set<String> desiredColumns = new HashSet<>(Arrays.asList(selectedColumnsArray));
        reportColumnFilter.setUserDnVisible(desiredColumns.contains("userDN"));
        reportColumnFilter.setLdapProfileVisible(desiredColumns.contains("ldapProfile"));
        reportColumnFilter.setUsernameVisible(desiredColumns.contains("username"));
        reportColumnFilter.setEmailVisible(desiredColumns.contains("email"));
        reportColumnFilter.setUserGuidVisible(desiredColumns.contains("userGUID"));
        reportColumnFilter.setAccountExpirationTimeVisible(desiredColumns.contains("accountExpirationTime"));
        reportColumnFilter.setLastLoginTimeVisible(desiredColumns.contains("lastLoginTime"));
        reportColumnFilter.setPasswordExpirationTimeVisible(desiredColumns.contains("passwordExpirationTime"));
        reportColumnFilter.setPasswordChangeTimeVisible(desiredColumns.contains("passwordChangeTime"));
        reportColumnFilter.setResponseSetTimeVisible(desiredColumns.contains("responseSetTime"));
        reportColumnFilter.setHasResponsesVisible(desiredColumns.contains("hasResponses"));
        reportColumnFilter.setHasHelpdeskResponsesVisible(desiredColumns.contains("hasHelpdeskResponses"));
        reportColumnFilter.setResponseStorageMethodVisible(desiredColumns.contains("responseStorageMethod"));
        reportColumnFilter.setResponseFormatTypeVisible(desiredColumns.contains("responseFormatType"));
        reportColumnFilter.setPasswordStatusExpiredVisible(desiredColumns.contains("passwordStatusExpired"));
        reportColumnFilter.setPasswordStatusPreExpiredVisible(desiredColumns.contains("passwordStatusPreExpired"));
        reportColumnFilter.setPasswordStatusViolatesPolicyVisible(desiredColumns.contains("passwordStatusViolatesPolicy"));
        reportColumnFilter.setPasswordStatusWarnPeriodVisible(desiredColumns.contains("passwordStatusWarnPeriod"));
        reportColumnFilter.setRequiresPasswordUpdateVisible(desiredColumns.contains("requiresPasswordUpdate"));
        reportColumnFilter.setRequiresResponseUpdateVisible(desiredColumns.contains("requiresResponseUpdate"));
        reportColumnFilter.setRequiresProfileUpdateVisible(desiredColumns.contains("requiresProfileUpdate"));
        reportColumnFilter.setCacheTimestampVisible(desiredColumns.contains("cacheTimestamp"));
    }
    return reportColumnFilter;
}
Also used : ReportColumnFilter(password.pwm.svc.report.ReportColumnFilter) HashSet(java.util.HashSet)

Example 4 with ReportColumnFilter

use of password.pwm.svc.report.ReportColumnFilter in project pwm by pwm-project.

the class ReportUtilsTest method testToReportColumnFilter.

@Test
public void testToReportColumnFilter() {
    String desiredColumns = "username,userDN,ldapProfile,userGUID,accountExpirationTime,passwordExpirationTime,passwordChangeTime,responseSetTime,lastLoginTime,hasResponses,hasHelpdeskResponses,responseStorageMethod,responseFormatType,requiresPasswordUpdate,requiresResponseUpdate,requiresProfileUpdate,cacheTimestamp";
    ReportColumnFilter reportColumnFilter = ReportUtils.toReportColumnFilter(desiredColumns);
    // Verify the column name string gets translated into a ReportColumnFilter correctly:
    assertThat(reportColumnFilter.isUserDnVisible()).isEqualTo(true);
    assertThat(reportColumnFilter.isLdapProfileVisible()).isEqualTo(true);
    assertThat(reportColumnFilter.isUsernameVisible()).isEqualTo(true);
    assertThat(reportColumnFilter.isUserGuidVisible()).isEqualTo(true);
    assertThat(reportColumnFilter.isAccountExpirationTimeVisible()).isEqualTo(true);
    assertThat(reportColumnFilter.isLastLoginTimeVisible()).isEqualTo(true);
    assertThat(reportColumnFilter.isPasswordExpirationTimeVisible()).isEqualTo(true);
    assertThat(reportColumnFilter.isPasswordChangeTimeVisible()).isEqualTo(true);
    assertThat(reportColumnFilter.isResponseSetTimeVisible()).isEqualTo(true);
    assertThat(reportColumnFilter.isHasResponsesVisible()).isEqualTo(true);
    assertThat(reportColumnFilter.isHasHelpdeskResponsesVisible()).isEqualTo(true);
    assertThat(reportColumnFilter.isResponseStorageMethodVisible()).isEqualTo(true);
    assertThat(reportColumnFilter.isResponseFormatTypeVisible()).isEqualTo(true);
    assertThat(reportColumnFilter.isRequiresPasswordUpdateVisible()).isEqualTo(true);
    assertThat(reportColumnFilter.isRequiresResponseUpdateVisible()).isEqualTo(true);
    assertThat(reportColumnFilter.isRequiresProfileUpdateVisible()).isEqualTo(true);
    assertThat(reportColumnFilter.isCacheTimestampVisible()).isEqualTo(true);
    assertThat(reportColumnFilter.isEmailVisible()).isEqualTo(false);
    assertThat(reportColumnFilter.isPasswordStatusExpiredVisible()).isEqualTo(false);
    assertThat(reportColumnFilter.isPasswordStatusPreExpiredVisible()).isEqualTo(false);
    assertThat(reportColumnFilter.isPasswordStatusViolatesPolicyVisible()).isEqualTo(false);
    assertThat(reportColumnFilter.isPasswordStatusWarnPeriodVisible()).isEqualTo(false);
}
Also used : ReportColumnFilter(password.pwm.svc.report.ReportColumnFilter) Test(org.junit.Test)

Aggregations

ReportColumnFilter (password.pwm.svc.report.ReportColumnFilter)4 Test (org.junit.Test)2 ChaiUnavailableException (com.novell.ldapchai.exception.ChaiUnavailableException)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 HashSet (java.util.HashSet)1 ServletException (javax.servlet.ServletException)1 PwmApplication (password.pwm.PwmApplication)1 ErrorInformation (password.pwm.error.ErrorInformation)1 PwmException (password.pwm.error.PwmException)1 PwmOperationalException (password.pwm.error.PwmOperationalException)1 PwmUnrecoverableException (password.pwm.error.PwmUnrecoverableException)1 ReportCsvUtility (password.pwm.svc.report.ReportCsvUtility)1 DatabaseException (password.pwm.util.db.DatabaseException)1 LocalDBException (password.pwm.util.localdb.LocalDBException)1