Initial commit

This commit is contained in:
Dave
2014-12-16 01:01:48 +02:00
commit 38c2d0de5d
30 changed files with 1377 additions and 0 deletions

View File

@@ -0,0 +1,82 @@
package nodash.core;
import java.io.File;
import java.security.PublicKey;
import nodash.core.spheres.NoByteSetSphere;
import nodash.core.spheres.NoHashSphere;
import nodash.core.spheres.NoSessionSphere;
import nodash.exceptions.NoDashSessionBadUUID;
import nodash.exceptions.NoSessionAlreadyAwaitingConfirmationException;
import nodash.exceptions.NoSessionConfirmedException;
import nodash.exceptions.NoSessionExpiredException;
import nodash.exceptions.NoSessionNotAwaitingConfirmationException;
import nodash.exceptions.NoSessionNotChangedException;
import nodash.exceptions.NoUserAlreadyOnlineException;
import nodash.exceptions.NoUserNotValidException;
import nodash.models.NoByteSet;
import nodash.models.NoUser;
import nodash.models.NoSession.NoState;
public final class NoCore {
public static NoConfig config;
public static void setup() {
File configFile = new File(NoConfig.CONFIG_FILENAME);
if (configFile.exists()) {
config = NoConfig.getNoConfigFromFile(configFile);
} else {
config = new NoConfig();
config.saveNoConfigToFile(configFile);
}
NoHashSphere.setup();
}
public static byte[] login(byte[] data, char[] password) throws NoUserNotValidException, NoUserAlreadyOnlineException, NoSessionExpiredException {
/* steps 1 through to pre-3 */
return NoSessionSphere.login(data, password);
}
public static NoRegister register(NoUser user, char[] password) {
/* Straight to step 4 */
return NoSessionSphere.registerUser(user, password);
}
public static NoUser getUser(byte[] cookie) throws NoSessionExpiredException, NoSessionConfirmedException, NoDashSessionBadUUID {
/* Facilitates step 3
* allow website-side modifications to the NoUser or NoUser inheritant */
return NoSessionSphere.getUser(cookie);
}
public static NoState getSessionState(byte[] cookie) throws NoSessionExpiredException, NoSessionConfirmedException, NoDashSessionBadUUID {
/* Facilitates step 3
* allow front-side to keep track of session state */
return NoSessionSphere.getState(cookie);
}
public static byte[] requestSave(byte[] cookie, char[] password) throws NoSessionExpiredException, NoSessionConfirmedException, NoSessionNotChangedException, NoSessionAlreadyAwaitingConfirmationException, NoDashSessionBadUUID {
/* Step 4. Provides a user with the new binary file */
return NoSessionSphere.save(cookie, password);
}
public static void confirm(byte[] cookie, char[] password, byte[] data) throws NoSessionExpiredException, NoSessionConfirmedException, NoSessionNotAwaitingConfirmationException, NoUserNotValidException, NoDashSessionBadUUID {
/* Step 5. Assumes the user has re-uploaded the file along with providing the same password.
* Further attempts of getUser or getSessionState will fail with a NoSessionExpiredException*/
NoSessionSphere.confirm(cookie, password, data);
}
public static void addByteSet(NoByteSet byteSet, PublicKey publicKey) {
NoByteSetSphere.add(byteSet, publicKey);
}
public static void shred(byte[] cookie) {
/* 3.2 Hot pull */
NoSessionSphere.shred(cookie);
}
public static void triggerPrune() {
NoSessionSphere.prune();
}
}