Commit 6900b1e7 authored by Armando Jagucki's avatar Armando Jagucki Committed by ajagucki

JM-1419: Added encoding for non-ASCII characters in many webservice URL...

JM-1419: Added encoding for non-ASCII characters in many webservice URL requests. To be reviewed by Gabriel.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@10639 b35dd754-fafc-0310-a699-88a17e54d16e
parent f3850767
...@@ -65,7 +65,7 @@ public class ClearspaceAdminProvider implements AdminProvider { ...@@ -65,7 +65,7 @@ public class ClearspaceAdminProvider implements AdminProvider {
} }
catch (ConnectException e) { catch (ConnectException e) {
Log.error(e); Log.error(e);
return new ArrayList(); return new ArrayList<JID>();
} }
catch (Exception e) { catch (Exception e) {
// It is not supported exception, wrap it into an UnsupportedOperationException // It is not supported exception, wrap it into an UnsupportedOperationException
......
...@@ -16,6 +16,7 @@ import static org.jivesoftware.openfire.clearspace.ClearspaceManager.HttpType.GE ...@@ -16,6 +16,7 @@ import static org.jivesoftware.openfire.clearspace.ClearspaceManager.HttpType.GE
import org.jivesoftware.openfire.net.SASLAuthentication; import org.jivesoftware.openfire.net.SASLAuthentication;
import org.jivesoftware.openfire.user.UserNotFoundException; import org.jivesoftware.openfire.user.UserNotFoundException;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
import org.jdesktop.jdic.desktop.internal.impl.URLUTF8Encoder;
/** /**
* The ClearspaceAuthProvider uses the PermissionService web service inside of Clearspace * The ClearspaceAuthProvider uses the PermissionService web service inside of Clearspace
...@@ -52,7 +53,7 @@ public class ClearspaceAuthProvider implements AuthProvider { ...@@ -52,7 +53,7 @@ public class ClearspaceAuthProvider implements AuthProvider {
} }
/** /**
* Authenticates the user using permissionService/authenticate servicie of Clearspace. * Authenticates the user using permissionService/authenticate service of Clearspace.
* Throws an UnauthorizedException if the user or password are incorrect. * Throws an UnauthorizedException if the user or password are incorrect.
* *
* @param username the username. * @param username the username.
...@@ -63,6 +64,8 @@ public class ClearspaceAuthProvider implements AuthProvider { ...@@ -63,6 +64,8 @@ public class ClearspaceAuthProvider implements AuthProvider {
try { try {
// Un-escape username. // Un-escape username.
username = JID.unescapeNode(username); username = JID.unescapeNode(username);
// Encode potentially non-ASCII characters
username = URLUTF8Encoder.encode(username);
String path = URL_PREFIX + "authenticate/" + username + "/" + password; String path = URL_PREFIX + "authenticate/" + username + "/" + password;
ClearspaceManager.getInstance().executeRequest(GET, path); ClearspaceManager.getInstance().executeRequest(GET, path);
} catch (UnauthorizedException ue) { } catch (UnauthorizedException ue) {
......
...@@ -22,6 +22,7 @@ import org.jivesoftware.openfire.group.GroupNotFoundException; ...@@ -22,6 +22,7 @@ import org.jivesoftware.openfire.group.GroupNotFoundException;
import org.jivesoftware.openfire.group.GroupProvider; import org.jivesoftware.openfire.group.GroupProvider;
import org.jivesoftware.openfire.user.UserNotFoundException; import org.jivesoftware.openfire.user.UserNotFoundException;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
import org.jdesktop.jdic.desktop.internal.impl.URLUTF8Encoder;
import java.util.*; import java.util.*;
...@@ -229,6 +230,8 @@ public class ClearspaceGroupProvider implements GroupProvider { ...@@ -229,6 +230,8 @@ public class ClearspaceGroupProvider implements GroupProvider {
*/ */
private Element getGroupByName(String name) throws GroupNotFoundException { private Element getGroupByName(String name) throws GroupNotFoundException {
try { try {
// Encode potentially non-ASCII characters
name = URLUTF8Encoder.encode(name);
String path = URL_PREFIX + "socialGroupsByName/" + name; String path = URL_PREFIX + "socialGroupsByName/" + name;
return ClearspaceManager.getInstance().executeRequest(GET, path); return ClearspaceManager.getInstance().executeRequest(GET, path);
......
...@@ -22,6 +22,7 @@ import org.jivesoftware.openfire.lockout.LockOutProvider; ...@@ -22,6 +22,7 @@ import org.jivesoftware.openfire.lockout.LockOutProvider;
import org.jivesoftware.openfire.user.UserNotFoundException; import org.jivesoftware.openfire.user.UserNotFoundException;
import org.jivesoftware.util.Log; import org.jivesoftware.util.Log;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
import org.jdesktop.jdic.desktop.internal.impl.URLUTF8Encoder;
import java.util.List; import java.util.List;
...@@ -209,6 +210,8 @@ public class ClearspaceLockOutProvider implements LockOutProvider { ...@@ -209,6 +210,8 @@ public class ClearspaceLockOutProvider implements LockOutProvider {
try { try {
// Un-escape username. // Un-escape username.
username = JID.unescapeNode(username); username = JID.unescapeNode(username);
// Encode potentially non-ASCII characters
username = URLUTF8Encoder.encode(username);
// Requests the user // Requests the user
String path = USER_URL_PREFIX + "users/" + username; String path = USER_URL_PREFIX + "users/" + username;
// return the response // return the response
......
...@@ -47,6 +47,7 @@ import org.xmlpull.v1.XmlPullParserException; ...@@ -47,6 +47,7 @@ import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory; import org.xmlpull.v1.XmlPullParserFactory;
import org.xmpp.packet.IQ; import org.xmpp.packet.IQ;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
import org.jdesktop.jdic.desktop.internal.impl.URLUTF8Encoder;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
...@@ -330,6 +331,8 @@ public class ClearspaceManager extends BasicModule implements ExternalComponentM ...@@ -330,6 +331,8 @@ public class ClearspaceManager extends BasicModule implements ExternalComponentM
try { try {
// Un-escape username. // Un-escape username.
username = JID.unescapeNode(username); username = JID.unescapeNode(username);
// Encode potentially non-ASCII characters
username = URLUTF8Encoder.encode(username);
String path = ClearspaceAuthProvider.URL_PREFIX + "authenticate/" + username + "/" + password; String path = ClearspaceAuthProvider.URL_PREFIX + "authenticate/" + username + "/" + password;
executeRequest(GET, path); executeRequest(GET, path);
return true; return true;
...@@ -985,6 +988,8 @@ public class ClearspaceManager extends BasicModule implements ExternalComponentM ...@@ -985,6 +988,8 @@ public class ClearspaceManager extends BasicModule implements ExternalComponentM
// Un-escape username. // Un-escape username.
String unescapedUsername = JID.unescapeNode(username); String unescapedUsername = JID.unescapeNode(username);
// Encode potentially non-ASCII characters
unescapedUsername = URLUTF8Encoder.encode(unescapedUsername);
// Gets the user's ID from Clearspace // Gets the user's ID from Clearspace
try { try {
String path = ClearspaceUserProvider.USER_URL_PREFIX + "users/" + unescapedUsername; String path = ClearspaceUserProvider.USER_URL_PREFIX + "users/" + unescapedUsername;
...@@ -1070,6 +1075,8 @@ public class ClearspaceManager extends BasicModule implements ExternalComponentM ...@@ -1070,6 +1075,8 @@ public class ClearspaceManager extends BasicModule implements ExternalComponentM
return groupIDCache.get(groupname); return groupIDCache.get(groupname);
} }
try { try {
// Encode potentially non-ASCII characters
groupname = URLUTF8Encoder.encode(groupname);
String path = ClearspaceGroupProvider.URL_PREFIX + "groups/" + groupname; String path = ClearspaceGroupProvider.URL_PREFIX + "groups/" + groupname;
Element element = executeRequest(org.jivesoftware.openfire.clearspace.ClearspaceManager.HttpType.GET, path); Element element = executeRequest(org.jivesoftware.openfire.clearspace.ClearspaceManager.HttpType.GET, path);
......
...@@ -19,6 +19,7 @@ import org.jivesoftware.openfire.security.SecurityAuditEvent; ...@@ -19,6 +19,7 @@ import org.jivesoftware.openfire.security.SecurityAuditEvent;
import org.jivesoftware.openfire.security.SecurityAuditProvider; import org.jivesoftware.openfire.security.SecurityAuditProvider;
import org.jivesoftware.util.Log; import org.jivesoftware.util.Log;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
import org.jdesktop.jdic.desktop.internal.impl.URLUTF8Encoder;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -56,6 +57,8 @@ public class ClearspaceSecurityAuditProvider implements SecurityAuditProvider { ...@@ -56,6 +57,8 @@ public class ClearspaceSecurityAuditProvider implements SecurityAuditProvider {
Element userE = rootE.addElement("username"); Element userE = rootE.addElement("username");
// Un-escape username. // Un-escape username.
username = JID.unescapeNode(username); username = JID.unescapeNode(username);
// Encode potentially non-ASCII characters
username = URLUTF8Encoder.encode(username);
userE.addText(username); userE.addText(username);
Element descE = rootE.addElement("description"); Element descE = rootE.addElement("description");
if (summary != null) { if (summary != null) {
......
...@@ -124,7 +124,7 @@ public class ClearspaceUserProvider implements UserProvider { ...@@ -124,7 +124,7 @@ public class ClearspaceUserProvider implements UserProvider {
} }
/** /**
* Creates user using the userService/users DELETE service. If the user is not found returns. * Deletes a user using the userService/users DELETE service. If the user is not found returns.
* *
* @param username the username of the user to delete * @param username the username of the user to delete
*/ */
...@@ -135,7 +135,7 @@ public class ClearspaceUserProvider implements UserProvider { ...@@ -135,7 +135,7 @@ public class ClearspaceUserProvider implements UserProvider {
} }
try { try {
// Encode potentially non-ASCII characters // Encode potentially non-ASCII characters
username = URLUTF8Encoder.encode(username); username = URLUTF8Encoder.encode(username);
long userID = ClearspaceManager.getInstance().getUserID(username); long userID = ClearspaceManager.getInstance().getUserID(username);
String path = USER_URL_PREFIX + "users/" + userID; String path = USER_URL_PREFIX + "users/" + userID;
......
...@@ -158,7 +158,7 @@ public class User implements Cacheable, Externalizable, Result { ...@@ -158,7 +158,7 @@ public class User implements Cacheable, Externalizable, Result {
* Sets a new password for this user. * Sets a new password for this user.
* *
* @param password the new password for the user. * @param password the new password for the user.
* @throws UnsupportedOperationException * @throws UnsupportedOperationException exception
*/ */
public void setPassword(String password) throws UnsupportedOperationException { public void setPassword(String password) throws UnsupportedOperationException {
if (UserManager.getUserProvider().isReadOnly()) { if (UserManager.getUserProvider().isReadOnly()) {
......
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