Adding isReady()

This commit is contained in:
Dave
2015-01-05 23:10:40 +02:00
parent df651d96c9
commit 54ca67d27a
4 changed files with 18 additions and 0 deletions

View File

@@ -9,6 +9,7 @@ import javax.crypto.SecretKey;
import nodash.exceptions.NoDashFatalException;
public abstract class NoConfigBase implements NoConfigInterface {
protected boolean ready;
protected SecretKey secretKey;
protected boolean saveDatabase;
protected boolean saveByteSets;
@@ -26,6 +27,7 @@ public abstract class NoConfigBase implements NoConfigInterface {
@Override
public void construct() {
this.generateSecretKey();
this.ready = true;
}
@Override

View File

@@ -79,6 +79,12 @@ public final class NoConfigDefault extends NoConfigBase implements Serializable
} catch (ClassNotFoundException e) {
throw new NoDashFatalException("Given bytestream does not compile into a configuration object.", e);
}
this.ready = true;
return noConfig;
}
@Override
public boolean isReady() {
return this.ready;
}
}

View File

@@ -11,4 +11,5 @@ public interface NoConfigInterface {
public boolean saveByteSets();
public void saveNoConfig();
public NoConfigInterface loadNoConfig() throws IOException;
public boolean isReady();
}

View File

@@ -42,18 +42,26 @@ public final class NoCore {
public static NoConfigInterface config;
public static NoHashSphereInterface hashSphere;
public static boolean isReady() {
return (config != null && config.isReady()) &&
(hashSphere != null && hashSphere.isReady());
}
public static void setup(NoConfigInterface config, NoHashSphereInterface hashSphere) {
NoCore.setup(config);
NoCore.setup(hashSphere);
com.sun.org.apache.xml.internal.security.Init.init();
}
public static void setup(NoConfigInterface config) {
NoCore.config = config;
com.sun.org.apache.xml.internal.security.Init.init();
}
public static void setup(NoHashSphereInterface hashSphere) {
NoCore.hashSphere = hashSphere;
hashSphere.setup();
com.sun.org.apache.xml.internal.security.Init.init();
}
public static void setup() {
@@ -65,6 +73,7 @@ public final class NoCore {
}
NoCore.setup(newConfig);
NoCore.setup(new NoHashSphereDefault());
com.sun.org.apache.xml.internal.security.Init.init();
}
public static byte[] login(byte[] data, char[] password) throws NoUserNotValidException, NoUserAlreadyOnlineException, NoSessionExpiredException {