summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/openslx/satellitedaemon/AsymKeyHolder.java227
-rw-r--r--src/main/java/org/openslx/satellitedaemon/Globals.java43
-rw-r--r--src/main/java/org/openslx/satellitedaemon/Identity.java107
-rw-r--r--src/main/java/org/openslx/satellitedaemon/db/DbImage.java4
-rw-r--r--src/main/java/org/openslx/satellitedaemon/filetransfer/FileDownloadWorker.java60
-rw-r--r--src/main/java/org/openslx/satellitedaemon/filetransfer/FileUploadWorker.java11
-rw-r--r--src/main/java/org/openslx/satellitedaemon/filetransfer/ThriftConnection.java12
-rw-r--r--src/main/java/org/openslx/satellitedaemon/util/Util.java10
8 files changed, 341 insertions, 133 deletions
diff --git a/src/main/java/org/openslx/satellitedaemon/AsymKeyHolder.java b/src/main/java/org/openslx/satellitedaemon/AsymKeyHolder.java
index 7eab79f..d69ce76 100644
--- a/src/main/java/org/openslx/satellitedaemon/AsymKeyHolder.java
+++ b/src/main/java/org/openslx/satellitedaemon/AsymKeyHolder.java
@@ -6,11 +6,16 @@ import java.io.FileReader;
import java.io.IOException;
import java.math.BigInteger;
import java.security.KeyFactory;
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.PublicKey;
+import java.security.interfaces.RSAPrivateKey;
+import java.security.interfaces.RSAPublicKey;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.RSAPrivateKeySpec;
+import java.security.spec.RSAPublicKeySpec;
import org.apache.log4j.Logger;
@@ -21,88 +26,190 @@ public class AsymKeyHolder
private static PrivateKey privKey = null;
private static PublicKey pubKey = null;
+ public AsymKeyHolder(BigInteger privExp, BigInteger pubExp, BigInteger mod)
+ throws InvalidKeySpecException, NoSuchAlgorithmException {
+ final KeyFactory keyFact;
+ try {
+ keyFact = KeyFactory.getInstance( "RSA" );
+ } catch ( NoSuchAlgorithmException e ) {
+ throw new NoSuchAlgorithmException(e.getMessage());
+ }
+ if (privExp == null) {
+ // private exponent == null. Generate public key.
+ if (mod != null) {
+ try {
+ RSAPublicKeySpec keySpec = new RSAPublicKeySpec( mod, pubExp );
+ synchronized ( keyFact ) {
+ pubKey = keyFact.generatePublic( keySpec );
+ }
+ } catch ( InvalidKeySpecException e ) {
+ LOG.error( "Not able to build key with given numbers.", e );
+ throw new InvalidKeySpecException( e.getMessage() );
+ } catch ( NumberFormatException e ) {
+ LOG.error( "Invalid number format.", e );
+ throw new NumberFormatException( e.toString() );
+ }
+ }
+ } else if (pubExp == null) {
+ // public exponent == null. Generate private key.
+ if (mod != null) {
+ try {
+ RSAPrivateKeySpec keySpec = new RSAPrivateKeySpec( mod, privExp );
+ synchronized ( keyFact ) {
+ privKey = keyFact.generatePrivate( keySpec );
+ }
+ } catch ( InvalidKeySpecException e ) {
+ LOG.error( "Not able to build key with given numbers.", e );
+ throw new InvalidKeySpecException( e.getMessage() );
+ } catch ( NumberFormatException e ) {
+ LOG.error( "Invalid number format.", e );
+ throw new NumberFormatException( e.toString() );
+ }
+ }
+ } else {
+ // create both keys.
+ if (mod != null) {
+ try {
+ RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec( mod, pubExp );
+ RSAPrivateKeySpec privkeySpec = new RSAPrivateKeySpec( mod, privExp );
+ synchronized ( keyFact ) {
+ privKey = keyFact.generatePrivate( privkeySpec );
+ pubKey = keyFact.generatePublic( pubKeySpec );
+ }
+ } catch ( InvalidKeySpecException e ) {
+ LOG.error( "Not able to build key with given numbers.", e );
+ throw new InvalidKeySpecException( e.getMessage() );
+ } catch ( NumberFormatException e ) {
+ LOG.error( "Invalid number format.", e );
+ throw new NumberFormatException( e.toString() );
+ }
+ }
+ }
+ }
+
+ public AsymKeyHolder() throws NoSuchAlgorithmException {
+ generateKey();
+ }
+
+
/**
* Get private key for this server. If none exists yet, create a new one.
*
* @return
*/
- public static PrivateKey getPrivateKey()
+ public PrivateKey getPrivateKey()
{
if (privKey == null) {
- if (!loadKey() && !generateKey()) {
+ if (!generateKey()) {
LOG.warn( "Could not load or generate keypair for communication with masterserver" );
}
}
return privKey;
}
-
- private static boolean loadKey()
+
+ public PublicKey getPublicKey()
{
- BufferedReader br = null;
- String modulus, exponent;
- KeyFactory keyFact;
-
- try {
- keyFact = KeyFactory.getInstance( "RSA" );
- } catch ( NoSuchAlgorithmException nSAE ) {
- LOG.warn( "Could not get a KeyFactory to load the key from disk", nSAE );
- return false;
+ if (pubKey == null) {
+ if (!generateKey()) {
+ LOG.warn( "Could not generate keypair for communication with masterserver" );
+ }
}
+ return pubKey;
+ }
+// private boolean loadKey()
+// {
+// BufferedReader br = null;
+// String modulus, exponent;
+// KeyFactory keyFact;
+//
+// try {
+// keyFact = KeyFactory.getInstance( "RSA" );
+// } catch ( NoSuchAlgorithmException e ) {
+// LOG.warn( "Could not get a KeyFactory to load the key from disk", e );
+// return false;
+// }
+//
+// try {
+// br = new BufferedReader( new FileReader( "config/private.key" ) );
+// modulus = br.readLine();
+// exponent = br.readLine();
+// } catch ( FileNotFoundException e ) {
+// LOG.error( "File 'private.key' not found!", e );
+// return false;
+// } catch ( IOException e ) {
+// LOG.error( "File 'private.key' not correct readable.", e );
+// return false;
+// } finally {
+// try {
+// br.close();
+// } catch ( IOException e ) {
+// }
+// }
+// if ( modulus == null || exponent == null ) {
+// return false;
+// }
+//
+// try {
+// BigInteger mod = new BigInteger( modulus );
+// BigInteger exp = new BigInteger( exponent );
+//
+// RSAPrivateKeySpec keySpec = new RSAPrivateKeySpec( mod, exp );
+// synchronized ( keyFact ) {
+// privKey = keyFact.generatePrivate( keySpec );
+// }
+// return privKey != null;
+// } catch ( InvalidKeySpecException e ) {
+// LOG.error( "Not able to build key with given numbers.", e );
+// } catch ( NumberFormatException e ) {
+// LOG.error( "Invalid number format.", e );
+// }
+// return false;
+// }
+
+ private boolean generateKey()
+ {
+ KeyPairGenerator kpg;
try {
- br = new BufferedReader( new FileReader( "config/private.key" ) );
- modulus = br.readLine();
- exponent = br.readLine();
- } catch ( FileNotFoundException e ) {
- LOG.error( "File 'private.key' not found!", e );
- return false;
- } catch ( IOException e ) {
- LOG.error( "File 'private.key' not correct readable.", e );
+ kpg = KeyPairGenerator.getInstance("RSA");
+ } catch ( NoSuchAlgorithmException e ) {
+ LOG.error( "NoSuchAlgorithmException", e );
return false;
- } finally {
- try {
- br.close();
- } catch ( IOException e ) {
- }
}
- if ( modulus == null || exponent == null ) {
+
+ kpg.initialize(4096);
+ KeyPair kp = kpg.generateKeyPair();
+ RSAPrivateKey privateKey = (RSAPrivateKey) kp.getPrivate();
+ RSAPublicKey publicKey = (RSAPublicKey) kp.getPublic();
+
+ BigInteger pubMod = publicKey.getModulus();
+ BigInteger privMod = privateKey.getModulus();
+ assert(pubMod == privMod);
+
+ BigInteger pubExp = publicKey.getPublicExponent();
+ BigInteger privExp = privateKey.getPrivateExponent();
+
+ RSAPrivateKeySpec privKeySpec = new RSAPrivateKeySpec( privMod, privExp );
+ RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec( pubMod, pubExp );
+
+ KeyFactory keyFact;
+ try {
+ keyFact = KeyFactory.getInstance( "RSA" );
+ } catch ( NoSuchAlgorithmException e ) {
+ LOG.error( "NoSuchAlgorithmException", e );
return false;
}
-
- try {
- BigInteger mod = new BigInteger( modulus );
- BigInteger exp = new BigInteger( exponent );
-
- RSAPrivateKeySpec keySpec = new RSAPrivateKeySpec( mod, exp );
- synchronized ( keyFact ) {
- privKey = keyFact.generatePrivate( keySpec );
+
+ synchronized ( keyFact ) {
+ try {
+ privKey = keyFact.generatePrivate( privKeySpec );
+ pubKey = keyFact.generatePublic( pubKeySpec );
+ } catch ( InvalidKeySpecException e ) {
+ LOG.error( "InvalidKeySpecException", e );
+ return false;
}
- return privKey != null;
- } catch ( InvalidKeySpecException e ) {
- LOG.error( "Not able to build key with given numbers.", e );
- } catch ( NumberFormatException e ) {
- LOG.error( "Invalid number format.", e );
- }
- return false;
- }
-
- private static boolean generateKey()
- {
- // KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
- // kpg.initialize(4096);
- // KeyPair kp = kpg.generateKeyPair();
- // RSAPrivateKey privateKey = (RSAPrivateKey) kp.getPrivate();
- // RSAPublicKey publicKey = (RSAPublicKey) kp.getPublic();
- //
- // log.debug("modulus: " + privateKey.getModulus().toString());
- // log.debug("exponent: " + privateKey.getPrivateExponent().toString());
- //
- //
- // log.debug("modulus: " + publicKey.getModulus().toString());
- // log.debug("exponent: " + publicKey.getPublicExponent().toString());
- //
- // System.exit(1);
+ }
return true;
}
diff --git a/src/main/java/org/openslx/satellitedaemon/Globals.java b/src/main/java/org/openslx/satellitedaemon/Globals.java
index 8b0d182..a14f825 100644
--- a/src/main/java/org/openslx/satellitedaemon/Globals.java
+++ b/src/main/java/org/openslx/satellitedaemon/Globals.java
@@ -19,6 +19,7 @@ import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
import org.apache.log4j.Logger;
+import org.openslx.satellitedaemon.util.Util;
public class Globals
{
@@ -34,8 +35,7 @@ public class Globals
*/
// * Properties *//
-
- // Strings //
+
public static String getMasterserverHost()
{
return properties.getProperty( "MASTERSERVER_HOST" );
@@ -46,16 +46,13 @@ public class Globals
return properties.getProperty( "FILETRANSFER_KEYSTORE_PATH" );
}
- public static String getOrganizationName()
- {
- return properties.getProperty( "ORGANIZATION_NAME" );
- }
-
public static String getImageFolder()
{
return properties.getProperty( "IMAGE_FOLDER" );
}
+
+
// Integers //
public static int getThriftPort()
@@ -78,9 +75,9 @@ public class Globals
System.exit( 2 );
}
- notNullOrEmptyFatal( getMasterserverHost(), "Masterserver Host must not be empty!" );
- notNullOrEmptyFatal( getOrganizationName(), "Organiziation Name must not be empty!" );
- notNullOrEmptyFatal( getImageFolder(), "Image Folder must not be empty!" );
+ 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!" );
}
/***********************************************************************************************/
@@ -101,7 +98,8 @@ public class Globals
TrustManager[] trustManagers = tmf.getTrustManagers();
context.init( null, trustManagers, null );
} catch ( FileNotFoundException e ) {
- log.error( "Could not find the keystore for the filetransfer. Path was '" + getTruststorePath() + "'" );
+ log.error( "Could not find the keystore for the filetransfer. Path was '" +
+ getTruststorePath() + "'" );
return false;
} catch ( Exception e ) {
log.error( "Could not initialize SSL context.", e );
@@ -130,25 +128,4 @@ public class Globals
return 0;
}
}
-
- public static void notNullOrEmptyFatal( String something, String message )
- {
- if ( something == null || something.isEmpty() ) {
- if ( message != null )
- log.fatal( "[NOTNULL] " + message );
- log.warn( Thread.currentThread().getStackTrace().toString() );
- System.exit( 2 );
- }
- }
-
- /**
- * Get private key for this server. If none exists yet, create a new one.
- *
- * @return
- */
- public static PrivateKey getPrivateKey()
- {
- return AsymKeyHolder.getPrivateKey();
- }
-
-}
+} \ No newline at end of file
diff --git a/src/main/java/org/openslx/satellitedaemon/Identity.java b/src/main/java/org/openslx/satellitedaemon/Identity.java
new file mode 100644
index 0000000..b8ed1ee
--- /dev/null
+++ b/src/main/java/org/openslx/satellitedaemon/Identity.java
@@ -0,0 +1,107 @@
+package org.openslx.satellitedaemon;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.math.BigInteger;
+import java.nio.charset.StandardCharsets;
+import java.security.NoSuchAlgorithmException;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+import java.security.spec.InvalidKeySpecException;
+import java.util.Properties;
+
+import org.apache.log4j.Logger;
+import org.openslx.satellitedaemon.util.Util;
+
+public class Identity
+{
+ private static Logger log = Logger.getLogger( Identity.class );
+ private static final Properties properties = new Properties();
+
+ private static BigInteger mod = null;
+ private static BigInteger privExp = null;
+ private static BigInteger pubExp = null;
+
+ public static String getOrganizationName()
+ {
+ return properties.getProperty( "ORGANIZATION_NAME" );
+ }
+
+ public static BigInteger getModulus()
+ {
+ String privateModulus = properties.getProperty( "MODULUS" );
+ mod = new BigInteger( privateModulus );
+ return mod;
+ }
+
+ public static BigInteger getPublicExponent()
+ {
+ String publicModulus = properties.getProperty( "PUBLIC_EXPONENT" );
+ pubExp = new BigInteger( publicModulus );
+ return pubExp;
+ }
+
+ public static BigInteger getPrivateExponent()
+ {
+ String exponent = properties.getProperty( "PRIVATE_EXPONENT" );
+ privExp = new BigInteger( exponent );
+ return privExp;
+ }
+
+ /**
+ * Load properties
+ */
+ static {
+ try {
+ // Load all entries of the config file into properties
+ InputStreamReader stream = new InputStreamReader(
+ new FileInputStream( "config/identity.properties" ), StandardCharsets.UTF_8 );
+ properties.load( stream );
+ stream.close();
+ } catch ( IOException e ) {
+ log.error( "Could not load properties. Exiting." );
+ System.exit( 2 );
+ }
+
+ Util.notNullOrEmptyFatal( getOrganizationName(), "Organiziation Name must not be empty!" );
+ }
+
+ /**
+ * Get private key for this server. If none exists yet, create a new one.
+ *
+ * @return
+ */
+ public static PrivateKey getPrivateKey()
+ {
+ AsymKeyHolder akh;
+ try {
+ akh = new AsymKeyHolder( privExp, null, mod );
+ return akh.getPrivateKey();
+ } catch ( InvalidKeySpecException e ) {
+ log.error( "InvalidKeySpecException", e );
+ } catch ( NoSuchAlgorithmException e ) {
+ log.error( "NoSuchAlgorithmException", e );
+ }
+ return null;
+ }
+
+ /**
+ * Get public key for this server. If none exists yet, create a new one.
+ *
+ * @return
+ */
+ public static PublicKey getPublicKey()
+ {
+ AsymKeyHolder akh;
+ try {
+ akh = new AsymKeyHolder( null, pubExp, mod );
+ return akh.getPublicKey();
+ } catch ( InvalidKeySpecException e ) {
+ log.error( "InvalidKeySpecException", e );
+ } catch ( NoSuchAlgorithmException e ) {
+ log.error( "NoSuchAlgorithmException", e );
+ }
+ return null;
+ }
+}
diff --git a/src/main/java/org/openslx/satellitedaemon/db/DbImage.java b/src/main/java/org/openslx/satellitedaemon/db/DbImage.java
index c99ca40..03ad078 100644
--- a/src/main/java/org/openslx/satellitedaemon/db/DbImage.java
+++ b/src/main/java/org/openslx/satellitedaemon/db/DbImage.java
@@ -49,7 +49,7 @@ public class DbImage
public static List<DbImage> getAllMarkedForUpload()
{
return MySQL.findAll( DbImage.class, "SELECT image.GUID_imageID, image.image_name, image.imageVersion, image.image_path," +
- " user.loginName AS userID, image.image_filesize, image.rec_create_time, image.rec_change_time" +
+ " user.loginName AS userID, image.image_filesize, UNIX_TIMESTAMP(image.rec_create_time), UNIX_TIMESTAMP(image.rec_change_time)" +
" FROM m_VLData_imageInfo image" +
" INNER JOIN m_user user ON (image.image_owner = user.userID)" +
" INNER JOIN m_institution institution ON (institution.institutionID = user.institution)" +
@@ -67,7 +67,7 @@ public class DbImage
public static List<DbImage> getAllMarkedForDownload()
{
return MySQL.findAll( DbImage.class, "SELECT image.GUID_imageID, image.image_name, image.imageVersion, image.image_path," +
- " user.loginName AS userID, image.image_filesize, image.rec_create_time, image.rec_change_time" +
+ " user.loginName AS userID, image.image_filesize, UNIX_TIMESTAMP(image.rec_create_time), UNIX_TIMESTAMP(image.rec_change_time)" +
" FROM m_VLData_imageInfo image" +
" INNER JOIN m_user user ON (image.image_owner = user.userID)" +
" INNER JOIN m_institution institution ON (institution.institutionID = user.institution)" +
diff --git a/src/main/java/org/openslx/satellitedaemon/filetransfer/FileDownloadWorker.java b/src/main/java/org/openslx/satellitedaemon/filetransfer/FileDownloadWorker.java
index e8b8b4d..7ad08db 100644
--- a/src/main/java/org/openslx/satellitedaemon/filetransfer/FileDownloadWorker.java
+++ b/src/main/java/org/openslx/satellitedaemon/filetransfer/FileDownloadWorker.java
@@ -10,64 +10,68 @@ import org.openslx.filetransfer.FileRange;
import org.openslx.filetransfer.WantRangeCallback;
import org.openslx.imagemaster.thrift.iface.DownloadData;
import org.openslx.satellitedaemon.Globals;
+import org.openslx.satellitedaemon.Identity;
import org.openslx.satellitedaemon.db.DbImage;
import org.openslx.satellitedaemon.db.DbImage.Status;
-public class FileDownloadWorker implements Runnable {
- private static Logger log = Logger.getLogger(FileDownloadWorker.class);
+public class FileDownloadWorker implements Runnable
+{
+ private static Logger log = Logger.getLogger( FileDownloadWorker.class );
@Override
- public void run() {
- while (true) {
+ public void run()
+ {
+ while ( true ) {
List<DbImage> imageList = DbImage.getAllMarkedForDownload();
- log.info("imageList Contains " + imageList.size() + " items.");
- for (final DbImage image : imageList) {
+ log.info( "imageList Contains " + imageList.size() + " items." );
+ for ( final DbImage image : imageList ) {
List<Integer> range = new ArrayList<Integer>();
- for (long i = 0; i < (image.fileSize / Globals.BLOCKSIZE); i++) {
- range.add((int) i);
+ for ( long i = 0; i < ( image.fileSize / Globals.BLOCKSIZE ); i++ ) {
+ range.add( (int)i );
}
- DownloadData downInfos = ThriftConnection.getDownloadInfos(image);
- if (downInfos == null) {
- log.error("The DownloadInfos returned by ThriftConnection class are null");
+ DownloadData downInfos = ThriftConnection.getDownloadInfos( image );
+ if ( downInfos == null ) {
+ log.error( "The DownloadInfos returned by ThriftConnection class are null" );
continue;
}
// create new instance of Downloader.
Downloader d;
try {
- d = new Downloader(Globals.getMasterserverHost(),
- downInfos.port, Globals.getMasterServerSslContext(), downInfos.token);
- } catch (IOException e) {
+ d = new Downloader( Globals.getMasterserverHost(),
+ downInfos.port, Globals.getMasterServerSslContext(), downInfos.token );
+ } catch ( IOException e ) {
e.printStackTrace();
continue;
}
-
+
// start downloading process.
- d.download(Globals.getImageFolder() + "/" + image.path, new WantRangeCallback() {
+ d.download( Globals.getImageFolder() + "/" + image.path, new WantRangeCallback() {
long pos = 0;
long size = image.fileSize;
-
+
@Override
- public FileRange get() {
+ public FileRange get()
+ {
// get start of range.
- if (pos >= size) {
- log.debug("Download completed.");
- image.updateStatus(Status.successfully_decentralized);
+ if ( pos >= size ) {
+ log.debug( "Download completed." );
+ image.updateStatus( Status.successfully_decentralized );
return null;
}
-
- long startOfRange = pos;
- long endOfRange = Math.min(pos + Globals.BLOCKSIZE, image.fileSize);
- FileRange range = new FileRange(startOfRange, endOfRange);
+
+ long startOfRange = pos;
+ long endOfRange = Math.min( pos + Globals.BLOCKSIZE, image.fileSize );
+ FileRange range = new FileRange( startOfRange, endOfRange );
pos += Globals.BLOCKSIZE;
return range;
}
- });
+ } );
}
try {
- Thread.sleep(5 * 60 * 1000);
- } catch (InterruptedException e) {
+ Thread.sleep( 5 * 60 * 1000 );
+ } catch ( InterruptedException e ) {
Thread.currentThread().interrupt();
return;
}
diff --git a/src/main/java/org/openslx/satellitedaemon/filetransfer/FileUploadWorker.java b/src/main/java/org/openslx/satellitedaemon/filetransfer/FileUploadWorker.java
index 6947b5a..1034dd7 100644
--- a/src/main/java/org/openslx/satellitedaemon/filetransfer/FileUploadWorker.java
+++ b/src/main/java/org/openslx/satellitedaemon/filetransfer/FileUploadWorker.java
@@ -9,6 +9,7 @@ import org.openslx.imagemaster.thrift.iface.ImageData;
import org.openslx.imagemaster.thrift.iface.UploadData;
import org.openslx.imagemaster.thrift.iface.UserInfo;
import org.openslx.satellitedaemon.Globals;
+import org.openslx.satellitedaemon.Identity;
import org.openslx.satellitedaemon.db.DbImage;
import org.openslx.satellitedaemon.db.DbImage.Status;
import org.openslx.satellitedaemon.db.DbUser;
@@ -31,15 +32,15 @@ public class FileUploadWorker implements Runnable
ImageData imDat = new ImageData(
image.guid, image.rid,
image.name, image.createTime, image.changeTime, image.creator,
- "anyThing", true, false, "best", image.fileSize );
+ "anyThing", true, false, "best", image.fileSize );
String path = Globals.getImageFolder() + "/" + image.path;
// ThriftConnection.getUploadInfos returns uploadInfo and handles ThriftAuthentication
- DbUser dbUser = DbUser.getUserById(imDat.ownerLogin);
- UserInfo userInfo = new UserInfo(dbUser.userId, dbUser.firstName, dbUser.lastName, dbUser.email, null);
- ThriftConnection.publishUser(userInfo);
- UploadData upInfos = ThriftConnection.getUploadInfos( imDat, path);
+ DbUser dbUser = DbUser.getUserById( imDat.ownerLogin );
+ UserInfo userInfo = new UserInfo( dbUser.userId, dbUser.firstName, dbUser.lastName, dbUser.email, null );
+ ThriftConnection.publishUser( userInfo );
+ UploadData upInfos = ThriftConnection.getUploadInfos( imDat, path );
if ( upInfos == null ) {
log.error( "The UploadInfos returned by ThriftConnection Class are null" );
continue;
diff --git a/src/main/java/org/openslx/satellitedaemon/filetransfer/ThriftConnection.java b/src/main/java/org/openslx/satellitedaemon/filetransfer/ThriftConnection.java
index 5cae49b..f716077 100644
--- a/src/main/java/org/openslx/satellitedaemon/filetransfer/ThriftConnection.java
+++ b/src/main/java/org/openslx/satellitedaemon/filetransfer/ThriftConnection.java
@@ -29,6 +29,7 @@ import org.openslx.imagemaster.thrift.iface.UploadError;
import org.openslx.imagemaster.thrift.iface.UploadException;
import org.openslx.imagemaster.thrift.iface.UserInfo;
import org.openslx.satellitedaemon.Globals;
+import org.openslx.satellitedaemon.Identity;
import org.openslx.satellitedaemon.db.DbImage;
import org.openslx.satellitedaemon.db.DbImage.Status;
@@ -206,16 +207,16 @@ public class ThriftConnection
if ( !isAuthenticated ) {
try {
ByteBuffer tmpBuffer = theClient
- .startServerAuthentication( Globals
+ .startServerAuthentication( Identity
.getOrganizationName() );
byte[] toEncrypt = new byte[ tmpBuffer.remaining() ];
tmpBuffer.get( toEncrypt );
AsymEncryptionHandler aeh = new AsymEncryptionHandler(
- Globals.getPrivateKey() );
+ Identity.getPrivateKey() );
byte[] byteArray = aeh.encryptMessage( toEncrypt );
sSD = theClient.serverAuthenticate(
- Globals.getOrganizationName(),
+ Identity.getOrganizationName(),
ByteBuffer.wrap( byteArray ) );
} catch ( AuthenticationException e ) {
log.error( "ThriftConnection: AuthenticationException: Server Authetication was not sucessful.", e );
@@ -253,8 +254,9 @@ public class ThriftConnection
client.set( newClient );
return newClient;
}
-
- public static boolean publishUser(UserInfo userInfo) {
+
+ public static boolean publishUser( UserInfo userInfo )
+ {
ImageServer.Client theClient = null;
theClient = getConnection();
if ( theClient == null ) {
diff --git a/src/main/java/org/openslx/satellitedaemon/util/Util.java b/src/main/java/org/openslx/satellitedaemon/util/Util.java
index 4f39e71..24f9883 100644
--- a/src/main/java/org/openslx/satellitedaemon/util/Util.java
+++ b/src/main/java/org/openslx/satellitedaemon/util/Util.java
@@ -29,4 +29,14 @@ public class Util
System.exit( 2 );
}
}
+
+ public static void notNullOrEmptyFatal( String something, String message )
+ {
+ if ( something == null || something.isEmpty() ) {
+ if ( message != null )
+ log.fatal( "[NOTNULL] " + message );
+ log.warn( Thread.currentThread().getStackTrace().toString() );
+ System.exit( 2 );
+ }
+ }
}