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;
}
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);
}
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;
}
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);
}
Aggregations