diff --git a/lib/commons-codec-1.10.jar b/lib/commons-codec-1.10.jar new file mode 100644 index 0000000..1d7417c Binary files /dev/null and b/lib/commons-codec-1.10.jar differ diff --git a/src/nodash/core/NoCore.java b/src/nodash/core/NoCore.java index 763f2a6..7c51b21 100644 --- a/src/nodash/core/NoCore.java +++ b/src/nodash/core/NoCore.java @@ -50,18 +50,15 @@ public final class NoCore { public static void setup(NoConfigInterface config, NoHashSphereInterface hashSphere) { NoCore.setup(config); NoCore.setup(hashSphere); - com.sun.org.apache.xml.internal.security.Init.init(); } public static void setup(NoConfigInterface config) { NoCore.config = config; - com.sun.org.apache.xml.internal.security.Init.init(); } public static void setup(NoHashSphereInterface hashSphere) { NoCore.hashSphere = hashSphere; hashSphere.setup(); - com.sun.org.apache.xml.internal.security.Init.init(); } public static void setup() { @@ -73,7 +70,6 @@ public final class NoCore { } NoCore.setup(newConfig); NoCore.setup(new NoHashSphereDefault()); - com.sun.org.apache.xml.internal.security.Init.init(); } public static byte[] login(byte[] data, char[] password) throws NoUserNotValidException, NoUserAlreadyOnlineException, NoSessionExpiredException { diff --git a/src/nodash/core/spheres/NoSessionSphere.java b/src/nodash/core/spheres/NoSessionSphere.java index 3217068..bd10b0d 100644 --- a/src/nodash/core/spheres/NoSessionSphere.java +++ b/src/nodash/core/spheres/NoSessionSphere.java @@ -24,6 +24,8 @@ import java.util.Set; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; +import org.apache.commons.codec.binary.Base64; + import nodash.core.NoRegister; import nodash.exceptions.NoByteSetBadDecryptionException; import nodash.exceptions.NoDashFatalException; @@ -42,7 +44,7 @@ import nodash.models.NoSession.NoState; public final class NoSessionSphere { private static ConcurrentHashMap sessions = new ConcurrentHashMap(); - private static Set originalHashesOnline = Collections.newSetFromMap(new ConcurrentHashMap()); + private static Set originalHashesOnline = Collections.newSetFromMap(new ConcurrentHashMap()); public static synchronized void prune() { for (UUID uuid : NoSessionSphere.sessions.keySet()) { @@ -56,7 +58,7 @@ 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(session.getOriginalHash()); + NoSessionSphere.originalHashesOnline.remove(Base64.encodeBase64String(session.getOriginalHash())); NoSessionSphere.sessions.remove(uuid); session = null; } @@ -84,11 +86,11 @@ public final class NoSessionSphere { /* 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. */ - if (originalHashesOnline.contains(session.getOriginalHash())) { + if (originalHashesOnline.contains(Base64.encodeBase64String(session.getOriginalHash()))) { throw new NoUserAlreadyOnlineException(); } /* 1.2. User successfully logged in: set up session records. */ - NoSessionSphere.originalHashesOnline.add(session.getOriginalHash()); + NoSessionSphere.originalHashesOnline.add(Base64.encodeBase64String(session.getOriginalHash())); NoSessionSphere.sessions.put(session.uuid, session); /* 2. Check NoByteSetSphere for incoming Influences */ diff --git a/src/nodash/models/NoSession.java b/src/nodash/models/NoSession.java index 30715c2..3402781 100644 --- a/src/nodash/models/NoSession.java +++ b/src/nodash/models/NoSession.java @@ -8,8 +8,7 @@ import java.util.UUID; import javax.crypto.BadPaddingException; import javax.crypto.IllegalBlockSizeException; -import com.sun.org.apache.xml.internal.security.exceptions.Base64DecodingException; -import com.sun.org.apache.xml.internal.security.utils.Base64; +import org.apache.commons.codec.binary.Base64; import nodash.core.NoCore; import nodash.core.NoUtil; @@ -188,11 +187,7 @@ public final class NoSession implements Serializable { } public byte[] getEncryptedUUID() { - try { - return NoUtil.encrypt(Base64.decode(this.uuid.toString())); - } catch (Base64DecodingException e) { - throw new NoDashFatalException("Base64DecodingException while decoding session UUID.", e); - } + return NoUtil.encrypt(Base64.encodeBase64(this.uuid.toString().getBytes())); } public String getEncryptedUUIDAsString() { @@ -213,8 +208,10 @@ public final class NoSession implements Serializable { } try { - return UUID.fromString(new String(NoUtil.decrypt(data))); - } catch (IllegalBlockSizeException e) { + return UUID.fromString(new String(Base64.decodeBase64(NoUtil.decrypt(data)))); + } catch (IllegalArgumentException e) { + throw new NoDashSessionBadUUIDException(); + }catch (IllegalBlockSizeException e) { throw new NoDashSessionBadUUIDException(); } catch (BadPaddingException e) { throw new NoDashSessionBadUUIDException();