formatting

This commit is contained in:
Dave
2015-06-27 21:50:28 +02:00
parent 7bb6c6fdfa
commit 34b9a748f9
36 changed files with 2381 additions and 2360 deletions

View File

@@ -9,46 +9,46 @@ import javax.crypto.SecretKey;
import nodash.exceptions.NoDashFatalException; import nodash.exceptions.NoDashFatalException;
public abstract class NoConfigBase implements NoConfigInterface { public abstract class NoConfigBase implements NoConfigInterface {
protected boolean ready; protected boolean ready;
protected SecretKey secretKey; protected SecretKey secretKey;
protected boolean saveDatabase; protected boolean saveDatabase;
protected boolean saveByteSets; protected boolean saveByteSets;
protected final void generateSecretKey() { protected final void generateSecretKey() {
try { try {
KeyGenerator keyGenerator = KeyGenerator.getInstance(NoUtil.CIPHER_KEY_SPEC); KeyGenerator keyGenerator = KeyGenerator.getInstance(NoUtil.CIPHER_KEY_SPEC);
keyGenerator.init(NoUtil.AES_STRENGTH); keyGenerator.init(NoUtil.AES_STRENGTH);
this.secretKey = keyGenerator.generateKey(); this.secretKey = keyGenerator.generateKey();
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {
throw new NoDashFatalException("Value for CIPHER_KEY_SPEC not valid.", e); throw new NoDashFatalException("Value for CIPHER_KEY_SPEC not valid.", e);
} }
} }
@Override @Override
public void construct() { public void construct() {
this.generateSecretKey(); this.generateSecretKey();
this.ready = true; this.ready = true;
} }
@Override @Override
public SecretKey getSecretKey() { public SecretKey getSecretKey() {
return this.secretKey; return this.secretKey;
} }
@Override @Override
public boolean saveDatabase() { public boolean saveDatabase() {
return this.saveDatabase; return this.saveDatabase;
} }
@Override @Override
public boolean saveByteSets() { public boolean saveByteSets() {
return this.saveByteSets; return this.saveByteSets;
} }
@Override @Override
public abstract void saveNoConfig(); public abstract void saveNoConfig();
@Override @Override
public abstract NoConfigInterface loadNoConfig() throws IOException; public abstract NoConfigInterface loadNoConfig() throws IOException;
} }

View File

@@ -1,20 +1,17 @@
/* /*
* Copyright 2014 David Horscroft * Copyright 2014 David Horscroft
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* you may not use this file except in compliance with the License. * in compliance with the License. You may obtain a copy of the License at
* You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software distributed under the License
* distributed under the License is distributed on an "AS IS" BASIS, * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * or implied. See the License for the specific language governing permissions and limitations under
* See the License for the specific language governing permissions and * the License.
* limitations under the License.
* *
* The NoConfig is a means to store the server secret key, database address * The NoConfig is a means to store the server secret key, database address and other configs.
* and other configs.
*/ */
package nodash.core; package nodash.core;
@@ -32,59 +29,60 @@ import java.nio.file.StandardOpenOption;
import nodash.exceptions.NoDashFatalException; import nodash.exceptions.NoDashFatalException;
public final class NoConfigDefault extends NoConfigBase implements Serializable { public final class NoConfigDefault extends NoConfigBase implements Serializable {
private static final long serialVersionUID = -8498303909736017075L; private static final long serialVersionUID = -8498303909736017075L;
private static final String CONFIG_FILENAME = "noconfig.cfg"; private static final String CONFIG_FILENAME = "noconfig.cfg";
private String databaseFileName = "nodatabase.hash"; private String databaseFileName = "nodatabase.hash";
@Override @Override
public boolean saveDatabase() { public boolean saveDatabase() {
return saveDatabase; return saveDatabase;
} }
public String getDatabaseName() { public String getDatabaseName() {
return databaseFileName; return databaseFileName;
} }
@Override @Override
public boolean saveByteSets() { public boolean saveByteSets() {
return saveByteSets; return saveByteSets;
} }
@Override @Override
public void saveNoConfig() { public void saveNoConfig() {
try { try {
File file = new File(NoConfigDefault.CONFIG_FILENAME); File file = new File(NoConfigDefault.CONFIG_FILENAME);
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos); ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(this); oos.writeObject(this);
byte[] data = baos.toByteArray(); byte[] data = baos.toByteArray();
Files.write(file.toPath(), data, StandardOpenOption.CREATE_NEW); Files.write(file.toPath(), data, StandardOpenOption.CREATE_NEW);
} catch (IOException e) { } catch (IOException e) {
throw new NoDashFatalException("Unable to save config, including generated secret key.", e); throw new NoDashFatalException("Unable to save config, including generated secret key.", e);
} }
} }
@Override @Override
public NoConfigInterface loadNoConfig() throws IOException { public NoConfigInterface loadNoConfig() throws IOException {
File file = new File(NoConfigDefault.CONFIG_FILENAME); File file = new File(NoConfigDefault.CONFIG_FILENAME);
byte[] data = Files.readAllBytes(file.toPath()); byte[] data = Files.readAllBytes(file.toPath());
ByteArrayInputStream bais = new ByteArrayInputStream(data); ByteArrayInputStream bais = new ByteArrayInputStream(data);
ObjectInputStream ois = new ObjectInputStream(bais); ObjectInputStream ois = new ObjectInputStream(bais);
NoConfigInterface noConfig; NoConfigInterface noConfig;
try { try {
noConfig = (NoConfigDefault) ois.readObject(); noConfig = (NoConfigDefault) ois.readObject();
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
throw new NoDashFatalException("Given bytestream does not compile into a configuration object.", e); throw new NoDashFatalException(
} "Given bytestream does not compile into a configuration object.", e);
this.ready = true; }
return noConfig; this.ready = true;
} return noConfig;
}
@Override @Override
public boolean isReady() { public boolean isReady() {
return this.ready; return this.ready;
} }
} }

View File

@@ -5,11 +5,17 @@ import java.io.IOException;
import javax.crypto.SecretKey; import javax.crypto.SecretKey;
public interface NoConfigInterface { public interface NoConfigInterface {
public void construct(); public void construct();
public SecretKey getSecretKey();
public boolean saveDatabase(); public SecretKey getSecretKey();
public boolean saveByteSets();
public void saveNoConfig(); public boolean saveDatabase();
public NoConfigInterface loadNoConfig() throws IOException;
public boolean isReady(); public boolean saveByteSets();
public void saveNoConfig();
public NoConfigInterface loadNoConfig() throws IOException;
public boolean isReady();
} }

View File

@@ -1,20 +1,18 @@
/* /*
* Copyright 2014 David Horscroft * Copyright 2014 David Horscroft
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* you may not use this file except in compliance with the License. * in compliance with the License. You may obtain a copy of the License at
* You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software distributed under the License
* distributed under the License is distributed on an "AS IS" BASIS, * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * or implied. See the License for the specific language governing permissions and limitations under
* See the License for the specific language governing permissions and * the License.
* limitations under the License.
* *
* The NoCore class is the interface between which the wrapper application * The NoCore class is the interface between which the wrapper application (wrapplication?) accesses
* (wrapplication?) accesses no- functionality. * no- functionality.
*/ */
package nodash.core; package nodash.core;
@@ -39,83 +37,94 @@ import nodash.models.NoUser;
import nodash.models.NoSession.NoState; import nodash.models.NoSession.NoState;
public final class NoCore { public final class NoCore {
public static NoConfigInterface config; public static NoConfigInterface config;
public static NoHashSphereInterface hashSphere; public static NoHashSphereInterface hashSphere;
public static boolean isReady() { public static boolean isReady() {
return (config != null && config.isReady()) && return (config != null && config.isReady()) && (hashSphere != null && hashSphere.isReady());
(hashSphere != null && hashSphere.isReady()); }
}
public static void setup(NoConfigInterface config, NoHashSphereInterface hashSphere) { public static void setup(NoConfigInterface config, NoHashSphereInterface hashSphere) {
NoCore.setup(config); NoCore.setup(config);
NoCore.setup(hashSphere); NoCore.setup(hashSphere);
} }
public static void setup(NoConfigInterface config) { public static void setup(NoConfigInterface config) {
NoCore.config = config; NoCore.config = config;
} }
public static void setup(NoHashSphereInterface hashSphere) { public static void setup(NoHashSphereInterface hashSphere) {
NoCore.hashSphere = hashSphere; NoCore.hashSphere = hashSphere;
hashSphere.setup(); hashSphere.setup();
} }
public static void setup() { public static void setup() {
NoConfigInterface newConfig = new NoConfigDefault(); NoConfigInterface newConfig = new NoConfigDefault();
try { try {
newConfig = newConfig.loadNoConfig(); newConfig = newConfig.loadNoConfig();
} catch (IOException e) { } catch (IOException e) {
newConfig.construct(); newConfig.construct();
} }
NoCore.setup(newConfig); NoCore.setup(newConfig);
NoCore.setup(new NoHashSphereDefault()); NoCore.setup(new NoHashSphereDefault());
} }
public static byte[] login(byte[] data, char[] password) throws NoUserNotValidException, NoUserAlreadyOnlineException, NoSessionExpiredException { public static byte[] login(byte[] data, char[] password) throws NoUserNotValidException,
/* steps 1 through to pre-3 */ NoUserAlreadyOnlineException, NoSessionExpiredException {
return NoSessionSphere.login(data, password); /* steps 1 through to pre-3 */
} return NoSessionSphere.login(data, password);
}
public static NoRegister register(NoUser user, char[] password) { public static NoRegister register(NoUser user, char[] password) {
/* Straight to step 4 */ /* Straight to step 4 */
return NoSessionSphere.registerUser(user, password); return NoSessionSphere.registerUser(user, password);
} }
public static NoUser getUser(byte[] cookie) throws NoSessionExpiredException, NoSessionConfirmedException, NoDashSessionBadUUIDException { public static NoUser getUser(byte[] cookie) throws NoSessionExpiredException,
/* Facilitates step 3 NoSessionConfirmedException, NoDashSessionBadUUIDException {
* allow website-side modifications to the NoUser or NoUser inheritant */ /*
return NoSessionSphere.getUser(cookie); * 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, NoDashSessionBadUUIDException { public static NoState getSessionState(byte[] cookie) throws NoSessionExpiredException,
/* Facilitates step 3 NoSessionConfirmedException, NoDashSessionBadUUIDException {
* allow front-side to keep track of session state */ /*
return NoSessionSphere.getState(cookie); * 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, NoDashSessionBadUUIDException { public static byte[] requestSave(byte[] cookie, char[] password)
/* Step 4. Provides a user with the new binary file */ throws NoSessionExpiredException, NoSessionConfirmedException, NoSessionNotChangedException,
return NoSessionSphere.save(cookie, password); NoSessionAlreadyAwaitingConfirmationException, NoDashSessionBadUUIDException {
} /* 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, NoDashSessionBadUUIDException { public static void confirm(byte[] cookie, char[] password, byte[] data)
/* Step 5. Assumes the user has re-uploaded the file along with providing the same password. throws NoSessionExpiredException, NoSessionConfirmedException,
* Further attempts of getUser or getSessionState will fail with a NoSessionExpiredException*/ NoSessionNotAwaitingConfirmationException, NoUserNotValidException,
NoSessionSphere.confirm(cookie, password, data); NoDashSessionBadUUIDException {
} /*
* 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) { public static void addByteSet(NoByteSet byteSet, PublicKey publicKey) {
NoByteSetSphere.add(byteSet, publicKey); NoByteSetSphere.add(byteSet, publicKey);
} }
public static void shred(byte[] cookie) { public static void shred(byte[] cookie) {
/* 3.2 Hot pull */ /* 3.2 Hot pull */
NoSessionSphere.shred(cookie); NoSessionSphere.shred(cookie);
} }
public static void triggerPrune() { public static void triggerPrune() {
NoSessionSphere.prune(); NoSessionSphere.prune();
} }
} }

View File

@@ -1,25 +1,23 @@
/* /*
* Copyright 2014 David Horscroft * Copyright 2014 David Horscroft
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* you may not use this file except in compliance with the License. * in compliance with the License. You may obtain a copy of the License at
* You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software distributed under the License
* distributed under the License is distributed on an "AS IS" BASIS, * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * or implied. See the License for the specific language governing permissions and limitations under
* See the License for the specific language governing permissions and * the License.
* limitations under the License.
* *
* The NoRegister class is a simple model used to return both cookies and * The NoRegister class is a simple model used to return both cookies and download data upon user
* download data upon user registration. * registration.
*/ */
package nodash.core; package nodash.core;
public final class NoRegister { public final class NoRegister {
public byte[] cookie; public byte[] cookie;
public byte[] data; public byte[] data;
} }

View File

