changes to Base64 (sun --> apache codec)
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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<UUID, NoSession> sessions = new ConcurrentHashMap<UUID, NoSession>();
|
||||
private static Set<byte[]> originalHashesOnline = Collections.newSetFromMap(new ConcurrentHashMap<byte[], Boolean>());
|
||||
private static Set<String> originalHashesOnline = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
|
||||
|
||||
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 */
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user