Commit 59578723 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

Added possibility to deliver an arbitrary text.


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@202 b35dd754-fafc-0310-a699-88a17e54d16e
parent 490e5a7b
...@@ -14,6 +14,7 @@ package org.jivesoftware.messenger; ...@@ -14,6 +14,7 @@ package org.jivesoftware.messenger;
import org.jivesoftware.messenger.auth.UnauthorizedException; import org.jivesoftware.messenger.auth.UnauthorizedException;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.io.IOException;
import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter; import javax.xml.stream.XMLStreamWriter;
...@@ -130,4 +131,13 @@ public interface Connection { ...@@ -130,4 +131,13 @@ public interface Connection {
*/ */
void deliver(XMPPPacket packet) throws UnauthorizedException, XMLStreamException; void deliver(XMPPPacket packet) throws UnauthorizedException, XMLStreamException;
/**
* Delivers an arbitraty text to this XMPPAddress without checking the recipient.
*
* @param text The text to deliver.
* @throws UnauthorizedException If caller doesn't have permission to access this resource
* @throws IOException if there was a i/o problem sending the text
*/
void deliver(String text) throws UnauthorizedException, IOException;
} }
...@@ -18,6 +18,7 @@ import org.jivesoftware.messenger.user.UserNotFoundException; ...@@ -18,6 +18,7 @@ import org.jivesoftware.messenger.user.UserNotFoundException;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.util.Date; import java.util.Date;
import java.io.IOException;
import javax.xml.stream.XMLStreamWriter; import javax.xml.stream.XMLStreamWriter;
public class ServerSession implements Session { public class ServerSession implements Session {
...@@ -164,5 +165,9 @@ public class ServerSession implements Session { ...@@ -164,5 +165,9 @@ public class ServerSession implements Session {
throws UnauthorizedException { throws UnauthorizedException {
} }
public void deliver(String text) throws UnauthorizedException, IOException {
}
} }
} }
\ No newline at end of file
...@@ -194,4 +194,20 @@ public class SocketConnection extends BasicConnection { ...@@ -194,4 +194,20 @@ public class SocketConnection extends BasicConnection {
session.incrementServerPacketCount(); session.incrementServerPacketCount();
} }
} }
public void deliver(String text) throws UnauthorizedException, IOException {
if (isClosed()) {
// TODO Do we want to store offline this text?
//deliverer.deliver(packet);
}
else {
synchronized (writer) {
writer.write(text);
writer.flush();
}
// TODO Do we need to audit and count these packets?
//auditor.audit(packet);
//session.incrementServerPacketCount();
}
}
} }
...@@ -17,6 +17,7 @@ import org.jivesoftware.messenger.auth.Permissions; ...@@ -17,6 +17,7 @@ import org.jivesoftware.messenger.auth.Permissions;
import org.jivesoftware.messenger.auth.UnauthorizedException; import org.jivesoftware.messenger.auth.UnauthorizedException;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.io.IOException;
import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter; import javax.xml.stream.XMLStreamWriter;
...@@ -130,4 +131,16 @@ public class ConnectionProxy implements Connection { ...@@ -130,4 +131,16 @@ public class ConnectionProxy implements Connection {
} }
} }
public void deliver(String text) throws UnauthorizedException, IOException {
//if (permissions.hasPermission(Permissions.SYSTEM_ADMIN
// | Permissions.USER_ADMIN)) {
// Look into doing something about limiting delivery
// of packets until properly authenticated
if (true) {
conn.deliver(text);
}
else {
throw new UnauthorizedException();
}
}
} }
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