From 79211fe8f5e15d326f50c90067d0bc82f1f75bda Mon Sep 17 00:00:00 2001 From: Michael Petretti Date: Wed, 4 Jun 2014 15:01:27 +0200 Subject: Added log messages. --- .../satellitedaemon/ftp/ThriftConnection.java | 31 +++++++++++++++------- 1 file changed, 22 insertions(+), 9 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 e9ab3af..e7fe0b8 100644 --- a/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java +++ b/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java @@ -47,7 +47,7 @@ public class ThriftConnection try { client = getConnection(); if ( client == null ) { - log.info( "Client was null!" ); + log.error( "Client was null!" ); return null; } @@ -91,7 +91,7 @@ public class ThriftConnection * @return returns the client if successful. */ private static ImageServer.Client getConnection() - throws ServerAuthenticationException, TException, UnrecoverableKeyException, NoSuchAlgorithmException, CertificateException, FileNotFoundException, KeyStoreException, + throws UnrecoverableKeyException, NoSuchAlgorithmException, CertificateException, FileNotFoundException, KeyStoreException, IOException, InvalidKeyException, SignatureException { ImageServer.Client theClient = null; @@ -110,13 +110,25 @@ public class ThriftConnection } } if ( !isAuthenticated ) { - String toEncrypt = client.startServerAuthentication( "uni-freiburg.de" ); - // System.out.println( 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 ) ); + log.info( "ThriftConnection: Client not yet Authenticated. Trying..." ); + String toEncrypt; + try { + toEncrypt = client.startServerAuthentication( "uni-freiburg.de" ); + // System.out.println( 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 ) ); + } catch ( ServerAuthenticationException e ) { + log.error( "ThriftConnection: Server Authetication was not sucessful." ); + e.printStackTrace(); + } catch ( TException e ) { + log.error( "ThriftConnection: Server Authetication was not sucessful." ); + e.printStackTrace(); + } + log.info( "is Authenticated." ); + } return theClient; } @@ -131,6 +143,7 @@ public class ThriftConnection TProtocol protocol = new TBinaryProtocol( transport ); newClient = new ImageServer.Client( protocol ); } catch ( TException x ) { + log.error( "ThriftConnection coudn't create new client." ); x.printStackTrace(); return null; } -- cgit v1.2.3-55-g7522