summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Petretti2014-05-26 16:23:18 +0200
committerMichael Petretti2014-05-26 16:23:18 +0200
commitf6e13dd8004d9dbe857ffd22c242dd95523229ce (patch)
tree804be42aaf2d23556536b4a960aa2748bf00699c
parentAdded a Globals.java class for properties handling. (diff)
downloadsatellite-daemon-f6e13dd8004d9dbe857ffd22c242dd95523229ce.tar.gz
satellite-daemon-f6e13dd8004d9dbe857ffd22c242dd95523229ce.tar.xz
satellite-daemon-f6e13dd8004d9dbe857ffd22c242dd95523229ce.zip
Fixed most ToDo's.
-rw-r--r--src/main/java/org/openslx/satellitedaemon/ftp/FtpUploadWorker.java9
-rw-r--r--src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java18
2 files changed, 17 insertions, 10 deletions
diff --git a/src/main/java/org/openslx/satellitedaemon/ftp/FtpUploadWorker.java b/src/main/java/org/openslx/satellitedaemon/ftp/FtpUploadWorker.java
index 69c73a9..91d4e9c 100644
--- a/src/main/java/org/openslx/satellitedaemon/ftp/FtpUploadWorker.java
+++ b/src/main/java/org/openslx/satellitedaemon/ftp/FtpUploadWorker.java
@@ -17,6 +17,7 @@ import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
import org.apache.commons.net.ftp.FTPSClient;
+import org.apache.log4j.Logger;
import org.openslx.imagemaster.thrift.iface.FtpCredentials;
import org.openslx.imagemaster.thrift.iface.ImageData;
import org.openslx.satellitedaemon.Globals;
@@ -26,8 +27,7 @@ import org.openslx.satellitedaemon.db.DbImage;
public class FtpUploadWorker implements Runnable
{
- static String nilsIp = "132.230.4.23";
- static int ftpPort = 2221;
+ private static Logger log = Logger.getLogger( FtpUploadWorker.class );
@Override
public void run()
@@ -44,9 +44,12 @@ public class FtpUploadWorker implements Runnable
true, false, "best", "theVeryBest", 1024 );
FtpCredentials ftpc = ThriftConnection.getFtpCredentials( imDat );
- // TODO: Handle ftpc == null
+ if (ftpc == null) {
+ log.error( "The FtpCredentials are null" );
+ }
try {
+ // ToDo: Add everything with the keyStores to config/global.properties
TrustManagerFactory trustManagerFactory = TrustManagerFactory
.getInstance( KeyManagerFactory.getDefaultAlgorithm() );
KeyStore keystore = KeyStore.getInstance( "JKS" );
diff --git a/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java b/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java
index ed19a1a..e9ab3af 100644
--- a/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java
+++ b/src/main/java/org/openslx/satellitedaemon/ftp/ThriftConnection.java
@@ -10,6 +10,7 @@ import java.security.SignatureException;
import java.security.UnrecoverableKeyException;
import java.security.cert.CertificateException;
+import org.apache.log4j.Logger;
import org.apache.thrift.TException;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
@@ -20,8 +21,10 @@ import org.openslx.imagemaster.thrift.iface.ImageData;
import org.openslx.imagemaster.thrift.iface.ImageServer;
import org.openslx.imagemaster.thrift.iface.ServerAuthenticationException;
import org.openslx.imagemaster.thrift.iface.ServerSessionData;
+import org.openslx.satellitedaemon.Globals;
+import org.openslx.satellitedaemon.Globals.PropInt;
+import org.openslx.satellitedaemon.Globals.PropString;
import org.openslx.satellitedaemon.util.EncryptWithServerIdPublicKey;
-import org.openslx.satellitedaemon.util.Util;
/**
* Handles the authentication with the Satellite Server and sends the FtpCredentials, which
@@ -31,9 +34,7 @@ public class ThriftConnection
{
private static ImageServer.Client client = null;
private static ServerSessionData sSD = null;
- // TODO: All of the Strings and int's should not fall from sky. (Globals config)
- static String nilsIp = "132.230.4.23";
- static int thriftPort = 9090;
+ private static Logger log = Logger.getLogger( ThriftConnection.class );
/**
* The method calls getConnection() to check if the connection is ok,
@@ -45,7 +46,10 @@ public class ThriftConnection
{
try {
client = getConnection();
- Util.notNullFatal( client, "Client is null. Maybe a Network error." ); // TODO: Don't call fatal, it would exit the program, just log a message and return null
+ if ( client == null ) {
+ log.info( "Client was null!" );
+ return null;
+ }
return client.submitImage( sSD.sessionId, imDat );
} catch ( TException e ) {
@@ -121,8 +125,8 @@ public class ThriftConnection
{
ImageServer.Client newClient = null;
try {
- TTransport transport;
- transport = new TSocket( nilsIp, thriftPort ); // Nils IP
+ TTransport transport; // Is it really always the same IP:Port as from FTPServer?
+ transport = new TSocket( Globals.getPropertyString( PropString.FTPSERVERIP ), Globals.getPropertyInt( PropInt.FTPPORT ) );
transport.open();
TProtocol protocol = new TBinaryProtocol( transport );
newClient = new ImageServer.Client( protocol );