From 3ce1e77a76992a1c3011fcb663ebec040c2e5dca Mon Sep 17 00:00:00 2001 From: Michael Petretti Date: Wed, 11 Jun 2014 13:36:06 +0200 Subject: Narrowed the problem down to ThriftConnection class line 127 throwing a TTransportException. --- .../satellitedaemon/ftp/ThriftConnection.java | 45 ++++++++++++++-------- 1 file changed, 30 insertions(+), 15 deletions(-) (limited to 'src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java') 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(); -- cgit v1.2.3-55-g7522