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

Added checking of permissions.


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@1542 b35dd754-fafc-0310-a699-88a17e54d16e
parent 155f7ee8
...@@ -120,7 +120,6 @@ class ServerDialback { ...@@ -120,7 +120,6 @@ class ServerDialback {
* @return an OutgoingServerSession if the domain was authenticated or <tt>null</tt> if none. * @return an OutgoingServerSession if the domain was authenticated or <tt>null</tt> if none.
*/ */
public OutgoingServerSession createOutgoingSession(String domain, String hostname, int port) { public OutgoingServerSession createOutgoingSession(String domain, String hostname, int port) {
// TODO Check if the hostname is in the blacklist
String realHostname = null; String realHostname = null;
try { try {
// Establish a TCP connection to the Receiving Server // Establish a TCP connection to the Receiving Server
...@@ -393,8 +392,20 @@ class ServerDialback { ...@@ -393,8 +392,20 @@ class ServerDialback {
String recipient = doc.attributeValue("to"); String recipient = doc.attributeValue("to");
String hostname = doc.attributeValue("from"); String hostname = doc.attributeValue("from");
Log.debug("RS - Received dialback key from host: " + hostname + " to: " + recipient); Log.debug("RS - Received dialback key from host: " + hostname + " to: " + recipient);
boolean host_unknown = isHostUnknown(recipient); if (!RemoteServerManager.canAccess(hostname)) {
if (host_unknown) { // Remote server is not allowed to establish a connection to this server
error = new StreamError(StreamError.Condition.host_unknown);
sb = new StringBuilder();
sb.append(error.toXML());
connection.deliverRawText(sb.toString());
// Close the underlying connection
connection.close();
Log.debug("RS - Error, hostname is not allowed to establish a connection to " +
"this server: " +
recipient);
return false;
}
else if (isHostUnknown(recipient)) {
// address does not match a recognized hostname // address does not match a recognized hostname
error = new StreamError(StreamError.Condition.host_unknown); error = new StreamError(StreamError.Condition.host_unknown);
sb = new StringBuilder(); sb = new StringBuilder();
...@@ -483,7 +494,6 @@ class ServerDialback { ...@@ -483,7 +494,6 @@ class ServerDialback {
private boolean verifyKey(String key, String streamID, String recipient, String hostname, private boolean verifyKey(String key, String streamID, String recipient, String hostname,
String host, int port) throws IOException, XmlPullParserException, String host, int port) throws IOException, XmlPullParserException,
RemoteConnectionFailedException { RemoteConnectionFailedException {
// TODO Check if the hostname is in the blacklist
XPPPacketReader reader = null; XPPPacketReader reader = null;
Writer writer = null; Writer writer = null;
StreamError error; StreamError error;
......
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