Exemplo n.º 1
0
  private GluuAttribute createAttributeFromConfig(String prefix) {
    String attributeName = importConfiguration.getString(prefix + ATTRIBUTE_LDAP_NAME_SUFFIX, null);
    String displayName =
        importConfiguration.getString(prefix + ATTRIBUTE_DISPLAY_NAME_SUFFIX, null);
    String dataType = importConfiguration.getString(prefix + ATTRIBUTE_DATA_TYPE_SUFFIX, null);
    boolean required =
        importConfiguration.getBoolean(prefix + ATTRIBUTE_DATA_REQUIRED_SUFFIX, false);

    if (StringHelper.isNotEmpty(attributeName)
        && StringHelper.isNotEmpty(displayName)
        && StringHelper.isNotEmpty(dataType)) {
      GluuAttributeDataType attributeDataType = GluuAttributeDataType.getByValue(dataType);
      if (attributeDataType != null) {
        GluuAttribute attr = new GluuAttribute();
        attr.setName(attributeName);
        attr.setDisplayName(displayName);
        attr.setDataType(attributeDataType);
        attr.setRequred(required);

        return attr;
      }
    }

    return null;
  }
Exemplo n.º 2
0
  private Configuration() {
    FileConfiguration ldapConfiguration = new FileConfiguration(LDAP_PROPERTIES_FILE);

    String confDir = DIR;
    if (ldapConfiguration.isLoaded()) {
      String ldapConfDir = ldapConfiguration.getString("confDir");
      if (StringHelper.isNotEmpty(ldapConfDir)) {
        confDir = ldapConfDir;
      }
    }

    applicationConfiguration =
        new FileConfiguration(confDir + CONFIGURATION_FILE_APPLICATION_CONFIGURATION);
    cryptoConfiguration =
        new FileConfiguration(confDir + CONFIGURATION_FILE_CRYPTO_PROPERTIES_FILE);
  }
Exemplo n.º 3
0
  private List<GluuAttribute> prepareAttributes() throws Exception {
    List<GluuAttribute> result = new ArrayList<GluuAttribute>();
    if (!this.importConfiguration.isLoaded()) {
      return result;
    }

    Iterator<?> keys = importConfiguration.getProperties().keySet().iterator();
    while (keys.hasNext()) {
      String key = (String) keys.next();

      if (key.endsWith(ATTRIBUTE_LDAP_NAME_SUFFIX)) {
        int index = key.lastIndexOf(ATTRIBUTE_LDAP_NAME_SUFFIX);
        String prefix = key.substring(0, index);

        String attributeName =
            importConfiguration.getString(prefix + ATTRIBUTE_LDAP_NAME_SUFFIX, null);
        boolean required =
            importConfiguration.getBoolean(prefix + ATTRIBUTE_DATA_REQUIRED_SUFFIX, false);

        if (StringHelper.isNotEmpty(attributeName)) {
          GluuAttribute attr = null;
          try {
            attr = attributeService.getAttributeByName(attributeName);
          } catch (EntryPersistenceException ex) {
            log.error("Failed to load attribute '{0}' definition from LDAP", ex, attributeName);
          }
          if (attr == null) {
            log.warn("Failed to find attribute '{0}' definition in LDAP", attributeName);
            attr = createAttributeFromConfig(prefix);
            if (attr == null) {
              log.error(
                  "Failed to find attribute '{0}' definition in '{1}'",
                  attributeName, GLUU_IMPORT_PERSON_PROPERTIES_FILE);
              continue;
            }
          } else {
            attr.setRequred(required);
          }
          result.add(attr);
        }
      }
    }

    return result;
  }
Exemplo n.º 4
0
 public String getCryptoPropertyValue(String propertyName) {
   return cryptoConfiguration.getString(propertyName);
 }
Exemplo n.º 5
0
 public String getPropertyValue(String propertyName) {
   return applicationConfiguration.getString(propertyName);
 }