summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/openslx/satellitedaemon/Globals.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/openslx/satellitedaemon/Globals.java')
-rw-r--r--src/main/java/org/openslx/satellitedaemon/Globals.java32
1 files changed, 22 insertions, 10 deletions
diff --git a/src/main/java/org/openslx/satellitedaemon/Globals.java b/src/main/java/org/openslx/satellitedaemon/Globals.java
index a14f825..0b0d287 100644
--- a/src/main/java/org/openslx/satellitedaemon/Globals.java
+++ b/src/main/java/org/openslx/satellitedaemon/Globals.java
@@ -35,7 +35,7 @@ public class Globals
*/
// * Properties *//
-
+
public static String getMasterserverHost()
{
return properties.getProperty( "MASTERSERVER_HOST" );
@@ -43,7 +43,7 @@ public class Globals
public static String getTruststorePath()
{
- return properties.getProperty( "FILETRANSFER_KEYSTORE_PATH" );
+ return properties.getProperty( "TRUSTSTORE_PATH" );
}
public static String getImageFolder()
@@ -51,8 +51,6 @@ public class Globals
return properties.getProperty( "IMAGE_FOLDER" );
}
-
-
// Integers //
public static int getThriftPort()
@@ -64,29 +62,43 @@ public class Globals
* Load properties
*/
static {
+ InputStreamReader stream = null;
try {
// Load all entries of the config file into properties
- InputStreamReader stream = new InputStreamReader(
+ stream = new InputStreamReader(
new FileInputStream( "config/global.properties" ), StandardCharsets.UTF_8 );
properties.load( stream );
stream.close();
} catch ( IOException e ) {
- log.error( "Could not load properties. Exiting." );
+ log.error( "Could not load global.properties. Exiting." );
System.exit( 2 );
+ } finally {
+ Util.streamClose( stream );
}
Util.notNullOrEmptyFatal( getMasterserverHost(), "Masterserver Host must not be empty!" );
- Util.notNullOrEmptyFatal( getTruststorePath(), "Truststore Path must not be empty!" );
Util.notNullOrEmptyFatal( getImageFolder(), "Image Folder must not be empty!" );
}
/***********************************************************************************************/
/**
+ * Initialize the ssl context used everywhere for outgoing connections.
*
- * @return
+ * @return true on success, false on error
*/
public static boolean masterServerSslContextInit()
{
+ if ( context != null )
+ return true;
+ if ( getTruststorePath() == null || getTruststorePath().isEmpty() ) {
+ try {
+ context = SSLContext.getDefault();
+ } catch ( NoSuchAlgorithmException e ) {
+ log.error( "could not load system default ssl context.", e );
+ return false;
+ }
+ return true;
+ }
KeyStore keystore;
try {
keystore = KeyStore.getInstance( "JKS" );
@@ -110,7 +122,7 @@ public class Globals
public static SSLContext getMasterServerSslContext()
{
- return Globals.context;
+ return context;
}
/**
@@ -128,4 +140,4 @@ public class Globals
return 0;
}
}
-} \ No newline at end of file
+}