summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBjörn Hagemeister2014-10-07 14:52:34 +0200
committerBjörn Hagemeister2014-10-07 14:52:34 +0200
commit60145bf12aabd64902c11eccfcc4062c1a3047e8 (patch)
treea20ecf5793396501ca4f156bf4c84e9d60443c2a /src
parentAdapt to login@uni format for user-ids, Put asym keys in extra class (diff)
downloadsatellite-daemon-60145bf12aabd64902c11eccfcc4062c1a3047e8.tar.gz
satellite-daemon-60145bf12aabd64902c11eccfcc4062c1a3047e8.tar.xz
satellite-daemon-60145bf12aabd64902c11eccfcc4062c1a3047e8.zip
Added createTime and changeTime to DbImage.
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/openslx/satellitedaemon/db/DbImage.java10
-rw-r--r--src/main/java/org/openslx/satellitedaemon/filetransfer/FileUploadWorker.java14
-rw-r--r--src/main/java/org/openslx/satellitedaemon/util/EncryptWithServerIdPublicKey.java81
3 files changed, 10 insertions, 95 deletions
diff --git a/src/main/java/org/openslx/satellitedaemon/db/DbImage.java b/src/main/java/org/openslx/satellitedaemon/db/DbImage.java
index 7079380..c99ca40 100644
--- a/src/main/java/org/openslx/satellitedaemon/db/DbImage.java
+++ b/src/main/java/org/openslx/satellitedaemon/db/DbImage.java
@@ -15,13 +15,15 @@ public class DbImage
public final String path;
public final String creator;
public final long fileSize;
+ public final long changeTime;
+ public final long createTime;
public enum Status
{
only_local, to_be_published, being_published, successfully_published, to_be_decentralized, being_decentralized, successfully_decentralized
}
- public DbImage(String guid, String name, Integer rid, String path, String creator, Long fileSize)
+ public DbImage(String guid, String name, Integer rid, String path, String creator, Long fileSize, Long createTime, Long changeTime)
{
if ( rid == null )
rid = -1;
@@ -33,6 +35,8 @@ public class DbImage
this.path = path;
this.creator = creator;
this.fileSize = fileSize;
+ this.createTime = createTime;
+ this.changeTime = changeTime;
}
/**
@@ -45,7 +49,7 @@ public class DbImage
public static List<DbImage> getAllMarkedForUpload()
{
return MySQL.findAll( DbImage.class, "SELECT image.GUID_imageID, image.image_name, image.imageVersion, image.image_path," +
- " user.loginName, '@', institution.name) AS userID, image.image_filesize" +
+ " user.loginName AS userID, image.image_filesize, image.rec_create_time, image.rec_change_time" +
" FROM m_VLData_imageInfo image" +
" INNER JOIN m_user user ON (image.image_owner = user.userID)" +
" INNER JOIN m_institution institution ON (institution.institutionID = user.institution)" +
@@ -63,7 +67,7 @@ public class DbImage
public static List<DbImage> getAllMarkedForDownload()
{
return MySQL.findAll( DbImage.class, "SELECT image.GUID_imageID, image.image_name, image.imageVersion, image.image_path," +
- " Concat(user.loginName, '@', institution.name) AS userID, image.image_filesize" +
+ " user.loginName AS userID, image.image_filesize, image.rec_create_time, image.rec_change_time" +
" FROM m_VLData_imageInfo image" +
" INNER JOIN m_user user ON (image.image_owner = user.userID)" +
" INNER JOIN m_institution institution ON (institution.institutionID = user.institution)" +
diff --git a/src/main/java/org/openslx/satellitedaemon/filetransfer/FileUploadWorker.java b/src/main/java/org/openslx/satellitedaemon/filetransfer/FileUploadWorker.java
index b7b87cb..8ace390 100644
--- a/src/main/java/org/openslx/satellitedaemon/filetransfer/FileUploadWorker.java
+++ b/src/main/java/org/openslx/satellitedaemon/filetransfer/FileUploadWorker.java
@@ -27,18 +27,10 @@ public class FileUploadWorker implements Runnable
// Upload one Image after the other.
for ( DbImage image : imageList ) {
- // TODO: still some fields for ImageData, which i can't fill with info from DbImage.
- // ImageData imDat = new ImageData(image.guid, image.rid,
- // image.name, System.currentTimeMillis(),
- // System.currentTimeMillis(), image.creator, "anyThing", // TODO: fields in databases need to fit somehow...
- // true, false, "best", "theVeryBest", image.fileSize);
-
- // Only for testing because a random UUID is used. Later the method above should be used.
ImageData imDat = new ImageData(
- UUID.randomUUID().toString(), image.rid,
- image.name, ( System.currentTimeMillis() / 1000 ),
- ( System.currentTimeMillis() / 1000 ), image.creator, "anyThing",
- true, false, "best", image.fileSize );
+ image.guid, image.rid,
+ image.name, image.createTime, image.changeTime, image.creator,
+ "anyThing", true, false, "best", image.fileSize );
String path = Globals.getImageFolder() + "/" + image.path;
diff --git a/src/main/java/org/openslx/satellitedaemon/util/EncryptWithServerIdPublicKey.java b/src/main/java/org/openslx/satellitedaemon/util/EncryptWithServerIdPublicKey.java
deleted file mode 100644
index 2e4c925..0000000
--- a/src/main/java/org/openslx/satellitedaemon/util/EncryptWithServerIdPublicKey.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package org.openslx.satellitedaemon.util;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.security.InvalidKeyException;
-import java.security.Key;
-import java.security.KeyPair;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.PrivateKey;
-import java.security.PublicKey;
-import java.security.Signature;
-import java.security.SignatureException;
-import java.security.UnrecoverableKeyException;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateException;
-
-import org.apache.log4j.Logger;
-
-// TODO: More general naming; this isn't really limited to serverids...
-// Might also be worth moving this encrypt/decrypt stuff from satserver and masterserver to the
-// shared project (one class doing both)
-
-public class EncryptWithServerIdPublicKey
-{
-
- private static Logger log = Logger.getLogger( EncryptWithServerIdPublicKey.class );
-
- KeyPair pair;
-
- public EncryptWithServerIdPublicKey( String alias, String password, String file )
- {
- try {
- KeyStore keystore = KeyStore.getInstance( "JKS" );
- keystore.load( new FileInputStream( new File( file ) ),
- password.toCharArray() );
- Certificate cert = null;
-
- Key key = keystore.getKey( alias, password.toCharArray() );
-
- if ( key instanceof PrivateKey ) {
- cert = keystore.getCertificate( alias );
- PublicKey publicKey = cert.getPublicKey();
- pair = new KeyPair( publicKey, (PrivateKey)key );
- }
- } catch ( KeyStoreException e ) {
- log.error( "KeystoreException.", e );
- } catch ( FileNotFoundException e ) {
- log.error( "File " + file + " not found.", e );
- } catch ( UnrecoverableKeyException e ) {
- log.error( "UnrecoverableKeyException", e );
- } catch ( CertificateException e ) {
- log.error( "CertificateException", e );
- } catch ( NoSuchAlgorithmException e ) {
- log.error( "NoSuchAlgorithmException", e );
- } catch ( IOException e ) {
- log.error( "IOException", e );
- }
- }
-
- public byte[] encryptString( String message )
- {
- Signature signature = null;
- try {
- signature = Signature.getInstance( "SHA256WITHRSA" );
- signature.initSign( pair.getPrivate() );
- signature.update( message.getBytes() );
- return signature.sign();
- } catch ( NoSuchAlgorithmException e ) {
- log.error( "NoSuchAlgorithmException", e );
- } catch ( InvalidKeyException e ) {
- log.error( "InvalidKeyException", e );
- } catch ( SignatureException e ) {
- log.error( "SignatureException", e );
- }
- return null;
- }
-}