summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Petretti2014-07-10 16:48:49 +0200
committerMichael Petretti2014-07-10 16:48:49 +0200
commitc4b51e6fd2b7e0fc3531cb43064f64e9d0d0b74e (patch)
treef1ca31217db6ef1521f07f9c132e5a6c4844b09f
parentMerge branch 'master' of git.openslx.org:bwlp/satellite-daemon (diff)
downloadsatellite-daemon-c4b51e6fd2b7e0fc3531cb43064f64e9d0d0b74e.tar.gz
satellite-daemon-c4b51e6fd2b7e0fc3531cb43064f64e9d0d0b74e.tar.xz
satellite-daemon-c4b51e6fd2b7e0fc3531cb43064f64e9d0d0b74e.zip
Fixed a lot of TODOs and upload works.
-rw-r--r--src/main/java/org/openslx/satellitedaemon/App.java16
-rw-r--r--src/main/java/org/openslx/satellitedaemon/Globals.java90
-rw-r--r--src/main/java/org/openslx/satellitedaemon/ftp/FtpDownloadWorker.java93
-rw-r--r--src/main/java/org/openslx/satellitedaemon/ftp/FtpUploadWorker.java72
-rw-r--r--src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java54
5 files changed, 136 insertions, 189 deletions
diff --git a/src/main/java/org/openslx/satellitedaemon/App.java b/src/main/java/org/openslx/satellitedaemon/App.java
index 7210c47..cd99ec0 100644
--- a/src/main/java/org/openslx/satellitedaemon/App.java
+++ b/src/main/java/org/openslx/satellitedaemon/App.java
@@ -1,21 +1,13 @@
package org.openslx.satellitedaemon;
-import java.io.FileNotFoundException;
import java.io.IOException;
-import java.security.InvalidKeyException;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.SignatureException;
-import java.security.UnrecoverableKeyException;
-import java.security.cert.CertificateException;
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Logger;
-import org.openslx.imagemaster.thrift.iface.ServerAuthenticationException;
import org.openslx.satellitedaemon.ftp.FtpDownloadWorker;
import org.openslx.satellitedaemon.ftp.FtpUploadWorker;
-/**
+/***********************************************************************************************
* Main class for uploading images from the HS-Server to the Satellite Server.
*
*/
@@ -24,8 +16,6 @@ public class App
private static Logger log = Logger.getLogger( App.class );
public static void main( String[] args )
- throws NoSuchAlgorithmException, KeyStoreException, CertificateException, FileNotFoundException, IOException, ServerAuthenticationException, UnrecoverableKeyException,
- InvalidKeyException, SignatureException
{
BasicConfigurator.configure();
try {
@@ -38,6 +28,10 @@ public class App
log.error( "Could not load config file. Quitting." );
System.exit( 1 );
}
+ if (!Globals.masterServerSslContextInit()){
+ log.error( "Problem with initializing the SSLContext" );
+ System.exit( 1 );
+ }
Thread uploadWorker = new Thread( new FtpUploadWorker() );
uploadWorker.start();
Thread downloadWorker = new Thread( new FtpDownloadWorker() );
diff --git a/src/main/java/org/openslx/satellitedaemon/Globals.java b/src/main/java/org/openslx/satellitedaemon/Globals.java
index 3bfd5cb..afcb3c6 100644
--- a/src/main/java/org/openslx/satellitedaemon/Globals.java
+++ b/src/main/java/org/openslx/satellitedaemon/Globals.java
@@ -2,15 +2,29 @@ package org.openslx.satellitedaemon;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.IOException;
+import java.security.KeyManagementException;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.CertificateException;
import java.util.Properties;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.TrustManagerFactory;
+
+import org.apache.log4j.Logger;
+
public class Globals
{
+ private static Logger log = Logger.getLogger( Globals.class );
private static final Properties properties = new Properties();
private static boolean loadedProperties = false;
+ private static SSLContext context = null;
- /**
+ /***********************************************************************************************
* If there are more ints or Strings which should be added to config/global.properties,
* add to suiting enum, add a 'case' to getPropertyInt/String() and add checks to
* propertiesValid().
@@ -20,7 +34,7 @@ public class Globals
*/
public static enum PropInt
{
- FTPPORT, THRIFTPORT // More int's? Add them separated with ","
+ FTPPORT, THRIFTPORT, BLOCKSIZE // More int's? Add them separated with ","
}
public static enum PropString
@@ -29,6 +43,11 @@ public class Globals
RNDSTRINGENCRYPTALIAS, RNDSTRINGENCRYPTPASSWORD, RNDSTRINGENCRYPTPATH
}
+ /***********************************************************************************************
+ *
+ * @return
+ * @throws IOException
+ */
public static boolean loadProperties() throws IOException
{
if ( loadedProperties )
@@ -42,7 +61,11 @@ public class Globals
return true;
}
- // Calling
+ /***********************************************************************************************
+ *
+ * @param props
+ * @return
+ */
public static int getPropertyInt( Globals.PropInt props )
{
String result = null;
@@ -51,6 +74,9 @@ public class Globals
case FTPPORT:
result = properties.getProperty( "ftp_port" );
break;
+ case BLOCKSIZE:
+ result = properties.getProperty( "blockSize" );
+ break;
case THRIFTPORT:
result = properties.getProperty( "ThriftPort" );
break;
@@ -64,6 +90,11 @@ public class Globals
return Integer.valueOf( result );
}
+ /***********************************************************************************************
+ *
+ * @param props
+ * @return
+ */
public static String getPropertyString( Globals.PropString props )
{
String result = null;
@@ -100,9 +131,15 @@ public class Globals
return result;
}
+ // TODO: add real checks
+ /***********************************************************************************************
+ *
+ * @return
+ */
public static boolean propertiesValid()
{
if ( Globals.getPropertyInt( PropInt.FTPPORT ) == 0
+ || Globals.getPropertyInt( PropInt.BLOCKSIZE ) == 0
|| Globals.getPropertyInt( PropInt.THRIFTPORT ) == 0
|| Globals.getPropertyString( PropString.FTPSERVERIP ).isEmpty()
|| Globals.getPropertyString( PropString.FTPSERVERIP ) == null
@@ -126,4 +163,51 @@ public class Globals
return true;
}
}
+
+ /***********************************************************************************************
+ *
+ * @return
+ */
+ public static boolean masterServerSslContextInit()
+ {
+ char[] passphrase = Globals.getPropertyString( PropString.FTPSKEYSTOREPWD ).toCharArray();
+ KeyStore keystore;
+ try {
+ keystore = KeyStore.getInstance( "JKS" );
+ keystore.load( new FileInputStream( Globals.getPropertyString( PropString.FTPSKEYSTOREPATH ) ), passphrase );
+ 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("FileNotFoundException");
+ return false;
+ } catch ( IOException e ) {
+ log.error("IOException");
+ return false;
+ } catch ( KeyManagementException e ) {
+ log.error("KeyManagementException");
+ return false;
+ }
+ return true;
+ }
+
+
+ /***********************************************************************************************
+ *
+ * @return
+ */
+ public static SSLContext getMasterServerSslContext(){
+ return Globals.context;
+ }
}
diff --git a/src/main/java/org/openslx/satellitedaemon/ftp/FtpDownloadWorker.java b/src/main/java/org/openslx/satellitedaemon/ftp/FtpDownloadWorker.java
index d315735..73e0b03 100644
--- a/src/main/java/org/openslx/satellitedaemon/ftp/FtpDownloadWorker.java
+++ b/src/main/java/org/openslx/satellitedaemon/ftp/FtpDownloadWorker.java
@@ -1,19 +1,8 @@
package org.openslx.satellitedaemon.ftp;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.security.KeyManagementException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.cert.CertificateException;
+import java.util.ArrayList;
import java.util.List;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.TrustManagerFactory;
-
import org.apache.log4j.Logger;
import org.openslx.filetransfer.Downloader;
import org.openslx.imagemaster.thrift.iface.DownloadInfos;
@@ -22,7 +11,6 @@ import org.openslx.satellitedaemon.Globals.PropInt;
import org.openslx.satellitedaemon.Globals.PropString;
import org.openslx.satellitedaemon.db.DbImage;
-// TODO: Pretty much the same todos as in the uploader apply here
public class FtpDownloadWorker implements Runnable
{
@@ -36,86 +24,21 @@ public class FtpDownloadWorker implements Runnable
log.info( "FtpDownloadWorker: imageList Contains " + imageList.size() + " items." );
for ( DbImage image : imageList ) {
- DownloadInfos downInfos = ThriftConnection.getDownloadInfos( image );
+ List<Integer> range = new ArrayList<Integer>();
+ for (long i = 0; i < (image.fileSize / Globals.getPropertyInt( PropInt.BLOCKSIZE )); i++) {
+ range.add( (int) i );
+ }
+ DownloadInfos downInfos = ThriftConnection.getDownloadInfos( image, range );
if ( downInfos == null ) {
log.error( "The DownloadInfos returned by ThriftConnection class are null" );
}
- char[] passphrase = Globals.getPropertyString( PropString.FTPSKEYSTOREPWD ).toCharArray();
- KeyStore keystore;
- try {
- keystore = KeyStore.getInstance( "JKS" );
- keystore.load( new FileInputStream( Globals.getPropertyString( PropString.FTPSKEYSTOREPATH ) ), passphrase );
- TrustManagerFactory tmf = TrustManagerFactory.getInstance( TrustManagerFactory.getDefaultAlgorithm() );
- tmf.init( keystore );
- SSLContext context = SSLContext.getInstance( "SSLv3" );
- TrustManager[] trustManagers = tmf.getTrustManagers();
- context.init( null, trustManagers, null );
-
- Downloader d = new Downloader( Globals.getPropertyString( PropString.FTPSERVERIP ), Globals.getPropertyInt( PropInt.FTPPORT ), context );
+ Downloader d = new Downloader( Globals.getPropertyString( PropString.FTPSERVERIP ), downInfos.port, Globals.getMasterServerSslContext() );
d.sendToken( downInfos.token );
+ d.setOutputFilename( "/home/michael/Downloads/tescht.whatever" );
while ( d.readMetaData() )
d.readBinary();
- } catch ( NoSuchAlgorithmException e ) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch ( CertificateException e ) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch ( FileNotFoundException e ) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch ( IOException e ) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch ( KeyStoreException e ) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch ( KeyManagementException e ) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- // try {
- // TrustManagerFactory trustManagerFactory = TrustManagerFactory
- // .getInstance( KeyManagerFactory.getDefaultAlgorithm() );
- // KeyStore keystore = KeyStore.getInstance( Globals.getPropertyString( PropString.KEYSTORETYPE ) );
- // keystore.load( new FileInputStream( new File(
- // Globals.getPropertyString( PropString.FTPSKEYSTOREPATH ) ) ),
- // Globals.getPropertyString( PropString.FTPSKEYSTOREPWD ).toCharArray() );
- // trustManagerFactory.init( keystore );
- // TrustManager trustManager = trustManagerFactory.getTrustManagers()[0];
- // FTPSClient ftpClient = new FTPSClient( "SSL", true );
- // ftpClient.setTrustManager( trustManager );
- // try {
- // ftpClient.connect( Globals.getPropertyString( PropString.FTPSERVERIP ), Globals.getPropertyInt( PropInt.FTPPORT ) );
- // if ( !ftpClient.login( ftpc.username, ftpc.password ) ) {
- // log.error( "FTP problem. Coundn't log in!" );
- // }
- // File file = new File( "/tmp/" + image.guid + ".vmdk");
- // ftpClient.setFileType( FTP.BINARY_FILE_TYPE );
- // log.info( "FtpDownloadWorker: ftpc.filename: " + ftpc.filename );
- // InputStream is = ftpClient.retrieveFileStream( ftpc.filename );
- // FileOutputStream fos = new FileOutputStream( file );
- // int b;
- // while ((b = is.read()) != -1) {
- // fos.write( b );
- // }
- // is.close();
- // fos.close();
- // ThriftConnection.finishedDownload( ftpc.username);
- //
- // } catch (IOException e) {
- // log.error("FtpDownloadWorker: Error creating the FileInputStream");
- // }
- // finally {
- // ftpClient.disconnect();
- // log.info( "FtpDownloadWorker: ftpClient disconnected" );
- // }
- // } catch ( NoSuchAlgorithmException | KeyStoreException | CertificateException | IOException e ) {
- // log.debug( "FtpDownloadWorker: Problem with Keystore ore FtpsClient creation." );
- // }
}
try {
Thread.sleep( 5 * 60 * 1000 );
diff --git a/src/main/java/org/openslx/satellitedaemon/ftp/FtpUploadWorker.java b/src/main/java/org/openslx/satellitedaemon/ftp/FtpUploadWorker.java
index aa750f2..4445a2e 100644
--- a/src/main/java/org/openslx/satellitedaemon/ftp/FtpUploadWorker.java
+++ b/src/main/java/org/openslx/satellitedaemon/ftp/FtpUploadWorker.java
@@ -1,25 +1,14 @@
package org.openslx.satellitedaemon.ftp;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.security.KeyManagementException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.cert.CertificateException;
import java.util.List;
import java.util.UUID;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.TrustManagerFactory;
-
import org.apache.log4j.Logger;
import org.openslx.filetransfer.Uploader;
import org.openslx.imagemaster.thrift.iface.ImageData;
import org.openslx.imagemaster.thrift.iface.UploadInfos;
import org.openslx.satellitedaemon.Globals;
+import org.openslx.satellitedaemon.Globals.PropInt;
import org.openslx.satellitedaemon.Globals.PropString;
import org.openslx.satellitedaemon.db.DbImage;
@@ -47,20 +36,6 @@ public class FtpUploadWorker implements Runnable
ImageData imDat = new ImageData( UUID.randomUUID().toString(), image.rid,
image.name, System.currentTimeMillis(), System.currentTimeMillis(), image.creator, "anyThing",
true, false, "best", "theVeryBest", image.fileSize );
- char[] passphrase = Globals.getPropertyString( PropString.FTPSKEYSTOREPWD ).toCharArray();
- KeyStore keystore;
- try {
-
- // All the necessary KeyStore handling for the "context"-item.
- // TODO: Don't do this again and again for every image, but once before the loop (or in the constructor)
- // Or better yet in a central spot, as the downloadworker needs the context too. Maybe something like Globals.getMasterServerSslContext()
- keystore = KeyStore.getInstance( "JKS" );
- keystore.load( new FileInputStream( Globals.getPropertyString( PropString.FTPSKEYSTOREPATH ) ), passphrase );
- TrustManagerFactory tmf = TrustManagerFactory.getInstance( TrustManagerFactory.getDefaultAlgorithm() );
- tmf.init( keystore );
- SSLContext context = SSLContext.getInstance( "SSLv3" );
- TrustManager[] trustManagers = tmf.getTrustManagers();
- context.init( null, trustManagers, null );
// uploadInfo and ThriftAuthentication
String crcPath = image.path.concat( ".crc" );
@@ -76,61 +51,28 @@ public class FtpUploadWorker implements Runnable
log.info( "Got upInfos. Trying to create Uploader with token: " + upInfos.token );
// creating the uploader with the "context"-item.
- Uploader u = new Uploader( Globals.getPropertyString( PropString.FTPSERVERIP ), upInfos.port, context );
+ Uploader u = new Uploader( Globals.getPropertyString( PropString.FTPSERVERIP ), upInfos.port, Globals.getMasterServerSslContext() );
u.sendToken( upInfos.token );
// continue sending Blocks until getMissingBlocks is empty.
-
-
-
while ( !upInfos.getMissingBlocks().isEmpty() ) {
// Send all Blocks from upInfos.getMissingBlocks() in ranges.
List<Integer> blocks = upInfos.getMissingBlocks();
int start = 0;
for ( int i = 0; i < blocks.size() - 1; i++ ) {
- if ( blocks.get( i ) != ( blocks.get( i + 1 ) - 1 ) ) { // TODO: !? u.sendRange expects byte values, upInfos contains block indexes (16MiB)
- u.sendRange( start, i );
+ if ( blocks.get( i ) != ( blocks.get( i + 1 ) - 1 ) ) {
+ u.sendRange( start * Globals.getPropertyInt( PropInt.BLOCKSIZE ), i * Globals.getPropertyInt( PropInt.BLOCKSIZE ));
u.sendFile( image.path );
start = i + 1;
}
if ( i == blocks.size() - 2 ) { // TODO: !=
- u.sendRange( start, blocks.size() - 1 );
+ u.sendRange( start * Globals.getPropertyInt( PropInt.BLOCKSIZE ), (blocks.size() - 1) * Globals.getPropertyInt( PropInt.BLOCKSIZE ) );
u.sendFile( image.path );
}
}
+ upInfos = ThriftConnection.getUploadInfos( imDat );
}
- // FIXME: Should be inside loop, otherwise you'll only ever upload the first 20 blocks
- upInfos = ThriftConnection.getUploadInfos( imDat );
-
-
- // TODO: Use more local try/catch-blocks, not a big one around everything, so you know what exactly caused the exception
- // and can handle it properly. There are roughly 3 types of error/exception you can encounter:
- // 1) Expected exception: Something you expect to go wrong, so you handle it in the catch block and let the code flow continue
- // 2) Minor exception: Something went wrong and you can't continue trying to upload that image. Try to clean things up that
- // you already did (like opening a file, opening a network connection) and then continue with the next image
- // 3) Major messup: Something went wrong that will prevent the whole application from continuing to work. Try to finish or cancel
- // any operation going on in your application and then exit (and don't forget to log meaningful information about the error)
- // Basically all those empty catch blocks below should be moved up and filled with logic.
- } catch ( NoSuchAlgorithmException e ) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch ( CertificateException e ) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch ( FileNotFoundException e ) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch ( IOException e ) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch ( KeyStoreException e ) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch ( KeyManagementException e ) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
+ u.close();
}
try {
Thread.sleep( 5 * 60 * 1000 );
diff --git a/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java b/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java
index cacd6c8..5d67635 100644
--- a/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java
+++ b/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java
@@ -9,6 +9,7 @@ import java.security.NoSuchAlgorithmException;
import java.security.SignatureException;
import java.security.UnrecoverableKeyException;
import java.security.cert.CertificateException;
+import java.util.List;
import org.apache.log4j.Logger;
import org.apache.thrift.TException;
@@ -31,7 +32,7 @@ import org.openslx.satellitedaemon.util.EncryptWithServerIdPublicKey;
// TODO: Handle all the auto-generated catch blocks in a meaningful way
-/**
+/***********************************************************************************************
* Handles the authentication with the Satellite Server and sends the FtpCredentials, which
* are necessary for the upload of the image.
*/
@@ -42,14 +43,14 @@ public class ThriftConnection
private static Logger log = Logger.getLogger( ThriftConnection.class );
private static CRCFile crc = null;
- /**
- * Method for getting UploadeInfos
+ /***********************************************************************************************
+ * Method for getting UploadeInfos
*
- * !! on the first Call !!
+ * !! on the first Call !!
*
* when the CRCsum need to be transfered.
- * The method calls getConnection() to check if the connection is ok
- * and to get the ServerSessionData. If connection is ok, it calls
+ * The method calls getConnection() to check if the connection is ok
+ * and to get the ServerSessionData. If connection is ok, it calls
* submitImage with CRCsum in List<Integer>.
*
* @return returns 'null' if there is a problem.
@@ -66,7 +67,7 @@ public class ThriftConnection
// .submitImage needs the List<Integer> from CRCFile.getCRCs() only
// on the first time called. null afterwards.
log.info( "First call of submitImage following..." );
- crc = new CRCFile(filename);
+ crc = new CRCFile( filename );
log.info( "Made CRCFile from " + filename );
return theClient.submitImage( sSD.sessionId, imDat, crc.getCrcSums() );
} catch ( TException e ) {
@@ -99,12 +100,13 @@ public class ThriftConnection
}
return null;
}
-
- /**
+
+ /***********************************************************************************************
* Method for getting UploadeInfos when CRCsum was already transfered on first call.
- * The method calls getConnection() to check if the connection is ok
- * and to get the ServerSessionData. If connection is ok, it calls
+ * The method calls getConnection() to check if the connection is ok
+ * and to get the ServerSessionData. If connection is ok, it calls
* submitImage with sSD.sessionId, imDat and !!null!!
+ *
* @return returns 'null' if there is a problem.
*/
public static UploadInfos getUploadInfos( ImageData imDat )
@@ -118,7 +120,7 @@ public class ThriftConnection
}
// .submitImage needs the List<Integer> from CRCFile.getCRCs() only
// on the first time called. null afterwards.
- return theClient.submitImage( sSD.sessionId, imDat, crc.getCrcSums());
+ return theClient.submitImage( sSD.sessionId, imDat, crc.getCrcSums() );
} catch ( TException e ) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -149,14 +151,14 @@ public class ThriftConnection
}
return null;
}
-
- /**
- * The method calls getConnection() to check if the connection is ok
- * and to get the DownloadeInfos. If connection is ok, it returns ftpCredential.
+
+ /***********************************************************************************************
+ * Method for getting DonwloadInfos. Calls getConnection if client was null.
+ * You need to spezifie all Blocks you want to have in an List.
*
* @return returns 'null' if there is a problem.
*/
- public static DownloadInfos getDownloadInfos( DbImage imDat )
+ public static DownloadInfos getDownloadInfos( DbImage imDat, List<Integer> range )
{
ImageServer.Client theClient = null;
try {
@@ -166,7 +168,7 @@ public class ThriftConnection
return null;
}
- return theClient.getImage( imDat.guid, sSD.sessionId );
+ return theClient.getImage( imDat.guid, sSD.sessionId, range );
} catch ( TException e ) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -198,9 +200,7 @@ public class ThriftConnection
return null;
}
-
-
- /**
+ /***********************************************************************************************
* This method checks if there is already a working connection. If not,
* newClient() establishes one. Also it does the Authentication if not done
* yet.
@@ -209,7 +209,7 @@ public class ThriftConnection
*/
private static ImageServer.Client getConnection()
throws UnrecoverableKeyException, NoSuchAlgorithmException, CertificateException,
- FileNotFoundException, KeyStoreException, IOException, InvalidKeyException, SignatureException
+ FileNotFoundException, KeyStoreException, IOException, InvalidKeyException, SignatureException
{
ImageServer.Client theClient = null;
boolean isAuthenticated = false;
@@ -241,14 +241,14 @@ public class ThriftConnection
return null;
}
try {
- toEncrypt = theClient.startServerAuthentication( Globals.getPropertyString( PropString.THRIFTORGANIZATIONNAME) );
+ toEncrypt = theClient.startServerAuthentication( Globals.getPropertyString( PropString.THRIFTORGANIZATIONNAME ) );
log.info( "The random String we want to encrypt: " + toEncrypt );
EncryptWithServerIdPublicKey rse = new EncryptWithServerIdPublicKey( Globals.getPropertyString( PropString.RNDSTRINGENCRYPTALIAS ),
Globals.getPropertyString( PropString.RNDSTRINGENCRYPTPASSWORD ),
Globals.getPropertyString( PropString.RNDSTRINGENCRYPTPATH ) );
byte[] byteArray = rse.encryptString( toEncrypt );
sSD = theClient.serverAuthenticate(
- Globals.getPropertyString( PropString.THRIFTORGANIZATIONNAME), ByteBuffer.wrap( byteArray ) );
+ Globals.getPropertyString( PropString.THRIFTORGANIZATIONNAME ), ByteBuffer.wrap( byteArray ) );
} catch ( ServerAuthenticationException e ) {
log.error( "ThriftConnection: ServerAuthenticationException: Server Authetication was not sucessful." );
e.printStackTrace();
@@ -265,11 +265,15 @@ public class ThriftConnection
return theClient;
}
+ /***********************************************************************************************
+ *
+ * @return
+ */
private static ImageServer.Client newClient()
{
ImageServer.Client newClient = null;
try {
- TTransport transport;
+ TTransport transport;
transport = new TSocket( Globals.getPropertyString( PropString.FTPSERVERIP ), Globals.getPropertyInt( PropInt.THRIFTPORT ) );
transport.open();
TProtocol protocol = new TBinaryProtocol( transport );