summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/openslx/imagemaster/server/ApiServer.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/openslx/imagemaster/server/ApiServer.java')
-rw-r--r--src/main/java/org/openslx/imagemaster/server/ApiServer.java29
1 files changed, 14 insertions, 15 deletions
diff --git a/src/main/java/org/openslx/imagemaster/server/ApiServer.java b/src/main/java/org/openslx/imagemaster/server/ApiServer.java
index 6c5413f..aaad0db 100644
--- a/src/main/java/org/openslx/imagemaster/server/ApiServer.java
+++ b/src/main/java/org/openslx/imagemaster/server/ApiServer.java
@@ -3,7 +3,6 @@ package org.openslx.imagemaster.server;
import java.nio.ByteBuffer;
import java.util.List;
-import org.apache.thrift.TException;
import org.openslx.imagemaster.db.DbImage;
import org.openslx.imagemaster.db.DbSatellite;
import org.openslx.imagemaster.serverconnection.ImageProcessor;
@@ -25,8 +24,6 @@ import org.openslx.imagemaster.thrift.iface.ImageDataError;
import org.openslx.imagemaster.thrift.iface.ImageDataException;
import org.openslx.imagemaster.thrift.iface.InvalidTokenException;
import org.openslx.imagemaster.thrift.iface.OrganizationData;
-import org.openslx.imagemaster.thrift.iface.ServerAuthenticationError;
-import org.openslx.imagemaster.thrift.iface.ServerAuthenticationException;
import org.openslx.imagemaster.thrift.iface.ServerSessionData;
import org.openslx.imagemaster.thrift.iface.SessionData;
import org.openslx.imagemaster.thrift.iface.UploadData;
@@ -121,16 +118,16 @@ public class ApiServer
* @throws ServerAuthenticationException when organization is invalid/unknown
*/
public static ByteBuffer startServerAuthentication( String organizationId )
- throws ServerAuthenticationException
+ throws AuthenticationException
{
if ( organizationId == null || organizationId.isEmpty() )
- throw new ServerAuthenticationException( ServerAuthenticationError.INVALID_ORGANIZATION, "Empty organization" );
+ throw new AuthenticationException( AuthenticationError.INVALID_ORGANIZATION, "Empty organization" );
DbSatellite satellite = DbSatellite.fromOrganizationId( organizationId );
if ( satellite == null )
- throw new ServerAuthenticationException( ServerAuthenticationError.INVALID_ORGANIZATION, "Unknown organization: '" + organizationId + "'" );
+ throw new AuthenticationException( AuthenticationError.INVALID_ORGANIZATION, "Unknown organization: '" + organizationId + "'" );
if ( satellite.getPubkey() == null )
- throw new ServerAuthenticationException( ServerAuthenticationError.INVALID_KEY, "There is no public key known for your organization." );
+ throw new AuthenticationException( AuthenticationError.INVALID_KEY, "There is no public key known for your organization." );
return ServerAuthenticator.startServerAuthentication( organizationId );
}
@@ -141,20 +138,18 @@ public class ApiServer
* @param challengeResponse the encrypted string
* @return session data iff the authentication was successful
* @throws AuthenticationException
- * @throws TException
*/
public static ServerSessionData serverAuthenticate( String organizationId,
- ByteBuffer challengeResponse ) throws ServerAuthenticationException,
- TException
+ ByteBuffer challengeResponse ) throws AuthenticationException
{
if ( organizationId == null || challengeResponse == null ) {
- throw new ServerAuthenticationException( ServerAuthenticationError.INVALID_ORGANIZATION, "Empty organization or challengeResponse" );
+ throw new AuthenticationException( AuthenticationError.INVALID_ORGANIZATION, "Empty organization or challengeResponse" );
}
DbSatellite satellite = DbSatellite.fromOrganizationId( organizationId );
if ( satellite == null )
- throw new ServerAuthenticationException( ServerAuthenticationError.INVALID_ORGANIZATION, "Unknown organization" );
+ throw new AuthenticationException( AuthenticationError.INVALID_ORGANIZATION, "Unknown organization" );
if ( satellite.getPubkey() == null )
- throw new ServerAuthenticationException( ServerAuthenticationError.INVALID_KEY, "There is no public key known for your organization." );
+ throw new AuthenticationException( AuthenticationError.INVALID_KEY, "There is no public key known for your organization." );
final ServerUser serverUser = ServerAuthenticator.serverAuthenticate( satellite, challengeResponse );
@@ -181,7 +176,11 @@ public class ApiServer
public static List<OrganizationData> getOrganizations()
{
- // TODO Auto-generated method stub
- return null;
+ return DbSatellite.asOrganizationDataList();
+ }
+
+ public static List<ImageData> getPublicImages( String sessionId, int page )
+ {
+ return DbImage.asImageDataList( page * 100, ( page + 1 ) * 100 );
}
}