import cleanup
This commit is contained in:
@@ -36,6 +36,8 @@ public interface NoAdapter {
|
||||
|
||||
public Collection<NoByteSet> pollNoByteSets(PublicKey address) throws NoAdapterException;
|
||||
|
||||
public void addNoByteSets(Collection<NoByteSet> noByteSets, PublicKey address)
|
||||
public void addNoByteSet(NoByteSet byteSet, PublicKey address) throws NoAdapterException;
|
||||
|
||||
public void addNoByteSets(Collection<NoByteSet> byteSets, PublicKey address)
|
||||
throws NoAdapterException;
|
||||
}
|
||||
|
||||
@@ -196,6 +196,14 @@ public class NoDefaultAdapter implements NoAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNoByteSet(NoByteSet byteSet, PublicKey address) {
|
||||
if (!byteSets.containsKey(address)) {
|
||||
byteSets.put(address, new ArrayList<NoByteSet>());
|
||||
}
|
||||
byteSets.get(address).add(byteSet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNoByteSets(Collection<NoByteSet> addedByteSets, PublicKey address) {
|
||||
if (byteSets.containsKey(address)) {
|
||||
|
||||
@@ -28,7 +28,6 @@ import java.security.spec.KeySpec;
|
||||
import javax.crypto.BadPaddingException;
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.IllegalBlockSizeException;
|
||||
import javax.crypto.KeyGenerator;
|
||||
import javax.crypto.NoSuchPaddingException;
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.crypto.SecretKeyFactory;
|
||||
|
||||
@@ -13,11 +13,8 @@ import javax.crypto.IllegalBlockSizeException;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
|
||||
import nodash.core.NoAdapter;
|
||||
import nodash.core.NoCore;
|
||||
import nodash.core.NoUtil;
|
||||
import nodash.exceptions.NoByteSetBadDecryptionException;
|
||||
import nodash.exceptions.NoDashFatalException;
|
||||
import nodash.exceptions.NoDashSessionBadUuidException;
|
||||
import nodash.exceptions.NoSessionConfirmedException;
|
||||
import nodash.exceptions.NoSessionExpiredException;
|
||||
import nodash.exceptions.NoSessionNotAwaitingConfirmationException;
|
||||
@@ -191,26 +188,6 @@ public final class NoSession implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
private static String decryptUuid(String data) throws NoDashSessionBadUuidException {
|
||||
return decryptUuid(Base64.decodeBase64(data));
|
||||
}
|
||||
|
||||
private static String decryptUuid(byte[] data) throws NoDashSessionBadUuidException {
|
||||
if (data == null) {
|
||||
throw new NoDashSessionBadUuidException();
|
||||
}
|
||||
|
||||
try {
|
||||
return Base64.encodeBase64String(NoUtil.decrypt(data));
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new NoDashSessionBadUuidException();
|
||||
} catch (IllegalBlockSizeException e) {
|
||||
throw new NoDashSessionBadUuidException();
|
||||
} catch (BadPaddingException e) {
|
||||
throw new NoDashSessionBadUuidException();
|
||||
}
|
||||
}
|
||||
|
||||
public void setIncoming(Collection<NoByteSet> incoming) {
|
||||
this.incoming = incoming;
|
||||
}
|
||||
|
||||
@@ -23,8 +23,10 @@ package nodash.models.noactiontypes;
|
||||
|
||||
import java.security.PublicKey;
|
||||
|
||||
import nodash.core.NoCore;
|
||||
import nodash.core.NoAdapter;
|
||||
import nodash.exceptions.NoAdapterException;
|
||||
import nodash.exceptions.NoCannotGetInfluenceException;
|
||||
import nodash.exceptions.NoDashFatalException;
|
||||
import nodash.models.NoByteSet;
|
||||
import nodash.models.NoInfluence;
|
||||
|
||||
@@ -36,20 +38,27 @@ public abstract class NoErrorableAction extends NoTargetedAction {
|
||||
super(source);
|
||||
}
|
||||
|
||||
public void execute() {
|
||||
@Override
|
||||
public void execute(NoAdapter adapter) {
|
||||
this.process();
|
||||
try {
|
||||
NoInfluence influence = this.generateTargetInfluence();
|
||||
if (influence != null) {
|
||||
NoByteSet byteSet = influence.getByteSet(this.target);
|
||||
NoCore.addByteSet(byteSet, this.target);
|
||||
adapter.addNoByteSet(byteSet, this.target);
|
||||
}
|
||||
} catch (NoCannotGetInfluenceException e) {
|
||||
NoInfluence errorInfluence = e.getResponseInfluence();
|
||||
if (errorInfluence != null) {
|
||||
NoByteSet byteSet = errorInfluence.getByteSet(this.target);
|
||||
NoCore.addByteSet(byteSet, this.target);
|
||||
try {
|
||||
adapter.addNoByteSet(byteSet, this.target);
|
||||
} catch (NoAdapterException e1) {
|
||||
throw new NoDashFatalException("Could not add the error byte set to the pool.");
|
||||
}
|
||||
}
|
||||
} catch (NoAdapterException e) {
|
||||
throw new NoDashFatalException("Could not add the byte set to the pool.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +23,10 @@ package nodash.models.noactiontypes;
|
||||
|
||||
import java.security.PublicKey;
|
||||
|
||||
import nodash.core.NoCore;
|
||||
import nodash.core.NoAdapter;
|
||||
import nodash.exceptions.NoAdapterException;
|
||||
import nodash.exceptions.NoCannotGetInfluenceException;
|
||||
import nodash.exceptions.NoDashFatalException;
|
||||
import nodash.models.NoByteSet;
|
||||
import nodash.models.NoInfluence;
|
||||
|
||||
@@ -37,30 +39,33 @@ public abstract class NoHandshakeAction extends NoSourcedAction {
|
||||
super(target, source);
|
||||
}
|
||||
|
||||
public void execute() {
|
||||
@Override
|
||||
public void execute(NoAdapter adapter) {
|
||||
this.process();
|
||||
try {
|
||||
NoInfluence influence = this.generateTargetInfluence();
|
||||
if (influence != null) {
|
||||
NoByteSet byteSet = influence.getByteSet(this.target);
|
||||
NoCore.addByteSet(byteSet, this.target);
|
||||
adapter.addNoByteSet(byteSet, this.target);
|
||||
}
|
||||
|
||||
NoInfluence result = this.generateReturnedInfluence();
|
||||
if (result != null) {
|
||||
NoByteSet byteSet = result.getByteSet(this.source);
|
||||
NoCore.addByteSet(byteSet, this.source);
|
||||
adapter.addNoByteSet(byteSet, this.source);
|
||||
}
|
||||
} catch (NoCannotGetInfluenceException e) {
|
||||
NoInfluence errorInfluence = e.getResponseInfluence();
|
||||
if (errorInfluence != null) {
|
||||
NoByteSet byteSet = errorInfluence.getByteSet(this.source);
|
||||
NoCore.addByteSet(byteSet, this.source);
|
||||
try {
|
||||
adapter.addNoByteSet(byteSet, this.source);
|
||||
} catch (NoAdapterException e1) {
|
||||
throw new NoDashFatalException("Could not add error byte set to the pool.");
|
||||
}
|
||||
}
|
||||
} catch (NoAdapterException e) {
|
||||
throw new NoDashFatalException("Could not add byte sets to the pool.", e);
|
||||
}
|
||||
|
||||
public void purge() {
|
||||
super.purge();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,8 +22,10 @@ package nodash.models.noactiontypes;
|
||||
|
||||
import java.security.PublicKey;
|
||||
|
||||
import nodash.core.NoCore;
|
||||
import nodash.core.NoAdapter;
|
||||
import nodash.exceptions.NoAdapterException;
|
||||
import nodash.exceptions.NoCannotGetInfluenceException;
|
||||
import nodash.exceptions.NoDashFatalException;
|
||||
import nodash.models.NoByteSet;
|
||||
import nodash.models.NoInfluence;
|
||||
|
||||
@@ -38,23 +40,31 @@ public abstract class NoSourcedAction extends NoTargetedAction {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
public void execute() {
|
||||
@Override
|
||||
public void execute(NoAdapter adapter) {
|
||||
this.process();
|
||||
try {
|
||||
NoInfluence influence = this.generateTargetInfluence();
|
||||
if (influence != null) {
|
||||
NoByteSet byteSet = influence.getByteSet(this.target);
|
||||
NoCore.addByteSet(byteSet, this.target);
|
||||
adapter.addNoByteSet(byteSet, this.target);
|
||||
}
|
||||
} catch (NoCannotGetInfluenceException e) {
|
||||
NoInfluence errorInfluence = e.getResponseInfluence();
|
||||
if (errorInfluence != null) {
|
||||
NoByteSet byteSet = errorInfluence.getByteSet(this.source);
|
||||
NoCore.addByteSet(byteSet, this.source);
|
||||
try {
|
||||
adapter.addNoByteSet(byteSet, this.source);
|
||||
} catch (NoAdapterException e1) {
|
||||
throw new NoDashFatalException("Could not add error byte set to the pool.", e);
|
||||
}
|
||||
}
|
||||
} catch (NoAdapterException e) {
|
||||
throw new NoDashFatalException("Could not add byte set to the pool.", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void purge() {
|
||||
super.purge();
|
||||
this.source = null;
|
||||
|
||||
@@ -19,7 +19,8 @@ package nodash.models.noactiontypes;
|
||||
|
||||
import java.security.PublicKey;
|
||||
|
||||
import nodash.core.NoCore;
|
||||
import nodash.core.NoAdapter;
|
||||
import nodash.exceptions.NoAdapterException;
|
||||
import nodash.exceptions.NoCannotGetInfluenceException;
|
||||
import nodash.exceptions.NoDashFatalException;
|
||||
import nodash.models.NoAction;
|
||||
@@ -36,22 +37,26 @@ public abstract class NoTargetedAction extends NoAction {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public void execute() {
|
||||
@Override
|
||||
public void execute(NoAdapter adapter) {
|
||||
this.process();
|
||||
try {
|
||||
NoInfluence influence = this.generateTargetInfluence();
|
||||
if (influence != null) {
|
||||
NoByteSet byteSet = influence.getByteSet(this.target);
|
||||
NoCore.addByteSet(byteSet, this.target);
|
||||
adapter.addNoByteSet(byteSet, this.target);
|
||||
}
|
||||
} catch (NoCannotGetInfluenceException e) {
|
||||
if (e.getResponseInfluence() != null) {
|
||||
throw new NoDashFatalException(
|
||||
"Unsourced action has generated an error with an undeliverable influence.", e);
|
||||
}
|
||||
} catch (NoAdapterException e) {
|
||||
throw new NoDashFatalException("Could not add byte set to the pool.", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void purge() {
|
||||
this.target = null;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ import nodash.exceptions.NoSessionNotAwaitingConfirmationException;
|
||||
import nodash.exceptions.NoSessionNotChangedException;
|
||||
import nodash.exceptions.NoUserAlreadyOnlineException;
|
||||
import nodash.exceptions.NoUserNotValidException;
|
||||
import nodash.models.NoSession;
|
||||
import nodash.models.NoUser;
|
||||
|
||||
import org.junit.Test;
|
||||
@@ -123,19 +122,16 @@ public class NoCoreTest {
|
||||
|
||||
@Test
|
||||
public void testGetUser() {
|
||||
NoCore core = new NoCore(new NoDefaultAdapter());
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSessionState() {
|
||||
NoCore core = new NoCore(new NoDefaultAdapter());
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShred() {
|
||||
NoCore core = new NoCore(new NoDefaultAdapter());
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
package nodash.test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import nodash.core.NoCore;
|
||||
import nodash.exceptions.NoSessionConfirmedException;
|
||||
import nodash.exceptions.NoSessionExpiredException;
|
||||
import nodash.models.NoSession;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class NoSessionTest {
|
||||
|
||||
@@ -8,11 +8,9 @@ import java.util.Arrays;
|
||||
import javax.crypto.BadPaddingException;
|
||||
import javax.crypto.IllegalBlockSizeException;
|
||||
|
||||
import nodash.core.NoCore;
|
||||
import nodash.models.NoUser;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class NoUserTest {
|
||||
|
||||
@@ -13,12 +13,9 @@ import java.util.Arrays;
|
||||
import javax.crypto.BadPaddingException;
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.IllegalBlockSizeException;
|
||||
import javax.crypto.NoSuchPaddingException;
|
||||
|
||||
import nodash.core.NoCore;
|
||||
import nodash.core.NoUtil;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class NoUtilTest {
|
||||
|
||||
Reference in New Issue
Block a user