Class IQBlockingHandler
- java.lang.Object
-
- org.jivesoftware.openfire.container.BasicModule
-
- org.jivesoftware.openfire.handler.IQHandler
-
- org.jivesoftware.openfire.handler.IQBlockingHandler
-
- All Implemented Interfaces:
ChannelHandler
,Module
,ServerFeaturesProvider
public class IQBlockingHandler extends IQHandler implements ServerFeaturesProvider
Implementation of XEP-0191 "Blocking Command". This implementation uses the default privacy list of a user to store its blocklist.- Author:
- Guus der Kinderen, guus.der.kinderen@gmail.com
-
-
Field Summary
-
Fields inherited from class org.jivesoftware.openfire.handler.IQHandler
deliverer, sessionManager
-
-
Constructor Summary
Constructors Constructor Description IQBlockingHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addToBlockList(User user, List<org.xmpp.packet.JID> toBlocks)
Adds a collection of JIDs to the blocklist of the provided user.protected Set<org.xmpp.packet.JID>
getBlocklist(User user)
Retrieves all of the JIDs that are on the blocklist of the provided user.Iterator<String>
getFeatures()
Returns an Iterator (of String) with the supported features by the server.IQHandlerInfo
getInfo()
Returns the handler information to help generically handle IQ packets.org.xmpp.packet.IQ
handleIQ(org.xmpp.packet.IQ iq)
Handles the received IQ packet.protected void
pushBlocklistUpdates(User user, Collection<org.xmpp.packet.JID> newBlocks)
Sends an IQ-set with the newly blocked JIDs to all resources of the user that have requested the blocklist.protected void
pushBlocklistUpdates(User user, List<org.xmpp.packet.JID> newBlocks)
Sends an IQ-set with the newly blocked JIDs to all resources of the user that have requested the blocklist.protected Set<org.xmpp.packet.JID>
removeFromBlockList(User user, Collection<org.xmpp.packet.JID> toUnblocks)
Removes a collection of JIDs from the blocklist of the provided user.-
Methods inherited from class org.jivesoftware.openfire.handler.IQHandler
initialize, process
-
Methods inherited from class org.jivesoftware.openfire.container.BasicModule
destroy, getName, start, stop
-
-
-
-
Method Detail
-
getInfo
public IQHandlerInfo getInfo()
Description copied from class:IQHandler
Returns the handler information to help generically handle IQ packets. IQHandlers that aren't local server iq handlers (e.g. chatbots, transports, etc) returnnull
.
-
getFeatures
public Iterator<String> getFeatures()
Description copied from interface:ServerFeaturesProvider
Returns an Iterator (of String) with the supported features by the server. The features to include are the features offered and supported protocols by the SERVER. The idea is that different modules may provide their features that will ultimately be part of the features offered by the server.- Specified by:
getFeatures
in interfaceServerFeaturesProvider
- Returns:
- an Iterator (of String) with the supported features by the server.
-
handleIQ
public org.xmpp.packet.IQ handleIQ(org.xmpp.packet.IQ iq) throws UnauthorizedException
Description copied from class:IQHandler
Handles the received IQ packet.- Specified by:
handleIQ
in classIQHandler
- Parameters:
iq
- the IQ packet to handle.- Returns:
- the response to send back.
- Throws:
UnauthorizedException
- if the user that sent the packet is not authorized to request the given operation.
-
getBlocklist
protected Set<org.xmpp.packet.JID> getBlocklist(User user)
Retrieves all of the JIDs that are on the blocklist of the provided user.- Parameters:
user
- The use for which to retrieve the blocklist (cannot be null).- Returns:
- The JIDs that are on the blocklist (possibly empty, but never null).
-
addToBlockList
protected void addToBlockList(User user, List<org.xmpp.packet.JID> toBlocks)
Adds a collection of JIDs to the blocklist of the provided user. This method adds the JIDs to the default privacy list, creating a new privacy list (and setting it as default) if the user does not have a default privacy list. The newly added JIDs are push on the front end of the list. The order of pre-existing list items is modified.- Parameters:
user
- The owner of the blocklist to which JIDs are to be added (cannot be null).toBlocks
- The JIDs to be added (can be null, which results in a noop).
-
pushBlocklistUpdates
protected void pushBlocklistUpdates(User user, List<org.xmpp.packet.JID> newBlocks)
Sends an IQ-set with the newly blocked JIDs to all resources of the user that have requested the blocklist.- Parameters:
user
- The for which updates are to be broadcasted (cannot be null).newBlocks
- The JIDs for which an update needs to be sent (cannot be null, can be empty).
-
removeFromBlockList
protected Set<org.xmpp.packet.JID> removeFromBlockList(User user, Collection<org.xmpp.packet.JID> toUnblocks)
Removes a collection of JIDs from the blocklist of the provided user. This method removes the JIDs to the default privacy list. When no default privacy list exists for this user, this method does nothing.- Parameters:
user
- The owner of the blocklist to which JIDs are to be added (cannot be null).toUnblocks
- The JIDs to be removed (can be null, which results in a noop).- Returns:
- The JIDs that are removed (never null, possibly empty).
-
pushBlocklistUpdates
protected void pushBlocklistUpdates(User user, Collection<org.xmpp.packet.JID> newBlocks)
Sends an IQ-set with the newly blocked JIDs to all resources of the user that have requested the blocklist.- Parameters:
user
- The for which updates are to be broadcasted (cannot be null).newBlocks
- The JIDs for which an update needs to be sent (cannot be null, can be empty).
-
-