Example #1
0
  @Test
  public void testWritable() throws IOException {
    assertTrue(true);
    Settings settings = SettingsBuilder.createDefault().build();
    assertNotNull(settings.getString("foo"));
    assertEquals("bar", settings.getString("foo"));
    assertNotNull(settings.getString("os.name"));
    assertEquals(System.getProperty("os.name"), settings.getString("os.name"));

    WritableSettings w = new WritableSettings("whoo", settings);
    w.setString("wow", "its writable");
    assertNotNull(w.getString("wow"));
    assertEquals("its writable", w.getString("wow"));
    assertEquals("x", w.getString("wubbity", "x"));
    assertEquals(23, w.getInt("age", -1));
    assertEquals(23L, w.getLong("age", -1L));
    assertNull(settings.getString("wow"));

    assertEquals(System.getProperty("os.name"), w.getString("os.name"));
    w.setString("os.name", "BeOS");
    assertEquals("BeOS", w.getString("os.name"));

    w.clear("os.name");
    assertNull(w.getString("os.name"));

    w.setString("os.name", "OS/2");
    assertEquals("OS/2", w.getString("os.name"));
  }
Example #2
0
 @Inject
 PasswordHasher(Settings settings, Charset charset) throws NoSuchAlgorithmException {
   this.charset = charset;
   String salt = settings.getString(SETTINGS_KEY_PASSWORD_SALT, DEFAULT_SALT);
   String alg = settings.getString(SETTINGS_KEY_HASHING_ALGORITHM, DEFAULT_HASHING_ALGORITHM);
   if (settings.getBoolean("productionMode", false) && DEFAULT_SALT.equals(salt)) {
     throw new ConfigurationError(
         "Default password salt should not be used in "
             + "production mode.  Set property salt for namespace timetracker to "
             + "be something else");
   }
   saltBytes = salt.getBytes(charset);
   this.algorithm = alg;
   // fail early
   hash("abcd");
 }
Example #3
0
 /** Construction dynamique d'un contact à partir du fullname */
 private Name buildDn(Operator_Ldap o) {
   DistinguishedName dn =
       new DistinguishedName(
           Settings.getString(Settings.SYSTEM.section, Settings.SYSTEM.base_user));
   dn.add("sn", o.getSn());
   return dn;
 }
Example #4
0
 /** Construction dynamique d'un contact à partir de uid */
 private Name buildDn(String sn) {
   DistinguishedName dn =
       new DistinguishedName(
           Settings.getString(Settings.SYSTEM.section, Settings.SYSTEM.base_user));
   dn.add("sn", sn);
   return dn;
 }
Example #5
0
  @Test
  public void test() throws IOException {
    Settings config =
        new SettingsBuilder()
            .addDefaultsFromClasspath()
            .addGeneratedDefaultsFromClasspath()
            .build();
    assertNotNull(config);
    assertTrue(config.getBoolean("auto"));

    assertEquals("bar", config.getString("foo"));

    assertFalse(config.getBoolean("hey", false));
    assertNull(config.getString("Nothing!"));

    assertEquals("whoopty", config.getString("whee"));
  }
Example #6
0
 public boolean onPreferenceChange(Preference paramPreference, Object paramObject) {
   ListPreference localListPreference = (ListPreference) paramPreference;
   int i = localListPreference.findIndexOfValue((String) paramObject);
   String str = localListPreference.getEntries()[i].toString();
   Settings localSettings = this.a;
   Object[] arrayOfObject = new Object[1];
   arrayOfObject[0] = str;
   paramPreference.setTitle(localSettings.getString(2131296703, arrayOfObject));
   return true;
 }
Example #7
0
 /**
  * Outil de recherche de contact, celui-ci renvoit tous les contacts.
  *
  * @param param : critère demandé.
  * @return : Liste du critère demandé de tous les utilisateurs.
  */
 @Override
 public List findAll(final String param) {
   String base = Settings.getString(Settings.SYSTEM.section, Settings.SYSTEM.base_user);
   return ldapTemplate.search(
       base,
       "(objectClass=Person)",
       new AttributesMapper() {
         public Object mapFromAttributes(Attributes attrs) throws NamingException {
           return attrs.get("sn").get();
         }
       });
 }
Example #8
0
 @Test
 public void testLayered() throws IOException {
   com.mastfrog.settings.Settings config =
       new SettingsBuilder()
           .addDefaultsFromClasspath()
           .addGeneratedDefaultsFromClasspath()
           .build();
   Settings config2 =
       new SettingsBuilder()
           .add(config)
           .add("com/mastfrog/configuration/others.properties")
           .add("com/mastfrog/configuration/more.properties")
           .build();
   assertEquals("oobiedoobie", config2.getString("whee"));
 }