Commit 3df66a4c authored by Armando Jagucki's avatar Armando Jagucki Committed by ajagucki

New interface: UserIdentitiesProvider. Makes IQDiscoInfoHandler more general...

New interface: UserIdentitiesProvider. Makes IQDiscoInfoHandler more general for discovering identities of registered users.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/branches@8774 b35dd754-fafc-0310-a699-88a17e54d16e
parent ef06d092
...@@ -27,6 +27,7 @@ import org.jivesoftware.openfire.disco.IQDiscoItemsHandler; ...@@ -27,6 +27,7 @@ import org.jivesoftware.openfire.disco.IQDiscoItemsHandler;
import org.jivesoftware.openfire.disco.ServerFeaturesProvider; import org.jivesoftware.openfire.disco.ServerFeaturesProvider;
import org.jivesoftware.openfire.disco.ServerIdentitiesProvider; import org.jivesoftware.openfire.disco.ServerIdentitiesProvider;
import org.jivesoftware.openfire.disco.ServerItemsProvider; import org.jivesoftware.openfire.disco.ServerItemsProvider;
import org.jivesoftware.openfire.disco.UserIdentitiesProvider;
import org.jivesoftware.openfire.filetransfer.DefaultFileTransferManager; import org.jivesoftware.openfire.filetransfer.DefaultFileTransferManager;
import org.jivesoftware.openfire.filetransfer.FileTransferManager; import org.jivesoftware.openfire.filetransfer.FileTransferManager;
import org.jivesoftware.openfire.filetransfer.proxy.FileTransferProxy; import org.jivesoftware.openfire.filetransfer.proxy.FileTransferProxy;
...@@ -1246,6 +1247,21 @@ public class XMPPServer { ...@@ -1246,6 +1247,21 @@ public class XMPPServer {
} }
return answer; return answer;
} }
/**
* Returns a list with all the modules that provide "discoverable" user identities.
*
* @return a list with all the modules that provide "discoverable" user identities.
*/
public List<UserIdentitiesProvider> getUserIdentitiesProviders() {
List<UserIdentitiesProvider> answer = new ArrayList<UserIdentitiesProvider>();
for (Module module : modules.values()) {
if (module instanceof UserIdentitiesProvider) {
answer.add((UserIdentitiesProvider) module);
}
}
return answer;
}
/** /**
* Returns the <code>IQDiscoInfoHandler</code> registered with this server. The * Returns the <code>IQDiscoInfoHandler</code> registered with this server. The
......
...@@ -286,21 +286,21 @@ public class IQDiscoInfoHandler extends IQHandler implements ClusterEventListene ...@@ -286,21 +286,21 @@ public class IQDiscoInfoHandler extends IQHandler implements ClusterEventListene
for (ServerFeaturesProvider provider : server.getServerFeaturesProviders()) { for (ServerFeaturesProvider provider : server.getServerFeaturesProviders()) {
addServerFeaturesProvider(provider); addServerFeaturesProvider(provider);
} }
// Track the implementors of ServerIdentitiesProvider so that we can collect the identities // Collect the implementors of ServerIdentitiesProvider so that we can collect the identities
// for protocols supported by the server // for protocols supported by the server
for (ServerIdentitiesProvider provider : server.getServerIdentitiesProviders()) { for (ServerIdentitiesProvider provider : server.getServerIdentitiesProviders()) {
for (Iterator<Element> it = provider.getIdentities(); it.hasNext();) { for (Iterator<Element> it = provider.getIdentities(); it.hasNext();) {
serverIdentities.add(it.next()); serverIdentities.add(it.next());
} }
} }
// Collect the implementors of UserIdentitiesProvider so that we can collect identities
// FIXME: Create a UserIdentityProvider interface // for registered users.
if (server.getIQPEPHandler() != null) { for (UserIdentitiesProvider provider : server.getUserIdentitiesProviders()) {
Element userIdentity = DocumentHelper.createElement("identity"); for (Iterator<Element> it = provider.getIdentities(); it.hasNext();) {
userIdentity.addAttribute("category", "pubsub"); registeredUserIdentities.add(it.next());
userIdentity.addAttribute("type", "pep"); }
registeredUserIdentities.add(0, userIdentity);
} }
setProvider(server.getServerInfo().getName(), getServerInfoProvider()); setProvider(server.getServerInfo().getName(), getServerInfoProvider());
// Listen to cluster events // Listen to cluster events
ClusterManager.addListener(this); ClusterManager.addListener(this);
......
...@@ -17,7 +17,7 @@ import org.dom4j.Element; ...@@ -17,7 +17,7 @@ import org.dom4j.Element;
/** /**
* <p> * <p>
* A <code>ServerIdentityProvider</code> is responsible for providing the identities * A <code>ServerIdentitiesProvider</code> is responsible for providing the identities
* of protocols supported by the SERVER. An example of a server identity is that * of protocols supported by the SERVER. An example of a server identity is that
* for PEP (XEP-0163): <identity category="pubsub" type="pep" /> * for PEP (XEP-0163): <identity category="pubsub" type="pep" />
* <p/> * <p/>
......
...@@ -18,6 +18,7 @@ import org.jivesoftware.openfire.XMPPServer; ...@@ -18,6 +18,7 @@ import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.auth.UnauthorizedException; import org.jivesoftware.openfire.auth.UnauthorizedException;
import org.jivesoftware.openfire.disco.ServerFeaturesProvider; import org.jivesoftware.openfire.disco.ServerFeaturesProvider;
import org.jivesoftware.openfire.disco.ServerIdentitiesProvider; import org.jivesoftware.openfire.disco.ServerIdentitiesProvider;
import org.jivesoftware.openfire.disco.UserIdentitiesProvider;
import org.jivesoftware.openfire.handler.IQHandler; import org.jivesoftware.openfire.handler.IQHandler;
import org.jivesoftware.openfire.pubsub.LeafNode; import org.jivesoftware.openfire.pubsub.LeafNode;
import org.jivesoftware.openfire.pubsub.PubSubEngine; import org.jivesoftware.openfire.pubsub.PubSubEngine;
...@@ -59,7 +60,7 @@ import java.util.concurrent.ConcurrentHashMap; ...@@ -59,7 +60,7 @@ import java.util.concurrent.ConcurrentHashMap;
* *
*/ */
public class IQPEPHandler extends IQHandler implements ServerIdentitiesProvider, public class IQPEPHandler extends IQHandler implements ServerIdentitiesProvider,
ServerFeaturesProvider { ServerFeaturesProvider, UserIdentitiesProvider {
// Map of PEP services. Table, Key: bare JID (String); Value: PEPService // Map of PEP services. Table, Key: bare JID (String); Value: PEPService
private Map<String, PEPService> pepServices; private Map<String, PEPService> pepServices;
...@@ -164,8 +165,8 @@ public class IQPEPHandler extends IQHandler implements ServerIdentitiesProvider, ...@@ -164,8 +165,8 @@ public class IQPEPHandler extends IQHandler implements ServerIdentitiesProvider,
} }
/** /**
* Implements ServerIdentitiesProvider, adding the PEP identity to the * Implements ServerIdentitiesProvider and UserIdentitiesProvider, adding
* server's disco#info result. * the PEP identity to the respective disco#info results.
*/ */
public Iterator<Element> getIdentities() { public Iterator<Element> getIdentities() {
ArrayList<Element> identities = new ArrayList<Element>(); ArrayList<Element> identities = new ArrayList<Element>();
......
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