From b3dff2789104e11f0b7ba9e47385ead9a6166d53 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 21 Nov 2014 12:21:25 +0100 Subject: Add TLS support for thrift connection to master, switch to TLSv1.2 everywhere --- .../java/org/openslx/satellitedaemon/Identity.java | 33 +++++++++++----------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'src/main/java/org/openslx/satellitedaemon/Identity.java') diff --git a/src/main/java/org/openslx/satellitedaemon/Identity.java b/src/main/java/org/openslx/satellitedaemon/Identity.java index 6ddbfb3..bb5ba29 100644 --- a/src/main/java/org/openslx/satellitedaemon/Identity.java +++ b/src/main/java/org/openslx/satellitedaemon/Identity.java @@ -31,7 +31,7 @@ public class Identity public static String getOrganizationName() { - return properties.getProperty( "ORGANIZATION_NAME" ); + return properties.getProperty( "ORGANIZATION_NAME", "" ); } private static BigInteger getModulus() @@ -52,7 +52,8 @@ public class Identity /** * Load properties */ - static { + public static boolean load() + { InputStreamReader stream = null; try { // Load all entries of the config file into properties @@ -61,20 +62,27 @@ public class Identity properties.load( stream ); stream.close(); } catch ( IOException e ) { - log.error( "Could not load identity.properties. Exiting." ); - System.exit( 2 ); + log.error( "Could not load identity.properties." ); + return false; } finally { Util.streamClose( stream ); } - Util.notNullOrEmptyFatal( getOrganizationName(), "Organiziation Name must not be empty!" ); + if ( getOrganizationName().isEmpty() ) { + log.error( "Organiziation Name must not be empty!" ); + return false; + } try { akh = new AsymKeyHolder( getPrivateExponent(), getPublicExponent(), getModulus() ); + if ( akh.getPrivateKey() != null && akh.getPublicExponent() != null ) + return true; + log.error( "Organization name is empty!" ); } catch ( InvalidKeySpecException e ) { log.error( "InvalidKeySpecException", e ); } catch ( NoSuchAlgorithmException e ) { log.error( "NoSuchAlgorithmException", e ); } + return false; } /** @@ -177,6 +185,7 @@ public class Identity /** * Submit new satellite - ipAddress to master with organizationId, ipAddress * and key - information. + * * @param ipAddress * @return true, if successful. */ @@ -197,9 +206,10 @@ public class Identity pubKey.getModulus().toString(), pubKey.getPublicExponent().toString() ); } - + /** * Update already existing satellite - ipAddress in master - Db. + * * @param ipAddress * @return true, if successful. */ @@ -252,17 +262,6 @@ public class Identity } } - /** - * Check modulus, privExp and pubExp for not being null. - * - * @return - */ - private static boolean checkMembers() - { - return ( ( getModulus() != null ) && - ( getPrivateExponent() != null ) && ( getPublicExponent() != null ) ); - } - /** * Get BigInteger of read String number. * -- cgit v1.2.3-55-g7522