diff options
Diffstat (limited to 'src/main/java/org/openslx/satellitedaemon/Identity.java')
-rw-r--r-- | src/main/java/org/openslx/satellitedaemon/Identity.java | 33 |
1 files changed, 16 insertions, 17 deletions
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. */ @@ -253,17 +263,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. * * @param str |