summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Petretti2014-05-08 15:54:24 +0200
committerMichael Petretti2014-05-08 15:54:24 +0200
commit617aeaa7e3c5560fe56a5eb2f45fd95151e41c5a (patch)
tree8165142b59c5388ed67e998fc5d6a0a6be3cce08
parentEven prettier. (diff)
downloadsatellite-daemon-617aeaa7e3c5560fe56a5eb2f45fd95151e41c5a.tar.gz
satellite-daemon-617aeaa7e3c5560fe56a5eb2f45fd95151e41c5a.tar.xz
satellite-daemon-617aeaa7e3c5560fe56a5eb2f45fd95151e41c5a.zip
some ToDos for me
-rw-r--r--src/main/java/org/openslx/satellitedaemon/App.java5
-rw-r--r--src/main/java/org/openslx/satellitedaemon/ftp/GetFtpCredentials.java36
2 files changed, 25 insertions, 16 deletions
diff --git a/src/main/java/org/openslx/satellitedaemon/App.java b/src/main/java/org/openslx/satellitedaemon/App.java
index 6c88ece..26aa899 100644
--- a/src/main/java/org/openslx/satellitedaemon/App.java
+++ b/src/main/java/org/openslx/satellitedaemon/App.java
@@ -7,6 +7,7 @@ import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import org.openslx.imagemaster.thrift.iface.FtpCredentials;
+import org.openslx.imagemaster.thrift.iface.ServerAuthenticationException;
import org.openslx.satellitedaemon.ftp.FtpImageUploader;
import org.openslx.satellitedaemon.ftp.GetFtpCredentials;
@@ -16,12 +17,12 @@ import org.openslx.satellitedaemon.ftp.GetFtpCredentials;
*/
public class App
{
- public static void main( String[] args ) throws NoSuchAlgorithmException, KeyStoreException, CertificateException, FileNotFoundException, IOException
+ public static void main( String[] args ) throws NoSuchAlgorithmException, KeyStoreException, CertificateException, FileNotFoundException, IOException, ServerAuthenticationException
{
// TODO: A Thread that starts the call for new credentials and the upload
// whenever a new image was sceduled in the db.
- FtpCredentials ftpc = GetFtpCredentials.now();
+ FtpCredentials ftpc = GetFtpCredentials.getFtpCredentials();
FtpImageUploader ftpIU = new FtpImageUploader( ftpc );
ftpIU.connectTest();
diff --git a/src/main/java/org/openslx/satellitedaemon/ftp/GetFtpCredentials.java b/src/main/java/org/openslx/satellitedaemon/ftp/GetFtpCredentials.java
index fff2f7f..2fdeb66 100644
--- a/src/main/java/org/openslx/satellitedaemon/ftp/GetFtpCredentials.java
+++ b/src/main/java/org/openslx/satellitedaemon/ftp/GetFtpCredentials.java
@@ -1,3 +1,7 @@
+// TODO: rename crative
+// some kind of check if Socket connection is still running when get FtpCredentials is called, otherwise open new
+// how: Sketch: make a getClient method. empty the static. getFtpCredentials calls getClient, which checks if every thing is ok, if not make it if not possible blame network
+
package org.openslx.satellitedaemon.ftp;
import java.io.FileNotFoundException;
@@ -19,19 +23,20 @@ import org.apache.thrift.transport.TTransport;
import org.openslx.imagemaster.thrift.iface.FtpCredentials;
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.util.EncryptWithServerIdPublicKey;
public class GetFtpCredentials
{
- private static FtpCredentials ftpc = null;
+ private static ImageServer.Client client = null;
// TODO: All of the Strings and int's should not fall from sky.
static String nilsIp = "132.230.4.23";
static int thriftPort = 9090;
/**
- * Handles the authentication with the Satellite Server and sends the FtpCredentials, which
- * are necessary for the upload of the image.
+ * Handles the authentication with the Satellite Server and sends the FtpCredentials, which
+ * are necessary for the upload of the image.
*/
static {
try {
@@ -40,7 +45,15 @@ public class GetFtpCredentials
transport.open();
TProtocol protocol = new TBinaryProtocol( transport );
- ImageServer.Client client = new ImageServer.Client( protocol );
+ client = new ImageServer.Client( protocol );
+ } catch ( TException x ) {
+ x.printStackTrace();
+ }
+ }
+
+ public static FtpCredentials getFtpCredentials() throws ServerAuthenticationException
+ {
+ try {
String toEncrypt = client.startServerAuthentication( "uni-freiburg.de" );
// System.out.println( toEncrypt );
EncryptWithServerIdPublicKey rse = new EncryptWithServerIdPublicKey( "serverid", "password",
@@ -54,11 +67,7 @@ public class GetFtpCredentials
"TestImage", System.currentTimeMillis(), System.currentTimeMillis(), "me", "anyThing",
true, false, "theBest", "theVeryBest", 1024 );
- ftpc = client.submitImage( sSD.sessionId, imDat );
-
- transport.close();
- } catch ( TException x ) {
- x.printStackTrace();
+ return client.submitImage( sSD.sessionId, imDat );
} catch ( InvalidKeyException e ) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -83,11 +92,10 @@ public class GetFtpCredentials
} catch ( IOException e ) {
// TODO Auto-generated catch block
e.printStackTrace();
+ } catch ( TException e ) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
}
- }
-
- public static FtpCredentials now()
- {
- return ftpc;
+ return null;
}
}