Commit 5144b608 authored by Daniel Henninger's avatar Daniel Henninger Committed by dhenninger

Various work. Presence was not working right at all before. Working better...

Various work.  Presence was not working right at all before.  Working better now but not completely.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk/src/plugins/gateway@4501 b35dd754-fafc-0310-a699-88a17e54d16e
parent 87be85bc
......@@ -31,9 +31,10 @@ public class SubscriptionInfo implements Serializable {
* @param username The username
* @param password The password
*/
public SubscriptionInfo(String username, String password) {
public SubscriptionInfo(String username, String password, JID jid) {
this.username = username;
this.password = password;
this.jid = jid;
}
/**
......@@ -61,6 +62,7 @@ public class SubscriptionInfo implements Serializable {
*
* @see org.xmpp.packet.JID
*/
public transient JID jid;
//public transient JID jid;
public JID jid;
}
......@@ -304,6 +304,7 @@ public class YahooGatewaySession extends AbstractGatewaySession implements Endpo
String node = to.getNode();
if (node == null || node.length() == 0) throw new UnknownForeignContactException("invalidnode", node.toString());
YahooUser user = session.getUser(node);
Log.debug("getUser on node " + node);
if (user == null) throw new UnknownForeignContactException("invaliduser");
return new YahooForeignContact(session.getUser(to.getNode()), this.gateway);
}
......
......@@ -16,6 +16,7 @@ import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.lang.Byte;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Executors;
......@@ -147,20 +148,21 @@ public class PersistenceManager implements Serializable {
* The key is stored in the registry so the key is as secure as the
* registry is secure.
*/
byte[] rawKey = Preferences.systemNodeForPackage(this.getClass()).getByteArray(".key", null);
//byte[] rawKey = Preferences.systemNodeForPackage(this.getClass()).getByteArray(".key", null);
if (rawKey == null) {
Log.error(LocaleUtils.getLocalizedString("persistencemanager.nokey", "gateway"));
return;
}
//if (rawKey == null) {
// Log.error(LocaleUtils.getLocalizedString("persistencemanager.nokey", "gateway"));
// return;
//}
SecretKeySpec key = new SecretKeySpec(rawKey, "AES");
Cipher c = Cipher.getInstance("AES");
c.init(Cipher.DECRYPT_MODE, key);
//SecretKeySpec key = new SecretKeySpec(rawKey, "AES");
//Cipher c = Cipher.getInstance("AES");
//c.init(Cipher.DECRYPT_MODE, key);
CipherInputStream cis = new CipherInputStream(new FileInputStream(db), c);
//CipherInputStream cis = new CipherInputStream(new FileInputStream(db), c);
ObjectInputStream is = new ObjectInputStream(cis);
//ObjectInputStream is = new ObjectInputStream(cis);
ObjectInputStream is = new ObjectInputStream(new FileInputStream(db));
contactManager = (ContactManager)is.readObject() ;
registrar = (Registrar) is.readObject() ;
is.close();
......@@ -206,22 +208,23 @@ public class PersistenceManager implements Serializable {
* @throws Exception
*/
public synchronized void store() throws Exception {
Preferences prefs = Preferences.systemNodeForPackage(this.getClass());
byte[] rawKey = prefs.getByteArray(".key", null);
if (rawKey == null) {
Log.error(LocaleUtils.getLocalizedString("persistencemanager.gennewkey", "gateway"));
KeyGenerator kg = KeyGenerator.getInstance("AES");
SecretKey key = kg.generateKey();
rawKey = key.getEncoded();
prefs.putByteArray(".key", rawKey);
}
//Preferences prefs = Preferences.systemNodeForPackage(this.getClass());
//byte[] rawKey = prefs.getByteArray(".key", null);
//if (rawKey == null) {
// Log.error(LocaleUtils.getLocalizedString("persistencemanager.gennewkey", "gateway"));
// KeyGenerator kg = KeyGenerator.getInstance("AES");
// SecretKey key = kg.generateKey();
// rawKey = key.getEncoded();
// prefs.putByteArray(".key", rawKey);
//}
SecretKeySpec key = new SecretKeySpec(rawKey, "AES");
Cipher c = Cipher.getInstance("AES");
c.init(Cipher.ENCRYPT_MODE, key);
CipherOutputStream os = new CipherOutputStream(new FileOutputStream(db), c);
ObjectOutputStream oos = new ObjectOutputStream(os);
//SecretKeySpec key = new SecretKeySpec(rawKey, "AES");
//Cipher c = Cipher.getInstance("AES");
//c.init(Cipher.ENCRYPT_MODE, key);
//CipherOutputStream os = new CipherOutputStream(new FileOutputStream(db), c);
//ObjectOutputStream oos = new ObjectOutputStream(os);
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(db));
oos.writeObject(contactManager);
oos.writeObject(registrar);
oos.flush();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment