bwLehrpool Masterserver
Manages authentication and sharing of virtual machines between participating institutions
MasterServerHandler.java
Go to the documentation of this file.
1 package org.openslx.imagemaster.thrift.server;
2 
3 import java.io.File;
4 import java.nio.ByteBuffer;
5 import java.security.Key;
6 import java.security.NoSuchAlgorithmException;
7 import java.security.spec.InvalidKeySpecException;
8 import java.sql.SQLException;
9 import java.util.ArrayList;
10 import java.util.List;
11 
12 import org.apache.logging.log4j.LogManager;
13 import org.apache.logging.log4j.Logger;
14 import org.apache.thrift.TException;
15 import org.openslx.bwlp.thrift.iface.AuthorizationError;
16 import org.openslx.bwlp.thrift.iface.ClientSessionData;
17 import org.openslx.bwlp.thrift.iface.ImageDetailsRead;
18 import org.openslx.bwlp.thrift.iface.ImagePublishData;
19 import org.openslx.bwlp.thrift.iface.ImageSummaryRead;
20 import org.openslx.bwlp.thrift.iface.InvocationError;
21 import org.openslx.bwlp.thrift.iface.MasterServer;
22 import org.openslx.bwlp.thrift.iface.MasterSoftware;
23 import org.openslx.bwlp.thrift.iface.MasterTag;
24 import org.openslx.bwlp.thrift.iface.OperatingSystem;
25 import org.openslx.bwlp.thrift.iface.Organization;
26 import org.openslx.bwlp.thrift.iface.Satellite;
27 import org.openslx.bwlp.thrift.iface.ServerSessionData;
28 import org.openslx.bwlp.thrift.iface.SessionData;
29 import org.openslx.bwlp.thrift.iface.TAuthorizationException;
30 import org.openslx.bwlp.thrift.iface.TInvalidTokenException;
31 import org.openslx.bwlp.thrift.iface.TInvocationException;
32 import org.openslx.bwlp.thrift.iface.TNotFoundException;
33 import org.openslx.bwlp.thrift.iface.TTransferRejectedException;
34 import org.openslx.bwlp.thrift.iface.TransferInformation;
35 import org.openslx.bwlp.thrift.iface.TransferStatus;
36 import org.openslx.bwlp.thrift.iface.UserInfo;
37 import org.openslx.bwlp.thrift.iface.Virtualizer;
38 import org.openslx.encryption.AsymKeyHolder;
39 import org.openslx.filetransfer.util.ChunkList;
40 import org.openslx.filetransfer.util.FileChunk;
61 import org.openslx.thrifthelper.ImagePublishDataEx;
62 
63 public class MasterServerHandler implements MasterServer.Iface
64 {
65 
66  private static final Logger LOGGER = LogManager.getLogger( MasterServerHandler.class );
67 
68  @Override
69  public boolean ping()
70  {
71  return true;
72  }
73 
74  @Override
75  public SessionData authenticate( String login, String password ) throws TAuthorizationException, TInvocationException
76  {
77  ClientSessionData csd = localAccountLogin( login, password );
78  String serverAddress = null;
79  if ( csd.satellites != null && !csd.satellites.isEmpty() ) {
80  for ( Satellite sat : csd.satellites ) {
81  if ( sat.addressList == null || sat.addressList.isEmpty() )
82  continue;
83  if ( serverAddress == null || ( sat.displayName != null && sat.displayName.equals( "default" ) ) ) {
84  serverAddress = sat.addressList.get( 0 );
85  }
86  }
87  }
88  return new SessionData( csd.sessionId, csd.authToken, serverAddress );
89  }
90 
99  @Override
100  public ClientSessionData localAccountLogin( String login, String password )
101  throws TAuthorizationException, TInvocationException
102  {
103  if ( login == null || password == null ) {
104  throw new TAuthorizationException(
105  AuthorizationError.INVALID_CREDENTIALS,
106  "Empty username or password!" );
107  }
108  final UserInfo user = Authenticator.authenticate( login, password );
109 
110  final Session session = new Session( user );
111  return SessionManager.addSession( session );
112  }
113 
117  @Override
118  public void setUsedSatellite( String sessionId, String satelliteName )
119  {
120  Session session = SessionManager.getSessionFromSessionId( sessionId );
121  if ( session == null )
122  return;
123  //session.setUsedSatellite( satelliteName );
124  }
125 
126  @Override
127  public List<UserInfo> findUser( String sessionId, String organizationId, String searchTerm )
128  throws TAuthorizationException, TInvocationException
129  {
130  // Needs to be a logged in user
131  if ( SessionManager.getSessionFromSessionId( sessionId ) == null )
132  throw new TAuthorizationException( AuthorizationError.NOT_AUTHENTICATED, "Session ID not valid" );
133  // Search string needs to be at least 2 characters (FIXME: quick and dirty ignoring LIKE chars)
134  if ( searchTerm == null || searchTerm.length() < 2 || searchTerm.replaceAll( "[%_]", "" ).length() < 2 )
135  return new ArrayList<>( 0 );
136  return DbUser.findUser( organizationId, searchTerm );
137  }
138 
139  @Override
140  public List<ImageSummaryRead> getPublicImages( String sessionId, int page )
141  throws TAuthorizationException, TInvocationException
142  {
143  if ( Globals.isReadOnlyMode() ) {
144  throw new TInvocationException( InvocationError.INTERNAL_SERVER_ERROR,
145  "This is a read-only failover master-server. Image up-/downloads are not available." );
146  }
147  Session session = SessionManager.getSessionFromSessionId( sessionId );
148  if ( session == null )
149  throw new TAuthorizationException( AuthorizationError.NOT_AUTHENTICATED, "Session ID not valid" );
150  UserUtil.assertTutor( session.getUserInfo() );
151  try {
152  return DbImage.getPublicList( page );
153  } catch ( SQLException e ) {
154  throw new TInvocationException( InvocationError.INTERNAL_SERVER_ERROR, "Database failure" );
155  }
156  }
157 
158  @Override
159  public ImageDetailsRead getImageDetails( String sessionId, String imageBaseId )
160  throws TAuthorizationException, TNotFoundException, TInvocationException
161  {
162  Session session = SessionManager.getSessionFromSessionId( sessionId );
163  if ( session == null )
164  throw new TAuthorizationException( AuthorizationError.NOT_AUTHENTICATED, "Session ID not valid" );
165  UserUtil.assertTutor( session.getUserInfo() );
166  try {
167  return DbImage.getImageDetails( imageBaseId );
168  } catch ( SQLException e ) {
169  throw new TInvocationException( InvocationError.INTERNAL_SERVER_ERROR, "Database failure" );
170  }
171  }
172 
173  @Override
174  public void invalidateSession( String sessionId ) throws TInvalidTokenException
175  {
176  SessionManager.invalidate( sessionId );
177  }
178 
179  @Override
180  public ClientSessionData getSessionFromAccessCode( String accessCode ) throws TNotFoundException, TException
181  {
182  return SessionManager.getSessionFromAccessCode( accessCode );
183  }
184 
192  @Override
193  public UserInfo getUserFromToken( String token ) throws TInvalidTokenException
194  {
195  final Session session = SessionManager.getSessionFromToken( token );
196  if ( session == null )
197  throw new TInvalidTokenException();
198  return session.getUserInfo();
199  }
200 
201  @Override
202  public boolean isServerAuthenticated( String serverSessionId )
203  {
204  return ( ServerSessionManager.getSession( serverSessionId ) != null );
205  }
206 
215  @Override
216  public ByteBuffer startServerAuthentication( int satelliteId ) throws TAuthorizationException, TInvocationException
217  {
218  LocalSatellite satellite = DbSatellite.get( satelliteId );
219  if ( satellite == null )
220  throw new TAuthorizationException( AuthorizationError.INVALID_ORGANIZATION, "Unknown satellite id: " + satelliteId );
221  if ( satellite.getPubkey() == null )
222  throw new TAuthorizationException( AuthorizationError.INVALID_KEY, "There is no public key known for your satellite." );
223  return ServerAuthenticator.startServerAuthentication( satelliteId );
224  }
225 
233  @Override
234  public ServerSessionData serverAuthenticate( int satelliteId, ByteBuffer challengeResponse )
235  throws TAuthorizationException, TInvocationException
236  {
237  if ( challengeResponse == null )
238  throw new TAuthorizationException( AuthorizationError.INVALID_ORGANIZATION, "Empty organization or challengeResponse" );
239  LocalSatellite satellite = DbSatellite.get( satelliteId );
240  if ( satellite == null )
241  throw new TAuthorizationException( AuthorizationError.INVALID_ORGANIZATION, "Unknown satellite id: " + satelliteId );
242  if ( satellite.getPubkey() == null )
243  throw new TAuthorizationException( AuthorizationError.INVALID_KEY, "There is no public key known for your satellite." );
244 
245  ServerAuthenticator.serverAuthenticate( satellite, challengeResponse );
246 
247  final ServerSession session = new ServerSession( satellite );
248  return ServerSessionManager.addSession( session );
249  }
250 
251  @Override
252  public ImagePublishData getImageData( String serverSessionId, String imageVersionId )
253  throws TAuthorizationException, TInvocationException, TNotFoundException
254  {
255  Session session = SessionManager.getSessionFromSessionIdOrToken( serverSessionId );
256  if ( session == null )
257  throw new TAuthorizationException( AuthorizationError.INVALID_TOKEN, "Unknown session id/token" );
258  UserUtil.assertTutor( session.getUserInfo() );
259  try {
260  return DbImage.getImageVersion( imageVersionId );
261  } catch ( SQLException e ) {
262  throw new TInvocationException( InvocationError.INTERNAL_SERVER_ERROR, "Database error" );
263  }
264  }
265 
266  @Override
267  public TransferInformation submitImage( String userToken, ImagePublishData img, List<ByteBuffer> blockHashes )
268  throws TAuthorizationException, TInvocationException, TTransferRejectedException
269  {
270  // Fallback mode, don't allow up/downloads
271  if( Globals.isReadOnlyMode() ) {
272  throw new TTransferRejectedException( "This is a read-only failover master-server. Image up-/downloads are not available." );
273  }
274  // Valid submit session?
275  Session session = SessionManager.getSessionFromToken( userToken );
276  if ( session == null )
277  throw new TAuthorizationException( AuthorizationError.INVALID_TOKEN, "Given user token not known to the server" );
278  UserUtil.assertTutor( session.getUserInfo() );
279  img.owner = UserUtil.getFirstPublishingUser( img.owner, img.uploader, session.getUserInfo() );
280  img.uploader = UserUtil.getFirstPublishingUserOrDummy( img.uploader, session.getUserInfo() );
281  // check image data
282  if ( Util.isEmpty( img.imageName ) )
283  throw new TInvocationException( InvocationError.INVALID_DATA, "Image name not set" );
284  if ( img.fileSize <= 0 )
285  throw new TInvocationException( InvocationError.INVALID_DATA, "File size is too small" );
286  if ( !Util.isUUID( img.imageBaseId ) )
287  throw new TInvocationException( InvocationError.MISSING_DATA, "ImagePublishData has invalid imageBaseId" );
288  if ( !Util.isUUID( img.imageVersionId ) )
289  throw new TInvocationException( InvocationError.MISSING_DATA, "ImagePublishData has invalid imageVersionId" );
290  if ( img.owner == null || img.owner.userId == null )
291  throw new TInvocationException( InvocationError.MISSING_DATA, "Missing owner or owner is anonymous" );
292  if ( img.uploader == null || img.uploader.userId == null )
293  throw new TInvocationException( InvocationError.MISSING_DATA, "Missing uploader or uploader is anonymous" );
294  // check for complete block hash list
295  boolean listComplete = false;
296  if ( blockHashes != null && blockHashes.size() == FileChunk.fileSizeToChunkCount( img.fileSize ) ) {
297  listComplete = true;
298  for ( ByteBuffer bb : blockHashes ) {
299  if ( bb == null || bb.remaining() != FileChunk.SHA1_LENGTH ) {
300  listComplete = false;
301  break;
302  }
303  }
304  }
305  if ( !listComplete )
306  throw new TInvocationException( InvocationError.INVALID_DATA, "Chunk hash list missing or incomplete" );
307  // Check if an upload is already assigned
308  IncomingTransfer existingUpload = ConnectionHandler.getExistingUpload( img, blockHashes );
309  if ( existingUpload != null ) {
310  LOGGER.info( "Satellite tried to register already existing upload for version " + img.imageVersionId + " - is "
311  + existingUpload.getId() );
312  return existingUpload.getTransferInfo();
313  }
314  // Check if version already exists
315  ImagePublishDataEx existing;
316  try {
317  existing = DbImage.getImageVersion( img.imageVersionId );
318  if ( existing != null ) {
319  if ( existing.fileSize != img.fileSize )
320  throw new TInvocationException( InvocationError.INVALID_DATA, "Image already exists; file size mismatch" );
321  List<ByteBuffer> existingHashes = DbImageBlock.getBlockHashes( img.imageVersionId );
322  if ( !ChunkList.hashListsEqualBbBb( blockHashes, existingHashes ) )
323  throw new TInvocationException( InvocationError.INVALID_DATA, "Image already exists; block hashes mismatch" );
324  }
325  } catch ( SQLException e ) {
326  throw new TInvocationException( InvocationError.INTERNAL_SERVER_ERROR, "Internal database error" );
327  }
328  // No existing upload - create new one
329  // checks that hit the db
330  if ( !DbOsVirt.osExists( img.osId ) )
331  throw new TInvocationException( InvocationError.INVALID_DATA, "Content operating system not set" );
332  if ( !DbOsVirt.virtExists( img.virtId ) )
333  throw new TInvocationException( InvocationError.INVALID_DATA, "Content virtualizer system not set" );
334  // Make sure we have a destination to write to
335  if ( !new File( Globals.getImageDir() ).isDirectory() )
336  throw new TInvocationException( InvocationError.INTERNAL_SERVER_ERROR, "Storage offline" );
337  // Try to register an upload
338  IncomingTransfer transfer = ConnectionHandler.registerUpload( img, blockHashes, existing );
339  try {
340  DbImage.createImageBase( img );
341  } catch ( TException t ) {
342  transfer.cancel();
343  ConnectionHandler.removeUpload( transfer );
344  throw t;
345  }
346  if ( existing == null ) {
347  try {
348  DbImage.createImageVersion( img, transfer.getRelativePath() );
349  } catch ( SQLException e1 ) {
350  transfer.cancel();
351  ConnectionHandler.removeUpload( transfer );
352  if ( Database.isDuplicateKeyException( e1 ) ) {
353  throw new TInvocationException( InvocationError.INVALID_DATA, "The image already exists on the server" );
354  } else {
355  throw new TInvocationException( InvocationError.INTERNAL_SERVER_ERROR, "Database error" );
356  }
357  }
358  }
359  try {
360  DbImageBlock.insertChunkList( img.imageVersionId, transfer.getChunks().getAll(), true );
361  } catch ( SQLException e ) {
362  LOGGER.warn( "Could not insert block hashes of image " + img.imageVersionId + " to db" );
363  }
364  return transfer.getTransferInfo();
365  }
366 
367  @Override
368  public TransferInformation downloadImage( String sessionId, String imageVersionId )
369  throws TAuthorizationException, TInvocationException, TNotFoundException, TTransferRejectedException
370  {
371  // Fallback mode, don't allow up/downloads
372  if( Globals.isReadOnlyMode() ) {
373  throw new TTransferRejectedException( "This is a read-only failover master-server. Image up-/downloads are not available." );
374  }
375  // Valid submit session?
376  Session session = SessionManager.getSessionFromToken( sessionId );
377  if ( session == null )
378  throw new TAuthorizationException( AuthorizationError.INVALID_TOKEN, "Given user token not known to the server" );
379  UserUtil.assertTutor( session.getUserInfo() );
380  ImagePublishDataEx img;
381  List<ByteBuffer> blockHashes;
382  try {
383  img = DbImage.getImageVersion( imageVersionId );
384  if ( img != null ) {
385  blockHashes = DbImageBlock.getBlockHashes( img.imageVersionId );
386  } else {
387  blockHashes = null;
388  }
389  } catch ( SQLException e ) {
390  throw new TInvocationException( InvocationError.INTERNAL_SERVER_ERROR, "Database error" );
391  }
392  if ( img == null || !img.exIsValid )
393  throw new TNotFoundException();
394  TransferInformation ti = ConnectionHandler.registerDownload( img );
395  ti.machineDescription = img.machineDescription;
396  ti.blockHashes = blockHashes;
397  return ti;
398  }
399 
400  @Override
401  public List<Organization> getOrganizations() throws TInvocationException
402  {
403  try {
404  return DbOrganization.getAll();
405  } catch ( SQLException e ) {
406  throw new TInvocationException( InvocationError.INTERNAL_SERVER_ERROR, "Database error" );
407  }
408  }
409 
410  @Override
411  public List<OperatingSystem> getOperatingSystems() throws TInvocationException
412  {
413  try {
414  return DbOsVirt.getOsList();
415  } catch ( SQLException e ) {
416  throw new TInvocationException( InvocationError.INTERNAL_SERVER_ERROR, "Database error" );
417  }
418  }
419 
420  @Override
421  public List<Virtualizer> getVirtualizers() throws TInvocationException
422  {
423  try {
424  return DbOsVirt.getVirtualizerList();
425  } catch ( SQLException e ) {
426  throw new TInvocationException( InvocationError.INTERNAL_SERVER_ERROR, "Database error" );
427  }
428  }
429 
430  @Override
431  public List<MasterTag> getTags( long startDate ) throws TInvocationException
432  {
433  // TODO Auto-generated method stub
434  return null;
435  }
436 
437  @Override
438  public List<MasterSoftware> getSoftware( long startDate ) throws TInvocationException
439  {
440  // TODO Auto-generated method stub
441  return null;
442  }
443 
444  @Override
445  public int registerSatellite( String userToken, String displayName, List<String> addresses, String modulus,
446  String exponent, ByteBuffer certSha256 ) throws TInvocationException
447  {
448  if ( userToken == null || exponent == null || modulus == null )
449  throw new TInvocationException( InvocationError.MISSING_DATA, "A required parameter is null" );
450  final Session session = SessionManager.getSessionFromToken( userToken );
451  if ( session == null || session.getUserInfo() == null )
452  throw new TInvocationException( InvocationError.UNKNOWN_USER, "Not a valid user token" );
453  String organizationId = session.getUserInfo().organizationId;
454  Key newKey;
455  try {
456  newKey = new AsymKeyHolder( null, Util.tryToParseBigInt( exponent ), Util.tryToParseBigInt( modulus ) ).getPublicKey();
457  } catch ( NoSuchAlgorithmException | InvalidKeySpecException e ) {
458  LOGGER.warn( "Invalid public key in registerOrganization for " + organizationId + " (By " + session.getLogin() + ")", e );
459  throw new TInvocationException( InvocationError.INVALID_DATA, "Cannot reconstruct public key" );
460  }
461  LocalSatellite existing = DbSatellite.get( organizationId, displayName );
462  if ( existing != null ) {
463  Key existingKey = existing.getPubkey();
464  if ( existingKey != null && Util.keysEqual( newKey, existingKey ) )
465  return existing.satelliteId;
466  }
467  try {
468  return DbPendingSatellite.add( session.getUserInfo(), displayName, addresses, modulus, exponent );
469  } catch ( SQLException e ) {
470  throw new TInvocationException();
471  }
472  }
473 
474  @Override
475  public boolean updateSatellite( String serverSessionId, String displayName, List<String> addresses )
476  throws TAuthorizationException, TInvocationException
477  {
478  ServerSession session = ServerSessionManager.getSession( serverSessionId );
479  if ( session == null )
480  throw new TAuthorizationException( AuthorizationError.NOT_AUTHENTICATED, "No valid serverSessionId" );
481  // TODO
482  return false;
483  }
484 
485  @Override
486  public TransferStatus queryUploadStatus( String uploadToken ) throws TInvalidTokenException
487  {
488  IncomingTransfer upload = ConnectionHandler.getUploadByToken( uploadToken );
489  if ( upload == null )
490  throw new TInvalidTokenException();
491  return upload.getStatus();
492  }
493 
494  @Override
495  public UserInfo getUser( String userToken, String userId )
496  throws TAuthorizationException, TNotFoundException, TInvocationException
497  {
498  Session session = SessionManager.getSessionFromSessionId( userToken );
499  if ( session == null )
500  throw new TAuthorizationException( AuthorizationError.NOT_AUTHENTICATED, "No valid user token" );
501  UserInfo queryingUser = session.getUserInfo();
502  UserUtil.assertTutor( queryingUser );
503  UserInfo queriedUser = new UserInfo( userId, null, null, null, null );
504  queriedUser = UserUtil.getFirstPublishingUser( queriedUser );
505  if ( queriedUser == null )
506  throw new TNotFoundException( "Unknown userid" );
507  return queriedUser;
508  }
509 
510 }
static boolean isDuplicateKeyException(SQLException e)
Definition: Database.java:181
static ByteBuffer startServerAuthentication(int satelliteId)
Start the server authentification.
static List< ImageSummaryRead > getPublicList(int page)
Definition: DbImage.java:197
static ServerSessionData addSession(ServerSession serverSession)
static ImageDetailsRead getImageDetails(String imageBaseId)
Definition: DbImage.java:257
static Session getSessionFromToken(String token)
Get from userToken, known to satellite servers.
static int add(UserInfo user, String displayName, List< String > address, String modulus, String exponent)
static List< Virtualizer > getVirtualizerList()
Definition: DbOsVirt.java:63
List< UserInfo > findUser(String sessionId, String organizationId, String searchTerm)
Manages all server sessions and kicks timed out sessions.
static List< UserInfo > findUser(String organizationId, String searchTerm)
Definition: DbUser.java:89
Authenticating a server with message signing.
int registerSatellite(String userToken, String displayName, List< String > addresses, String modulus, String exponent, ByteBuffer certSha256)
static List< Organization > getAll()
Return all known satellites/organizations as List of OrganizationData, which can be used directly by ...
static void insertChunkList(String imageVersionId, List< FileChunk > all, boolean missing)
static IncomingTransfer getUploadByToken(String uploadToken)
Representing an image in the database.
Definition: DbImage.java:32
static ClientSessionData getSessionFromAccessCode(String accessCode)
Get the according session data (satToken, masterToken) for given access code, which was supplied by t...
Represents a user that can login against the masterserver.
Definition: DbUser.java:22
Represents an organization in the database.
static ImagePublishDataEx getImageVersion(String imageVersionId)
Definition: DbImage.java:39
static boolean isReadOnlyMode()
Definition: Globals.java:162
static UserInfo authenticate(String username, String password)
Authenticate the user against whatever backend.
ClientSessionData localAccountLogin(String login, String password)
Request for authentication.
Class to handle all incoming and outgoing connections.
static List< OperatingSystem > getOsList()
Definition: DbOsVirt.java:24
static BigInteger tryToParseBigInt(String s)
Tries to parse a bigint.
Definition: Util.java:169
static UserInfo getFirstPublishingUserOrDummy(UserInfo...user)
Given a list of users, return the first one that isn't anonymous, which means they opted in for globa...
Definition: UserUtil.java:43
static ClientSessionData addSession(Session session)
static IncomingTransfer getExistingUpload(ImagePublishData imageData, List< ByteBuffer > crcSums)
static void createImageVersion(ImagePublishData img, String relLocalPath)
Definition: DbImage.java:120
Class to hold global constants and properties from 'config/global.properties'.
Definition: Globals.java:16
static boolean virtExists(String virtId)
Definition: DbOsVirt.java:94
Authenticates a user against a backend (mysql here)
Simple representation of a user session.
Definition: Session.java:11
TransferInformation submitImage(String userToken, ImagePublishData img, List< ByteBuffer > blockHashes)
static boolean isUUID(String id)
Definition: Util.java:238
ImagePublishData getImageData(String serverSessionId, String imageVersionId)
static TransferInformation registerDownload(ImagePublishDataEx img)
static void assertTutor(UserInfo userInfo)
Definition: UserUtil.java:55
static void serverAuthenticate(LocalSatellite satellite, ByteBuffer challengeResponse)
Authenticate with the challengeResponse.
TransferInformation downloadImage(String sessionId, String imageVersionId)
static Session getSessionFromSessionIdOrToken(String sessionId)
ServerSessionData serverAuthenticate(int satelliteId, ByteBuffer challengeResponse)
Authenticate the uni/hs satellite server with the encrypted string.
boolean updateSatellite(String serverSessionId, String displayName, List< String > addresses)
static UserInfo getFirstPublishingUser(UserInfo...user)
Given a list of users, return the first one that isn't anonymous, which means they opted in for globa...
Definition: UserUtil.java:19
SessionData authenticate(String login, String password)
ImageDetailsRead getImageDetails(String sessionId, String imageBaseId)
Class for managing active user sessions.
Some utilities to make our lives easier.
Definition: Util.java:18
static LocalSatellite get(int satelliteId)
static Session getSessionFromSessionId(String sessionId)
Get from sessionId, only known by client/user and us.
static boolean isEmpty(String str)
Definition: Util.java:123
UserInfo getUserFromToken(String token)
Request information about user for given token.
List< ImageSummaryRead > getPublicImages(String sessionId, int page)
static List< ByteBuffer > getBlockHashes(String imageVersionId)
void setUsedSatellite(String sessionId, String satelliteName)
User tells us which satellite they connected to.
Holds the session id of the server and manages the timeout.
static boolean keysEqual(Key k1, Key k2)
Checks whether the two given keys are equal.
Definition: Util.java:202
static IncomingTransfer registerUpload(ImagePublishData img, List< ByteBuffer > blockHashes, ImagePublishDataEx existing)
Register new incoming transfer from a satellite server.
ByteBuffer startServerAuthentication(int satelliteId)
Start the server authentication of a uni/hs satellite server.
static void createImageBase(ImagePublishData img)
Definition: DbImage.java:73