Exemple #1
0
  public String toMenuLocationDebug(final String profileID, final Locale locale) {
    final String SEPARATOR =
        LocaleHelper.getLocalizedMessage(locale, Config.Display_SettingNavigationSeparator, null);
    final StringBuilder sb = new StringBuilder();

    PwmSettingCategory nextCategory = this;
    while (nextCategory != null) {
      if (nextCategory != this) {
        sb.insert(0, nextCategory.getLabel(locale) + SEPARATOR);
      } else {
        sb.insert(0, nextCategory.getLabel(locale));
      }
      nextCategory = nextCategory.getParent();
    }

    if (this.hasProfiles()) {
      if (profileID != null) {
        sb.append(SEPARATOR);
        sb.append(profileID);
      } else {
        final String NULL_PROFILE =
            LocaleHelper.getLocalizedMessage(
                locale, Config.Display_SettingNavigationNullProfile, null);
        sb.append(SEPARATOR);
        sb.append(NULL_PROFILE);
      }
    }

    return sb.toString();
  }
 void initRequestAttributes(final PwmRequest pwmRequest) throws PwmUnrecoverableException {
   final ConfigurationReader configurationReader =
       pwmRequest.getContextManager().getConfigReader();
   pwmRequest.setAttribute(
       PwmRequest.Attribute.PageTitle,
       LocaleHelper.getLocalizedMessage(Config.Title_ConfigManager, pwmRequest));
   pwmRequest.setAttribute(
       PwmRequest.Attribute.ApplicationPath,
       pwmRequest.getPwmApplication().getPwmEnvironment().getApplicationPath().getAbsolutePath());
   pwmRequest.setAttribute(
       PwmRequest.Attribute.ConfigFilename, configurationReader.getConfigFile().getAbsolutePath());
   {
     final Date lastModifyTime = configurationReader.getStoredConfiguration().modifyTime();
     final String output =
         lastModifyTime == null
             ? LocaleHelper.getLocalizedMessage(Display.Value_NotApplicable, pwmRequest)
             : PwmConstants.DEFAULT_DATETIME_FORMAT.format(lastModifyTime);
     pwmRequest.setAttribute(PwmRequest.Attribute.ConfigLastModified, output);
   }
   pwmRequest.setAttribute(
       PwmRequest.Attribute.ConfigHasPassword,
       LocaleHelper.booleanString(
           configurationReader.getStoredConfiguration().hasPassword(),
           pwmRequest.getLocale(),
           pwmRequest.getConfig()));
 }
Exemple #3
0
 public String getLabel(final Locale locale) {
   try {
     final String keyName = "Statistic_Label." + this.getKey();
     return LocaleHelper.getLocalizedMessage(locale, keyName, null, Admin.class);
   } catch (MissingResourceException e) {
     return "MISSING STATISTIC LABEL for " + this.getKey();
   }
 }
 @Override
 public String toDebugString(Locale locale) {
   if (values == null) {
     return "";
   }
   final StringBuilder sb = new StringBuilder();
   for (final String localeKey : values.keySet()) {
     if (!values.get(localeKey).isEmpty()) {
       sb.append("Locale: ")
           .append(LocaleHelper.debugLabel(LocaleHelper.parseLocaleString(localeKey)))
           .append("\n");
       for (final String value : values.get(localeKey)) {
         sb.append("  ").append(value).append("\n");
       }
     }
   }
   return sb.toString();
 }
Exemple #5
0
 public String getDescription(final Locale locale) {
   final String keyName = "Statistic_Description." + this.getKey();
   try {
     return LocaleHelper.getLocalizedMessage(locale, keyName, null, Admin.class);
   } catch (Exception e) {
     LOGGER.error("unable to load localization for " + keyName + ", error: " + e.getMessage());
     return "missing localization for " + keyName;
   }
 }
Exemple #6
0
  private Map<String, String> makeDisplayData(
      final PwmApplication pwmApplication, final PwmSession pwmSession, final String bundleName) {
    Class displayClass = LocaleHelper.classForShortName(bundleName);
    displayClass = displayClass == null ? Display.class : displayClass;

    final Locale userLocale = pwmSession.getSessionStateBean().getLocale();
    final Configuration config = pwmApplication.getConfig();
    final TreeMap<String, String> displayStrings = new TreeMap<>();
    final ResourceBundle bundle = ResourceBundle.getBundle(displayClass.getName());
    try {
      final MacroMachine macroMachine =
          pwmSession.getSessionManager().getMacroMachine(pwmApplication);
      for (final String key : new TreeSet<>(Collections.list(bundle.getKeys()))) {
        String displayValue =
            LocaleHelper.getLocalizedMessage(userLocale, key, config, displayClass);
        displayValue = macroMachine.expandMacros(displayValue);
        displayStrings.put(key, displayValue);
      }
    } catch (Exception e) {
      LOGGER.error(pwmSession, "error expanding macro display value: " + e.getMessage());
    }
    return displayStrings;
  }
