blob: 653e2557a32de9f6b314b2f7dabd75d07088f844 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
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;
}
}
|