diff options
Diffstat (limited to 'src/main/java/org/openslx/imagemaster/Globals.java')
| -rw-r--r-- | src/main/java/org/openslx/imagemaster/Globals.java | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/main/java/org/openslx/imagemaster/Globals.java b/src/main/java/org/openslx/imagemaster/Globals.java index b766b27..653e255 100644 --- a/src/main/java/org/openslx/imagemaster/Globals.java +++ b/src/main/java/org/openslx/imagemaster/Globals.java @@ -2,10 +2,57 @@ package org.openslx.imagemaster; import java.util.Properties; +import org.apache.commons.lang3.StringUtils; import org.openslx.imagemaster.server.MasterFtpServer; public class Globals { public static final Properties properties = new Properties(); + public static final MasterFtpServer ftpServer = new MasterFtpServer(2221, "admin", "SI*HoZCC!]V)p>B2", Globals.properties.getProperty("ftp_base_dir")); + + // properties + public static final String ftpBaseDir = "ftp_base_dir"; + public static final String imageDir = "image_dir"; + public static final String ldapPort = "ldap_port"; + public static final String ldapHost = "ldap_host"; + public static final String ldapSsl = "ldap_ssl"; + public static final String ldapBindQuery = "ldap_bind_query"; + public static final String ldapSearchBaseDn = "ldap_search_base_dn"; + public static final String ldapSearchFilter = "ldap_search_filter"; + + public static boolean propertiesValid() { + if (Globals.properties.getProperty(ftpBaseDir).isEmpty() + || Globals.properties.getProperty(imageDir).isEmpty() + || Globals.properties.getProperty(ldapPort).isEmpty() + || Globals.properties.getProperty(ldapHost).isEmpty() + || Globals.properties.getProperty(ldapSsl).isEmpty() + || Globals.properties.getProperty(ldapBindQuery).isEmpty() + || Globals.properties.getProperty(ldapSearchBaseDn).isEmpty() + || Globals.properties.getProperty(ldapSearchBaseDn).isEmpty() + ) { + return false; + } + + if (StringUtils.countMatches(Globals.properties.getProperty(ldapBindQuery), "%") != 1) { + return false; + } + + if (StringUtils.countMatches(Globals.properties.getProperty(ldapSearchFilter), "%") != 1) { + return false; + } + + // remove "/" at the end of the path + String ftp = Globals.properties.getProperty(ftpBaseDir); + if (ftp.endsWith("/")) { + Globals.properties.put(ftpBaseDir, ftp.substring(0, ftp.length() - 1)); + } + + String image = Globals.properties.getProperty(imageDir); + if (image.endsWith("/")) { + Globals.properties.put(imageDir, image.substring(0, image.length() -1 )); + } + + return true; + } } |