@@ -1,20 +1,18 @@
/* /*
* Copyright 2014 David Horscroft * Copyright 2014 David Horscroft
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* you may not use this file except in compliance with the License. * in compliance with the License. You may obtain a copy of the License at
* You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software distributed under the License
* distributed under the License is distributed on an "AS IS" BASIS, * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * or implied. See the License for the specific language governing permissions and limitations under
* See the License for the specific language governing permissions and * the License.
* limitations under the License.
* *
* The NoUtil class encapsulates no- standard functions such as encryption/decryption * The NoUtil class encapsulates no- standard functions such as encryption/decryption and hashing
* and hashing algorithms. * algorithms.
*/ */
package nodash.core; package nodash.core;
@@ -39,171 +37,176 @@ import javax.crypto.spec.SecretKeySpec;
import nodash.exceptions.NoDashFatalException; import nodash.exceptions.NoDashFatalException;
public final class NoUtil { public final class NoUtil {
public static final String CIPHER_TYPE = "AES/ECB/PKCS5PADDING"; public static final String CIPHER_TYPE = "AES/ECB/PKCS5PADDING";
public static final String CIPHER_KEY_SPEC = "AES"; public static final String CIPHER_KEY_SPEC = "AES";
public static final String DIGEST_TYPE = "SHA-512"; public static final String DIGEST_TYPE = "SHA-512";
public static final String PBE_TYPE = "PBKDF2WithHmacSHA1"; public static final String PBE_TYPE = "PBKDF2WithHmacSHA1";
public static final String CIPHER_RSA_TYPE = "RSA/ECB/PKCS1PADDING"; public static final String CIPHER_RSA_TYPE = "RSA/ECB/PKCS1PADDING";
public static final String KEYPAIR_ALGORITHM = "RSA"; public static final String KEYPAIR_ALGORITHM = "RSA";
public static final String SECURERANDOM_ALGORITHM = "SHA1PRNG"; public static final String SECURERANDOM_ALGORITHM = "SHA1PRNG";
public static final String SECURERANDOM_PROVIDER = "SUN"; public static final String SECURERANDOM_PROVIDER = "SUN";
public static final int RSA_STRENGTH = 4096; public static final int RSA_STRENGTH = 4096;
public static final int AES_STRENGTH = 256; public static final int AES_STRENGTH = 256;
public static final byte BLANK_BYTE = 'A'; public static final byte BLANK_BYTE = 'A';
public static char[] bytesToChars(byte[] array) { public static char[] bytesToChars(byte[] array) {
char[] result = new char[array.length]; char[] result = new char[array.length];
for (int x=0; x<array.length; x++) { for (int x = 0; x < array.length; x++) {
result[x] = (char) array[x]; result[x] = (char) array[x];
} }
return result; return result;
} }
public static byte[] charsToBytes(char[] array) { public static byte[] charsToBytes(char[] array) {
byte[] result = new byte[array.length]; byte[] result = new byte[array.length];
for (int x=0; x<array.length; x++) { for (int x = 0; x < array.length; x++) {
result[x] = (byte) array[x]; result[x] = (byte) array[x];
} }
return result; return result;
} }
public static void wipeBytes(byte[] array) { public static void wipeBytes(byte[] array) {
for (int x=0; x<array.length; x++) { for (int x = 0; x < array.length; x++) {
array[x] = NoUtil.BLANK_BYTE; array[x] = NoUtil.BLANK_BYTE;
} }
} }
public static void wipeChars(char[] array) { public static void wipeChars(char[] array) {
for (int x=0; x<array.length; x++) { for (int x = 0; x < array.length; x++) {
array[x] = NoUtil.BLANK_BYTE; array[x] = NoUtil.BLANK_BYTE;
} }
} }
private static byte[] getPBEKeyFromPassword(char[] password) { private static byte[] getPBEKeyFromPassword(char[] password) {
SecretKeyFactory skf; SecretKeyFactory skf;
try { try {
skf = SecretKeyFactory.getInstance(NoUtil.PBE_TYPE); skf = SecretKeyFactory.getInstance(NoUtil.PBE_TYPE);
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {
throw new NoDashFatalException("Value for PBE_TYPE is not valid.", e); throw new NoDashFatalException("Value for PBE_TYPE is not valid.", e);
} }
KeySpec spec = new PBEKeySpec(password, NoCore.config.getSecretKey().getEncoded(), 65536, 256); KeySpec spec = new PBEKeySpec(password, NoCore.config.getSecretKey().getEncoded(), 65536, 256);
SecretKey key; SecretKey key;
try { try {
key = skf.generateSecret(spec); key = skf.generateSecret(spec);
} catch (InvalidKeySpecException e) { } catch (InvalidKeySpecException e) {
throw new NoDashFatalException("PBE manager unable to derive key from password.", e); throw new NoDashFatalException("PBE manager unable to derive key from password.", e);
} }
NoUtil.wipeChars(password); NoUtil.wipeChars(password);
return key.getEncoded(); return key.getEncoded();
} }
public static byte[] getHashFromByteArray(byte[] bytes) { public static byte[] getHashFromByteArray(byte[] bytes) {
try { try {
MessageDigest messageDigest = MessageDigest.getInstance(NoUtil.DIGEST_TYPE); MessageDigest messageDigest = MessageDigest.getInstance(NoUtil.DIGEST_TYPE);
return messageDigest.digest(bytes); return messageDigest.digest(bytes);
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {
throw new NoDashFatalException("Value for DIGEST_TYPE not valid.", e); throw new NoDashFatalException("Value for DIGEST_TYPE not valid.", e);
} }
} }
public static byte[] decrypt(byte[] data, char[] password) throws IllegalBlockSizeException, BadPaddingException { public static byte[] decrypt(byte[] data, char[] password) throws IllegalBlockSizeException,
byte[] passwordByte = NoUtil.getPBEKeyFromPassword(password); BadPaddingException {
byte[] response = NoUtil.decrypt(NoUtil.decrypt(data), passwordByte); byte[] passwordByte = NoUtil.getPBEKeyFromPassword(password);
NoUtil.wipeBytes(passwordByte); byte[] response = NoUtil.decrypt(NoUtil.decrypt(data), passwordByte);
return response; NoUtil.wipeBytes(passwordByte);
} return response;
}
public static byte[] encrypt(byte[] data, char[] password) { public static byte[] encrypt(byte[] data, char[] password) {
byte[] passwordByte = NoUtil.getPBEKeyFromPassword(password); byte[] passwordByte = NoUtil.getPBEKeyFromPassword(password);
byte[] response = NoUtil.encrypt(NoUtil.encrypt(data, passwordByte)); byte[] response = NoUtil.encrypt(NoUtil.encrypt(data, passwordByte));
NoUtil.wipeBytes(passwordByte); NoUtil.wipeBytes(passwordByte);
return response; return response;
} }
public static byte[] encrypt(byte[] data, byte[] key) { public static byte[] encrypt(byte[] data, byte[] key) {
Cipher cipher; Cipher cipher;
try { try {
cipher = Cipher.getInstance(NoUtil.CIPHER_TYPE); cipher = Cipher.getInstance(NoUtil.CIPHER_TYPE);
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {
throw new NoDashFatalException("Value for CIPHER_TYPE is not valid (no such algorithm).", e); throw new NoDashFatalException("Value for CIPHER_TYPE is not valid (no such algorithm).", e);
} catch (NoSuchPaddingException e) { } catch (NoSuchPaddingException e) {
throw new NoDashFatalException("Value for CIPHER_TYPE is not valid (no such padding).", e); throw new NoDashFatalException("Value for CIPHER_TYPE is not valid (no such padding).", e);
} }
SecretKeySpec secretKey = new SecretKeySpec(key, NoUtil.CIPHER_KEY_SPEC); SecretKeySpec secretKey = new SecretKeySpec(key, NoUtil.CIPHER_KEY_SPEC);
try { try {
cipher.init(Cipher.ENCRYPT_MODE, secretKey); cipher.init(Cipher.ENCRYPT_MODE, secretKey);
} catch (InvalidKeyException e) { } catch (InvalidKeyException e) {
throw new NoDashFatalException("Secret key is invalid.", e); throw new NoDashFatalException("Secret key is invalid.", e);
} }
try { try {
return cipher.doFinal(data); return cipher.doFinal(data);
} catch (IllegalBlockSizeException e) { } catch (IllegalBlockSizeException e) {
throw new NoDashFatalException("Block size exception encountered during encryption.", e); throw new NoDashFatalException("Block size exception encountered during encryption.", e);
} catch (BadPaddingException e) { } catch (BadPaddingException e) {
throw new NoDashFatalException("Bad padding exception encountered during encryption.", e); throw new NoDashFatalException("Bad padding exception encountered during encryption.", e);
} }
} }
public static byte[] encrypt(byte[] data) { public static byte[] encrypt(byte[] data) {
return NoUtil.encrypt(data, NoCore.config.getSecretKey().getEncoded()); return NoUtil.encrypt(data, NoCore.config.getSecretKey().getEncoded());
} }
public static byte[] decrypt(byte[] data, byte[] key) throws IllegalBlockSizeException, BadPaddingException { public static byte[] decrypt(byte[] data, byte[] key) throws IllegalBlockSizeException,
Cipher cipher; BadPaddingException {
try { Cipher cipher;
cipher = Cipher.getInstance(NoUtil.CIPHER_TYPE); try {
} catch (NoSuchAlgorithmException e) { cipher = Cipher.getInstance(NoUtil.CIPHER_TYPE);
throw new NoDashFatalException("Value for CIPHER_TYPE is not valid (no such algorithm).", e); } catch (NoSuchAlgorithmException e) {
} catch (NoSuchPaddingException e) { throw new NoDashFatalException("Value for CIPHER_TYPE is not valid (no such algorithm).", e);
throw new NoDashFatalException("Value for CIPHER_TYPE is not valid (no such padding).", e); } catch (NoSuchPaddingException e) {
} throw new NoDashFatalException("Value for CIPHER_TYPE is not valid (no such padding).", e);
SecretKeySpec secretKey = new SecretKeySpec(key, NoUtil.CIPHER_KEY_SPEC); }
try { SecretKeySpec secretKey = new SecretKeySpec(key, NoUtil.CIPHER_KEY_SPEC);
cipher.init(Cipher.DECRYPT_MODE, secretKey); try {
} catch (InvalidKeyException e) { cipher.init(Cipher.DECRYPT_MODE, secretKey);
throw new NoDashFatalException("Secret key is invalid.", e); } catch (InvalidKeyException e) {
} throw new NoDashFatalException("Secret key is invalid.", e);
}
return cipher.doFinal(data); return cipher.doFinal(data);
} }
public static byte[] decrypt(byte[] data) throws IllegalBlockSizeException, BadPaddingException { public static byte[] decrypt(byte[] data) throws IllegalBlockSizeException, BadPaddingException {
return NoUtil.decrypt(data, NoCore.config.getSecretKey().getEncoded()); return NoUtil.decrypt(data, NoCore.config.getSecretKey().getEncoded());
} }
public static byte[] encryptRSA(byte[] data, PublicKey publicKey) { public static byte[] encryptRSA(byte[] data, PublicKey publicKey) {
Cipher cipher; Cipher cipher;
try { try {
cipher = Cipher.getInstance(NoUtil.CIPHER_RSA_TYPE); cipher = Cipher.getInstance(NoUtil.CIPHER_RSA_TYPE);
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {
throw new NoDashFatalException("Value for CIPHER_RSA_TYPE is not valid (no such algorithm).", e); throw new NoDashFatalException("Value for CIPHER_RSA_TYPE is not valid (no such algorithm).",
} catch (NoSuchPaddingException e) { e);
throw new NoDashFatalException("Value for CIPHER_RSA_TYPE is not valid (no such padding).", e); } catch (NoSuchPaddingException e) {
} throw new NoDashFatalException("Value for CIPHER_RSA_TYPE is not valid (no such padding).", e);
try { }
cipher.init(Cipher.ENCRYPT_MODE, publicKey); try {
return cipher.doFinal(data); cipher.init(Cipher.ENCRYPT_MODE, publicKey);
} catch (InvalidKeyException e){ return cipher.doFinal(data);
throw new NoDashFatalException("Public key invalid.", e); } catch (InvalidKeyException e) {
} catch (IllegalBlockSizeException e) { throw new NoDashFatalException("Public key invalid.", e);
throw new NoDashFatalException("Unable to encrypt data stream with public key.", e); } catch (IllegalBlockSizeException e) {
} catch (BadPaddingException e) { throw new NoDashFatalException("Unable to encrypt data stream with public key.", e);
throw new NoDashFatalException("Unable to encrypt data stream with public key.", e); } catch (BadPaddingException e) {
} throw new NoDashFatalException("Unable to encrypt data stream with public key.", e);
} }
}
public static byte[] decryptRSA(byte[] data, PrivateKey privateKey) throws InvalidKeyException, IllegalBlockSizeException, BadPaddingException { public static byte[] decryptRSA(byte[] data, PrivateKey privateKey) throws InvalidKeyException,
Cipher cipher; IllegalBlockSizeException, BadPaddingException {
try { Cipher cipher;
cipher = Cipher.getInstance(NoUtil.CIPHER_RSA_TYPE); try {
} catch (NoSuchAlgorithmException e) { cipher = Cipher.getInstance(NoUtil.CIPHER_RSA_TYPE);
throw new NoDashFatalException("Value for CIPHER_RSA_TYPE is not valid (no such algorithm).", e); } catch (NoSuchAlgorithmException e) {
} catch (NoSuchPaddingException e) { throw new NoDashFatalException("Value for CIPHER_RSA_TYPE is not valid (no such algorithm).",
throw new NoDashFatalException("Value for CIPHER_RSA_TYPE is not valid (no such padding).", e); e);
} } catch (NoSuchPaddingException e) {
cipher.init(Cipher.DECRYPT_MODE, privateKey); throw new NoDashFatalException("Value for CIPHER_RSA_TYPE is not valid (no such padding).", e);
return cipher.doFinal(data); }
} cipher.init(Cipher.DECRYPT_MODE, privateKey);
return cipher.doFinal(data);
}
} }

View File

@@ -1,20 +1,18 @@
/* /*
* Copyright 2014 David Horscroft * Copyright 2014 David Horscroft
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* you may not use this file except in compliance with the License. * in compliance with the License. You may obtain a copy of the License at
* You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software distributed under the License
* distributed under the License is distributed on an "AS IS" BASIS, * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * or implied. See the License for the specific language governing permissions and limitations under
* See the License for the specific language governing permissions and * the License.
* limitations under the License.
* *
* The NoByteSetSphere stores user-to-user influences and their encryption * The NoByteSetSphere stores user-to-user influences and their encryption keys in an accessible
* keys in an accessible manner. * manner.
*/ */
package nodash.core.spheres; package nodash.core.spheres;
@@ -27,31 +25,32 @@ import nodash.models.NoByteSet;
import nodash.models.NoUser; import nodash.models.NoUser;
public final class NoByteSetSphere { public final class NoByteSetSphere {
private static final ArrayList<NoByteSet> EMPTY_BYTESET_LIST = new ArrayList<NoByteSet>(0); private static final ArrayList<NoByteSet> EMPTY_BYTESET_LIST = new ArrayList<NoByteSet>(0);
private static ConcurrentHashMap<PublicKey, ArrayList<NoByteSet>> byteSets = new ConcurrentHashMap<PublicKey, ArrayList<NoByteSet>>(); private static ConcurrentHashMap<PublicKey, ArrayList<NoByteSet>> byteSets =
new ConcurrentHashMap<PublicKey, ArrayList<NoByteSet>>();
public static void add(NoByteSet byteSet, PublicKey publicKey) { public static void add(NoByteSet byteSet, PublicKey publicKey) {
if (!NoByteSetSphere.byteSets.containsKey(publicKey)) { if (!NoByteSetSphere.byteSets.containsKey(publicKey)) {
NoByteSetSphere.byteSets.put(publicKey, new ArrayList<NoByteSet>()); NoByteSetSphere.byteSets.put(publicKey, new ArrayList<NoByteSet>());
} }
NoByteSetSphere.byteSets.get(publicKey).add(byteSet); NoByteSetSphere.byteSets.get(publicKey).add(byteSet);
} }
public static void addList(ArrayList<NoByteSet> byteSetList, PublicKey publicKey) { public static void addList(ArrayList<NoByteSet> byteSetList, PublicKey publicKey) {
if (!NoByteSetSphere.byteSets.containsKey(publicKey)) { if (!NoByteSetSphere.byteSets.containsKey(publicKey)) {
NoByteSetSphere.byteSets.put(publicKey, new ArrayList<NoByteSet>()); NoByteSetSphere.byteSets.put(publicKey, new ArrayList<NoByteSet>());
} }
NoByteSetSphere.byteSets.get(publicKey).addAll(byteSetList); NoByteSetSphere.byteSets.get(publicKey).addAll(byteSetList);
} }
public static ArrayList<NoByteSet> consume(NoUser user) { public static ArrayList<NoByteSet> consume(NoUser user) {
if (NoByteSetSphere.byteSets.containsKey(user.getRSAPublicKey())) { if (NoByteSetSphere.byteSets.containsKey(user.getRSAPublicKey())) {
ArrayList<NoByteSet> result = NoByteSetSphere.byteSets.get(user.getRSAPublicKey()); ArrayList<NoByteSet> result = NoByteSetSphere.byteSets.get(user.getRSAPublicKey());
NoByteSetSphere.byteSets.remove(user.getRSAPublicKey()); NoByteSetSphere.byteSets.remove(user.getRSAPublicKey());
return result; return result;
} else { } else {
return NoByteSetSphere.EMPTY_BYTESET_LIST; return NoByteSetSphere.EMPTY_BYTESET_LIST;
} }
} }
} }

View File

@@ -1,17 +1,15 @@
/* /*
* Copyright 2014 David Horscroft * Copyright 2014 David Horscroft
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* you may not use this file except in compliance with the License. * in compliance with the License. You may obtain a copy of the License at
* You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software distributed under the License
* distributed under the License is distributed on an "AS IS" BASIS, * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * or implied. See the License for the specific language governing permissions and limitations under
* See the License for the specific language governing permissions and * the License.
* limitations under the License.
* *
* The NoHashSpehre stores database hashes for user verification. * The NoHashSpehre stores database hashes for user verification.
* *
@@ -38,77 +36,78 @@ import nodash.exceptions.NoDashFatalException;
import nodash.models.NoUser; import nodash.models.NoUser;
public final class NoHashSphereDefault implements NoHashSphereInterface { public final class NoHashSphereDefault implements NoHashSphereInterface {
private Set<String> database = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>()); private Set<String> database = Collections
private String fileName; .newSetFromMap(new ConcurrentHashMap<String, Boolean>());
private boolean ready = false; private String fileName;
private boolean ready = false;
public NoHashSphereDefault(String fileName) { public NoHashSphereDefault(String fileName) {
this.fileName = fileName; this.fileName = fileName;
} }
public NoHashSphereDefault() { public NoHashSphereDefault() {
this.fileName = ( (NoConfigDefault) NoCore.config).getDatabaseName(); this.fileName = ((NoConfigDefault) NoCore.config).getDatabaseName();
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void setup() { public void setup() {
if (NoCore.config.saveDatabase()) { if (NoCore.config.saveDatabase()) {
File file = new File(this.fileName); File file = new File(this.fileName);
if (file.exists()) { if (file.exists()) {
try { try {
byte[] data = Files.readAllBytes(file.toPath()); byte[] data = Files.readAllBytes(file.toPath());
ByteArrayInputStream bais = new ByteArrayInputStream(data); ByteArrayInputStream bais = new ByteArrayInputStream(data);
ObjectInputStream ois = new ObjectInputStream(bais); ObjectInputStream ois = new ObjectInputStream(bais);
this.database = (Set<String>) ois.readObject(); this.database = (Set<String>) ois.readObject();
ois.close(); ois.close();
bais.close(); bais.close();
} catch (IOException e){ } catch (IOException e) {
throw new NoDashFatalException("Unable to load up given database file.", e); throw new NoDashFatalException("Unable to load up given database file.", e);
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
throw new NoDashFatalException("Database file not in a verifiable format.", e); throw new NoDashFatalException("Database file not in a verifiable format.", e);
} }
} }
} }
this.ready = true; this.ready = true;
} }
public synchronized void saveToFile() throws IOException { public synchronized void saveToFile() throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos); ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(this.database); oos.writeObject(this.database);
byte[] data = baos.toByteArray(); byte[] data = baos.toByteArray();
oos.close(); oos.close();
baos.close(); baos.close();
File file = new File( ( (NoConfigDefault) NoCore.config).getDatabaseName()); File file = new File(((NoConfigDefault) NoCore.config).getDatabaseName());
Files.write(file.toPath(), data, StandardOpenOption.CREATE); Files.write(file.toPath(), data, StandardOpenOption.CREATE);
} }
public synchronized void addNewNoUser(NoUser user) throws IOException { public synchronized void addNewNoUser(NoUser user) throws IOException {
String hash = user.createHashString(); String hash = user.createHashString();
this.database.add(hash); this.database.add(hash);
this.saveToFile(); this.saveToFile();
} }
public synchronized void insertHash(String hash) throws IOException { public synchronized void insertHash(String hash) throws IOException {
this.database.add(hash); this.database.add(hash);
this.saveToFile(); this.saveToFile();
} }
public synchronized void removeHash(String hash) throws IOException { public synchronized void removeHash(String hash) throws IOException {
this.database.remove(hash); this.database.remove(hash);
this.saveToFile(); this.saveToFile();
} }
public synchronized boolean checkHash(String hash) { public synchronized boolean checkHash(String hash) {
return this.database.contains(hash); return this.database.contains(hash);
} }
public synchronized long size() { public synchronized long size() {
return this.database.size(); return this.database.size();
} }
@Override @Override
public boolean isReady() { public boolean isReady() {
return this.ready; return this.ready;
} }
} }

View File

@@ -5,12 +5,19 @@ import java.io.IOException;
import nodash.models.NoUser; import nodash.models.NoUser;
public interface NoHashSphereInterface { public interface NoHashSphereInterface {
public void setup(); public void setup();
public void saveToFile() throws IOException;
public void addNewNoUser(NoUser user) throws IOException; public void saveToFile() throws IOException;
public void insertHash(String hash) throws IOException;
public void removeHash(String hash) throws IOException; public void addNewNoUser(NoUser user) throws IOException;
public boolean checkHash(String hash);
public long size(); public void insertHash(String hash) throws IOException;
public boolean isReady();
public void removeHash(String hash) throws IOException;
public boolean checkHash(String hash);
public long size();
public boolean isReady();
} }

View File

@@ -1,20 +1,18 @@
/* /*
* Copyright 2014 David Horscroft * Copyright 2014 David Horscroft
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* you may not use this file except in compliance with the License. * in compliance with the License. You may obtain a copy of the License at
* You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software distributed under the License
* distributed under the License is distributed on an "AS IS" BASIS, * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * or implied. See the License for the specific language governing permissions and limitations under
* See the License for the specific language governing permissions and * the License.
* limitations under the License.
* *
* The NoSessionSphere stores user sessions and allows their access and * The NoSessionSphere stores user sessions and allows their access and manipulation with the use of
* manipulation with the use of their UUID. * their UUID.
*/ */
package nodash.core.spheres; package nodash.core.spheres;
@@ -43,148 +41,161 @@ import nodash.models.NoUser;
import nodash.models.NoSession.NoState; import nodash.models.NoSession.NoState;
public final class NoSessionSphere { public final class NoSessionSphere {
private static ConcurrentHashMap<UUID, NoSession> sessions = new ConcurrentHashMap<UUID, NoSession>(); private static ConcurrentHashMap<UUID, NoSession> sessions =
private static Set<String> originalHashesOnline = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>()); new ConcurrentHashMap<UUID, NoSession>();
private static Set<String> originalHashesOnline = Collections
.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
public static synchronized void prune() { public static synchronized void prune() {
for (UUID uuid : NoSessionSphere.sessions.keySet()) { for (UUID uuid : NoSessionSphere.sessions.keySet()) {
pruneSingle(uuid); pruneSingle(uuid);
} }
} }
public static void shred(byte[] encryptedUUID) { public static void shred(byte[] encryptedUUID) {
try { try {
UUID uuid = NoSession.decryptUUID(encryptedUUID); UUID uuid = NoSession.decryptUUID(encryptedUUID);
if (NoSessionSphere.sessions.containsKey(uuid)) { if (NoSessionSphere.sessions.containsKey(uuid)) {
NoSession session = NoSessionSphere.sessions.get(uuid); NoSession session = NoSessionSphere.sessions.get(uuid);
NoByteSetSphere.addList(session.incoming, session.current.getRSAPublicKey()); NoByteSetSphere.addList(session.incoming, session.current.getRSAPublicKey());
NoSessionSphere.originalHashesOnline.remove(Base64.encodeBase64String(session.getOriginalHash())); NoSessionSphere.originalHashesOnline.remove(Base64.encodeBase64String(session
NoSessionSphere.sessions.remove(uuid); .getOriginalHash()));
session = null; NoSessionSphere.sessions.remove(uuid);
} session = null;
} catch (NoDashSessionBadUUIDException e) { }
// Suppress, doesn't matter } catch (NoDashSessionBadUUIDException e) {
} // Suppress, doesn't matter
} }
}
public static synchronized void pruneSingle(UUID uuid) { public static synchronized void pruneSingle(UUID uuid) {
NoSession session = NoSessionSphere.sessions.get(uuid); NoSession session = NoSessionSphere.sessions.get(uuid);
try { try {
session.check(); session.check();
} catch (NoSessionExpiredException e) { } catch (NoSessionExpiredException e) {
/* Resultant from 3.1 and 3.2 */ /* Resultant from 3.1 and 3.2 */
NoByteSetSphere.addList(session.incoming, session.current.getRSAPublicKey()); NoByteSetSphere.addList(session.incoming, session.current.getRSAPublicKey());
NoSessionSphere.originalHashesOnline.remove(session.getOriginalHash()); NoSessionSphere.originalHashesOnline.remove(session.getOriginalHash());
NoSessionSphere.sessions.remove(uuid); NoSessionSphere.sessions.remove(uuid);
session = null; session = null;
} catch (NoSessionConfirmedException e) { } catch (NoSessionConfirmedException e) {
/* Should be cleaned up at 5.2 */ /* Should be cleaned up at 5.2 */
} }
} }
public static synchronized byte[] login(byte[] data, char[] password) throws NoUserNotValidException, NoUserAlreadyOnlineException, NoSessionExpiredException { public static synchronized byte[] login(byte[] data, char[] password)
/* 1. Login with byte[] data and byte[] password */ throws NoUserNotValidException, NoUserAlreadyOnlineException, NoSessionExpiredException {
NoSession session = new NoSession(data, password); /* 1. Login with byte[] data and byte[] password */
/* 1.1. User currently has an online session, must wait for it to expire. */ NoSession session = new NoSession(data, password);
if (originalHashesOnline.contains(Base64.encodeBase64String(session.getOriginalHash()))) { /* 1.1. User currently has an online session, must wait for it to expire. */
throw new NoUserAlreadyOnlineException(); if (originalHashesOnline.contains(Base64.encodeBase64String(session.getOriginalHash()))) {
} throw new NoUserAlreadyOnlineException();
/* 1.2. User successfully logged in: set up session records. */ }
NoSessionSphere.originalHashesOnline.add(Base64.encodeBase64String(session.getOriginalHash())); /* 1.2. User successfully logged in: set up session records. */
NoSessionSphere.sessions.put(session.uuid, session); NoSessionSphere.originalHashesOnline.add(Base64.encodeBase64String(session.getOriginalHash()));
NoSessionSphere.sessions.put(session.uuid, session);
/* 2. Check NoByteSetSphere for incoming Influences */ /* 2. Check NoByteSetSphere for incoming Influences */
session.incoming = NoByteSetSphere.consume(session.current); session.incoming = NoByteSetSphere.consume(session.current);
for (NoByteSet nbs : session.incoming) { for (NoByteSet nbs : session.incoming) {
/* 2.1 Decrypt NoInfluence from NoByteSet, let the current user consume them */ /* 2.1 Decrypt NoInfluence from NoByteSet, let the current user consume them */
try { try {
session.consume(nbs); session.consume(nbs);
} catch (NoByteSetBadDecryptionException e) { } catch (NoByteSetBadDecryptionException e) {
throw new NoDashFatalException("Bad byte sets on consumption.", e); throw new NoDashFatalException("Bad byte sets on consumption.", e);
} }
} /* 2.2 Alternatively, no NoByteSets to consume */ } /* 2.2 Alternatively, no NoByteSets to consume */
try { try {
session.check(); session.check();
} catch (NoSessionConfirmedException e) { } catch (NoSessionConfirmedException e) {
/* Should be impossible to reach */ /* Should be impossible to reach */
throw new NoDashFatalException(e); throw new NoDashFatalException(e);
} }
/* Will set to 2.1[MODIFIED] or 2.2[IDLE] */ /* Will set to 2.1[MODIFIED] or 2.2[IDLE] */
/* Precursor to 3.; allow website to associate user session with a cookie. */ /* Precursor to 3.; allow website to associate user session with a cookie. */
return session.getEncryptedUUID(); return session.getEncryptedUUID();
} }
public static NoUser getUser(byte[] encryptedUUID) throws NoDashSessionBadUUIDException, NoSessionExpiredException, NoSessionConfirmedException { public static NoUser getUser(byte[] encryptedUUID) throws NoDashSessionBadUUIDException,
UUID uuid = NoSession.decryptUUID(encryptedUUID); NoSessionExpiredException, NoSessionConfirmedException {
if (NoSessionSphere.sessions.containsKey(uuid)) { UUID uuid = NoSession.decryptUUID(encryptedUUID);
NoSessionSphere.pruneSingle(uuid); if (NoSessionSphere.sessions.containsKey(uuid)) {
try { NoSessionSphere.pruneSingle(uuid);
return NoSessionSphere.sessions.get(uuid).getNoUser(); try {
} catch (NullPointerException e) { return NoSessionSphere.sessions.get(uuid).getNoUser();
throw new NoSessionExpiredException(); } catch (NullPointerException e) {
} throw new NoSessionExpiredException();
} }
throw new NoSessionExpiredException(); }
} throw new NoSessionExpiredException();
}
public static NoState getState(byte[] encryptedUUID) throws NoDashSessionBadUUIDException, NoSessionExpiredException, NoSessionConfirmedException { public static NoState getState(byte[] encryptedUUID) throws NoDashSessionBadUUIDException,
UUID uuid = NoSession.decryptUUID(encryptedUUID); NoSessionExpiredException, NoSessionConfirmedException {
if (NoSessionSphere.sessions.containsKey(uuid)) { UUID uuid = NoSession.decryptUUID(encryptedUUID);
NoSessionSphere.pruneSingle(uuid); if (NoSessionSphere.sessions.containsKey(uuid)) {
NoSession session = NoSessionSphere.sessions.get(uuid); NoSessionSphere.pruneSingle(uuid);
return session.getNoState(); NoSession session = NoSessionSphere.sessions.get(uuid);
} return session.getNoState();
throw new NoSessionExpiredException(); }
} throw new NoSessionExpiredException();
}
public static synchronized byte[] save(byte[] encryptedUUID, char[] password) throws NoDashSessionBadUUIDException, NoSessionExpiredException, NoSessionConfirmedException, NoSessionNotChangedException, NoSessionAlreadyAwaitingConfirmationException { public static synchronized byte[] save(byte[] encryptedUUID, char[] password)
UUID uuid = NoSession.decryptUUID(encryptedUUID); throws NoDashSessionBadUUIDException, NoSessionExpiredException, NoSessionConfirmedException,
if (NoSessionSphere.sessions.containsKey(uuid)) { NoSessionNotChangedException, NoSessionAlreadyAwaitingConfirmationException {
NoSessionSphere.pruneSingle(uuid); UUID uuid = NoSession.decryptUUID(encryptedUUID);
NoSession session = NoSessionSphere.sessions.get(uuid); if (NoSessionSphere.sessions.containsKey(uuid)) {
NoSessionSphere.pruneSingle(uuid);
NoSession session = NoSessionSphere.sessions.get(uuid);
if (session.getNoState().equals(NoState.IDLE)) { if (session.getNoState().equals(NoState.IDLE)) {
throw new NoSessionNotChangedException(); throw new NoSessionNotChangedException();
} else if (session.getNoState().equals(NoState.AWAITING_CONFIRMATION)) { } else if (session.getNoState().equals(NoState.AWAITING_CONFIRMATION)) {
throw new NoSessionAlreadyAwaitingConfirmationException(); throw new NoSessionAlreadyAwaitingConfirmationException();
} }
return session.initiateSaveAttempt(password); return session.initiateSaveAttempt(password);
} }
throw new NoSessionExpiredException(); throw new NoSessionExpiredException();
} }
public static synchronized void confirm(byte[] encryptedUUID, char[] password, byte[] data) throws NoDashSessionBadUUIDException, NoSessionExpiredException, NoSessionConfirmedException, NoSessionNotAwaitingConfirmationException, NoUserNotValidException { public static synchronized void confirm(byte[] encryptedUUID, char[] password, byte[] data)
UUID uuid = NoSession.decryptUUID(encryptedUUID); throws NoDashSessionBadUUIDException, NoSessionExpiredException, NoSessionConfirmedException,
if (NoSessionSphere.sessions.containsKey(uuid)) { NoSessionNotAwaitingConfirmationException, NoUserNotValidException {
NoSessionSphere.pruneSingle(uuid); UUID uuid = NoSession.decryptUUID(encryptedUUID);
NoSession session = NoSessionSphere.sessions.get(uuid); if (NoSessionSphere.sessions.containsKey(uuid)) {
session.confirmSave(data, password); NoSessionSphere.pruneSingle(uuid);
return; NoSession session = NoSessionSphere.sessions.get(uuid);
} session.confirmSave(data, password);
throw new NoSessionExpiredException(); return;
} }
throw new NoSessionExpiredException();
}
public static synchronized NoRegister registerUser(NoUser user, char[] password) { public static synchronized NoRegister registerUser(NoUser user, char[] password) {
NoRegister result = new NoRegister(); NoRegister result = new NoRegister();
NoSession session = new NoSession(user); NoSession session = new NoSession(user);
NoSessionSphere.sessions.put(session.uuid, session); NoSessionSphere.sessions.put(session.uuid, session);
result.cookie = session.getEncryptedUUID(); result.cookie = session.getEncryptedUUID();
try { try {
result.data = NoSessionSphere.save(result.cookie, password); result.data = NoSessionSphere.save(result.cookie, password);
} catch (NoDashSessionBadUUIDException e) { } catch (NoDashSessionBadUUIDException e) {
throw new NoDashFatalException("Immediately generated cookie throwing bad cookie error.", e); throw new NoDashFatalException("Immediately generated cookie throwing bad cookie error.", e);
} catch (NoSessionExpiredException e) { } catch (NoSessionExpiredException e) {
throw new NoDashFatalException("Session expired before it was even returned to client.", e); throw new NoDashFatalException("Session expired before it was even returned to client.", e);
} catch (NoSessionConfirmedException e) { } catch (NoSessionConfirmedException e) {
throw new NoDashFatalException("Session is in confirmed state before it was returned to client.", e); throw new NoDashFatalException(
} catch (NoSessionNotChangedException e) { "Session is in confirmed state before it was returned to client.", e);
throw new NoDashFatalException("Session claims to be unchanged but user is newly registered.", e); } catch (NoSessionNotChangedException e) {
} catch (NoSessionAlreadyAwaitingConfirmationException e) { throw new NoDashFatalException(
throw new NoDashFatalException("Session claims to be awaiting confirmation before returning data to the user.", e); "Session claims to be unchanged but user is newly registered.", e);
} } catch (NoSessionAlreadyAwaitingConfirmationException e) {
return result; throw new NoDashFatalException(
} "Session claims to be awaiting confirmation before returning data to the user.", e);
}
return result;
}
} }

View File

@@ -1,29 +1,26 @@
/* /*
* Copyright 2014 David Horscroft * Copyright 2014 David Horscroft
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* you may not use this file except in compliance with the License. * in compliance with the License. You may obtain a copy of the License at
* You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software distributed under the License
* distributed under the License is distributed on an "AS IS" BASIS, * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * or implied. See the License for the specific language governing permissions and limitations under
* See the License for the specific language governing permissions and * the License.
* limitations under the License.
* *
* NoByteSetBadDecryptionException is triggered when no- is unable to * NoByteSetBadDecryptionException is triggered when no- is unable to decrypt a given byte stream.
* decrypt a given byte stream.
*/ */
package nodash.exceptions; package nodash.exceptions;
public class NoByteSetBadDecryptionException extends NoDashException { public class NoByteSetBadDecryptionException extends NoDashException {
private static final long serialVersionUID = -8579497499272656543L; private static final long serialVersionUID = -8579497499272656543L;
public NoByteSetBadDecryptionException(Exception e) { public NoByteSetBadDecryptionException(Exception e) {
super(e); super(e);
} }
} }

View File

@@ -1,21 +1,19 @@
/* /*
* Copyright 2014 David Horscroft * Copyright 2014 David Horscroft
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* you may not use this file except in compliance with the License. * in compliance with the License. You may obtain a copy of the License at
* You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software distributed under the License
* distributed under the License is distributed on an "AS IS" BASIS, * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * or implied. See the License for the specific language governing permissions and limitations under
* See the License for the specific language governing permissions and * the License.
* limitations under the License.
* *
* NoCannotGetInfluenceException is returned when an action is unable to * NoCannotGetInfluenceException is returned when an action is unable to render a successful
* render a successful influence for the target, instead returning an * influence for the target, instead returning an influence to be returned to the sender if
* influence to be returned to the sender if possible. * possible.
*/ */
package nodash.exceptions; package nodash.exceptions;
@@ -23,16 +21,16 @@ package nodash.exceptions;
import nodash.models.NoInfluence; import nodash.models.NoInfluence;
public class NoCannotGetInfluenceException extends Exception { public class NoCannotGetInfluenceException extends Exception {
private static final long serialVersionUID = 4581361079067540974L; private static final long serialVersionUID = 4581361079067540974L;
private NoInfluence returnable; private NoInfluence returnable;
public NoCannotGetInfluenceException(NoInfluence returnable) { public NoCannotGetInfluenceException(NoInfluence returnable) {
super(); super();
this.returnable = returnable; this.returnable = returnable;
} }
public NoInfluence getResponseInfluence() { public NoInfluence getResponseInfluence() {
return returnable; return returnable;
} }
} }

View File

@@ -1,17 +1,15 @@
/* /*
* Copyright 2014 David Horscroft * Copyright 2014 David Horscroft
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* you may not use this file except in compliance with the License. * in compliance with the License. You may obtain a copy of the License at
* You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software distributed under the License
* distributed under the License is distributed on an "AS IS" BASIS, * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * or implied. See the License for the specific language governing permissions and limitations under
* See the License for the specific language governing permissions and * the License.
* limitations under the License.
* *
* NoDashException is the base class for no- related exceptions. * NoDashException is the base class for no- related exceptions.
*/ */
@@ -19,13 +17,13 @@
package nodash.exceptions; package nodash.exceptions;
public class NoDashException extends Exception { public class NoDashException extends Exception {
private static final long serialVersionUID = -8579497499272656543L; private static final long serialVersionUID = -8579497499272656543L;
public NoDashException() { public NoDashException() {
super(); super();
} }
public NoDashException(Exception e) { public NoDashException(Exception e) {
super(e); super(e);
} }
} }

View File

@@ -1,17 +1,15 @@
/* /*
* Copyright 2014 David Horscroft * Copyright 2014 David Horscroft
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* you may not use this file except in compliance with the License. * in compliance with the License. You may obtain a copy of the License at
* You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software distributed under the License
* distributed under the License is distributed on an "AS IS" BASIS, * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * or implied. See the License for the specific language governing permissions and limitations under
* See the License for the specific language governing permissions and * the License.
* limitations under the License.
* *
* NoDashFatalException is the base exception for no- related runtime exceptions. * NoDashFatalException is the base exception for no- related runtime exceptions.
*/ */
@@ -19,17 +17,17 @@
package nodash.exceptions; package nodash.exceptions;
public class NoDashFatalException extends RuntimeException { public class NoDashFatalException extends RuntimeException {
private static final long serialVersionUID = -8254102569327237811L; private static final long serialVersionUID = -8254102569327237811L;
public NoDashFatalException(Exception e) { public NoDashFatalException(Exception e) {
super(e); super(e);
} }
public NoDashFatalException(String string) { public NoDashFatalException(String string) {
super(string); super(string);
} }
public NoDashFatalException(String string, Exception e) { public NoDashFatalException(String string, Exception e) {
super(string, e); super(string, e);
} }
} }

View File

@@ -1,32 +1,30 @@
/* /*
* Copyright 2014 David Horscroft * Copyright 2014 David Horscroft
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* you may not use this file except in compliance with the License. * in compliance with the License. You may obtain a copy of the License at
* You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software distributed under the License
* distributed under the License is distributed on an "AS IS" BASIS, * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * or implied. See the License for the specific language governing permissions and limitations under
* See the License for the specific language governing permissions and * the License.
* limitations under the License.
* *
* NoDashSessionBadUUIDException is triggered when the NoSessionSphere is * NoDashSessionBadUUIDException is triggered when the NoSessionSphere is unable to find a valid
* unable to find a valid session for the provided UUID. * session for the provided UUID.
*/ */
package nodash.exceptions; package nodash.exceptions;
public class NoDashSessionBadUUIDException extends Exception { public class NoDashSessionBadUUIDException extends Exception {
private static final long serialVersionUID = -402131397575158344L; private static final long serialVersionUID = -402131397575158344L;
public NoDashSessionBadUUIDException() { public NoDashSessionBadUUIDException() {
super(); super();
} }
public NoDashSessionBadUUIDException(Exception e) { public NoDashSessionBadUUIDException(Exception e) {
super(e); super(e);
} }
} }

View File

@@ -1,25 +1,22 @@
/* /*
* Copyright 2014 David Horscroft * Copyright 2014 David Horscroft
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* you may not use this file except in compliance with the License. * in compliance with the License. You may obtain a copy of the License at
* You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software distributed under the License
* distributed under the License is distributed on an "AS IS" BASIS, * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * or implied. See the License for the specific language governing permissions and limitations under
* See the License for the specific language governing permissions and * the License.
* limitations under the License.
* *
* NoSessionAlreadyAWaitingConfirmationException is triggered when a * NoSessionAlreadyAWaitingConfirmationException is triggered when a save request is attempted for a
* save request is attempted for a session, but it is already awaiting * session, but it is already awaiting a confirmation upload.
* a confirmation upload.
*/ */
package nodash.exceptions; package nodash.exceptions;
public class NoSessionAlreadyAwaitingConfirmationException extends NoDashException { public class NoSessionAlreadyAwaitingConfirmationException extends NoDashException {
private static final long serialVersionUID = 6046203718016296554L; private static final long serialVersionUID = 6046203718016296554L;
} }

View File

@@ -1,24 +1,22 @@
/* /*
* Copyright 2014 David Horscroft * Copyright 2014 David Horscroft
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* you may not use this file except in compliance with the License. * in compliance with the License. You may obtain a copy of the License at
* You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software distributed under the License
* distributed under the License is distributed on an "AS IS" BASIS, * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * or implied. See the License for the specific language governing permissions and limitations under
* See the License for the specific language governing permissions and * the License.
* limitations under the License.
* *
* NoSessionConfirmedException is triggered when an interaction attempt is * NoSessionConfirmedException is triggered when an interaction attempt is made on a session that
* made on a session that has recently been confirmed and thus closed. * has recently been confirmed and thus closed.
*/ */
package nodash.exceptions; package nodash.exceptions;
public class NoSessionConfirmedException extends NoDashException { public class NoSessionConfirmedException extends NoDashException {
private static final long serialVersionUID = -8065331145629402524L; private static final long serialVersionUID = -8065331145629402524L;
} }

View File

@@ -1,24 +1,21 @@
/* /*
* Copyright 2014 David Horscroft * Copyright 2014 David Horscroft
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* you may not use this file except in compliance with the License. * in compliance with the License. You may obtain a copy of the License at
* You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software distributed under the License
* distributed under the License is distributed on an "AS IS" BASIS, * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * or implied. See the License for the specific language governing permissions and limitations under
* See the License for the specific language governing permissions and * the License.
* limitations under the License.
* *
* NoSessionExpiredException is thrown when an interaction is attempted with * NoSessionExpiredException is thrown when an interaction is attempted with an expired session.
* an expired session.
*/ */
package nodash.exceptions; package nodash.exceptions;
public class NoSessionExpiredException extends NoDashException { public class NoSessionExpiredException extends NoDashException {
private static final long serialVersionUID = -541733773743173644L; private static final long serialVersionUID = -541733773743173644L;
} }

View File

@@ -1,25 +1,22 @@
/* /*
* Copyright 2014 David Horscroft * Copyright 2014 David Horscroft
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* you may not use this file except in compliance with the License. * in compliance with the License. You may obtain a copy of the License at
* You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software distributed under the License
* distributed under the License is distributed on an "AS IS" BASIS, * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * or implied. See the License for the specific language governing permissions and limitations under
* See the License for the specific language governing permissions and * the License.
* limitations under the License.
* *
* NoSessionNotAwaitingConfirmationException is thrown when an attempt is made * NoSessionNotAwaitingConfirmationException is thrown when an attempt is made to confirm a session
* to confirm a session with a password/byte[] combination, but the session is * with a password/byte[] combination, but the session is not currently awaiting a confirmation.
* not currently awaiting a confirmation.
*/ */
package nodash.exceptions; package nodash.exceptions;
public class NoSessionNotAwaitingConfirmationException extends NoDashException { public class NoSessionNotAwaitingConfirmationException extends NoDashException {
private static final long serialVersionUID = -2563955621281305198L; private static final long serialVersionUID = -2563955621281305198L;
} }

View File

@@ -1,24 +1,22 @@
/* /*
* Copyright 2014 David Horscroft * Copyright 2014 David Horscroft
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* you may not use this file except in compliance with the License. * in compliance with the License. You may obtain a copy of the License at
* You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software distributed under the License
* distributed under the License is distributed on an "AS IS" BASIS, * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * or implied. See the License for the specific language governing permissions and limitations under
* See the License for the specific language governing permissions and * the License.
* limitations under the License.
* *
* NoSessionNotChangedException is thrown when a save is requested for a session * NoSessionNotChangedException is thrown when a save is requested for a session whilst the user
* whilst the user object remains unchanged. * object remains unchanged.
*/ */
package nodash.exceptions; package nodash.exceptions;
public class NoSessionNotChangedException extends NoDashException { public class NoSessionNotChangedException extends NoDashException {
private static final long serialVersionUID = 8049751796255114602L; private static final long serialVersionUID = 8049751796255114602L;
} }

View File

@@ -1,25 +1,23 @@
/* /*
* Copyright 2014 David Horscroft * Copyright 2014 David Horscroft
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* you may not use this file except in compliance with the License. * in compliance with the License. You may obtain a copy of the License at
* You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software distributed under the License
* distributed under the License is distributed on an "AS IS" BASIS, * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * or implied. See the License for the specific language governing permissions and limitations under
* See the License for the specific language governing permissions and * the License.
* limitations under the License.
* *
* NoUserAlreadyOnlineException is thrown when a login attempt is made for * NoUserAlreadyOnlineException is thrown when a login attempt is made for a user who is currently
* a user who is currently online. * online.
*/ */
package nodash.exceptions; package nodash.exceptions;
public class NoUserAlreadyOnlineException extends NoDashException { public class NoUserAlreadyOnlineException extends NoDashException {
private static final long serialVersionUID = -2922060333175653034L; private static final long serialVersionUID = -2922060333175653034L;
} }

View File

@@ -1,24 +1,21 @@
/* /*
* Copyright 2014 David Horscroft * Copyright 2014 David Horscroft
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* you may not use this file except in compliance with the License. * in compliance with the License. You may obtain a copy of the License at
* You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software distributed under the License
* distributed under the License is distributed on an "AS IS" BASIS, * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * or implied. See the License for the specific language governing permissions and limitations under
* See the License for the specific language governing permissions and * the License.
* limitations under the License.
* *
* NoUserNotValidException is thrown when a user file does not hash to a known * NoUserNotValidException is thrown when a user file does not hash to a known hash.
* hash.
*/ */
package nodash.exceptions; package nodash.exceptions;
public class NoUserNotValidException extends NoDashException { public class NoUserNotValidException extends NoDashException {
private static final long serialVersionUID = -6432604940919299965L; private static final long serialVersionUID = -6432604940919299965L;
} }

View File

@@ -1,20 +1,18 @@
/* /*
* Copyright 2014 David Horscroft * Copyright 2014 David Horscroft
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* you may not use this file except in compliance with the License. * in compliance with the License. You may obtain a copy of the License at
* You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software distributed under the License
* distributed under the License is distributed on an "AS IS" BASIS, * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * or implied. See the License for the specific language governing permissions and limitations under
* See the License for the specific language governing permissions and * the License.
* limitations under the License.
* *
* NoAction is an abstract class to allow for the inheritance of actions which * NoAction is an abstract class to allow for the inheritance of actions which users can queue
* users can queue before confirmation (user-to-user and user-to-server). * before confirmation (user-to-user and user-to-server).
*/ */
package nodash.models; package nodash.models;
@@ -22,8 +20,11 @@ package nodash.models;
import java.io.Serializable; import java.io.Serializable;
public abstract class NoAction implements Serializable { public abstract class NoAction implements Serializable {
private static final long serialVersionUID = -194752850197321803L; private static final long serialVersionUID = -194752850197321803L;
public abstract void process();
public abstract void execute(); public abstract void process();
public abstract void purge();
public abstract void execute();
public abstract void purge();
} }

View File

@@ -1,31 +1,29 @@
/* /*
* Copyright 2014 David Horscroft * Copyright 2014 David Horscroft
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* you may not use this file except in compliance with the License. * in compliance with the License. You may obtain a copy of the License at
* You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software distributed under the License
* distributed under the License is distributed on an "AS IS" BASIS, * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * or implied. See the License for the specific language governing permissions and limitations under
* See the License for the specific language governing permissions and * the License.
* limitations under the License.
* *
* NoByteSet stores an AES key which has been RSA-4096 encrypted and a data * NoByteSet stores an AES key which has been RSA-4096 encrypted and a data stream which has been
* stream which has been encrypted by this key. * encrypted by this key.
*/ */
package nodash.models; package nodash.models;
public final class NoByteSet { public final class NoByteSet {
public byte[] key; public byte[] key;
public byte[] data; public byte[] data;
public NoByteSet(byte[] key, byte[] data) { public NoByteSet(byte[] key, byte[] data) {
this.key = key; this.key = key;
this.data = data; this.data = data;
} }
} }

View File

@@ -1,22 +1,20 @@
/* /*
* Copyright 2014 David Horscroft * Copyright 2014 David Horscroft
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* you may not use this file except in compliance with the License. * in compliance with the License. You may obtain a copy of the License at
* You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software distributed under the License
* distributed under the License is distributed on an "AS IS" BASIS, * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * or implied. See the License for the specific language governing permissions and limitations under
* See the License for the specific language governing permissions and * the License.
* limitations under the License.
* *
* NoInfluence is an abstract class allowing for the subclassing of user * NoInfluence is an abstract class allowing for the subclassing of user influences, generated by
* influences, generated by both actions and the server. Upon login, the user * both actions and the server. Upon login, the user consumes NoByteSets (generated by
* consumes NoByteSets (generated by .getByteSet()) into the primary NoInfluence, * .getByteSet()) into the primary NoInfluence, which is then applied to the user with
* which is then applied to the user with .applyTo(NoUser). * .applyTo(NoUser).
* *
* Examples include incoming messages, financial changes or charges or updates. * Examples include incoming messages, financial changes or charges or updates.
*/ */
@@ -41,52 +39,53 @@ import nodash.core.NoUtil;
import nodash.exceptions.NoDashFatalException; import nodash.exceptions.NoDashFatalException;
public abstract class NoInfluence implements Serializable { public abstract class NoInfluence implements Serializable {
private static final long serialVersionUID = -7509462039664862920L; private static final long serialVersionUID = -7509462039664862920L;
public abstract void applyTo(NoUser user); public abstract void applyTo(NoUser user);
public final NoByteSet getByteSet(PublicKey publicKey) { public final NoByteSet getByteSet(PublicKey publicKey) {
KeyGenerator keyGen; KeyGenerator keyGen;
try { try {
keyGen = KeyGenerator.getInstance(NoUtil.CIPHER_KEY_SPEC); keyGen = KeyGenerator.getInstance(NoUtil.CIPHER_KEY_SPEC);
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {
throw new NoDashFatalException("Value for CIPHER_KEY_SPEC is not valid.", e); throw new NoDashFatalException("Value for CIPHER_KEY_SPEC is not valid.", e);
} }
keyGen.init(NoUtil.AES_STRENGTH); keyGen.init(NoUtil.AES_STRENGTH);
SecretKey secretKey = keyGen.generateKey(); SecretKey secretKey = keyGen.generateKey();
byte[] key = secretKey.getEncoded(); byte[] key = secretKey.getEncoded();
byte[] encryptedKey = NoUtil.encryptRSA(key, publicKey); byte[] encryptedKey = NoUtil.encryptRSA(key, publicKey);
byte[] data = this.getEncrypted(key); byte[] data = this.getEncrypted(key);
NoUtil.wipeBytes(key); NoUtil.wipeBytes(key);
return new NoByteSet(encryptedKey, data); return new NoByteSet(encryptedKey, data);
} }
private final byte[] getEncrypted(byte[] key) { private final byte[] getEncrypted(byte[] key) {
try { try {
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos); ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(this); oos.writeObject(this);
byte[] encrypted = NoUtil.encrypt(baos.toByteArray(), key); byte[] encrypted = NoUtil.encrypt(baos.toByteArray(), key);
oos.close(); oos.close();
baos.close(); baos.close();
return encrypted; return encrypted;
} catch (IOException e) { } catch (IOException e) {
throw new NoDashFatalException("Unable to write NoInfluence object to byte stream.", e); throw new NoDashFatalException("Unable to write NoInfluence object to byte stream.", e);
} }
} }
public static NoInfluence decrypt(byte[] data, byte[] key) throws IllegalBlockSizeException, BadPaddingException, ClassNotFoundException { public static NoInfluence decrypt(byte[] data, byte[] key) throws IllegalBlockSizeException,
byte[] decrypted = NoUtil.decrypt(data, key); BadPaddingException, ClassNotFoundException {
ByteArrayInputStream bais = new ByteArrayInputStream(decrypted); byte[] decrypted = NoUtil.decrypt(data, key);
try { ByteArrayInputStream bais = new ByteArrayInputStream(decrypted);
ObjectInputStream ois = new ObjectInputStream(bais); try {
NoInfluence noInfluence = (NoInfluence) ois.readObject(); ObjectInputStream ois = new ObjectInputStream(bais);
ois.close(); NoInfluence noInfluence = (NoInfluence) ois.readObject();
bais.close(); ois.close();
return noInfluence; bais.close();
} catch (IOException e) { return noInfluence;
throw new NoDashFatalException("Unable to read out provided data stream.", e); } catch (IOException e) {
} throw new NoDashFatalException("Unable to read out provided data stream.", e);
} }
}
} }

View File

@@ -21,208 +21,212 @@ import nodash.exceptions.NoSessionNotAwaitingConfirmationException;
import nodash.exceptions.NoUserNotValidException; import nodash.exceptions.NoUserNotValidException;
public final class NoSession implements Serializable { public final class NoSession implements Serializable {
private static final long serialVersionUID = 1814807373427948931L; private static final long serialVersionUID = 1814807373427948931L;
public static final long SESSION_DURATION = 1000 * 60 * 30; //30 minute sessions public static final long SESSION_DURATION = 1000 * 60 * 30; // 30 minute sessions
public static enum NoState {
IDLE, MODIFIED, AWAITING_CONFIRMATION, CONFIRMED, CLOSED;
};
private NoUser original; public static enum NoState {
private NoState state; IDLE, MODIFIED, AWAITING_CONFIRMATION, CONFIRMED, CLOSED;
private final long expiry; };
private boolean newUserSession;
public ArrayList<NoByteSet> incoming; private NoUser original;
public NoUser current; private NoState state;
public UUID uuid; private final long expiry;
private boolean newUserSession;
public NoSession() { public ArrayList<NoByteSet> incoming;
this.state = NoState.IDLE; public NoUser current;
this.expiry = System.currentTimeMillis() + NoSession.SESSION_DURATION; public UUID uuid;
this.uuid = UUID.randomUUID();
}
public NoSession(NoUser newUser) { public NoSession() {
this(); this.state = NoState.IDLE;
this.state = NoState.MODIFIED; this.expiry = System.currentTimeMillis() + NoSession.SESSION_DURATION;
this.original = null; this.uuid = UUID.randomUUID();
this.current = newUser; }
this.newUserSession = true;
}
public NoSession(byte[] data, char[] password) throws NoUserNotValidException { public NoSession(NoUser newUser) {
this(); this();
this.newUserSession = false; this.state = NoState.MODIFIED;
this.state = NoState.IDLE; this.original = null;
char[] passwordDupe = password.clone(); this.current = newUser;
try { this.newUserSession = true;
this.original = NoUser.createUserFromFile(data, password); }
if (NoCore.hashSphere.checkHash(this.original.createHashString())) {
this.current = NoUser.createUserFromFile(data, passwordDupe);
this.uuid = UUID.randomUUID();
NoUtil.wipeBytes(data);
} else {
throw new NoUserNotValidException();
}
} catch (IOException e) {
throw new NoUserNotValidException();
} catch (IllegalBlockSizeException e) {
throw new NoUserNotValidException();
} catch (BadPaddingException e) {
throw new NoUserNotValidException();
} catch (ClassNotFoundException e) {
throw new NoUserNotValidException();
}
}
public void check() throws NoSessionConfirmedException, NoSessionExpiredException { public NoSession(byte[] data, char[] password) throws NoUserNotValidException {
if (this.state == NoState.CONFIRMED) { this();
throw new NoSessionConfirmedException(); this.newUserSession = false;
} else if (this.state == NoState.CLOSED || System.currentTimeMillis() > this.expiry) { this.state = NoState.IDLE;
this.state = NoState.CLOSED; char[] passwordDupe = password.clone();
throw new NoSessionExpiredException(); try {
} this.original = NoUser.createUserFromFile(data, password);
} if (NoCore.hashSphere.checkHash(this.original.createHashString())) {
this.current = NoUser.createUserFromFile(data, passwordDupe);
this.uuid = UUID.randomUUID();
NoUtil.wipeBytes(data);
} else {
throw new NoUserNotValidException();
}
} catch (IOException e) {
throw new NoUserNotValidException();
} catch (IllegalBlockSizeException e) {
throw new NoUserNotValidException();
} catch (BadPaddingException e) {
throw new NoUserNotValidException();
} catch (ClassNotFoundException e) {
throw new NoUserNotValidException();
}
}
public NoState touchState() throws NoSessionConfirmedException, NoSessionExpiredException { public void check() throws NoSessionConfirmedException, NoSessionExpiredException {
this.check(); if (this.state == NoState.CONFIRMED) {
if (this.newUserSession) { throw new NoSessionConfirmedException();
if (this.state != NoState.AWAITING_CONFIRMATION) { } else if (this.state == NoState.CLOSED || System.currentTimeMillis() > this.expiry) {
this.state = NoState.MODIFIED; this.state = NoState.CLOSED;
} throw new NoSessionExpiredException();
} else { }
String originalHash = this.original.createHashString(); }
String currentHash = this.current.createHashString();
if (originalHash.equals(currentHash)) {
this.state = NoState.IDLE;
} else if (this.state != NoState.AWAITING_CONFIRMATION) {
this.state = NoState.MODIFIED;
}
}
return this.state;
}
public byte[] initiateSaveAttempt(char[] password) throws NoSessionConfirmedException, NoSessionExpiredException { public NoState touchState() throws NoSessionConfirmedException, NoSessionExpiredException {
this.touchState(); this.check();
this.state = NoState.AWAITING_CONFIRMATION; if (this.newUserSession) {
byte[] file = this.current.createFile(password); if (this.state != NoState.AWAITING_CONFIRMATION) {
NoUtil.wipeChars(password); this.state = NoState.MODIFIED;
return file; }
} } else {
String originalHash = this.original.createHashString();
String currentHash = this.current.createHashString();
if (originalHash.equals(currentHash)) {
this.state = NoState.IDLE;
} else if (this.state != NoState.AWAITING_CONFIRMATION) {
this.state = NoState.MODIFIED;
}
}
return this.state;
}
public void confirmSave(byte[] confirmData, char[] password) throws NoSessionConfirmedException, NoSessionExpiredException, public byte[] initiateSaveAttempt(char[] password) throws NoSessionConfirmedException,
NoSessionNotAwaitingConfirmationException, NoUserNotValidException { NoSessionExpiredException {
this.check(); this.touchState();
if (this.state != NoState.AWAITING_CONFIRMATION) { this.state = NoState.AWAITING_CONFIRMATION;
throw new NoSessionNotAwaitingConfirmationException(); byte[] file = this.current.createFile(password);
} NoUtil.wipeChars(password);
return file;
}
NoUser confirmed; public void confirmSave(byte[] confirmData, char[] password) throws NoSessionConfirmedException,
try { NoSessionExpiredException, NoSessionNotAwaitingConfirmationException, NoUserNotValidException {
confirmed = NoUser.createUserFromFile(confirmData, password); this.check();
} catch (IOException e) { if (this.state != NoState.AWAITING_CONFIRMATION) {
throw new NoUserNotValidException(); throw new NoSessionNotAwaitingConfirmationException();
} catch (IllegalBlockSizeException e) { }
throw new NoUserNotValidException();
} catch (BadPaddingException e) {
throw new NoUserNotValidException();
} catch (ClassNotFoundException e) {
throw new NoUserNotValidException();
}
NoUtil.wipeBytes(confirmData); NoUser confirmed;
NoUtil.wipeChars(password); try {
if (confirmed.createHashString().equals(this.current.createHashString())) { confirmed = NoUser.createUserFromFile(confirmData, password);
this.state = NoState.CONFIRMED; } catch (IOException e) {
/* 5.2: confirmed! */ throw new NoUserNotValidException();
if (!this.newUserSession) { } catch (IllegalBlockSizeException e) {
/* 5.2.1: remove old hash from array */ throw new NoUserNotValidException();
try { } catch (BadPaddingException e) {
NoCore.hashSphere.removeHash(this.original.createHashString()); throw new NoUserNotValidException();
} catch (IOException e) { } catch (ClassNotFoundException e) {
throw new NoDashFatalException("Unable to remove hash on confirm.", e); throw new NoUserNotValidException();
} }
}
/* 5.2.2: add new hash to array */
try {
NoCore.hashSphere.insertHash(this.current.createHashString());
} catch (IOException e) {
throw new NoDashFatalException("Unable to remove hash on confirm.", e);
}
/* 5.2.3: clear influences as they will not need to be re-applied */ NoUtil.wipeBytes(confirmData);
ArrayList<NoAction> actions = this.current.getNoActions(); NoUtil.wipeChars(password);
this.incoming = null; if (confirmed.createHashString().equals(this.current.createHashString())) {
this.original = null; this.state = NoState.CONFIRMED;
this.current = null; /* 5.2: confirmed! */
/* 5.2.4: execute NoActions */ if (!this.newUserSession) {
for (NoAction action : actions) { /* 5.2.1: remove old hash from array */
/* It is assumed that actions are not long-running tasks try {
* It is also assumed that actions have the information they need without the user objects */ NoCore.hashSphere.removeHash(this.original.createHashString());
action.execute(); } catch (IOException e) {
action.purge(); throw new NoDashFatalException("Unable to remove hash on confirm.", e);
} }
} else { }
throw new NoUserNotValidException(); /* 5.2.2: add new hash to array */
} try {
} NoCore.hashSphere.insertHash(this.current.createHashString());
} catch (IOException e) {
throw new NoDashFatalException("Unable to remove hash on confirm.", e);
}
public NoState getNoState() throws NoSessionConfirmedException, NoSessionExpiredException { /* 5.2.3: clear influences as they will not need to be re-applied */
this.touchState(); ArrayList<NoAction> actions = this.current.getNoActions();
return this.state; this.incoming = null;
} this.original = null;
this.current = null;
/* 5.2.4: execute NoActions */
for (NoAction action : actions) {
/*
* It is assumed that actions are not long-running tasks It is also assumed that actions
* have the information they need without the user objects
*/
action.execute();
action.purge();
}
} else {
throw new NoUserNotValidException();
}
}
public NoUser getNoUser() throws NoSessionConfirmedException, NoSessionExpiredException { public NoState getNoState() throws NoSessionConfirmedException, NoSessionExpiredException {
this.check(); this.touchState();
return this.current; return this.state;
} }
public UUID getUUID() { public NoUser getNoUser() throws NoSessionConfirmedException, NoSessionExpiredException {
return this.uuid; this.check();
} return this.current;
}
public String getUUIDAsString() { public UUID getUUID() {
return this.uuid.toString(); return this.uuid;
} }
public byte[] getEncryptedUUID() { public String getUUIDAsString() {
return NoUtil.encrypt(Base64.encodeBase64(this.uuid.toString().getBytes())); return this.uuid.toString();
} }
public String getEncryptedUUIDAsString() { public byte[] getEncryptedUUID() {
return new String(this.getEncryptedUUID()); return NoUtil.encrypt(Base64.encodeBase64(this.uuid.toString().getBytes()));
} }
public byte[] getOriginalHash() { public String getEncryptedUUIDAsString() {
if (this.original != null) { return new String(this.getEncryptedUUID());
return this.original.createHash(); }
} else {
return null;
}
}
public static UUID decryptUUID(byte[] data) throws NoDashSessionBadUUIDException { public byte[] getOriginalHash() {
if (data == null) { if (this.original != null) {
throw new NoDashSessionBadUUIDException(); return this.original.createHash();
} } else {
return null;
}
}
try { public static UUID decryptUUID(byte[] data) throws NoDashSessionBadUUIDException {
return UUID.fromString(new String(Base64.decodeBase64(NoUtil.decrypt(data)))); if (data == null) {
} catch (IllegalArgumentException e) { throw new NoDashSessionBadUUIDException();
throw new NoDashSessionBadUUIDException(); }
}catch (IllegalBlockSizeException e) {
throw new NoDashSessionBadUUIDException();
} catch (BadPaddingException e) {
throw new NoDashSessionBadUUIDException();
}
}
public void consume(NoByteSet byteSet) throws NoByteSetBadDecryptionException { try {
this.current.consume(byteSet); return UUID.fromString(new String(Base64.decodeBase64(NoUtil.decrypt(data))));
} } catch (IllegalArgumentException e) {
throw new NoDashSessionBadUUIDException();
} catch (IllegalBlockSizeException e) {
throw new NoDashSessionBadUUIDException();
} catch (BadPaddingException e) {
throw new NoDashSessionBadUUIDException();
}
}
public void close() { public void consume(NoByteSet byteSet) throws NoByteSetBadDecryptionException {
this.state = NoState.CLOSED; this.current.consume(byteSet);
} }
public void close() {
this.state = NoState.CLOSED;
}
} }

View File

@@ -1,21 +1,19 @@
/* /*
* Copyright 2014 David Horscroft * Copyright 2014 David Horscroft
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* you may not use this file except in compliance with the License. * in compliance with the License. You may obtain a copy of the License at
* You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software distributed under the License
* distributed under the License is distributed on an "AS IS" BASIS, * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * or implied. See the License for the specific language governing permissions and limitations under
* See the License for the specific language governing permissions and * the License.
* limitations under the License.
* *
* NoUser allows the subclassing of custom user objects whilst keeping the * NoUser allows the subclassing of custom user objects whilst keeping the core requirements of a
* core requirements of a NoUser: the public and private keys. It also supports * NoUser: the public and private keys. It also supports the serialization, decryption and NoByteSet
* the serialization, decryption and NoByteSet consumption. * consumption.
*/ */
package nodash.models; package nodash.models;
@@ -48,148 +46,152 @@ import nodash.exceptions.NoByteSetBadDecryptionException;
import nodash.exceptions.NoDashFatalException; import nodash.exceptions.NoDashFatalException;
public class NoUser implements Serializable { public class NoUser implements Serializable {
private static final long serialVersionUID = 7132405837081692211L; private static final long serialVersionUID = 7132405837081692211L;
private PublicKey publicKey; private PublicKey publicKey;
private PrivateKey privateKey; private PrivateKey privateKey;
@SuppressWarnings("unused") @SuppressWarnings("unused")
private String randomized; private String randomized;
public int influences; public int influences;
public int actions; public int actions;
private ArrayList<NoAction> outgoing = new ArrayList<NoAction>(); private ArrayList<NoAction> outgoing = new ArrayList<NoAction>();
public NoUser() { public NoUser() {
KeyPairGenerator kpg; KeyPairGenerator kpg;
try { try {
kpg = KeyPairGenerator.getInstance(NoUtil.KEYPAIR_ALGORITHM); kpg = KeyPairGenerator.getInstance(NoUtil.KEYPAIR_ALGORITHM);
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {
throw new NoDashFatalException("Value for KEYPAIR_ALGORITHM is not valid.", e); throw new NoDashFatalException("Value for KEYPAIR_ALGORITHM is not valid.", e);
} }
try { try {
kpg.initialize(NoUtil.RSA_STRENGTH, SecureRandom.getInstance(NoUtil.SECURERANDOM_ALGORITHM, NoUtil.SECURERANDOM_PROVIDER)); kpg.initialize(NoUtil.RSA_STRENGTH,
} catch (NoSuchAlgorithmException e) { SecureRandom.getInstance(NoUtil.SECURERANDOM_ALGORITHM, NoUtil.SECURERANDOM_PROVIDER));
throw new NoDashFatalException("Value for SECURERANDOM_ALGORITHM not valid.", e); } catch (NoSuchAlgorithmException e) {
} catch (NoSuchProviderException e) { throw new NoDashFatalException("Value for SECURERANDOM_ALGORITHM not valid.", e);
throw new NoDashFatalException("Value for SECURERANDOM_PROVIDER not valid.", e); } catch (NoSuchProviderException e) {
} throw new NoDashFatalException("Value for SECURERANDOM_PROVIDER not valid.", e);
}
KeyPair keyPair = kpg.generateKeyPair(); KeyPair keyPair = kpg.generateKeyPair();
this.publicKey = keyPair.getPublic(); this.publicKey = keyPair.getPublic();
this.privateKey = keyPair.getPrivate(); this.privateKey = keyPair.getPrivate();
this.influences = 0; this.influences = 0;
this.actions = 0; this.actions = 0;
this.touchRandomizer(); this.touchRandomizer();
} }
private void touchRandomizer() { private void touchRandomizer() {
byte[] randomBytes = new byte[64]; byte[] randomBytes = new byte[64];
try { try {
SecureRandom.getInstance(NoUtil.SECURERANDOM_ALGORITHM).nextBytes(randomBytes); SecureRandom.getInstance(NoUtil.SECURERANDOM_ALGORITHM).nextBytes(randomBytes);
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {
throw new NoDashFatalException("Value for SECURERANDOM_ALGORITHM not valid.", e); throw new NoDashFatalException("Value for SECURERANDOM_ALGORITHM not valid.", e);
} }
this.randomized = new String(randomBytes); this.randomized = new String(randomBytes);
} }
public final byte[] createFile(char[] password) { public final byte[] createFile(char[] password) {
ArrayList<NoAction> temp = this.outgoing; ArrayList<NoAction> temp = this.outgoing;
try { try {
this.touchRandomizer(); this.touchRandomizer();
this.outgoing = new ArrayList<NoAction>(); this.outgoing = new ArrayList<NoAction>();
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos); ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(this); oos.writeObject(this);
byte[] encrypted = NoUtil.encrypt(baos.toByteArray(), password); byte[] encrypted = NoUtil.encrypt(baos.toByteArray(), password);
oos.close(); oos.close();
baos.close(); baos.close();
return encrypted; return encrypted;
} catch (IOException e) { } catch (IOException e) {
throw new NoDashFatalException("IO Exception encountered while generating encrypted user file byte stream.", e); throw new NoDashFatalException(
} finally { "IO Exception encountered while generating encrypted user file byte stream.", e);
this.outgoing = temp; } finally {
} this.outgoing = temp;
} }
}
public final byte[] createHash() { public final byte[] createHash() {
ArrayList<NoAction> temp = this.outgoing; ArrayList<NoAction> temp = this.outgoing;
try { try {
this.outgoing = new ArrayList<NoAction>(); this.outgoing = new ArrayList<NoAction>();
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos); ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(this); oos.writeObject(this);
byte[] userBytes = baos.toByteArray(); byte[] userBytes = baos.toByteArray();
return NoUtil.getHashFromByteArray(userBytes); return NoUtil.getHashFromByteArray(userBytes);
} catch (IOException e) { } catch (IOException e) {
throw new NoDashFatalException("IO Exception encountered while generating user hash.", e); throw new NoDashFatalException("IO Exception encountered while generating user hash.", e);
} finally { } finally {
this.outgoing = temp; this.outgoing = temp;
} }
} }
public final String createHashString() { public final String createHashString() {
return new String(this.createHash()); return new String(this.createHash());
} }
public final void consume(NoByteSet byteSet) throws NoByteSetBadDecryptionException { public final void consume(NoByteSet byteSet) throws NoByteSetBadDecryptionException {
try { try {
SecretKey secretKey = new SecretKeySpec(decryptRSA(byteSet.key), NoUtil.CIPHER_KEY_SPEC); SecretKey secretKey = new SecretKeySpec(decryptRSA(byteSet.key), NoUtil.CIPHER_KEY_SPEC);
byte[] key = secretKey.getEncoded(); byte[] key = secretKey.getEncoded();
secretKey = null; secretKey = null;
NoInfluence influence = NoInfluence.decrypt(byteSet.data, key); NoInfluence influence = NoInfluence.decrypt(byteSet.data, key);
NoUtil.wipeBytes(key); NoUtil.wipeBytes(key);
influence.applyTo(this); influence.applyTo(this);
this.influences++; this.influences++;
} catch (BadPaddingException e) { } catch (BadPaddingException e) {
throw new NoByteSetBadDecryptionException(e); throw new NoByteSetBadDecryptionException(e);
} catch (IllegalBlockSizeException e) { } catch (IllegalBlockSizeException e) {
throw new NoByteSetBadDecryptionException(e); throw new NoByteSetBadDecryptionException(e);
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
throw new NoByteSetBadDecryptionException(e); throw new NoByteSetBadDecryptionException(e);
} catch (InvalidKeyException e) { } catch (InvalidKeyException e) {
throw new NoByteSetBadDecryptionException(e); throw new NoByteSetBadDecryptionException(e);
} }
} }
public final void addAction(NoAction action) { public final void addAction(NoAction action) {
this.outgoing.add(action); this.outgoing.add(action);
this.actions++; this.actions++;
} }
public final ArrayList<NoAction> getNoActions() { public final ArrayList<NoAction> getNoActions() {
return this.outgoing; return this.outgoing;
} }
public final BigInteger getPublicExponent() { public final BigInteger getPublicExponent() {
return ((RSAPublicKeyImpl) publicKey).getPublicExponent(); return ((RSAPublicKeyImpl) publicKey).getPublicExponent();
} }
public final BigInteger getModulus() { public final BigInteger getModulus() {
return ((RSAPublicKeyImpl) publicKey).getModulus(); return ((RSAPublicKeyImpl) publicKey).getModulus();
} }
public final PublicKey getRSAPublicKey() { public final PublicKey getRSAPublicKey() {
try { try {
return new RSAPublicKeyImpl(this.getModulus(), this.getPublicExponent()); return new RSAPublicKeyImpl(this.getModulus(), this.getPublicExponent());
} catch (InvalidKeyException e) { } catch (InvalidKeyException e) {
throw new NoDashFatalException("Invalid key while re-generating a RSAPublicKey.", e); throw new NoDashFatalException("Invalid key while re-generating a RSAPublicKey.", e);
} }
} }
private final byte[] decryptRSA(byte[] data) throws InvalidKeyException, IllegalBlockSizeException, BadPaddingException { private final byte[] decryptRSA(byte[] data) throws InvalidKeyException,
return NoUtil.decryptRSA(data, this.privateKey); IllegalBlockSizeException, BadPaddingException {
} return NoUtil.decryptRSA(data, this.privateKey);
}
public static NoUser createUserFromFile(byte[] data, char[] password) throws IllegalBlockSizeException, BadPaddingException, IOException, ClassNotFoundException { public static NoUser createUserFromFile(byte[] data, char[] password)
byte[] decrypted = NoUtil.decrypt(data, password); throws IllegalBlockSizeException, BadPaddingException, IOException, ClassNotFoundException {
ByteArrayInputStream bais = new ByteArrayInputStream(decrypted); byte[] decrypted = NoUtil.decrypt(data, password);
ObjectInputStream ois = new ObjectInputStream(bais); ByteArrayInputStream bais = new ByteArrayInputStream(decrypted);
NoUser noUser = (NoUser) ois.readObject(); ObjectInputStream ois = new ObjectInputStream(bais);
ois.close(); NoUser noUser = (NoUser) ois.readObject();
bais.close(); ois.close();
return noUser; bais.close();
} return noUser;
}
} }

View File

@@ -1,25 +1,22 @@
/* /*
* Copyright 2014 David Horscroft * Copyright 2014 David Horscroft
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* you may not use this file except in compliance with the License. * in compliance with the License. You may obtain a copy of the License at
* You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software distributed under the License
* distributed under the License is distributed on an "AS IS" BASIS, * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * or implied. See the License for the specific language governing permissions and limitations under
* See the License for the specific language governing permissions and * the License.
* limitations under the License.
* *
* NoErrorableAction is a subclassing of NoTargetedAction for user-server * NoErrorableAction is a subclassing of NoTargetedAction for user-server interactions that require
* interactions that require an error to be returned if a * an error to be returned if a NoCannotGetInfluenceException is thrown. The target is not a
* NoCannotGetInfluenceException is thrown. The target is not a destination user, * destination user, but is instead treated as the source.
* but is instead treated as the source.
* *
* As with all sourced actions it is advised to avoid their use unless the logic * As with all sourced actions it is advised to avoid their use unless the logic demands it, as it
* demands it, as it establishes a connection between a server action and a user address. * establishes a connection between a server action and a user address.
*/ */
package nodash.models.noactiontypes; package nodash.models.noactiontypes;
@@ -32,27 +29,27 @@ import nodash.models.NoByteSet;
import nodash.models.NoInfluence; import nodash.models.NoInfluence;
public abstract class NoErrorableAction extends NoTargetedAction { public abstract class NoErrorableAction extends NoTargetedAction {
private static final long serialVersionUID = -6077150774349400823L; private static final long serialVersionUID = -6077150774349400823L;
public NoErrorableAction(PublicKey source) { public NoErrorableAction(PublicKey source) {
// Note that // Note that
super(source); super(source);
} }
public void execute() { public void execute() {
this.process(); this.process();
try { try {
NoInfluence influence = this.generateTargetInfluence(); NoInfluence influence = this.generateTargetInfluence();
if (influence != null) { if (influence != null) {
NoByteSet byteSet = influence.getByteSet(this.target); NoByteSet byteSet = influence.getByteSet(this.target);
NoCore.addByteSet(byteSet, this.target); NoCore.addByteSet(byteSet, this.target);
} }
} catch (NoCannotGetInfluenceException e) { } catch (NoCannotGetInfluenceException e) {
NoInfluence errorInfluence = e.getResponseInfluence(); NoInfluence errorInfluence = e.getResponseInfluence();
if (errorInfluence != null) { if (errorInfluence != null) {
NoByteSet byteSet = errorInfluence.getByteSet(this.target); NoByteSet byteSet = errorInfluence.getByteSet(this.target);
NoCore.addByteSet(byteSet, this.target); NoCore.addByteSet(byteSet, this.target);
} }
} }
} }
} }

View File

@@ -1,25 +1,22 @@
/* /*
* Copyright 2014 David Horscroft * Copyright 2014 David Horscroft
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* you may not use this file except in compliance with the License. * in compliance with the License. You may obtain a copy of the License at
* You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software distributed under the License
* distributed under the License is distributed on an "AS IS" BASIS, * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * or implied. See the License for the specific language governing permissions and limitations under
* See the License for the specific language governing permissions and * the License.
* limitations under the License.
* *
* NoHandshakeAction is a subclass of the NoSourcedAction with logic to * NoHandshakeAction is a subclass of the NoSourcedAction with logic to generate an applying
* generate an applying influence as well as a returned influence, whilst * influence as well as a returned influence, whilst also being capable of returned an error
* also being capable of returned an error influence if the * influence if the NoCannotGetInfluenceException is thrown.
* NoCannotGetInfluenceException is thrown.
* *
* As with all two-way or sourced actions, their use should be sparing as * As with all two-way or sourced actions, their use should be sparing as it establishes a
* it establishes a connection between two user addresses. * connection between two user addresses.
*/ */
package nodash.models.noactiontypes; package nodash.models.noactiontypes;
@@ -32,38 +29,38 @@ import nodash.models.NoByteSet;
import nodash.models.NoInfluence; import nodash.models.NoInfluence;
public abstract class NoHandshakeAction extends NoSourcedAction { public abstract class NoHandshakeAction extends NoSourcedAction {
private static final long serialVersionUID = 3195466136587475680L; private static final long serialVersionUID = 3195466136587475680L;
protected abstract NoInfluence generateReturnedInfluence(); protected abstract NoInfluence generateReturnedInfluence();
public NoHandshakeAction(PublicKey target, PublicKey source) { public NoHandshakeAction(PublicKey target, PublicKey source) {
super(target, source); super(target, source);
} }
public void execute() { public void execute() {
this.process(); this.process();
try { try {
NoInfluence influence = this.generateTargetInfluence(); NoInfluence influence = this.generateTargetInfluence();
if (influence != null) { if (influence != null) {
NoByteSet byteSet = influence.getByteSet(this.target); NoByteSet byteSet = influence.getByteSet(this.target);
NoCore.addByteSet(byteSet, this.target); NoCore.addByteSet(byteSet, this.target);
} }
NoInfluence result = this.generateReturnedInfluence(); NoInfluence result = this.generateReturnedInfluence();
if (result != null) { if (result != null) {
NoByteSet byteSet = result.getByteSet(this.source); NoByteSet byteSet = result.getByteSet(this.source);
NoCore.addByteSet(byteSet, this.source); NoCore.addByteSet(byteSet, this.source);
} }
} catch (NoCannotGetInfluenceException e) { } catch (NoCannotGetInfluenceException e) {
NoInfluence errorInfluence = e.getResponseInfluence(); NoInfluence errorInfluence = e.getResponseInfluence();
if (errorInfluence != null) { if (errorInfluence != null) {
NoByteSet byteSet = errorInfluence.getByteSet(this.source); NoByteSet byteSet = errorInfluence.getByteSet(this.source);
NoCore.addByteSet(byteSet, this.source); NoCore.addByteSet(byteSet, this.source);
} }
} }
} }
public void purge() { public void purge() {
super.purge(); super.purge();
} }
} }

View File

@@ -1,24 +1,21 @@
/* /*
* Copyright 2014 David Horscroft * Copyright 2014 David Horscroft
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* you may not use this file except in compliance with the License. * in compliance with the License. You may obtain a copy of the License at
* You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software distributed under the License
* distributed under the License is distributed on an "AS IS" BASIS, * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * or implied. See the License for the specific language governing permissions and limitations under
* See the License for the specific language governing permissions and * the License.
* limitations under the License.
* *
* NoSourcedAction is a subclassing of NoTargetedAction which additionally * NoSourcedAction is a subclassing of NoTargetedAction which additionally has a source, allowing
* has a source, allowing for errors to be returned if a NoCannotGetInfluenceException * for errors to be returned if a NoCannotGetInfluenceException is thrown.
* is thrown.
* *
* It is not advised to make a habit of using these for all user-user interactions * It is not advised to make a habit of using these for all user-user interactions as they provide a
* as they provide a clear link between two users. * clear link between two users.
*/ */
package nodash.models.noactiontypes; package nodash.models.noactiontypes;
@@ -31,34 +28,35 @@ import nodash.models.NoByteSet;
import nodash.models.NoInfluence; import nodash.models.NoInfluence;
public abstract class NoSourcedAction extends NoTargetedAction { public abstract class NoSourcedAction extends NoTargetedAction {
private static final long serialVersionUID = -2996690472537380062L; private static final long serialVersionUID = -2996690472537380062L;
protected PublicKey source; protected PublicKey source;
protected abstract NoInfluence generateTargetInfluence() throws NoCannotGetInfluenceException;
public NoSourcedAction(PublicKey target, PublicKey source) { protected abstract NoInfluence generateTargetInfluence() throws NoCannotGetInfluenceException;
super(target);
this.source = source;
}
public void execute() { public NoSourcedAction(PublicKey target, PublicKey source) {
this.process(); super(target);
try { this.source = source;
NoInfluence influence = this.generateTargetInfluence(); }
if (influence != null) {
NoByteSet byteSet = influence.getByteSet(this.target);
NoCore.addByteSet(byteSet, this.target);
}
} catch (NoCannotGetInfluenceException e) {
NoInfluence errorInfluence = e.getResponseInfluence();
if (errorInfluence != null) {
NoByteSet byteSet = errorInfluence.getByteSet(this.source);
NoCore.addByteSet(byteSet, this.source);
}
}
}
public void purge() { public void execute() {
super.purge(); this.process();
this.source = null; try {
} NoInfluence influence = this.generateTargetInfluence();
if (influence != null) {
NoByteSet byteSet = influence.getByteSet(this.target);
NoCore.addByteSet(byteSet, this.target);
}
} catch (NoCannotGetInfluenceException e) {
NoInfluence errorInfluence = e.getResponseInfluence();
if (errorInfluence != null) {
NoByteSet byteSet = errorInfluence.getByteSet(this.source);
NoCore.addByteSet(byteSet, this.source);
}
}
}
public void purge() {
super.purge();
this.source = null;
}
} }

View File

@@ -1,20 +1,18 @@
/* /*
* Copyright 2014 David Horscroft * Copyright 2014 David Horscroft
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* you may not use this file except in compliance with the License. * in compliance with the License. You may obtain a copy of the License at
* You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software distributed under the License
* distributed under the License is distributed on an "AS IS" BASIS, * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * or implied. See the License for the specific language governing permissions and limitations under
* See the License for the specific language governing permissions and * the License.
* limitations under the License.
* *
* NoTargetedAction is an abstract subclassing of NoAction aimed at providing the * NoTargetedAction is an abstract subclassing of NoAction aimed at providing the basis for an
* basis for an action that has a user target in mind. * action that has a user target in mind.
*/ */
package nodash.models.noactiontypes; package nodash.models.noactiontypes;
@@ -29,31 +27,32 @@ import nodash.models.NoByteSet;
import nodash.models.NoInfluence; import nodash.models.NoInfluence;
public abstract class NoTargetedAction extends NoAction { public abstract class NoTargetedAction extends NoAction {
private static final long serialVersionUID = -8893381130155149646L; private static final long serialVersionUID = -8893381130155149646L;
protected PublicKey target; protected PublicKey target;
protected abstract NoInfluence generateTargetInfluence() throws NoCannotGetInfluenceException; protected abstract NoInfluence generateTargetInfluence() throws NoCannotGetInfluenceException;
public NoTargetedAction(PublicKey target) { public NoTargetedAction(PublicKey target) {
this.target = target; this.target = target;
} }
public void execute() { public void execute() {
this.process(); this.process();
try { try {
NoInfluence influence = this.generateTargetInfluence(); NoInfluence influence = this.generateTargetInfluence();
if (influence != null) { if (influence != null) {
NoByteSet byteSet = influence.getByteSet(this.target); NoByteSet byteSet = influence.getByteSet(this.target);
NoCore.addByteSet(byteSet, this.target); NoCore.addByteSet(byteSet, this.target);
} }
} catch (NoCannotGetInfluenceException e) { } catch (NoCannotGetInfluenceException e) {
if (e.getResponseInfluence() != null) { if (e.getResponseInfluence() != null) {
throw new NoDashFatalException("Unsourced action has generated an error with an undeliverable influence.", e); throw new NoDashFatalException(
} "Unsourced action has generated an error with an undeliverable influence.", e);
} }
} }
}
public void purge() { public void purge() {
this.target = null; this.target = null;
} }
} }

View File

@@ -7,26 +7,26 @@ import nodash.models.NoInfluence;
import nodash.models.noactiontypes.NoTargetedAction; import nodash.models.noactiontypes.NoTargetedAction;
public class NoActionTest extends NoTargetedAction { public class NoActionTest extends NoTargetedAction {
/** /**
* *
*/ */
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private String newName; private String newName;
public NoActionTest(PublicKey target, String newName) { public NoActionTest(PublicKey target, String newName) {
super(target); super(target);
this.newName = newName; this.newName = newName;
} }
@Override @Override
protected NoInfluence generateTargetInfluence() throws NoCannotGetInfluenceException { protected NoInfluence generateTargetInfluence() throws NoCannotGetInfluenceException {
return new NoInfluenceTest(newName); return new NoInfluenceTest(newName);
} }
@Override @Override
public void process() { public void process() {
// Nothing; // Nothing;
} }
} }

File diff suppressed because it is too large Load Diff

View File

@@ -4,20 +4,20 @@ import nodash.models.NoInfluence;
import nodash.models.NoUser; import nodash.models.NoUser;
public class NoInfluenceTest extends NoInfluence { public class NoInfluenceTest extends NoInfluence {
/** /**
* *
*/ */
private static final long serialVersionUID = 5710677031891178814L; private static final long serialVersionUID = 5710677031891178814L;
private String newName; private String newName;
public NoInfluenceTest(String newName) { public NoInfluenceTest(String newName) {
super(); super();
this.newName = newName; this.newName = newName;
} }
@Override @Override
public void applyTo(NoUser user) { public void applyTo(NoUser user) {
((NoUserTest) user).setChangableString(this.newName); ((NoUserTest) user).setChangableString(this.newName);
} }
} }

View File

@@ -3,13 +3,13 @@ package nodash.test;
import nodash.exceptions.NoDashFatalException; import nodash.exceptions.NoDashFatalException;
public class NoTestNotReadyException extends NoDashFatalException { public class NoTestNotReadyException extends NoDashFatalException {
/** /**
* *
*/ */
private static final long serialVersionUID = -8955061212302042899L; private static final long serialVersionUID = -8955061212302042899L;
public NoTestNotReadyException(String string) { public NoTestNotReadyException(String string) {
super(string); super(string);
} }
} }

View File

@@ -4,23 +4,23 @@ import nodash.models.NoUser;
public class NoUserTest extends NoUser { public class NoUserTest extends NoUser {
/** /**
* *
*/ */
private static final long serialVersionUID = 7791713515804652613L; private static final long serialVersionUID = 7791713515804652613L;
private String changableString; private String changableString;
public NoUserTest(String changableString) { public NoUserTest(String changableString) {
super(); super();
setChangableString(changableString); setChangableString(changableString);
} }
public String getChangableString() { public String getChangableString() {
return changableString; return changableString;
} }
public void setChangableString(String changableString) { public void setChangableString(String changableString) {
this.changableString = changableString; this.changableString = changableString;
} }
} }