summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java
diff options
context:
space:
mode:
authorMichael Petretti2014-06-11 13:36:06 +0200
committerMichael Petretti2014-06-11 13:36:06 +0200
commit3ce1e77a76992a1c3011fcb663ebec040c2e5dca (patch)
tree21bc76288e768b3411dcd0c6ad4a696ebc2626ea /src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java
parentAdded log messages. (diff)
downloadsatellite-daemon-3ce1e77a76992a1c3011fcb663ebec040c2e5dca.tar.gz
satellite-daemon-3ce1e77a76992a1c3011fcb663ebec040c2e5dca.tar.xz
satellite-daemon-3ce1e77a76992a1c3011fcb663ebec040c2e5dca.zip
Narrowed the problem down to ThriftConnection class line 127 throwing a TTransportException.
Diffstat (limited to 'src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java')
-rw-r--r--src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java45
1 files changed, 30 insertions, 15 deletions
diff --git a/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java b/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java
index e7fe0b8..c3fb21c 100644
--- a/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java
+++ b/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java
@@ -44,14 +44,15 @@ public class ThriftConnection
*/
public static FtpCredentials getFtpCredentials( ImageData imDat )
{
+ ImageServer.Client theClient = null;
try {
- client = getConnection();
- if ( client == null ) {
+ theClient = getConnection();
+ if ( theClient == null ) {
log.error( "Client was null!" );
return null;
}
- return client.submitImage( sSD.sessionId, imDat );
+ return theClient.submitImage( sSD.sessionId, imDat );
} catch ( TException e ) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -95,41 +96,54 @@ public class ThriftConnection
IOException, InvalidKeyException, SignatureException
{
ImageServer.Client theClient = null;
- if ( client == null ) {
- theClient = newClient();
- } else {
- theClient = client;
- }
boolean isAuthenticated = false;
- try {
- isAuthenticated = theClient.ping();
- } catch ( TException x ) {
+ if ( client == null ) {
+ log.info( "The global client was null. Making a new client ..." );
theClient = newClient();
if ( theClient == null ) {
+ log.debug( "ThriftConnection: The client was null after newClient()" );
return null;
}
+ } else {
+ log.info( "The global Client was already used. Setting isAuthenticated = true." );
+ theClient = client;
+ isAuthenticated = true;
}
+ // try {
+ // isAuthenticated = theClient.ping();
+ // } catch ( TException x ) {
+ // theClient = newClient();
+ // if ( theClient == null ) {
+ // return null;
+ // }
+ // }
if ( !isAuthenticated ) {
log.info( "ThriftConnection: Client not yet Authenticated. Trying..." );
String toEncrypt;
+ if ( theClient == null ) {
+ log.debug( "The client was null" );
+ }
try {
- toEncrypt = client.startServerAuthentication( "uni-freiburg.de" );
- // System.out.println( toEncrypt );
+ toEncrypt = theClient.startServerAuthentication( "michis-test.de" );
+ log.info( "The random String we want to encrypt: " + toEncrypt );
EncryptWithServerIdPublicKey rse = new EncryptWithServerIdPublicKey( "serverid", "password",
"/home/michael/satellite-daemon/config/serverid.jks" );
byte[] byteArray = rse.encryptString( toEncrypt );
- sSD = client.serverAuthenticate(
- "uni-freiburg.de", ByteBuffer.wrap( byteArray ) );
+ sSD = theClient.serverAuthenticate(
+ "michis-test.de", ByteBuffer.wrap( byteArray ) );
} catch ( ServerAuthenticationException e ) {
log.error( "ThriftConnection: Server Authetication was not sucessful." );
e.printStackTrace();
+ return null;
} catch ( TException e ) {
log.error( "ThriftConnection: Server Authetication was not sucessful." );
e.printStackTrace();
+ return null;
}
log.info( "is Authenticated." );
}
+ client = theClient;
return theClient;
}
@@ -142,6 +156,7 @@ public class ThriftConnection
transport.open();
TProtocol protocol = new TBinaryProtocol( transport );
newClient = new ImageServer.Client( protocol );
+ log.debug( "ThriftConnection: Made a new Client" );
} catch ( TException x ) {
log.error( "ThriftConnection coudn't create new client." );
x.printStackTrace();