From 9b6f874b79655d8feda0dec05f11d2e6bab00ab0 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 8 Oct 2014 15:34:05 +0200 Subject: Configuration splitup (WIP) --- .../java/org/openslx/satellitedaemon/Globals.java | 55 ++-------------------- 1 file changed, 5 insertions(+), 50 deletions(-) diff --git a/src/main/java/org/openslx/satellitedaemon/Globals.java b/src/main/java/org/openslx/satellitedaemon/Globals.java index cf61aaf..8b0d182 100644 --- a/src/main/java/org/openslx/satellitedaemon/Globals.java +++ b/src/main/java/org/openslx/satellitedaemon/Globals.java @@ -41,41 +41,16 @@ public class Globals return properties.getProperty( "MASTERSERVER_HOST" ); } - public static String getKeystoreType() - { - return properties.getProperty( "KEYSTORE_TYPE" ); - } - - public static String getFiletransferKeystorePath() + public static String getTruststorePath() { return properties.getProperty( "FILETRANSFER_KEYSTORE_PATH" ); } - public static String getFiletransferKeystorePassword() - { - return properties.getProperty( "FILETRANSFER_KEYSTORE_PASSWORD" ); - } - public static String getOrganizationName() { return properties.getProperty( "ORGANIZATION_NAME" ); } - public static String getThriftKeystoreAlias() - { - return properties.getProperty( "THRIFT_KEYSTORE_ALIAS" ); - } - - public static String getThriftKeystorePassword() - { - return properties.getProperty( "THRIFT_KEYSTORE_PASSWORD" ); - } - - public static String getThriftKeystorePath() - { - return properties.getProperty( "THRIFT_KEYSTORE_PATH" ); - } - public static String getImageFolder() { return properties.getProperty( "IMAGE_FOLDER" ); @@ -104,13 +79,7 @@ public class Globals } notNullOrEmptyFatal( getMasterserverHost(), "Masterserver Host must not be empty!" ); - notNullOrEmptyFatal( getKeystoreType(), "Keystore Type must not be empty" ); - notNullOrEmptyFatal( getFiletransferKeystorePassword(), "File transfer Keystore Password must not be empty!" ); - notNullOrEmptyFatal( getFiletransferKeystorePath(), "File transfer Keystore Path must not be empty!" ); notNullOrEmptyFatal( getOrganizationName(), "Organiziation Name must not be empty!" ); - notNullOrEmptyFatal( getThriftKeystoreAlias(), "Thrift Keystore Alias must not be empty!" ); - notNullOrEmptyFatal( getThriftKeystorePassword(), "Thrift Keystore Password must not be empty!" ); - notNullOrEmptyFatal( getThriftKeystorePath(), "Thrift Keystore Path must not be empty!" ); notNullOrEmptyFatal( getImageFolder(), "Image Folder must not be empty!" ); } @@ -121,35 +90,21 @@ public class Globals */ public static boolean masterServerSslContextInit() { - char[] passphrase = getFiletransferKeystorePassword().toCharArray(); KeyStore keystore; try { keystore = KeyStore.getInstance( "JKS" ); - keystore.load( new FileInputStream( getFiletransferKeystorePath() ), - passphrase ); + keystore.load( new FileInputStream( getTruststorePath() ), null ); TrustManagerFactory tmf = TrustManagerFactory .getInstance( TrustManagerFactory.getDefaultAlgorithm() ); tmf.init( keystore ); context = SSLContext.getInstance( "SSLv3" ); TrustManager[] trustManagers = tmf.getTrustManagers(); context.init( null, trustManagers, null ); - } catch ( KeyStoreException e ) { - log.error( "KeyStoreException" ); - return false; - } catch ( NoSuchAlgorithmException e ) { - log.error( "NoSuchAlgorithmException" ); - return false; - } catch ( CertificateException e ) { - log.error( "CertificateException" ); - return false; } catch ( FileNotFoundException e ) { - log.error( "Could not find the keystore for the filetransfer. Path was '" + getFiletransferKeystorePath() + "'" ); - return false; - } catch ( IOException e ) { - log.error( "IOException", e ); + log.error( "Could not find the keystore for the filetransfer. Path was '" + getTruststorePath() + "'" ); return false; - } catch ( KeyManagementException e ) { - log.error( "KeyManagementException" ); + } catch ( Exception e ) { + log.error( "Could not initialize SSL context.", e ); return false; } return true; -- cgit v1.2.3-55-g7522