diff options
author | Simon Rettberg | 2015-09-08 18:16:50 +0200 |
---|---|---|
committer | Simon Rettberg | 2015-09-08 18:16:50 +0200 |
commit | 05c598c830d4ff10b926a3f413e8a6129fd4337a (patch) | |
tree | fccd910f1739e97b2132e8119fdda26893b75264 /src/main/java/org/openslx/imagemaster/Globals.java | |
parent | Compilable... (diff) | |
download | masterserver-05c598c830d4ff10b926a3f413e8a6129fd4337a.tar.gz masterserver-05c598c830d4ff10b926a3f413e8a6129fd4337a.tar.xz masterserver-05c598c830d4ff10b926a3f413e8a6129fd4337a.zip |
Stuff
Diffstat (limited to 'src/main/java/org/openslx/imagemaster/Globals.java')
-rw-r--r-- | src/main/java/org/openslx/imagemaster/Globals.java | 123 |
1 files changed, 37 insertions, 86 deletions
diff --git a/src/main/java/org/openslx/imagemaster/Globals.java b/src/main/java/org/openslx/imagemaster/Globals.java index eb83f4d..852d8dd 100644 --- a/src/main/java/org/openslx/imagemaster/Globals.java +++ b/src/main/java/org/openslx/imagemaster/Globals.java @@ -5,7 +5,6 @@ import java.io.FileInputStream; import java.io.IOException; import java.util.Properties; -import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import org.openslx.imagemaster.util.Util; @@ -15,7 +14,7 @@ import org.openslx.imagemaster.util.Util; public class Globals { - private static Logger log = Logger.getLogger( Globals.class ); + private static Logger LOGGER = Logger.getLogger( Globals.class ); private static final Properties properties = new Properties(); /* CONSTANTS */ @@ -37,155 +36,107 @@ public class Globals // check properties Util.notNullOrEmptyFatal( getImageDir(), "Image directory must be set." ); - Util.notNullOrEmptyFatal( getLdapHost(), "Ldap host must be set." ); - Util.notNullOrEmptyFatal( getLdapBindQuery(), "Ldap bind query must be set." ); - Util.notNullOrEmptyFatal( getLdapSearchBaseDn(), "Ldap search base dn must be set." ); - Util.notNullOrEmptyFatal( getLdapSearchFilter(), "Ldap search filter must be set." ); - Util.notNullFatal( getLdapKeystorePassword(), "Ldap keystore password must be set." ); - Util.notNullOrEmptyFatal( getLdapKeystorePath(), "Ldap keystore path must be set." ); Util.notNullOrEmptyFatal( getSslKeystoreFile(), "SSL keystore file must be set." ); Util.notNullOrEmptyFatal( getSslKeystoreAlias(), "SSL keystore alias must be set." ); Util.notNullOrEmptyFatal( getSslKeystorePassword(), "SSL keystore password must be set." ); - Util.notNullFatal( getLdapPort(), "Ldap port must be set." ); Util.notNullFatal( getSessionTimeoutUser(), "Session timeout user must be set." ); Util.notNullFatal( getSessionTimeoutServer(), "Session timeout server must be set." ); - Util.notNullFatal( getSslSocketPort(), "SSL socket port must be set." ); - Util.notNullFatal( getSslTimeout(), "SSL socket timeout must be set." ); - - if ( getSslTransmitTimes() <= 0 ) - log.fatal( "SSL socket transmitted times must be greater than 0." ); - - // check ldap_bind_query - if ( StringUtils.countMatches( getLdapBindQuery(), "%" ) == 0 ) { - log.fatal( "ldap_bind_query does not contain '%'" ); + if ( getFiletransferPortSsl() == 0 && getFiletransferPortPlain() == 0 ) { + LOGGER.fatal( "either SSL or plain port for file transfer must be set." ); + System.exit( 2 ); + } + if ( getThriftPortSsl() == 0 && getThriftPortPlain() == 0 ) { + LOGGER.fatal( "either SSL or plain port for thrift must be set." ); System.exit( 2 ); } - // check ldap_search_filter - if ( StringUtils.countMatches( getLdapSearchFilter(), "%" ) == 0 ) { - log.fatal( "ldap_search_filter does not contain '%'" ); + if ( getFiletransferRetransmits() <= 0 ) { + LOGGER.fatal( "SSL socket transmitted times must be greater than 0." ); System.exit( 2 ); } // check keystore if ( !getSslKeystoreFile().endsWith( ".jks" ) ) { - log.fatal( "Keystore is not in jks format." ); + LOGGER.fatal( "Keystore is not in jks format." ); System.exit( 2 ); } // remove "/" at the end of the paths String image = getImageDir(); if ( image.endsWith( "/" ) ) { - Globals.properties.put( "image_dir", image.substring( 0, image.length() - 1 ) ); + properties.put( "image_dir", image.substring( 0, image.length() - 1 ) ); } } catch ( IOException e ) { - log.fatal( "Could not load properties!" ); - log.warn( e.getStackTrace().toString() ); + LOGGER.fatal( "Could not load properties!" ); + LOGGER.warn( e.getStackTrace().toString() ); System.exit( 2 ); } - log.info( "Loaded properties successfully" ); + LOGGER.info( "Loaded properties successfully" ); } /* INTEGERS */ - public static int getLdapPort() - { - return Util.tryToParseInt( properties.getProperty( "ldap_port" ) ); - } - public static int getSessionTimeoutUser() { - return Util.tryToParseInt( properties.getProperty( "session_timeout_user" ) ); + return Util.tryToParseInt( properties.getProperty( "session.user.timeout" ) ); } public static int getSessionTimeoutServer() { - return Util.tryToParseInt( properties.getProperty( "session_timeout_user" ) ); - } - - public static int getSslSocketPort() - { - return Util.tryToParseInt( properties.getProperty( "ssl_socket_port" ) ); - } - - public static int getSslTimeout() - { - return Util.tryToParseInt( properties.getProperty( "ssl_socket_timeout" ) ); - } - - public static int getSslTransmitTimes() - { - return Util.tryToParseInt( properties.getProperty( "ssl_socket_transmit_times" ) ); - } - - public static int getCrcSchedulingInterval() - { - return Util.tryToParseInt( properties.getProperty( "crc_scheduling_interval" ) ); + return Util.tryToParseInt( properties.getProperty( "session.server.timeout" ) ); } - /* STRINGS */ - - public static String getImageDir() - { - return properties.getProperty( "image_dir" ); - } - - public static String getSslKeystoreFile() + public static int getFiletransferPortSsl() { - return properties.getProperty( "ssl_keystore_file" ); + return Util.tryToParseInt( properties.getProperty( "filetransfer.port.ssl" ) ); } - public static String getSslKeystoreAlias() + public static int getFiletransferPortPlain() { - return properties.getProperty( "ssl_keystore_alias" ); + return Util.tryToParseInt( properties.getProperty( "filetransfer.port.plain" ) ); } - public static String getSslKeystorePassword() + public static int getFiletransferTimeout() { - return properties.getProperty( "ssl_keystore_password" ); + return Util.tryToParseInt( properties.getProperty( "filetransfer.timeout" ) ); } - public static String getLdapHost() + public static int getFiletransferRetransmits() { - return properties.getProperty( "ldap_host" ); + return Util.tryToParseInt( properties.getProperty( "filetransfer.retries" ) ); } - public static String getLdapBindQuery() + public static int getThriftPortSsl() { - return properties.getProperty( "ldap_bind_query" ); + return Util.tryToParseInt( properties.getProperty( "thrift.port.ssl" ) ); } - public static String getLdapSearchBaseDn() + public static int getThriftPortPlain() { - return properties.getProperty( "ldap_search_base_dn" ); + return Util.tryToParseInt( properties.getProperty( "thrift.port.plain" ) ); } - public static String getLdapSearchFilter() - { - return properties.getProperty( "ldap_search_filter" ); - } + /* STRINGS */ - public static String getLdapKeystorePassword() + public static String getImageDir() { - return properties.getProperty( "ldap_keystore_password" ); + return properties.getProperty( "storage.dir" ); } - public static String getLdapKeystorePath() + public static String getSslKeystoreFile() { - return properties.getProperty( "ldap_keystore_path" ); + return properties.getProperty( "ssl.keystore.file" ); } - /* BOOLEANS */ - - public static boolean getLdapSsl() + public static String getSslKeystoreAlias() { - return Boolean.valueOf( properties.getProperty( "ldap_ssl" ) ); + return properties.getProperty( "ssl.keystore.alias" ); } - public static int getPlainSocketPort() + public static String getSslKeystorePassword() { - return Util.tryToParseInt( properties.getProperty( "filetransfer.port.plain" ) ); + return properties.getProperty( "ssl.keystore.password" ); } } |