Package org.jivesoftware.openfire.user
Class UserNameManager
java.lang.Object
org.jivesoftware.openfire.user.UserNameManager
Main responsibility of this class is to return the correct name of XMPP entities. For local
entities (i.e. users) the
User name is used. For remote entities the following logic
is used:
- Check if a
UserNameProvideris registered for the entity's domain. If a provider was found then use it to get the entity's name - If no provider was found then retrieve the vCard of the entity and return the name as defined in the vCard. This is not implemented yet.
- If no vCard was found then return the string representation of the entity's JID.
- Author:
- Gaston Dombiak
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddUserNameProvider(String domain, UserNameProvider provider) Adds the specifiedUserNameProvideras the provider of users of the specified domain.static StringgetUserName(org.xmpp.packet.JID entity) Returns the name of the XMPP entity.static StringgetUserName(org.xmpp.packet.JID entity, String defaultName) Returns the name of the XMPP entity.static voidremoveUserNameProvider(String domain) Removes anyUserNameProviderthat was associated with the specified domain.
-
Method Details
-
addUserNameProvider
Adds the specifiedUserNameProvideras the provider of users of the specified domain.- Parameters:
domain- the domain hosted by the UserNameProvider.provider- the provider that will provide the name of users in the specified domain.
-
removeUserNameProvider
Removes anyUserNameProviderthat was associated with the specified domain.- Parameters:
domain- the domain hosted by a UserNameProvider.
-
getUserName
Returns the name of the XMPP entity. If the entity is a local user then the User's name will be returned. However, if the user is not a local user then check if there exists a UserNameProvider that provides name for the specified domain. If none was found then the vCard of the entity might be requested and if none was found then a string representation of the entity's JID will be returned.- Parameters:
entity- the JID of the entity to get its name.- Returns:
- the name of the XMPP entity.
- Throws:
UserNotFoundException- if the jid belongs to the local server but no user was found for that jid.
-
getUserName
public static String getUserName(org.xmpp.packet.JID entity, String defaultName) throws UserNotFoundException Returns the name of the XMPP entity. If the entity is a local user then the User's name will be returned. However, if the user is not a local user then check if there exists a UserNameProvider that provides name for the specified domain. If none was found then the vCard of the entity might be requested and if none was found then a string representation of the entity's JID will be returned.- Parameters:
entity- the JID of the entity to get its name.defaultName- default name to return when no name was found.- Returns:
- the name of the XMPP entity.
- Throws:
UserNotFoundException- if the jid belongs to the local server but no user was found for that jid.
-