Commit 6fb84427 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

1) Added #getUsernames().

2) Setting new password was not being saved. JM-631

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@3736 b35dd754-fafc-0310-a699-88a17e54d16e
parent 52034d0a
...@@ -11,10 +11,10 @@ ...@@ -11,10 +11,10 @@
package org.jivesoftware.wildfire.ldap; package org.jivesoftware.wildfire.ldap;
import org.jivesoftware.wildfire.user.*;
import org.jivesoftware.util.JiveConstants; import org.jivesoftware.util.JiveConstants;
import org.jivesoftware.util.JiveGlobals; import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log; import org.jivesoftware.util.Log;
import org.jivesoftware.wildfire.user.*;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
import javax.naming.NamingEnumeration; import javax.naming.NamingEnumeration;
...@@ -152,6 +152,11 @@ public class LdapUserProvider implements UserProvider { ...@@ -152,6 +152,11 @@ public class LdapUserProvider implements UserProvider {
} }
public Collection<User> getUsers() { public Collection<User> getUsers() {
Collection<String> usernames = getUsernames();
return new UserCollection(usernames.toArray(new String[usernames.size()]));
}
public Collection<String> getUsernames() {
List<String> usernames = new ArrayList<String>(); List<String> usernames = new ArrayList<String>();
LdapContext ctx = null; LdapContext ctx = null;
try { try {
...@@ -194,7 +199,7 @@ public class LdapUserProvider implements UserProvider { ...@@ -194,7 +199,7 @@ public class LdapUserProvider implements UserProvider {
if (Boolean.valueOf(JiveGlobals.getXMLProperty("ldap.clientSideSorting"))) { if (Boolean.valueOf(JiveGlobals.getXMLProperty("ldap.clientSideSorting"))) {
Collections.sort(usernames); Collections.sort(usernames);
} }
return new UserCollection(usernames.toArray(new String[usernames.size()])); return usernames;
} }
public Collection<User> getUsers(int startIndex, int numResults) { public Collection<User> getUsers(int startIndex, int numResults) {
......
...@@ -250,6 +250,11 @@ public class DefaultUserProvider implements UserProvider { ...@@ -250,6 +250,11 @@ public class DefaultUserProvider implements UserProvider {
} }
public Collection<User> getUsers() { public Collection<User> getUsers() {
Collection<String> usernames = getUsernames();
return new UserCollection(usernames.toArray(new String[usernames.size()]));
}
public Collection<String> getUsernames() {
List<String> usernames = new ArrayList<String>(500); List<String> usernames = new ArrayList<String>(500);
Connection con = null; Connection con = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
...@@ -274,7 +279,7 @@ public class DefaultUserProvider implements UserProvider { ...@@ -274,7 +279,7 @@ public class DefaultUserProvider implements UserProvider {
try { if (con != null) { con.close(); } } try { if (con != null) { con.close(); } }
catch (Exception e) { Log.error(e); } catch (Exception e) { Log.error(e); }
} }
return new UserCollection(usernames.toArray(new String[usernames.size()])); return usernames;
} }
public Collection<User> getUsers(int startIndex, int numResults) { public Collection<User> getUsers(int startIndex, int numResults) {
...@@ -470,7 +475,10 @@ public class DefaultUserProvider implements UserProvider { ...@@ -470,7 +475,10 @@ public class DefaultUserProvider implements UserProvider {
if (encryptedPassword == null) { if (encryptedPassword == null) {
pstmt.setNull(2, Types.VARCHAR); pstmt.setNull(2, Types.VARCHAR);
} }
pstmt.setString(2, username); else {
pstmt.setString(2, encryptedPassword);
}
pstmt.setString(3, username);
pstmt.executeUpdate(); pstmt.executeUpdate();
} }
catch (SQLException sqle) { catch (SQLException sqle) {
......
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
package org.jivesoftware.wildfire.user; package org.jivesoftware.wildfire.user;
import java.util.Date;
import java.util.Collection; import java.util.Collection;
import java.util.Date;
import java.util.Set; import java.util.Set;
/** /**
...@@ -73,6 +73,14 @@ public interface UserProvider { ...@@ -73,6 +73,14 @@ public interface UserProvider {
*/ */
public Collection<User> getUsers(); public Collection<User> getUsers();
/**
* Returns an unmodifiable Collection of usernames of all users in the system.
*
* @return an unmodifiable Collection of all usernames in the system.
*/
public Collection<String> getUsernames();
/** /**
* Returns an unmodifiable Collections of users in the system within the * Returns an unmodifiable Collections of users in the system within the
* specified range. The {@link UserCollection} class can be used to assist * specified range. The {@link UserCollection} class can be used to assist
......
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