Ejemplo n.º 1
0
 /**
  * Call this to transform a system setting to a more appropriate value. Importantly, this
  * (de)obfuscates the password fields as they go from and to the DB. We use the @{link
  * PicketBoxObfuscator} so that people are able encode their passwords in the system settings
  * export files using the "rhq-encode-password.sh" script.
  */
 private String transformSystemConfigurationPropertyFromDb(
     SystemSetting prop, String value, boolean unobfuscate) {
   // to support Oracle (whose booleans may be 1 or 0) transform the boolean settings properly
   switch (prop) {
     case LDAP_BASED_JAAS_PROVIDER:
       if (RHQConstants.JDBCJAASProvider.equals(value)) {
         return Boolean.toString(false);
       } else if (RHQConstants.LDAPJAASProvider.equals(value)) {
         return Boolean.toString(true);
       } else {
         return value == null ? "" : value;
       }
     case USE_SSL_FOR_LDAP:
       if (RHQConstants.LDAP_PROTOCOL_SECURED.equals(value)) {
         return Boolean.toString(true);
       } else {
         return Boolean.toString(false);
       }
     default:
       switch (prop.getType()) {
         case BOOLEAN:
           if ("0".equals(value)) {
             return Boolean.FALSE.toString();
           } else if ("1".equals(value)) {
             return Boolean.TRUE.toString();
           } else {
             return value == null ? Boolean.FALSE.toString() : value;
           }
         case PASSWORD:
           if (unobfuscate && value != null && value.trim().length() > 0) {
             return PicketBoxObfuscator.decode(value);
           } else {
             return value == null ? "" : value;
           }
         default:
           if (value == null) {
             switch (prop.getType()) {
               case DOUBLE:
               case FLOAT:
               case INTEGER:
               case LONG:
                 value = "0";
                 break;
               default:
                 value = "";
             }
           }
           return value;
       }
   }
 }
Ejemplo n.º 2
0
  private void checkFormats(SystemSettings settings, Properties config) {
    assert settings.size() == config.size()
        : "The old and new style system settings differ in size";

    for (String name : config.stringPropertyNames()) {
      SystemSetting setting = SystemSetting.getByInternalName(name);

      String oldStyleValue = config.getProperty(name);
      String newStyleValue = settings.get(setting);

      assert setting != null : "Could not find a system setting called '" + name + "'.";

      switch (setting) {
        case USE_SSL_FOR_LDAP:
          if (RHQConstants.LDAP_PROTOCOL_SECURED.equals(oldStyleValue)) {
            assert Boolean.valueOf(newStyleValue)
                : "Secured LDAP protocol should be represented by a 'true' in new style settings.";
          } else if (RHQConstants.LDAP_PROTOCOL_UNSECURED.equals(oldStyleValue)) {
            assert !Boolean.valueOf(newStyleValue)
                : "Unsecured LDAP protocol should be represented by a 'false' in the new style settings.";
          } else {
            assert false
                : "Unknown value for system setting '" + setting + "': [" + oldStyleValue + "].";
          }
          break;
        case LDAP_BASED_JAAS_PROVIDER:
          if (RHQConstants.LDAPJAASProvider.equals(oldStyleValue)) {
            assert Boolean.valueOf(newStyleValue)
                : "LDAP JAAS provider should be represented by a 'true' in new style settings.";
          } else if (RHQConstants.JDBCJAASProvider.equals(oldStyleValue)) {
            assert !Boolean.valueOf(newStyleValue)
                : "JDBC JAAS provider should be represented by a 'false' in the new style settings.";
          } else {
            assert false
                : "Unknown value for system setting '" + setting + "': [" + oldStyleValue + "].";
          }
          break;
        default:
          assert oldStyleValue != null
                  && newStyleValue != null
                  && oldStyleValue.equals(newStyleValue)
              : "Old and new style values unexpectedly differ for system setting '"
                  + setting
                  + "': old=["
                  + oldStyleValue
                  + "], new=["
                  + newStyleValue
                  + "].";
      }
    }
  }