Exemple #7
0
  public void outputToCsv(
      final OutputStream outputStream, final boolean includeHeader, final Locale locale)
      throws IOException, ChaiUnavailableException, ChaiOperationException,
          PwmUnrecoverableException, PwmOperationalException {
    final CSVPrinter csvPrinter = Helper.makeCsvPrinter(outputStream);
    final Configuration config = pwmApplication.getConfig();
    final Class localeClass = password.pwm.i18n.Admin.class;
    if (includeHeader) {
      final List<String> headerRow = new ArrayList<>();
      headerRow.add(
          LocaleHelper.getLocalizedMessage(locale, "Field_Report_UserDN", config, localeClass));
      headerRow.add(
          LocaleHelper.getLocalizedMessage(
              locale, "Field_Report_LDAP_Profile", config, localeClass));
      headerRow.add(
          LocaleHelper.getLocalizedMessage(locale, "Field_Report_Username", config, localeClass));
      headerRow.add(
          LocaleHelper.getLocalizedMessage(locale, "Field_Report_Email", config, localeClass));
      headerRow.add(
          LocaleHelper.getLocalizedMessage(locale, "Field_Report_UserGuid", config, localeClass));
      headerRow.add(
          LocaleHelper.getLocalizedMessage(locale, "Field_Report_LastLogin", config, localeClass));
      headerRow.add(
          LocaleHelper.getLocalizedMessage(
              locale, "Field_Report_PwdExpireTime", config, localeClass));
      headerRow.add(
          LocaleHelper.getLocalizedMessage(
              locale, "Field_Report_PwdChangeTime", config, localeClass));
      headerRow.add(
          LocaleHelper.getLocalizedMessage(
              locale, "Field_Report_ResponseSaveTime", config, localeClass));
      headerRow.add(
          LocaleHelper.getLocalizedMessage(
              locale, "Field_Report_HasResponses", config, localeClass));
      headerRow.add(
          LocaleHelper.getLocalizedMessage(
              locale, "Field_Report_HasHelpdeskResponses", config, localeClass));
      headerRow.add(
          LocaleHelper.getLocalizedMessage(
              locale, "Field_Report_ResponseStorageMethod", config, localeClass));
      headerRow.add(
          LocaleHelper.getLocalizedMessage(locale, "Field_Report_PwdExpired", config, localeClass));
      headerRow.add(
          LocaleHelper.getLocalizedMessage(
              locale, "Field_Report_PwdPreExpired", config, localeClass));
      headerRow.add(
          LocaleHelper.getLocalizedMessage(
              locale, "Field_Report_PwdViolatesPolicy", config, localeClass));
      headerRow.add(
          LocaleHelper.getLocalizedMessage(
              locale, "Field_Report_PwdWarnPeriod", config, localeClass));
      headerRow.add(
          LocaleHelper.getLocalizedMessage(
              locale, "Field_Report_RequiresPasswordUpdate", config, localeClass));
      headerRow.add(
          LocaleHelper.getLocalizedMessage(
              locale, "Field_Report_RequiresResponseUpdate", config, localeClass));
      headerRow.add(
          LocaleHelper.getLocalizedMessage(
              locale, "Field_Report_RequiresProfileUpdate", config, localeClass));
      headerRow.add(
          LocaleHelper.getLocalizedMessage(
              locale, "Field_Report_RecordCacheTime", config, localeClass));
      csvPrinter.printRecord(headerRow);
    }

    ClosableIterator<UserCacheRecord> cacheBeanIterator = null;
    try {
      cacheBeanIterator = this.iterator();
      while (cacheBeanIterator.hasNext()) {
        final UserCacheRecord userCacheRecord = cacheBeanIterator.next();
        outputRecordRow(config, locale, userCacheRecord, csvPrinter);
      }
    } finally {
      if (cacheBeanIterator != null) {
        cacheBeanIterator.close();
      }
    }

    csvPrinter.flush();
  }
Exemple #8
0
 public String getLabel(final Locale locale) {
   final String keyName = "Statistic_Label." + EpsType.class.getSimpleName() + "_" + this.name();
   return LocaleHelper.getLocalizedMessage(locale, keyName, null, Admin.class);
 }
Exemple #9
0
 public String getDescription(final Locale locale) {
   final String key = "Category_Description_" + this.getKey();
   return LocaleHelper.getLocalizedMessage(locale, key, null, ConfigEditor.class);
 }