summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/openslx/satellitedaemon/Identity.java
diff options
context:
space:
mode:
authorSimon Rettberg2014-11-21 12:21:25 +0100
committerSimon Rettberg2014-11-21 12:21:25 +0100
commitb3dff2789104e11f0b7ba9e47385ead9a6166d53 (patch)
tree17220e07a648e2986cb327029224e9bf08b2b425 /src/main/java/org/openslx/satellitedaemon/Identity.java
parentAdd 8 seconds timeout to thrift connection (diff)
downloadsatellite-daemon-b3dff2789104e11f0b7ba9e47385ead9a6166d53.tar.gz
satellite-daemon-b3dff2789104e11f0b7ba9e47385ead9a6166d53.tar.xz
satellite-daemon-b3dff2789104e11f0b7ba9e47385ead9a6166d53.zip
Add TLS support for thrift connection to master, switch to TLSv1.2 everywhere
Diffstat (limited to 'src/main/java/org/openslx/satellitedaemon/Identity.java')
-rw-r--r--src/main/java/org/openslx/satellitedaemon/Identity.java33
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