Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
Openfire
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Openfire
Commits
8fad4b8e
Commit
8fad4b8e
authored
Nov 14, 2017
by
Dave Cridland
Committed by
akrherz
Nov 14, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OF-1427 Respond to PEP node disco#info
parent
aa5ff6ee
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
97 additions
and
18 deletions
+97
-18
IQDiscoInfoHandler.java
...a/org/jivesoftware/openfire/disco/IQDiscoInfoHandler.java
+23
-4
IQPEPHandler.java
src/java/org/jivesoftware/openfire/pep/IQPEPHandler.java
+74
-14
No files found.
src/java/org/jivesoftware/openfire/disco/IQDiscoInfoHandler.java
View file @
8fad4b8e
...
...
@@ -426,7 +426,7 @@ public class IQDiscoInfoHandler extends IQHandler implements ClusterEventListene
// Redirect the request to the disco info provider of the specified node
return
serverNodeProviders
.
get
(
node
).
getIdentities
(
name
,
node
,
senderJID
);
}
if
(
name
!=
null
&&
name
.
equals
(
XMPPServer
.
getInstance
().
getServerInfo
().
getXMPPDomain
()))
{
if
(
name
==
null
||
name
.
equals
(
XMPPServer
.
getInstance
().
getServerInfo
().
getXMPPDomain
()))
{
// Answer identity of the server
synchronized
(
identities
)
{
if
(
identities
.
isEmpty
())
{
...
...
@@ -446,6 +446,9 @@ public class IQDiscoInfoHandler extends IQHandler implements ClusterEventListene
}
return
identities
.
iterator
();
}
else
if
(
node
!=
null
)
{
return
XMPPServer
.
getInstance
().
getIQPEPHandler
().
getIdentities
(
name
,
node
,
senderJID
);
}
else
{
if
(
SessionManager
.
getInstance
().
isAnonymousRoute
(
name
))
{
// Answer identity of an anonymous user.
...
...
@@ -465,6 +468,9 @@ public class IQDiscoInfoHandler extends IQHandler implements ClusterEventListene
// Redirect the request to the disco info provider of the specified node
return
serverNodeProviders
.
get
(
node
).
getFeatures
(
name
,
node
,
senderJID
);
}
if
(
node
!=
null
&&
name
!=
null
)
{
return
XMPPServer
.
getInstance
().
getIQPEPHandler
().
getFeatures
(
name
,
node
,
senderJID
);
}
// Answer features of the server
return
new
HashSet
<>(
serverFeatures
.
keySet
()).
iterator
();
}
...
...
@@ -476,14 +482,24 @@ public class IQDiscoInfoHandler extends IQHandler implements ClusterEventListene
// Redirect the request to the disco info provider of the specified node
return
serverNodeProviders
.
get
(
node
).
hasInfo
(
name
,
node
,
senderJID
);
}
if
(
name
!=
null
)
{
return
XMPPServer
.
getInstance
().
getIQPEPHandler
().
hasInfo
(
name
,
node
,
senderJID
);
}
// Unknown node
return
false
;
}
try
{
// True if it is an info request of the server, a registered user or an
// anonymous user. We now support disco of user's bare JIDs
return
name
==
null
||
UserManager
.
getInstance
().
getUser
(
name
)
!=
null
||
SessionManager
.
getInstance
().
isAnonymousRoute
(
name
);
if
(
name
==
null
)
return
true
;
if
(
UserManager
.
getInstance
().
getUser
(
name
)
!=
null
||
SessionManager
.
getInstance
().
isAnonymousRoute
(
name
))
{
if
(
node
==
null
)
{
return
true
;
}
return
XMPPServer
.
getInstance
().
getIQPEPHandler
().
hasInfo
(
name
,
node
,
senderJID
);
}
return
false
;
}
catch
(
UserNotFoundException
e
)
{
return
false
;
...
...
@@ -496,8 +512,11 @@ public class IQDiscoInfoHandler extends IQHandler implements ClusterEventListene
// Redirect the request to the disco info provider of the specified node
return
serverNodeProviders
.
get
(
node
).
getExtendedInfo
(
name
,
node
,
senderJID
);
}
if
(
node
!=
null
&&
name
!=
null
)
{
return
XMPPServer
.
getInstance
().
getIQPEPHandler
().
getExtendedInfo
(
name
,
node
,
senderJID
);
}
return
null
;
}
};
}
}
\ No newline at end of file
}
src/java/org/jivesoftware/openfire/pep/IQPEPHandler.java
View file @
8fad4b8e
...
...
@@ -20,10 +20,7 @@
package
org
.
jivesoftware
.
openfire
.
pep
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Iterator
;
import
java.util.Map
;
import
java.util.*
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.TimeUnit
;
...
...
@@ -34,18 +31,11 @@ import org.dom4j.QName;
import
org.jivesoftware.openfire.IQHandlerInfo
;
import
org.jivesoftware.openfire.XMPPServer
;
import
org.jivesoftware.openfire.auth.UnauthorizedException
;
import
org.jivesoftware.openfire.disco.ServerFeaturesProvider
;
import
org.jivesoftware.openfire.disco.ServerIdentitiesProvider
;
import
org.jivesoftware.openfire.disco.UserIdentitiesProvider
;
import
org.jivesoftware.openfire.disco.UserItemsProvider
;
import
org.jivesoftware.openfire.disco.*
;
import
org.jivesoftware.openfire.event.UserEventDispatcher
;
import
org.jivesoftware.openfire.event.UserEventListener
;
import
org.jivesoftware.openfire.handler.IQHandler
;
import
org.jivesoftware.openfire.pubsub.CollectionNode
;
import
org.jivesoftware.openfire.pubsub.LeafNode
;
import
org.jivesoftware.openfire.pubsub.Node
;
import
org.jivesoftware.openfire.pubsub.NodeSubscription
;
import
org.jivesoftware.openfire.pubsub.PubSubEngine
;
import
org.jivesoftware.openfire.pubsub.*
;
import
org.jivesoftware.openfire.pubsub.models.AccessModel
;
import
org.jivesoftware.openfire.roster.Roster
;
import
org.jivesoftware.openfire.roster.RosterEventDispatcher
;
...
...
@@ -97,7 +87,7 @@ import org.xmpp.packet.Presence;
*/
public
class
IQPEPHandler
extends
IQHandler
implements
ServerIdentitiesProvider
,
ServerFeaturesProvider
,
UserIdentitiesProvider
,
UserItemsProvider
,
PresenceEventListener
,
RosterEventListener
,
UserEventListener
{
RosterEventListener
,
UserEventListener
,
DiscoInfoProvider
{
private
static
final
Logger
Log
=
LoggerFactory
.
getLogger
(
IQPEPHandler
.
class
);
...
...
@@ -659,6 +649,76 @@ public class IQPEPHandler extends IQHandler implements ServerIdentitiesProvider,
// Do nothing
}
// DiscoInfoProvider
/*
* With all these, there are basically two axes of binary choice.
* Either the PEPService exists already - in which case we can defer to it,
* or else it doesn't, in which case we should use the generic engine.
*
* In either case, we might be being asked for a node, or the root. If we're
* asked for a node when the PEPService doesn't exist that's an error. Otherwise
* if we're asked for the root we can safely defer to the generic engine.
*/
@Override
public
Iterator
<
Element
>
getIdentities
(
String
name
,
String
node
,
JID
senderJID
)
{
String
recipientJID
=
XMPPServer
.
getInstance
().
createJID
(
name
,
null
,
true
).
toBareJID
();
PEPService
pepService
=
pepServiceManager
.
getPEPService
(
recipientJID
);
if
(
node
!=
null
&&
pepService
!=
null
)
{
Node
pubNode
=
pepService
.
getNode
(
node
);
if
(
pubNode
==
null
)
return
null
;
// Answer the identity of a given node
Element
identity
=
DocumentHelper
.
createElement
(
"identity"
);
identity
.
addAttribute
(
"category"
,
"pubsub"
);
identity
.
addAttribute
(
"type"
,
pubNode
.
isCollectionNode
()
?
"collection"
:
"leaf"
);
List
<
Element
>
identities
=
new
LinkedList
<>();
identities
.
add
(
identity
);
return
identities
.
iterator
();
}
else
if
(
node
!=
null
)
{
return
null
;
}
else
{
PubSubModule
pubsub
=
XMPPServer
.
getInstance
().
getPubSubModule
();
return
pubsub
.
getIdentities
(
null
,
null
,
senderJID
);
}
}
@Override
public
Iterator
<
String
>
getFeatures
(
String
name
,
String
node
,
JID
senderJID
)
{
if
(
node
==
null
)
{
PubSubModule
pubsub
=
XMPPServer
.
getInstance
().
getPubSubModule
();
return
pubsub
.
getFeatures
(
null
,
null
,
senderJID
);
}
else
{
List
<
String
>
features
=
new
LinkedList
<>();
features
.
add
(
"http://jabber.org/protocol/pubsub"
);
return
features
.
iterator
();
}
}
@Override
public
DataForm
getExtendedInfo
(
String
name
,
String
node
,
JID
senderJID
)
{
String
recipientJID
=
XMPPServer
.
getInstance
().
createJID
(
name
,
null
,
true
).
toBareJID
();
PEPService
pepService
=
pepServiceManager
.
getPEPService
(
recipientJID
);
if
(
node
!=
null
)
{
// Answer the extended info of a given node
Node
pubNode
=
pepService
.
getNode
(
node
);
// Get the metadata data form
return
pubNode
.
getMetadataForm
();
}
return
null
;
}
@Override
public
boolean
hasInfo
(
String
name
,
String
node
,
JID
senderJID
)
{
if
(
node
==
null
)
return
true
;
String
recipientJID
=
XMPPServer
.
getInstance
().
createJID
(
name
,
null
,
true
).
toBareJID
();
PEPService
pepService
=
pepServiceManager
.
getPEPService
(
recipientJID
);
return
pepService
.
getNode
(
node
)
!=
null
;
}
private
class
GetNotificationsOnInitialPresence
implements
Runnable
{
private
final
JID
availableSessionJID
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment