formatting
This commit is contained in:
@@ -1,20 +1,17 @@
|
||||
/*
|
||||
* Copyright 2014 David Horscroft
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*
|
||||
* The NoConfig is a means to store the server secret key, database address
|
||||
* and other configs.
|
||||
* The NoConfig is a means to store the server secret key, database address and other configs.
|
||||
*/
|
||||
|
||||
package nodash.core;
|
||||
@@ -77,7 +74,8 @@ public final class NoConfigDefault extends NoConfigBase implements Serializable
|
||||
try {
|
||||
noConfig = (NoConfigDefault) ois.readObject();
|
||||
} 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;
|
||||
|
||||
@@ -6,10 +6,16 @@ import javax.crypto.SecretKey;
|
||||
|
||||
public interface NoConfigInterface {
|
||||
public void construct();
|
||||
|
||||
public SecretKey getSecretKey();
|
||||
|
||||
public boolean saveDatabase();
|
||||
|
||||
public boolean saveByteSets();
|
||||
|
||||
public void saveNoConfig();
|
||||
|
||||
public NoConfigInterface loadNoConfig() throws IOException;
|
||||
|
||||
public boolean isReady();
|
||||
}
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
/*
|
||||
* Copyright 2014 David Horscroft
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*
|
||||
* The NoCore class is the interface between which the wrapper application
|
||||
* (wrapplication?) accesses no- functionality.
|
||||
* The NoCore class is the interface between which the wrapper application (wrapplication?) accesses
|
||||
* no- functionality.
|
||||
*/
|
||||
|
||||
package nodash.core;
|
||||
@@ -43,8 +41,7 @@ public final class NoCore {
|
||||
public static NoHashSphereInterface hashSphere;
|
||||
|
||||
public static boolean isReady() {
|
||||
return (config != null && config.isReady()) &&
|
||||
(hashSphere != null && hashSphere.isReady());
|
||||
return (config != null && config.isReady()) && (hashSphere != null && hashSphere.isReady());
|
||||
}
|
||||
|
||||
public static void setup(NoConfigInterface config, NoHashSphereInterface hashSphere) {
|
||||
@@ -72,7 +69,8 @@ public final class NoCore {
|
||||
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 */
|
||||
return NoSessionSphere.login(data, password);
|
||||
}
|
||||
@@ -82,26 +80,37 @@ public final class NoCore {
|
||||
return NoSessionSphere.registerUser(user, password);
|
||||
}
|
||||
|
||||
public static NoUser getUser(byte[] cookie) throws NoSessionExpiredException, NoSessionConfirmedException, NoDashSessionBadUUIDException {
|
||||
/* Facilitates step 3
|
||||
* allow website-side modifications to the NoUser or NoUser inheritant */
|
||||
public static NoUser getUser(byte[] cookie) throws NoSessionExpiredException,
|
||||
NoSessionConfirmedException, NoDashSessionBadUUIDException {
|
||||
/*
|
||||
* 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 {
|
||||
/* Facilitates step 3
|
||||
* allow front-side to keep track of session state */
|
||||
public static NoState getSessionState(byte[] cookie) throws NoSessionExpiredException,
|
||||
NoSessionConfirmedException, NoDashSessionBadUUIDException {
|
||||
/*
|
||||
* 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)
|
||||
throws NoSessionExpiredException, NoSessionConfirmedException, NoSessionNotChangedException,
|
||||
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 {
|
||||
/* 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*/
|
||||
public static void confirm(byte[] cookie, char[] password, byte[] data)
|
||||
throws NoSessionExpiredException, NoSessionConfirmedException,
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
/*
|
||||
* Copyright 2014 David Horscroft
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*
|
||||
* The NoRegister class is a simple model used to return both cookies and
|
||||
* download data upon user registration.
|
||||
* The NoRegister class is a simple model used to return both cookies and download data upon user
|
||||
* registration.
|
||||
*/
|
||||
|
||||
package nodash.core;
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
/*
|
||||
* Copyright 2014 David Horscroft
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*
|
||||
* The NoUtil class encapsulates no- standard functions such as encryption/decryption
|
||||
* and hashing algorithms.
|
||||
* The NoUtil class encapsulates no- standard functions such as encryption/decryption and hashing
|
||||
* algorithms.
|
||||
*/
|
||||
|
||||
package nodash.core;
|
||||
@@ -53,7 +51,7 @@ public final class NoUtil {
|
||||
|
||||
public static char[] bytesToChars(byte[] array) {
|
||||
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];
|
||||
}
|
||||
return result;
|
||||
@@ -61,20 +59,20 @@ public final class NoUtil {
|
||||
|
||||
public static byte[] charsToBytes(char[] array) {
|
||||
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];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -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[] response = NoUtil.decrypt(NoUtil.decrypt(data), passwordByte);
|
||||
NoUtil.wipeBytes(passwordByte);
|
||||
@@ -149,7 +148,8 @@ public final class NoUtil {
|
||||
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;
|
||||
try {
|
||||
cipher = Cipher.getInstance(NoUtil.CIPHER_TYPE);
|
||||
@@ -177,14 +177,15 @@ public final class NoUtil {
|
||||
try {
|
||||
cipher = Cipher.getInstance(NoUtil.CIPHER_RSA_TYPE);
|
||||
} 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) {
|
||||
throw new NoDashFatalException("Value for CIPHER_RSA_TYPE is not valid (no such padding).", e);
|
||||
}
|
||||
try {
|
||||
cipher.init(Cipher.ENCRYPT_MODE, publicKey);
|
||||
return cipher.doFinal(data);
|
||||
} catch (InvalidKeyException e){
|
||||
} catch (InvalidKeyException e) {
|
||||
throw new NoDashFatalException("Public key invalid.", e);
|
||||
} catch (IllegalBlockSizeException e) {
|
||||
throw new NoDashFatalException("Unable to encrypt data stream with public key.", 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;
|
||||
try {
|
||||
cipher = Cipher.getInstance(NoUtil.CIPHER_RSA_TYPE);
|
||||
} 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) {
|
||||
throw new NoDashFatalException("Value for CIPHER_RSA_TYPE is not valid (no such padding).", e);
|
||||
}
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
/*
|
||||
* Copyright 2014 David Horscroft
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*
|
||||
* The NoByteSetSphere stores user-to-user influences and their encryption
|
||||
* keys in an accessible manner.
|
||||
* The NoByteSetSphere stores user-to-user influences and their encryption keys in an accessible
|
||||
* manner.
|
||||
*/
|
||||
|
||||
package nodash.core.spheres;
|
||||
@@ -29,7 +27,8 @@ import nodash.models.NoUser;
|
||||
public final class NoByteSetSphere {
|
||||
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) {
|
||||
if (!NoByteSetSphere.byteSets.containsKey(publicKey)) {
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
/*
|
||||
* Copyright 2014 David Horscroft
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*
|
||||
* The NoHashSpehre stores database hashes for user verification.
|
||||
*
|
||||
@@ -38,7 +36,8 @@ import nodash.exceptions.NoDashFatalException;
|
||||
import nodash.models.NoUser;
|
||||
|
||||
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 boolean ready = false;
|
||||
|
||||
@@ -47,7 +46,7 @@ public final class NoHashSphereDefault implements NoHashSphereInterface {
|
||||
}
|
||||
|
||||
public NoHashSphereDefault() {
|
||||
this.fileName = ( (NoConfigDefault) NoCore.config).getDatabaseName();
|
||||
this.fileName = ((NoConfigDefault) NoCore.config).getDatabaseName();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -62,7 +61,7 @@ public final class NoHashSphereDefault implements NoHashSphereInterface {
|
||||
this.database = (Set<String>) ois.readObject();
|
||||
ois.close();
|
||||
bais.close();
|
||||
} catch (IOException e){
|
||||
} catch (IOException e) {
|
||||
throw new NoDashFatalException("Unable to load up given database file.", e);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new NoDashFatalException("Database file not in a verifiable format.", e);
|
||||
@@ -79,7 +78,7 @@ public final class NoHashSphereDefault implements NoHashSphereInterface {
|
||||
byte[] data = baos.toByteArray();
|
||||
oos.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);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,11 +6,18 @@ import nodash.models.NoUser;
|
||||
|
||||
public interface NoHashSphereInterface {
|
||||
public void setup();
|
||||
|
||||
public void saveToFile() throws IOException;
|
||||
|
||||
public void addNewNoUser(NoUser user) throws IOException;
|
||||
|
||||
public void insertHash(String hash) throws IOException;
|
||||
|
||||
public void removeHash(String hash) throws IOException;
|
||||
|
||||
public boolean checkHash(String hash);
|
||||
|
||||
public long size();
|
||||
|
||||
public boolean isReady();
|
||||
}
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
/*
|
||||
* Copyright 2014 David Horscroft
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*
|
||||
* The NoSessionSphere stores user sessions and allows their access and
|
||||
* manipulation with the use of their UUID.
|
||||
* The NoSessionSphere stores user sessions and allows their access and manipulation with the use of
|
||||
* their UUID.
|
||||
*/
|
||||
|
||||
package nodash.core.spheres;
|
||||
@@ -43,8 +41,10 @@ import nodash.models.NoUser;
|
||||
import nodash.models.NoSession.NoState;
|
||||
|
||||
public final class NoSessionSphere {
|
||||
private static ConcurrentHashMap<UUID, NoSession> sessions = new ConcurrentHashMap<UUID, NoSession>();
|
||||
private static Set<String> originalHashesOnline = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
|
||||
private static ConcurrentHashMap<UUID, NoSession> sessions =
|
||||
new ConcurrentHashMap<UUID, NoSession>();
|
||||
private static Set<String> originalHashesOnline = Collections
|
||||
.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
|
||||
|
||||
public static synchronized void prune() {
|
||||
for (UUID uuid : NoSessionSphere.sessions.keySet()) {
|
||||
@@ -58,7 +58,8 @@ public final class NoSessionSphere {
|
||||
if (NoSessionSphere.sessions.containsKey(uuid)) {
|
||||
NoSession session = NoSessionSphere.sessions.get(uuid);
|
||||
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);
|
||||
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 */
|
||||
NoSession session = new NoSession(data, password);
|
||||
/* 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();
|
||||
}
|
||||
|
||||
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);
|
||||
if (NoSessionSphere.sessions.containsKey(uuid)) {
|
||||
NoSessionSphere.pruneSingle(uuid);
|
||||
@@ -130,7 +133,8 @@ public final class NoSessionSphere {
|
||||
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);
|
||||
if (NoSessionSphere.sessions.containsKey(uuid)) {
|
||||
NoSessionSphere.pruneSingle(uuid);
|
||||
@@ -140,7 +144,9 @@ public final class NoSessionSphere {
|
||||
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);
|
||||
if (NoSessionSphere.sessions.containsKey(uuid)) {
|
||||
NoSessionSphere.pruneSingle(uuid);
|
||||
@@ -156,7 +162,9 @@ public final class NoSessionSphere {
|
||||
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);
|
||||
if (NoSessionSphere.sessions.containsKey(uuid)) {
|
||||
NoSessionSphere.pruneSingle(uuid);
|
||||
@@ -179,11 +187,14 @@ public final class NoSessionSphere {
|
||||
} catch (NoSessionExpiredException e) {
|
||||
throw new NoDashFatalException("Session expired before it was even returned to client.", 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) {
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -1,20 +1,17 @@
|
||||
/*
|
||||
* Copyright 2014 David Horscroft
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*
|
||||
* NoByteSetBadDecryptionException is triggered when no- is unable to
|
||||
* decrypt a given byte stream.
|
||||
* NoByteSetBadDecryptionException is triggered when no- is unable to decrypt a given byte stream.
|
||||
*/
|
||||
|
||||
package nodash.exceptions;
|
||||
|
||||
@@ -1,21 +1,19 @@
|
||||
/*
|
||||
* Copyright 2014 David Horscroft
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*
|
||||
* NoCannotGetInfluenceException is returned when an action is unable to
|
||||
* render a successful influence for the target, instead returning an
|
||||
* influence to be returned to the sender if possible.
|
||||
* NoCannotGetInfluenceException is returned when an action is unable to render a successful
|
||||
* influence for the target, instead returning an influence to be returned to the sender if
|
||||
* possible.
|
||||
*/
|
||||
|
||||
package nodash.exceptions;
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
/*
|
||||
* Copyright 2014 David Horscroft
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*
|
||||
* NoDashException is the base class for no- related exceptions.
|
||||
*/
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
/*
|
||||
* Copyright 2014 David Horscroft
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*
|
||||
* NoDashFatalException is the base exception for no- related runtime exceptions.
|
||||
*/
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
/*
|
||||
* Copyright 2014 David Horscroft
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*
|
||||
* NoDashSessionBadUUIDException is triggered when the NoSessionSphere is
|
||||
* unable to find a valid session for the provided UUID.
|
||||
* NoDashSessionBadUUIDException is triggered when the NoSessionSphere is unable to find a valid
|
||||
* session for the provided UUID.
|
||||
*/
|
||||
|
||||
package nodash.exceptions;
|
||||
|
||||
@@ -1,21 +1,18 @@
|
||||
/*
|
||||
* Copyright 2014 David Horscroft
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*
|
||||
* NoSessionAlreadyAWaitingConfirmationException is triggered when a
|
||||
* save request is attempted for a session, but it is already awaiting
|
||||
* a confirmation upload.
|
||||
* NoSessionAlreadyAWaitingConfirmationException is triggered when a save request is attempted for a
|
||||
* session, but it is already awaiting a confirmation upload.
|
||||
*/
|
||||
|
||||
package nodash.exceptions;
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
/*
|
||||
* Copyright 2014 David Horscroft
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*
|
||||
* NoSessionConfirmedException is triggered when an interaction attempt is
|
||||
* made on a session that has recently been confirmed and thus closed.
|
||||
* NoSessionConfirmedException is triggered when an interaction attempt is made on a session that
|
||||
* has recently been confirmed and thus closed.
|
||||
*/
|
||||
|
||||
package nodash.exceptions;
|
||||
|
||||
@@ -1,20 +1,17 @@
|
||||
/*
|
||||
* Copyright 2014 David Horscroft
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*
|
||||
* NoSessionExpiredException is thrown when an interaction is attempted with
|
||||
* an expired session.
|
||||
* NoSessionExpiredException is thrown when an interaction is attempted with an expired session.
|
||||
*/
|
||||
|
||||
package nodash.exceptions;
|
||||
|
||||
@@ -1,21 +1,18 @@
|
||||
/*
|
||||
* Copyright 2014 David Horscroft
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*
|
||||
* NoSessionNotAwaitingConfirmationException is thrown when an attempt is made
|
||||
* to confirm a session with a password/byte[] combination, but the session is
|
||||
* not currently awaiting a confirmation.
|
||||
* NoSessionNotAwaitingConfirmationException is thrown when an attempt is made to confirm a session
|
||||
* with a password/byte[] combination, but the session is not currently awaiting a confirmation.
|
||||
*/
|
||||
|
||||
package nodash.exceptions;
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
/*
|
||||
* Copyright 2014 David Horscroft
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*
|
||||
* NoSessionNotChangedException is thrown when a save is requested for a session
|
||||
* whilst the user object remains unchanged.
|
||||
* NoSessionNotChangedException is thrown when a save is requested for a session whilst the user
|
||||
* object remains unchanged.
|
||||
*/
|
||||
|
||||
package nodash.exceptions;
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
/*
|
||||
* Copyright 2014 David Horscroft
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*
|
||||
* NoUserAlreadyOnlineException is thrown when a login attempt is made for
|
||||
* a user who is currently online.
|
||||
* NoUserAlreadyOnlineException is thrown when a login attempt is made for a user who is currently
|
||||
* online.
|
||||
*/
|
||||
|
||||
package nodash.exceptions;
|
||||
|
||||
@@ -1,20 +1,17 @@
|
||||
/*
|
||||
* Copyright 2014 David Horscroft
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*
|
||||
* NoUserNotValidException is thrown when a user file does not hash to a known
|
||||
* hash.
|
||||
* NoUserNotValidException is thrown when a user file does not hash to a known hash.
|
||||
*/
|
||||
|
||||
package nodash.exceptions;
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
/*
|
||||
* Copyright 2014 David Horscroft
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*
|
||||
* NoAction is an abstract class to allow for the inheritance of actions which
|
||||
* users can queue before confirmation (user-to-user and user-to-server).
|
||||
* NoAction is an abstract class to allow for the inheritance of actions which users can queue
|
||||
* before confirmation (user-to-user and user-to-server).
|
||||
*/
|
||||
|
||||
package nodash.models;
|
||||
@@ -23,7 +21,10 @@ import java.io.Serializable;
|
||||
|
||||
public abstract class NoAction implements Serializable {
|
||||
private static final long serialVersionUID = -194752850197321803L;
|
||||
|
||||
public abstract void process();
|
||||
|
||||
public abstract void execute();
|
||||
|
||||
public abstract void purge();
|
||||
}
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
/*
|
||||
* Copyright 2014 David Horscroft
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*
|
||||
* NoByteSet stores an AES key which has been RSA-4096 encrypted and a data
|
||||
* stream which has been encrypted by this key.
|
||||
* NoByteSet stores an AES key which has been RSA-4096 encrypted and a data stream which has been
|
||||
* encrypted by this key.
|
||||
*/
|
||||
|
||||
package nodash.models;
|
||||
|
||||
@@ -1,22 +1,20 @@
|
||||
/*
|
||||
* Copyright 2014 David Horscroft
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*
|
||||
* NoInfluence is an abstract class allowing for the subclassing of user
|
||||
* influences, generated by both actions and the server. Upon login, the user
|
||||
* consumes NoByteSets (generated by .getByteSet()) into the primary NoInfluence,
|
||||
* which is then applied to the user with .applyTo(NoUser).
|
||||
* NoInfluence is an abstract class allowing for the subclassing of user influences, generated by
|
||||
* both actions and the server. Upon login, the user consumes NoByteSets (generated by
|
||||
* .getByteSet()) into the primary NoInfluence, which is then applied to the user with
|
||||
* .applyTo(NoUser).
|
||||
*
|
||||
* 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);
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(decrypted);
|
||||
try {
|
||||
|
||||
@@ -23,7 +23,8 @@ import nodash.exceptions.NoUserNotValidException;
|
||||
public final class NoSession implements Serializable {
|
||||
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;
|
||||
};
|
||||
@@ -103,7 +104,8 @@ public final class NoSession implements Serializable {
|
||||
return this.state;
|
||||
}
|
||||
|
||||
public byte[] initiateSaveAttempt(char[] password) throws NoSessionConfirmedException, NoSessionExpiredException {
|
||||
public byte[] initiateSaveAttempt(char[] password) throws NoSessionConfirmedException,
|
||||
NoSessionExpiredException {
|
||||
this.touchState();
|
||||
this.state = NoState.AWAITING_CONFIRMATION;
|
||||
byte[] file = this.current.createFile(password);
|
||||
@@ -111,8 +113,8 @@ public final class NoSession implements Serializable {
|
||||
return file;
|
||||
}
|
||||
|
||||
public void confirmSave(byte[] confirmData, char[] password) throws NoSessionConfirmedException, NoSessionExpiredException,
|
||||
NoSessionNotAwaitingConfirmationException, NoUserNotValidException {
|
||||
public void confirmSave(byte[] confirmData, char[] password) throws NoSessionConfirmedException,
|
||||
NoSessionExpiredException, NoSessionNotAwaitingConfirmationException, NoUserNotValidException {
|
||||
this.check();
|
||||
if (this.state != NoState.AWAITING_CONFIRMATION) {
|
||||
throw new NoSessionNotAwaitingConfirmationException();
|
||||
@@ -158,8 +160,10 @@ public final class NoSession implements Serializable {
|
||||
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 */
|
||||
/*
|
||||
* 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();
|
||||
}
|
||||
@@ -211,7 +215,7 @@ public final class NoSession implements Serializable {
|
||||
return UUID.fromString(new String(Base64.decodeBase64(NoUtil.decrypt(data))));
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new NoDashSessionBadUUIDException();
|
||||
}catch (IllegalBlockSizeException e) {
|
||||
} catch (IllegalBlockSizeException e) {
|
||||
throw new NoDashSessionBadUUIDException();
|
||||
} catch (BadPaddingException e) {
|
||||
throw new NoDashSessionBadUUIDException();
|
||||
|
||||
@@ -1,21 +1,19 @@
|
||||
/*
|
||||
* Copyright 2014 David Horscroft
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*
|
||||
* NoUser allows the subclassing of custom user objects whilst keeping the
|
||||
* core requirements of a NoUser: the public and private keys. It also supports
|
||||
* the serialization, decryption and NoByteSet consumption.
|
||||
* NoUser allows the subclassing of custom user objects whilst keeping the core requirements of a
|
||||
* NoUser: the public and private keys. It also supports the serialization, decryption and NoByteSet
|
||||
* consumption.
|
||||
*/
|
||||
|
||||
package nodash.models;
|
||||
@@ -68,7 +66,8 @@ public class NoUser implements Serializable {
|
||||
}
|
||||
|
||||
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) {
|
||||
throw new NoDashFatalException("Value for SECURERANDOM_ALGORITHM not valid.", e);
|
||||
} catch (NoSuchProviderException e) {
|
||||
@@ -106,7 +105,8 @@ public class NoUser implements Serializable {
|
||||
baos.close();
|
||||
return encrypted;
|
||||
} 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 {
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(decrypted);
|
||||
ObjectInputStream ois = new ObjectInputStream(bais);
|
||||
|
||||
@@ -1,25 +1,22 @@
|
||||
/*
|
||||
* Copyright 2014 David Horscroft
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*
|
||||
* NoErrorableAction is a subclassing of NoTargetedAction for user-server
|
||||
* interactions that require an error to be returned if a
|
||||
* NoCannotGetInfluenceException is thrown. The target is not a destination user,
|
||||
* but is instead treated as the source.
|
||||
* NoErrorableAction is a subclassing of NoTargetedAction for user-server interactions that require
|
||||
* an error to be returned if a NoCannotGetInfluenceException is thrown. The target is not a
|
||||
* destination user, but is instead treated as the source.
|
||||
*
|
||||
* As with all sourced actions it is advised to avoid their use unless the logic
|
||||
* demands it, as it establishes a connection between a server action and a user address.
|
||||
* As with all sourced actions it is advised to avoid their use unless the logic demands it, as it
|
||||
* establishes a connection between a server action and a user address.
|
||||
*/
|
||||
|
||||
package nodash.models.noactiontypes;
|
||||
|
||||
@@ -1,25 +1,22 @@
|
||||
/*
|
||||
* Copyright 2014 David Horscroft
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*
|
||||
* NoHandshakeAction is a subclass of the NoSourcedAction with logic to
|
||||
* generate an applying influence as well as a returned influence, whilst
|
||||
* also being capable of returned an error influence if the
|
||||
* NoCannotGetInfluenceException is thrown.
|
||||
* NoHandshakeAction is a subclass of the NoSourcedAction with logic to generate an applying
|
||||
* influence as well as a returned influence, whilst also being capable of returned an error
|
||||
* influence if the NoCannotGetInfluenceException is thrown.
|
||||
*
|
||||
* As with all two-way or sourced actions, their use should be sparing as
|
||||
* it establishes a connection between two user addresses.
|
||||
* As with all two-way or sourced actions, their use should be sparing as it establishes a
|
||||
* connection between two user addresses.
|
||||
*/
|
||||
|
||||
package nodash.models.noactiontypes;
|
||||
|
||||
@@ -1,24 +1,21 @@
|
||||
/*
|
||||
* Copyright 2014 David Horscroft
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*
|
||||
* NoSourcedAction is a subclassing of NoTargetedAction which additionally
|
||||
* has a source, allowing for errors to be returned if a NoCannotGetInfluenceException
|
||||
* is thrown.
|
||||
* NoSourcedAction is a subclassing of NoTargetedAction which additionally has a source, allowing
|
||||
* for errors to be returned if a NoCannotGetInfluenceException is thrown.
|
||||
*
|
||||
* It is not advised to make a habit of using these for all user-user interactions
|
||||
* as they provide a clear link between two users.
|
||||
* It is not advised to make a habit of using these for all user-user interactions as they provide a
|
||||
* clear link between two users.
|
||||
*/
|
||||
|
||||
package nodash.models.noactiontypes;
|
||||
@@ -33,6 +30,7 @@ import nodash.models.NoInfluence;
|
||||
public abstract class NoSourcedAction extends NoTargetedAction {
|
||||
private static final long serialVersionUID = -2996690472537380062L;
|
||||
protected PublicKey source;
|
||||
|
||||
protected abstract NoInfluence generateTargetInfluence() throws NoCannotGetInfluenceException;
|
||||
|
||||
public NoSourcedAction(PublicKey target, PublicKey source) {
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
/*
|
||||
* Copyright 2014 David Horscroft
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*
|
||||
* NoTargetedAction is an abstract subclassing of NoAction aimed at providing the
|
||||
* basis for an action that has a user target in mind.
|
||||
* NoTargetedAction is an abstract subclassing of NoAction aimed at providing the basis for an
|
||||
* action that has a user target in mind.
|
||||
*/
|
||||
|
||||
package nodash.models.noactiontypes;
|
||||
@@ -48,7 +46,8 @@ public abstract class NoTargetedAction extends NoAction {
|
||||
}
|
||||
} catch (NoCannotGetInfluenceException e) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,18 +16,9 @@ import nodash.exceptions.NoUserNotValidException;
|
||||
import nodash.models.NoSession.NoState;
|
||||
|
||||
public class NoCoreTest {
|
||||
private static final String[] CHANGE = new String[] {
|
||||
"first-string",
|
||||
"second-string",
|
||||
"third-string",
|
||||
"forth-string",
|
||||
"fifth-string",
|
||||
"sixth-string",
|
||||
"seventh-string",
|
||||
"eighth-string",
|
||||
"ninth-string",
|
||||
"tenth-string"
|
||||
};
|
||||
private static final String[] CHANGE = new String[] {"first-string", "second-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 final String PASSWORD = "password";
|
||||
@@ -132,7 +123,8 @@ public class NoCoreTest {
|
||||
printIf("NoDashSessionBadUUIDException thrown, passed.");
|
||||
return true;
|
||||
} 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);
|
||||
}
|
||||
return false;
|
||||
@@ -151,7 +143,8 @@ public class NoCoreTest {
|
||||
printIf("NoUserNotValidException thrown, passed.");
|
||||
return true;
|
||||
} 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);
|
||||
}
|
||||
return false;
|
||||
@@ -169,7 +162,8 @@ public class NoCoreTest {
|
||||
printIf("NoUserNotValidException thrown, passed.");
|
||||
return true;
|
||||
} 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);
|
||||
}
|
||||
return false;
|
||||
@@ -223,7 +217,8 @@ public class NoCoreTest {
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -260,7 +255,8 @@ public class NoCoreTest {
|
||||
try {
|
||||
NoCore.confirm(register.cookie, PASSWORD.toCharArray(), register.data);
|
||||
} 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);
|
||||
throw new NoTestNotReadyException("Failed to set up user file.");
|
||||
}
|
||||
@@ -274,12 +270,14 @@ public class NoCoreTest {
|
||||
byte[] cookie = null;
|
||||
try {
|
||||
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) {
|
||||
printIf("NoUserNotValidException thrown, passed.");
|
||||
return true;
|
||||
} 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);
|
||||
} finally {
|
||||
NoCore.shred(cookie);
|
||||
@@ -302,7 +300,8 @@ public class NoCoreTest {
|
||||
printIf("NoUserNotValidException thrown, passed.");
|
||||
return true;
|
||||
} 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);
|
||||
} finally {
|
||||
NoCore.shred(cookie);
|
||||
@@ -328,12 +327,14 @@ public class NoCoreTest {
|
||||
byte[] secondCookie = null;
|
||||
try {
|
||||
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) {
|
||||
printIf("NoUserAlreadyOnlineException thrown, passed.");
|
||||
return true;
|
||||
} 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);
|
||||
} finally {
|
||||
NoCore.shred(secondCookie);
|
||||
@@ -380,7 +381,8 @@ public class NoCoreTest {
|
||||
return false;
|
||||
}
|
||||
} 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);
|
||||
return false;
|
||||
}
|
||||
@@ -416,8 +418,7 @@ public class NoCoreTest {
|
||||
}
|
||||
|
||||
/*
|
||||
* END Login methods
|
||||
* BEGIN Login-Logout methods
|
||||
* END Login methods BEGIN Login-Logout methods
|
||||
*/
|
||||
|
||||
public static boolean testLoginModifyLogout(byte[] data) {
|
||||
@@ -428,7 +429,8 @@ public class NoCoreTest {
|
||||
try {
|
||||
cookie = NoCore.login(copy(data), PASSWORD.toCharArray());
|
||||
} 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);
|
||||
return false;
|
||||
}
|
||||
@@ -450,7 +452,8 @@ public class NoCoreTest {
|
||||
try {
|
||||
stateModified = NoCore.getSessionState(cookie);
|
||||
} 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);
|
||||
NoCore.shred(cookie);
|
||||
return false;
|
||||
@@ -466,7 +469,8 @@ public class NoCoreTest {
|
||||
try {
|
||||
newData = NoCore.requestSave(cookie, PASSWORD.toCharArray());
|
||||
} 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);
|
||||
NoCore.shred(cookie);
|
||||
return false;
|
||||
@@ -477,7 +481,8 @@ public class NoCoreTest {
|
||||
try {
|
||||
stateAwaiting = NoCore.getSessionState(cookie);
|
||||
} 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);
|
||||
NoCore.shred(cookie);
|
||||
return false;
|
||||
@@ -508,7 +513,8 @@ public class NoCoreTest {
|
||||
} catch (NoSessionConfirmedException e) {
|
||||
printIf("NoSessionConfirmed exception thrown.");
|
||||
} 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);
|
||||
return false;
|
||||
} finally {
|
||||
@@ -519,7 +525,8 @@ public class NoCoreTest {
|
||||
try {
|
||||
cookie = NoCore.login(copy(data), PASSWORD.toCharArray());
|
||||
} 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);
|
||||
return false;
|
||||
}
|
||||
@@ -528,7 +535,8 @@ public class NoCoreTest {
|
||||
try {
|
||||
user = (NoUserTest) NoCore.getUser(cookie);
|
||||
} 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);
|
||||
return false;
|
||||
}
|
||||
@@ -559,7 +567,8 @@ public class NoCoreTest {
|
||||
address = user.getRSAPublicKey();
|
||||
currentString = user.getChangableString();
|
||||
} 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);
|
||||
return false;
|
||||
} finally {
|
||||
@@ -573,7 +582,8 @@ public class NoCoreTest {
|
||||
try {
|
||||
secondUserCookie = NoCore.login(copy(secondUserData), PASSWORD.toCharArray());
|
||||
} 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);
|
||||
return false;
|
||||
}
|
||||
@@ -582,7 +592,8 @@ public class NoCoreTest {
|
||||
try {
|
||||
user = (NoUserTest) NoCore.getUser(secondUserCookie);
|
||||
} 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);
|
||||
return false;
|
||||
}
|
||||
@@ -597,7 +608,8 @@ public class NoCoreTest {
|
||||
secondUserData = NoCore.requestSave(secondUserCookie, PASSWORD.toCharArray());
|
||||
NoCore.confirm(secondUserCookie, PASSWORD.toCharArray(), copy(secondUserData));
|
||||
} 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);
|
||||
NoCore.shred(secondUserCookie);
|
||||
return false;
|
||||
@@ -609,7 +621,8 @@ public class NoCoreTest {
|
||||
try {
|
||||
cookie = NoCore.login(copy(data), PASSWORD.toCharArray());
|
||||
} 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);
|
||||
return false;
|
||||
}
|
||||
@@ -618,7 +631,8 @@ public class NoCoreTest {
|
||||
try {
|
||||
state = NoCore.getSessionState(cookie);
|
||||
} 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);
|
||||
NoCore.shred(cookie);
|
||||
return false;
|
||||
@@ -631,7 +645,8 @@ public class NoCoreTest {
|
||||
try {
|
||||
user = (NoUserTest) NoCore.getUser(cookie);
|
||||
} 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);
|
||||
NoCore.shred(cookie);
|
||||
return false;
|
||||
@@ -641,7 +656,8 @@ public class NoCoreTest {
|
||||
logger.severe("User information has not changed (still " + user.getChangableString() + ").");
|
||||
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
|
||||
NoCore.shred(cookie);
|
||||
@@ -649,7 +665,8 @@ public class NoCoreTest {
|
||||
try {
|
||||
cookie = NoCore.login(copy(data), PASSWORD.toCharArray());
|
||||
} 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);
|
||||
return false;
|
||||
}
|
||||
@@ -657,7 +674,8 @@ public class NoCoreTest {
|
||||
try {
|
||||
state = NoCore.getSessionState(cookie);
|
||||
} 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);
|
||||
NoCore.shred(cookie);
|
||||
return false;
|
||||
@@ -670,7 +688,8 @@ public class NoCoreTest {
|
||||
try {
|
||||
user = (NoUserTest) NoCore.getUser(cookie);
|
||||
} 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);
|
||||
NoCore.shred(cookie);
|
||||
return false;
|
||||
@@ -680,7 +699,8 @@ public class NoCoreTest {
|
||||
logger.severe("User information has not changed (still " + user.getChangableString() + ").");
|
||||
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
|
||||
try {
|
||||
@@ -688,7 +708,8 @@ public class NoCoreTest {
|
||||
NoCore.confirm(cookie, PASSWORD.toCharArray(), copy(data));
|
||||
passoverData = copy(data);
|
||||
} 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);
|
||||
return false;
|
||||
}
|
||||
@@ -698,7 +719,8 @@ public class NoCoreTest {
|
||||
try {
|
||||
cookie = NoCore.login(copy(data), PASSWORD.toCharArray());
|
||||
} 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);
|
||||
return false;
|
||||
}
|
||||
@@ -706,7 +728,8 @@ public class NoCoreTest {
|
||||
try {
|
||||
state = NoCore.getSessionState(cookie);
|
||||
} 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);
|
||||
NoCore.shred(cookie);
|
||||
return false;
|
||||
@@ -719,7 +742,8 @@ public class NoCoreTest {
|
||||
try {
|
||||
user = (NoUserTest) NoCore.getUser(cookie);
|
||||
} 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);
|
||||
NoCore.shred(cookie);
|
||||
return false;
|
||||
@@ -729,7 +753,8 @@ public class NoCoreTest {
|
||||
logger.severe("User information has not changed (still " + user.getChangableString() + ").");
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -740,12 +765,12 @@ public class NoCoreTest {
|
||||
TestTicker ticker = new TestTicker();
|
||||
ticker.test(testLoginModifyLogout(data));
|
||||
if (passoverData != null && passoverData.getClass().equals(byte[].class)) {
|
||||
data = copy((byte[])passoverData);
|
||||
data = copy((byte[]) passoverData);
|
||||
passoverData = null;
|
||||
}
|
||||
ticker.test(testActionInfluenceLifecycle(data));
|
||||
if (passoverData != null && passoverData.getClass().equals(byte[].class)) {
|
||||
data = copy((byte[])passoverData);
|
||||
data = copy((byte[]) passoverData);
|
||||
passoverData = null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user