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

@@ -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;
@@ -77,7 +74,8 @@ public final class NoConfigDefault extends NoConfigBase implements Serializable
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; this.ready = true;
return noConfig; return noConfig;

View File

@@ -6,10 +6,16 @@ import javax.crypto.SecretKey;
public interface NoConfigInterface { public interface NoConfigInterface {
public void construct(); public void construct();
public SecretKey getSecretKey(); public SecretKey getSecretKey();
public boolean saveDatabase(); public boolean saveDatabase();
public boolean saveByteSets(); public boolean saveByteSets();
public void saveNoConfig(); public void saveNoConfig();
public NoConfigInterface loadNoConfig() throws IOException; public NoConfigInterface loadNoConfig() throws IOException;
public boolean isReady(); 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;
@@ -43,8 +41,7 @@ public final class NoCore {
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) {
@@ -72,7 +69,8 @@ public final class NoCore {
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,
NoUserAlreadyOnlineException, NoSessionExpiredException {
/* steps 1 through to pre-3 */ /* steps 1 through to pre-3 */
return NoSessionSphere.login(data, password); return NoSessionSphere.login(data, password);
} }
@@ -82,26 +80,37 @@ public final class NoCore {
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 */ /*
* Facilitates step 3 allow website-side modifications to the NoUser or NoUser inheritant
*/
return NoSessionSphere.getUser(cookie); 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 */ /*
* Facilitates step 3 allow front-side to keep track of session state
*/
return NoSessionSphere.getState(cookie); 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)
throws NoSessionExpiredException, NoSessionConfirmedException, NoSessionNotChangedException,
NoSessionAlreadyAwaitingConfirmationException, NoDashSessionBadUUIDException {
/* Step 4. Provides a user with the new binary file */ /* Step 4. Provides a user with the new binary file */
return NoSessionSphere.save(cookie, password); 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,
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); NoSessionSphere.confirm(cookie, password, 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 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;

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;
@@ -106,7 +104,8 @@ public final class NoUtil {
} }
} }
public static byte[] decrypt(byte[] data, char[] password) throws IllegalBlockSizeException, BadPaddingException { public static byte[] decrypt(byte[] data, char[] password) throws IllegalBlockSizeException,
BadPaddingException {
byte[] passwordByte = NoUtil.getPBEKeyFromPassword(password); byte[] passwordByte = NoUtil.getPBEKeyFromPassword(password);
byte[] response = NoUtil.decrypt(NoUtil.decrypt(data), passwordByte); byte[] response = NoUtil.decrypt(NoUtil.decrypt(data), passwordByte);
NoUtil.wipeBytes(passwordByte); NoUtil.wipeBytes(passwordByte);
@@ -149,7 +148,8 @@ public final class NoUtil {
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,
BadPaddingException {
Cipher cipher; Cipher cipher;
try { try {
cipher = Cipher.getInstance(NoUtil.CIPHER_TYPE); cipher = Cipher.getInstance(NoUtil.CIPHER_TYPE);
@@ -177,7 +177,8 @@ public final class NoUtil {
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).",
e);
} catch (NoSuchPaddingException e) { } catch (NoSuchPaddingException e) {
throw new NoDashFatalException("Value for CIPHER_RSA_TYPE is not valid (no such padding).", e); throw new NoDashFatalException("Value for CIPHER_RSA_TYPE is not valid (no such padding).", e);
} }
@@ -193,12 +194,14 @@ public final class NoUtil {
} }
} }
public static byte[] decryptRSA(byte[] data, PrivateKey privateKey) throws InvalidKeyException, IllegalBlockSizeException, BadPaddingException { public static byte[] decryptRSA(byte[] data, PrivateKey privateKey) throws InvalidKeyException,
IllegalBlockSizeException, BadPaddingException {
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).",
e);
} catch (NoSuchPaddingException e) { } catch (NoSuchPaddingException e) {
throw new NoDashFatalException("Value for CIPHER_RSA_TYPE is not valid (no such padding).", e); throw new NoDashFatalException("Value for CIPHER_RSA_TYPE is not valid (no such padding).", e);
} }

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;
@@ -29,7 +27,8 @@ 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)) {

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,7 +36,8 @@ 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
.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
private String fileName; private String fileName;
private boolean ready = false; private boolean ready = false;

View File

@@ -6,11 +6,18 @@ import nodash.models.NoUser;
public interface NoHashSphereInterface { public interface NoHashSphereInterface {
public void setup(); public void setup();
public void saveToFile() throws IOException; public void saveToFile() throws IOException;
public void addNewNoUser(NoUser user) throws IOException; public void addNewNoUser(NoUser user) throws IOException;
public void insertHash(String hash) throws IOException; public void insertHash(String hash) throws IOException;
public void removeHash(String hash) throws IOException; public void removeHash(String hash) throws IOException;
public boolean checkHash(String hash); public boolean checkHash(String hash);
public long size(); public long size();
public boolean isReady(); 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,8 +41,10 @@ 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()) {
@@ -58,7 +58,8 @@ public final class NoSessionSphere {
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
.getOriginalHash()));
NoSessionSphere.sessions.remove(uuid); NoSessionSphere.sessions.remove(uuid);
session = null; session = null;
} }
@@ -82,7 +83,8 @@ public final class NoSessionSphere {
} }
} }
public static synchronized byte[] login(byte[] data, char[] password) throws NoUserNotValidException, NoUserAlreadyOnlineException, NoSessionExpiredException { public static synchronized byte[] login(byte[] data, char[] password)
throws NoUserNotValidException, NoUserAlreadyOnlineException, NoSessionExpiredException {
/* 1. Login with byte[] data and byte[] password */ /* 1. Login with byte[] data and byte[] password */
NoSession session = new NoSession(data, password); NoSession session = new NoSession(data, password);
/* 1.1. User currently has an online session, must wait for it to expire. */ /* 1.1. User currently has an online session, must wait for it to expire. */
@@ -117,7 +119,8 @@ public final class NoSessionSphere {
return session.getEncryptedUUID(); return session.getEncryptedUUID();
} }
public static NoUser getUser(byte[] encryptedUUID) throws NoDashSessionBadUUIDException, NoSessionExpiredException, NoSessionConfirmedException { public static NoUser getUser(byte[] encryptedUUID) throws NoDashSessionBadUUIDException,
NoSessionExpiredException, NoSessionConfirmedException {
UUID uuid = NoSession.decryptUUID(encryptedUUID); UUID uuid = NoSession.decryptUUID(encryptedUUID);
if (NoSessionSphere.sessions.containsKey(uuid)) { if (NoSessionSphere.sessions.containsKey(uuid)) {
NoSessionSphere.pruneSingle(uuid); NoSessionSphere.pruneSingle(uuid);
@@ -130,7 +133,8 @@ public final class NoSessionSphere {
throw new NoSessionExpiredException(); throw new NoSessionExpiredException();
} }
public static NoState getState(byte[] encryptedUUID) throws NoDashSessionBadUUIDException, NoSessionExpiredException, NoSessionConfirmedException { public static NoState getState(byte[] encryptedUUID) throws NoDashSessionBadUUIDException,
NoSessionExpiredException, NoSessionConfirmedException {
UUID uuid = NoSession.decryptUUID(encryptedUUID); UUID uuid = NoSession.decryptUUID(encryptedUUID);
if (NoSessionSphere.sessions.containsKey(uuid)) { if (NoSessionSphere.sessions.containsKey(uuid)) {
NoSessionSphere.pruneSingle(uuid); NoSessionSphere.pruneSingle(uuid);
@@ -140,7 +144,9 @@ public final class NoSessionSphere {
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)
throws NoDashSessionBadUUIDException, NoSessionExpiredException, NoSessionConfirmedException,
NoSessionNotChangedException, NoSessionAlreadyAwaitingConfirmationException {
UUID uuid = NoSession.decryptUUID(encryptedUUID); UUID uuid = NoSession.decryptUUID(encryptedUUID);
if (NoSessionSphere.sessions.containsKey(uuid)) { if (NoSessionSphere.sessions.containsKey(uuid)) {
NoSessionSphere.pruneSingle(uuid); NoSessionSphere.pruneSingle(uuid);
@@ -156,7 +162,9 @@ public final class NoSessionSphere {
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)
throws NoDashSessionBadUUIDException, NoSessionExpiredException, NoSessionConfirmedException,
NoSessionNotAwaitingConfirmationException, NoUserNotValidException {
UUID uuid = NoSession.decryptUUID(encryptedUUID); UUID uuid = NoSession.decryptUUID(encryptedUUID);
if (NoSessionSphere.sessions.containsKey(uuid)) { if (NoSessionSphere.sessions.containsKey(uuid)) {
NoSessionSphere.pruneSingle(uuid); NoSessionSphere.pruneSingle(uuid);
@@ -179,11 +187,14 @@ public final class NoSessionSphere {
} 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(
"Session is in confirmed state before it was returned to client.", e);
} catch (NoSessionNotChangedException e) { } catch (NoSessionNotChangedException e) {
throw new NoDashFatalException("Session claims to be unchanged but user is newly registered.", e); throw new NoDashFatalException(
"Session claims to be unchanged but user is newly registered.", e);
} catch (NoSessionAlreadyAwaitingConfirmationException e) { } catch (NoSessionAlreadyAwaitingConfirmationException e) {
throw new NoDashFatalException("Session claims to be awaiting confirmation before returning data to the user.", e); throw new NoDashFatalException(
"Session claims to be awaiting confirmation before returning data to the user.", e);
} }
return result; return result;
} }

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.
* *
* 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;

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;

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.
*/ */

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.
*/ */

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.
* *
* 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;

View File

@@ -1,21 +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.
* *
* 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;

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.
* *
* 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;

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.
* *
* 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;

View File

@@ -1,21 +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.
* *
* 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;

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.
* *
* 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;

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.
* *
* 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;

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.
* *
* 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;

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;
@@ -23,7 +21,10 @@ 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 process();
public abstract void execute(); public abstract void execute();
public abstract void purge(); public abstract void purge();
} }

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.
* *
* 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;

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.
*/ */
@@ -75,7 +73,8 @@ public abstract class NoInfluence implements Serializable {
} }
} }
public static NoInfluence decrypt(byte[] data, byte[] key) throws IllegalBlockSizeException, BadPaddingException, ClassNotFoundException { public static NoInfluence decrypt(byte[] data, byte[] key) throws IllegalBlockSizeException,
BadPaddingException, ClassNotFoundException {
byte[] decrypted = NoUtil.decrypt(data, key); byte[] decrypted = NoUtil.decrypt(data, key);
ByteArrayInputStream bais = new ByteArrayInputStream(decrypted); ByteArrayInputStream bais = new ByteArrayInputStream(decrypted);
try { try {

View File

@@ -24,6 +24,7 @@ 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 { public static enum NoState {
IDLE, MODIFIED, AWAITING_CONFIRMATION, CONFIRMED, CLOSED; IDLE, MODIFIED, AWAITING_CONFIRMATION, CONFIRMED, CLOSED;
}; };
@@ -103,7 +104,8 @@ public final class NoSession implements Serializable {
return this.state; return this.state;
} }
public byte[] initiateSaveAttempt(char[] password) throws NoSessionConfirmedException, NoSessionExpiredException { public byte[] initiateSaveAttempt(char[] password) throws NoSessionConfirmedException,
NoSessionExpiredException {
this.touchState(); this.touchState();
this.state = NoState.AWAITING_CONFIRMATION; this.state = NoState.AWAITING_CONFIRMATION;
byte[] file = this.current.createFile(password); byte[] file = this.current.createFile(password);
@@ -111,8 +113,8 @@ public final class NoSession implements Serializable {
return file; return file;
} }
public void confirmSave(byte[] confirmData, char[] password) throws NoSessionConfirmedException, NoSessionExpiredException, public void confirmSave(byte[] confirmData, char[] password) throws NoSessionConfirmedException,
NoSessionNotAwaitingConfirmationException, NoUserNotValidException { NoSessionExpiredException, NoSessionNotAwaitingConfirmationException, NoUserNotValidException {
this.check(); this.check();
if (this.state != NoState.AWAITING_CONFIRMATION) { if (this.state != NoState.AWAITING_CONFIRMATION) {
throw new NoSessionNotAwaitingConfirmationException(); throw new NoSessionNotAwaitingConfirmationException();
@@ -158,8 +160,10 @@ public final class NoSession implements Serializable {
this.current = null; this.current = null;
/* 5.2.4: execute NoActions */ /* 5.2.4: execute NoActions */
for (NoAction action : actions) { 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 */ * 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.execute();
action.purge(); action.purge();
} }

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;
@@ -68,7 +66,8 @@ public class NoUser implements Serializable {
} }
try { try {
kpg.initialize(NoUtil.RSA_STRENGTH, SecureRandom.getInstance(NoUtil.SECURERANDOM_ALGORITHM, NoUtil.SECURERANDOM_PROVIDER)); kpg.initialize(NoUtil.RSA_STRENGTH,
SecureRandom.getInstance(NoUtil.SECURERANDOM_ALGORITHM, NoUtil.SECURERANDOM_PROVIDER));
} 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);
} catch (NoSuchProviderException e) { } catch (NoSuchProviderException e) {
@@ -106,7 +105,8 @@ public class NoUser implements Serializable {
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(
"IO Exception encountered while generating encrypted user file byte stream.", e);
} finally { } finally {
this.outgoing = temp; this.outgoing = temp;
} }
@@ -178,11 +178,13 @@ public class NoUser implements Serializable {
} }
} }
private final byte[] decryptRSA(byte[] data) throws InvalidKeyException, IllegalBlockSizeException, BadPaddingException { private final byte[] decryptRSA(byte[] data) throws InvalidKeyException,
IllegalBlockSizeException, BadPaddingException {
return NoUtil.decryptRSA(data, this.privateKey); 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)
throws IllegalBlockSizeException, BadPaddingException, IOException, ClassNotFoundException {
byte[] decrypted = NoUtil.decrypt(data, password); byte[] decrypted = NoUtil.decrypt(data, password);
ByteArrayInputStream bais = new ByteArrayInputStream(decrypted); ByteArrayInputStream bais = new ByteArrayInputStream(decrypted);
ObjectInputStream ois = new ObjectInputStream(bais); ObjectInputStream ois = new ObjectInputStream(bais);

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;

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;

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;
@@ -33,6 +30,7 @@ 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; protected abstract NoInfluence generateTargetInfluence() throws NoCannotGetInfluenceException;
public NoSourcedAction(PublicKey target, PublicKey source) { public NoSourcedAction(PublicKey target, PublicKey source) {

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;
@@ -48,7 +46,8 @@ public abstract class NoTargetedAction extends NoAction {
} }
} 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);
} }
} }
} }

View File

@@ -16,18 +16,9 @@ import nodash.exceptions.NoUserNotValidException;
import nodash.models.NoSession.NoState; import nodash.models.NoSession.NoState;
public class NoCoreTest { public class NoCoreTest {
private static final String[] CHANGE = new String[] { private static final String[] CHANGE = new String[] {"first-string", "second-string",
"first-string", "third-string", "forth-string", "fifth-string", "sixth-string", "seventh-string",
"second-string", "eighth-string", "ninth-string", "tenth-string"};
"third-string",
"forth-string",
"fifth-string",
"sixth-string",
"seventh-string",
"eighth-string",
"ninth-string",
"tenth-string"
};
private static Iterator<String> CHANGES = Arrays.asList(CHANGE).iterator(); private static Iterator<String> CHANGES = Arrays.asList(CHANGE).iterator();
private static final String PASSWORD = "password"; private static final String PASSWORD = "password";
@@ -132,7 +123,8 @@ public class NoCoreTest {
printIf("NoDashSessionBadUUIDException thrown, passed."); printIf("NoDashSessionBadUUIDException thrown, passed.");
return true; return true;
} catch (Exception e) { } catch (Exception e) {
logger.severe("Wrong error thrown, should have been NoDashSessionBadUUIDException, was " + e.getClass().getSimpleName()); logger.severe("Wrong error thrown, should have been NoDashSessionBadUUIDException, was "
+ e.getClass().getSimpleName());
printIf(e); printIf(e);
} }
return false; return false;
@@ -151,7 +143,8 @@ public class NoCoreTest {
printIf("NoUserNotValidException thrown, passed."); printIf("NoUserNotValidException thrown, passed.");
return true; return true;
} catch (Exception e) { } catch (Exception e) {
logger.severe("Wrong error thrown, should have been NoUserNotValidException, was " + e.getClass().getSimpleName()); logger.severe("Wrong error thrown, should have been NoUserNotValidException, was "
+ e.getClass().getSimpleName());
printIf(e); printIf(e);
} }
return false; return false;
@@ -169,7 +162,8 @@ public class NoCoreTest {
printIf("NoUserNotValidException thrown, passed."); printIf("NoUserNotValidException thrown, passed.");
return true; return true;
} catch (Exception e) { } catch (Exception e) {
logger.severe("Wrong error thrown, should have been NoUserNotValidException, was " + e.getClass().getSimpleName()); logger.severe("Wrong error thrown, should have been NoUserNotValidException, was "
+ e.getClass().getSimpleName());
printIf(e); printIf(e);
} }
return false; return false;
@@ -223,7 +217,8 @@ public class NoCoreTest {
} }
if (!accessed.getPublicExponent().equals(user.getPublicExponent())) { if (!accessed.getPublicExponent().equals(user.getPublicExponent())) {
logger.severe("Received user object from getUser has a different Public Exponent to the registered user."); logger
.severe("Received user object from getUser has a different Public Exponent to the registered user.");
return false; return false;
} }
@@ -260,7 +255,8 @@ public class NoCoreTest {
try { try {
NoCore.confirm(register.cookie, PASSWORD.toCharArray(), register.data); NoCore.confirm(register.cookie, PASSWORD.toCharArray(), register.data);
} catch (Exception e) { } catch (Exception e) {
logger.severe("Error encountered while trying to register, of type " + e.getClass().getSimpleName()); logger.severe("Error encountered while trying to register, of type "
+ e.getClass().getSimpleName());
printIf(e); printIf(e);
throw new NoTestNotReadyException("Failed to set up user file."); throw new NoTestNotReadyException("Failed to set up user file.");
} }
@@ -274,12 +270,14 @@ public class NoCoreTest {
byte[] cookie = null; byte[] cookie = null;
try { try {
cookie = NoCore.login(copy(data), BAD_PASSWORD.toCharArray()); cookie = NoCore.login(copy(data), BAD_PASSWORD.toCharArray());
logger.severe("Cookie (" + Base64.encodeBase64(cookie) + ") returned, even with bad password."); logger.severe("Cookie (" + Base64.encodeBase64(cookie)
+ ") returned, even with bad password.");
} catch (NoUserNotValidException e) { } catch (NoUserNotValidException e) {
printIf("NoUserNotValidException thrown, passed."); printIf("NoUserNotValidException thrown, passed.");
return true; return true;
} catch (Exception e) { } catch (Exception e) {
logger.severe("Wrong error thrown, should have been NoUserNotValidException, was " + e.getClass().getSimpleName()); logger.severe("Wrong error thrown, should have been NoUserNotValidException, was "
+ e.getClass().getSimpleName());
printIf(e); printIf(e);
} finally { } finally {
NoCore.shred(cookie); NoCore.shred(cookie);
@@ -302,7 +300,8 @@ public class NoCoreTest {
printIf("NoUserNotValidException thrown, passed."); printIf("NoUserNotValidException thrown, passed.");
return true; return true;
} catch (Exception e) { } catch (Exception e) {
logger.severe("Wrong error thrown, should have been NoUserNotValidException, was " + e.getClass().getSimpleName()); logger.severe("Wrong error thrown, should have been NoUserNotValidException, was "
+ e.getClass().getSimpleName());
printIf(e); printIf(e);
} finally { } finally {
NoCore.shred(cookie); NoCore.shred(cookie);
@@ -328,12 +327,14 @@ public class NoCoreTest {
byte[] secondCookie = null; byte[] secondCookie = null;
try { try {
secondCookie = NoCore.login(copy(data), PASSWORD.toCharArray()); secondCookie = NoCore.login(copy(data), PASSWORD.toCharArray());
logger.severe("Cookie (" + new String(secondCookie) + ") returned, even with concurrent session."); logger.severe("Cookie (" + new String(secondCookie)
+ ") returned, even with concurrent session.");
} catch (NoUserAlreadyOnlineException e) { } catch (NoUserAlreadyOnlineException e) {
printIf("NoUserAlreadyOnlineException thrown, passed."); printIf("NoUserAlreadyOnlineException thrown, passed.");
return true; return true;
} catch (Exception e) { } catch (Exception e) {
logger.severe("Wrong error thrown, should have been NoUserAlreadyOnlineException, was " + e.getClass().getSimpleName()); logger.severe("Wrong error thrown, should have been NoUserAlreadyOnlineException, was "
+ e.getClass().getSimpleName());
printIf(e); printIf(e);
} finally { } finally {
NoCore.shred(secondCookie); NoCore.shred(secondCookie);
@@ -380,7 +381,8 @@ public class NoCoreTest {
return false; return false;
} }
} catch (Exception e) { } catch (Exception e) {
logger.severe("Error thrown, should have returned state, was " + e.getClass().getSimpleName()); logger
.severe("Error thrown, should have returned state, was " + e.getClass().getSimpleName());
printIf(e); printIf(e);
return false; return false;
} }
@@ -416,8 +418,7 @@ public class NoCoreTest {
} }
/* /*
* END Login methods * END Login methods BEGIN Login-Logout methods
* BEGIN Login-Logout methods
*/ */
public static boolean testLoginModifyLogout(byte[] data) { public static boolean testLoginModifyLogout(byte[] data) {
@@ -428,7 +429,8 @@ public class NoCoreTest {
try { try {
cookie = NoCore.login(copy(data), PASSWORD.toCharArray()); cookie = NoCore.login(copy(data), PASSWORD.toCharArray());
} catch (Exception e) { } catch (Exception e) {
logger.severe("Error thrown, should have returned cookie, was " + e.getClass().getSimpleName()); logger.severe("Error thrown, should have returned cookie, was "
+ e.getClass().getSimpleName());
printIf(e); printIf(e);
return false; return false;
} }
@@ -450,7 +452,8 @@ public class NoCoreTest {
try { try {
stateModified = NoCore.getSessionState(cookie); stateModified = NoCore.getSessionState(cookie);
} catch (Exception e) { } catch (Exception e) {
logger.severe("Error thrown, should have returned state, was " + e.getClass().getSimpleName()); logger
.severe("Error thrown, should have returned state, was " + e.getClass().getSimpleName());
printIf(e); printIf(e);
NoCore.shred(cookie); NoCore.shred(cookie);
return false; return false;
@@ -466,7 +469,8 @@ public class NoCoreTest {
try { try {
newData = NoCore.requestSave(cookie, PASSWORD.toCharArray()); newData = NoCore.requestSave(cookie, PASSWORD.toCharArray());
} catch (Exception e) { } catch (Exception e) {
logger.severe("Error thrown, should have returned new byte array, was " + e.getClass().getSimpleName()); logger.severe("Error thrown, should have returned new byte array, was "
+ e.getClass().getSimpleName());
printIf(e); printIf(e);
NoCore.shred(cookie); NoCore.shred(cookie);
return false; return false;
@@ -477,7 +481,8 @@ public class NoCoreTest {
try { try {
stateAwaiting = NoCore.getSessionState(cookie); stateAwaiting = NoCore.getSessionState(cookie);
} catch (Exception e) { } catch (Exception e) {
logger.severe("Error thrown, should have returned state, was " + e.getClass().getSimpleName()); logger
.severe("Error thrown, should have returned state, was " + e.getClass().getSimpleName());
printIf(e); printIf(e);
NoCore.shred(cookie); NoCore.shred(cookie);
return false; return false;
@@ -508,7 +513,8 @@ public class NoCoreTest {
} catch (NoSessionConfirmedException e) { } catch (NoSessionConfirmedException e) {
printIf("NoSessionConfirmed exception thrown."); printIf("NoSessionConfirmed exception thrown.");
} catch (Exception e) { } catch (Exception e) {
logger.severe("Error thrown, should have been NoSessionConfirmedException, was " + e.getClass().getSimpleName()); logger.severe("Error thrown, should have been NoSessionConfirmedException, was "
+ e.getClass().getSimpleName());
printIf(e); printIf(e);
return false; return false;
} finally { } finally {
@@ -519,7 +525,8 @@ public class NoCoreTest {
try { try {
cookie = NoCore.login(copy(data), PASSWORD.toCharArray()); cookie = NoCore.login(copy(data), PASSWORD.toCharArray());
} catch (Exception e) { } catch (Exception e) {
logger.severe("Error thrown, should have returned cookie, was " + e.getClass().getSimpleName()); logger.severe("Error thrown, should have returned cookie, was "
+ e.getClass().getSimpleName());
printIf(e); printIf(e);
return false; return false;
} }
@@ -528,7 +535,8 @@ public class NoCoreTest {
try { try {
user = (NoUserTest) NoCore.getUser(cookie); user = (NoUserTest) NoCore.getUser(cookie);
} catch (Exception e) { } catch (Exception e) {
logger.severe("Error thrown on second login, should have returned user, was " + e.getClass().getSimpleName()); logger.severe("Error thrown on second login, should have returned user, was "
+ e.getClass().getSimpleName());
printIf(e); printIf(e);
return false; return false;
} }
@@ -559,7 +567,8 @@ public class NoCoreTest {
address = user.getRSAPublicKey(); address = user.getRSAPublicKey();
currentString = user.getChangableString(); currentString = user.getChangableString();
} catch (Exception e) { } catch (Exception e) {
logger.severe("Error thrown on address-getting login, gotten address and string, was " + e.getClass().getSimpleName()); logger.severe("Error thrown on address-getting login, gotten address and string, was "
+ e.getClass().getSimpleName());
printIf(e); printIf(e);
return false; return false;
} finally { } finally {
@@ -573,7 +582,8 @@ public class NoCoreTest {
try { try {
secondUserCookie = NoCore.login(copy(secondUserData), PASSWORD.toCharArray()); secondUserCookie = NoCore.login(copy(secondUserData), PASSWORD.toCharArray());
} catch (Exception e) { } catch (Exception e) {
logger.severe("Error thrown on second user login, should have returned cookie, was " + e.getClass().getSimpleName()); logger.severe("Error thrown on second user login, should have returned cookie, was "
+ e.getClass().getSimpleName());
printIf(e); printIf(e);
return false; return false;
} }
@@ -582,7 +592,8 @@ public class NoCoreTest {
try { try {
user = (NoUserTest) NoCore.getUser(secondUserCookie); user = (NoUserTest) NoCore.getUser(secondUserCookie);
} catch (Exception e) { } catch (Exception e) {
logger.severe("Error thrown on second user login, should have returned user, was " + e.getClass().getSimpleName()); logger.severe("Error thrown on second user login, should have returned user, was "
+ e.getClass().getSimpleName());
printIf(e); printIf(e);
return false; return false;
} }
@@ -597,7 +608,8 @@ public class NoCoreTest {
secondUserData = NoCore.requestSave(secondUserCookie, PASSWORD.toCharArray()); secondUserData = NoCore.requestSave(secondUserCookie, PASSWORD.toCharArray());
NoCore.confirm(secondUserCookie, PASSWORD.toCharArray(), copy(secondUserData)); NoCore.confirm(secondUserCookie, PASSWORD.toCharArray(), copy(secondUserData));
} catch (Exception e) { } catch (Exception e) {
logger.severe("Error thrown on second user confirm, should have returned user, was " + e.getClass().getSimpleName()); logger.severe("Error thrown on second user confirm, should have returned user, was "
+ e.getClass().getSimpleName());
printIf(e); printIf(e);
NoCore.shred(secondUserCookie); NoCore.shred(secondUserCookie);
return false; return false;
@@ -609,7 +621,8 @@ public class NoCoreTest {
try { try {
cookie = NoCore.login(copy(data), PASSWORD.toCharArray()); cookie = NoCore.login(copy(data), PASSWORD.toCharArray());
} catch (Exception e) { } catch (Exception e) {
logger.severe("Error thrown on first user, second login, should have returned cookie, was " + e.getClass().getSimpleName()); logger.severe("Error thrown on first user, second login, should have returned cookie, was "
+ e.getClass().getSimpleName());
printIf(e); printIf(e);
return false; return false;
} }
@@ -618,7 +631,8 @@ public class NoCoreTest {
try { try {
state = NoCore.getSessionState(cookie); state = NoCore.getSessionState(cookie);
} catch (Exception e) { } catch (Exception e) {
logger.severe("Error thrown on first user, second login, should have returned state, was " + e.getClass().getSimpleName()); logger.severe("Error thrown on first user, second login, should have returned state, was "
+ e.getClass().getSimpleName());
printIf(e); printIf(e);
NoCore.shred(cookie); NoCore.shred(cookie);
return false; return false;
@@ -631,7 +645,8 @@ public class NoCoreTest {
try { try {
user = (NoUserTest) NoCore.getUser(cookie); user = (NoUserTest) NoCore.getUser(cookie);
} catch (Exception e) { } catch (Exception e) {
logger.severe("Error thrown on first user, second login, should have returned user, was " + e.getClass().getSimpleName()); logger.severe("Error thrown on first user, second login, should have returned user, was "
+ e.getClass().getSimpleName());
printIf(e); printIf(e);
NoCore.shred(cookie); NoCore.shred(cookie);
return false; return false;
@@ -641,7 +656,8 @@ public class NoCoreTest {
logger.severe("User information has not changed (still " + user.getChangableString() + ")."); logger.severe("User information has not changed (still " + user.getChangableString() + ").");
return false; return false;
} }
printIf("User string changed on first return login, (" + currentString + " to " + user.getChangableString() + ")!"); printIf("User string changed on first return login, (" + currentString + " to "
+ user.getChangableString() + ")!");
// Test that the influence resets accordingly on hotpull // Test that the influence resets accordingly on hotpull
NoCore.shred(cookie); NoCore.shred(cookie);
@@ -649,7 +665,8 @@ public class NoCoreTest {
try { try {
cookie = NoCore.login(copy(data), PASSWORD.toCharArray()); cookie = NoCore.login(copy(data), PASSWORD.toCharArray());
} catch (Exception e) { } catch (Exception e) {
logger.severe("Error thrown on first user, third login, should have returned cookie, was " + e.getClass().getSimpleName()); logger.severe("Error thrown on first user, third login, should have returned cookie, was "
+ e.getClass().getSimpleName());
printIf(e); printIf(e);
return false; return false;
} }
@@ -657,7 +674,8 @@ public class NoCoreTest {
try { try {
state = NoCore.getSessionState(cookie); state = NoCore.getSessionState(cookie);
} catch (Exception e) { } catch (Exception e) {
logger.severe("Error thrown on first user, third login, should have returned state, was " + e.getClass().getSimpleName()); logger.severe("Error thrown on first user, third login, should have returned state, was "
+ e.getClass().getSimpleName());
printIf(e); printIf(e);
NoCore.shred(cookie); NoCore.shred(cookie);
return false; return false;
@@ -670,7 +688,8 @@ public class NoCoreTest {
try { try {
user = (NoUserTest) NoCore.getUser(cookie); user = (NoUserTest) NoCore.getUser(cookie);
} catch (Exception e) { } catch (Exception e) {
logger.severe("Error thrown on first user, third login, should have returned user, was " + e.getClass().getSimpleName()); logger.severe("Error thrown on first user, third login, should have returned user, was "
+ e.getClass().getSimpleName());
printIf(e); printIf(e);
NoCore.shred(cookie); NoCore.shred(cookie);
return false; return false;
@@ -680,7 +699,8 @@ public class NoCoreTest {
logger.severe("User information has not changed (still " + user.getChangableString() + ")."); logger.severe("User information has not changed (still " + user.getChangableString() + ").");
return false; return false;
} }
printIf("User string changed on second return login, (" + currentString + " to " + user.getChangableString() + ")!"); printIf("User string changed on second return login, (" + currentString + " to "
+ user.getChangableString() + ")!");
// Save-confirm // Save-confirm
try { try {
@@ -688,7 +708,8 @@ public class NoCoreTest {
NoCore.confirm(cookie, PASSWORD.toCharArray(), copy(data)); NoCore.confirm(cookie, PASSWORD.toCharArray(), copy(data));
passoverData = copy(data); passoverData = copy(data);
} catch (Exception e) { } catch (Exception e) {
logger.severe("Error thrown on first user, save-confirm, was " + e.getClass().getSimpleName()); logger
.severe("Error thrown on first user, save-confirm, was " + e.getClass().getSimpleName());
printIf(e); printIf(e);
return false; return false;
} }
@@ -698,7 +719,8 @@ public class NoCoreTest {
try { try {
cookie = NoCore.login(copy(data), PASSWORD.toCharArray()); cookie = NoCore.login(copy(data), PASSWORD.toCharArray());
} catch (Exception e) { } catch (Exception e) {
logger.severe("Error thrown on first user, final login, should have returned cookie, was " + e.getClass().getSimpleName()); logger.severe("Error thrown on first user, final login, should have returned cookie, was "
+ e.getClass().getSimpleName());
printIf(e); printIf(e);
return false; return false;
} }
@@ -706,7 +728,8 @@ public class NoCoreTest {
try { try {
state = NoCore.getSessionState(cookie); state = NoCore.getSessionState(cookie);
} catch (Exception e) { } catch (Exception e) {
logger.severe("Error thrown on first user, final login, should have returned state, was " + e.getClass().getSimpleName()); logger.severe("Error thrown on first user, final login, should have returned state, was "
+ e.getClass().getSimpleName());
printIf(e); printIf(e);
NoCore.shred(cookie); NoCore.shred(cookie);
return false; return false;
@@ -719,7 +742,8 @@ public class NoCoreTest {
try { try {
user = (NoUserTest) NoCore.getUser(cookie); user = (NoUserTest) NoCore.getUser(cookie);
} catch (Exception e) { } catch (Exception e) {
logger.severe("Error thrown on first user, final login, should have returned user, was " + e.getClass().getSimpleName()); logger.severe("Error thrown on first user, final login, should have returned user, was "
+ e.getClass().getSimpleName());
printIf(e); printIf(e);
NoCore.shred(cookie); NoCore.shred(cookie);
return false; return false;
@@ -729,7 +753,8 @@ public class NoCoreTest {
logger.severe("User information has not changed (still " + user.getChangableString() + ")."); logger.severe("User information has not changed (still " + user.getChangableString() + ").");
return false; return false;
} }
printIf("User string changed on final login (" + currentString + " to " + user.getChangableString() + "), while IDLE!"); printIf("User string changed on final login (" + currentString + " to "
+ user.getChangableString() + "), while IDLE!");
return true; return true;
} }