Ejemplo n.º 3
0
  public void loadConfigProperties(Properties prop) {
    baseUrl = prop.getProperty(RHQConstants.BaseURL);
    helpUserId = prop.getProperty(RHQConstants.HelpUser);
    helpPassword = prop.getProperty(RHQConstants.HelpUserPassword);

    String agentMaxQuietTimeAllowedValStr = prop.getProperty(RHQConstants.AgentMaxQuietTimeAllowed);
    Long agentMaxQuietTimeAllowedLong = new Long(agentMaxQuietTimeAllowedValStr);
    agentMaxQuietTimeAllowed = findTimeUnit(agentMaxQuietTimeAllowedLong.longValue());
    agentMaxQuietTimeAllowedVal = calcTimeUnit(agentMaxQuietTimeAllowedLong.longValue());

    String enableAgentAutoUpdateStr = prop.getProperty(RHQConstants.EnableAgentAutoUpdate);
    if (enableAgentAutoUpdateStr == null) {
      enableAgentAutoUpdateStr = Boolean.FALSE.toString();
    } else if (enableAgentAutoUpdateStr.equals("0")) {
      enableAgentAutoUpdateStr = Boolean.FALSE.toString();
    } else if (enableAgentAutoUpdateStr.equals("1")) {
      enableAgentAutoUpdateStr = Boolean.TRUE.toString();
    }
    enableAgentAutoUpdate = Boolean.valueOf(enableAgentAutoUpdateStr).booleanValue();

    String enableDebugModeStr = prop.getProperty(RHQConstants.EnableDebugMode);
    if (enableDebugModeStr == null) {
      enableDebugModeStr = Boolean.FALSE.toString();
    } else if (enableDebugModeStr.equals("0")) {
      enableDebugModeStr = Boolean.FALSE.toString();
    } else if (enableDebugModeStr.equals("1")) {
      enableDebugModeStr = Boolean.TRUE.toString();
    }
    enableDebugMode = Boolean.valueOf(enableDebugModeStr).booleanValue();

    String enableExperimentalFeaturesStr =
        prop.getProperty(RHQConstants.EnableExperimentalFeatures);
    if (enableExperimentalFeaturesStr == null) {
      enableExperimentalFeaturesStr = Boolean.FALSE.toString();
    } else if (enableExperimentalFeaturesStr.equals("0")) {
      enableExperimentalFeaturesStr = Boolean.FALSE.toString();
    } else if (enableExperimentalFeaturesStr.equals("1")) {
      enableExperimentalFeaturesStr = Boolean.TRUE.toString();
    }
    enableExperimentalFeatures = Boolean.valueOf(enableExperimentalFeaturesStr).booleanValue();

    String maintIntervalValStr = prop.getProperty(RHQConstants.DataMaintenance);
    Long maintIntervalLong = new Long(maintIntervalValStr);
    maintInterval = findTimeUnit(maintIntervalLong.longValue());
    maintIntervalVal = calcTimeUnit(maintIntervalLong.longValue());

    String nightlyReindexStr = prop.getProperty(RHQConstants.DataReindex);
    if (nightlyReindexStr == null) {
      nightlyReindexStr = Boolean.FALSE.toString();
    } else if (nightlyReindexStr.equals("0")) {
      nightlyReindexStr = Boolean.FALSE.toString();
    } else if (nightlyReindexStr.equals("1")) {
      nightlyReindexStr = Boolean.TRUE.toString();
    }
    reindex = Boolean.valueOf(nightlyReindexStr).booleanValue();

    String rtPurgeValStr = prop.getProperty(RHQConstants.RtDataPurge);
    Long rtPurgeLong = new Long(rtPurgeValStr);
    rtPurge = findTimeUnit(rtPurgeLong.longValue());
    rtPurgeVal = calcTimeUnit(rtPurgeLong.longValue());

    String alertPurgeValStr = prop.getProperty(RHQConstants.AlertPurge);
    Long alertPurgeLong = new Long(alertPurgeValStr);
    alertPurge = findTimeUnit(alertPurgeLong.longValue());
    alertPurgeVal = calcTimeUnit(alertPurgeLong.longValue());

    String eventPurgeValStr = prop.getProperty(RHQConstants.EventPurge);
    Long eventPurgeLong = new Long(eventPurgeValStr);
    eventPurge = findTimeUnit(eventPurgeLong.longValue());
    eventPurgeVal = calcTimeUnit(eventPurgeLong.longValue());

    String traitPurgeValStr = prop.getProperty(RHQConstants.TraitPurge);
    Long traitPurgeLong = new Long(traitPurgeValStr);
    traitPurge = findTimeUnit(traitPurgeLong.longValue());
    traitPurgeVal = calcTimeUnit(traitPurgeLong.longValue());

    String availPurgeValStr = prop.getProperty(RHQConstants.AvailabilityPurge);
    Long availPurgeLong = new Long(availPurgeValStr);
    availPurge = findTimeUnit(availPurgeLong.longValue());
    availPurgeVal = calcTimeUnit(availPurgeLong.longValue());

    String baselineFrequencyValStr = prop.getProperty(RHQConstants.BaselineFrequency);
    Long baselineFrequencyLong = new Long(baselineFrequencyValStr);
    baselineFrequency = findTimeUnit(baselineFrequencyLong.longValue());
    baselineFrequencyVal = calcTimeUnit(baselineFrequencyLong.longValue());

    String baselineDataSetValStr = prop.getProperty(RHQConstants.BaselineDataSet);
    Long baselineDataSetLong = new Long(baselineDataSetValStr);
    baselineDataSet = findTimeUnit(baselineDataSetLong.longValue());
    baselineDataSetVal = calcTimeUnit(baselineDataSetLong.longValue());

    ldapUrl = prop.getProperty(RHQConstants.LDAPUrl);
    ldapLoginProperty = prop.getProperty(RHQConstants.LDAPLoginProperty);
    ldapSearchBase = prop.getProperty(RHQConstants.LDAPBaseDN);
    ldapSearchFilter = prop.getProperty(RHQConstants.LDAPFilter);
    ldapGroupFilter = prop.getProperty(RHQConstants.LDAPGroupFilter);
    ldapGroupMember = prop.getProperty(RHQConstants.LDAPGroupMember);
    ldapUsername = prop.getProperty(RHQConstants.LDAPBindDN);
    ldapPassword = prop.getProperty(RHQConstants.LDAPBindPW);

    String ldapProtocol = prop.getProperty(RHQConstants.LDAPProtocol);
    ldapSsl = ldapProtocol.equals("ssl");

    String jaasProvider = prop.getProperty(RHQConstants.JAASProvider);
    ldapEnabled = RHQConstants.LDAPJAASProvider.equals(jaasProvider) ? Boolean.TRUE : null;

    String resourceGenericPropertiesUpgradeAllowed =
        prop.getProperty(RHQConstants.AllowResourceGenericPropertiesUpgrade);
    allowResourceGenericPropertiesUpgrade =
        Boolean.parseBoolean(resourceGenericPropertiesUpgradeAllowed);
  }