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
ca435745
Commit
ca435745
authored
Nov 14, 2017
by
Dave Cridland
Committed by
Guus der Kinderen
Nov 14, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OF-1427 Respond to PEP node disco#info
parent
38842fd5
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 @
ca435745
...
@@ -422,7 +422,7 @@ public class IQDiscoInfoHandler extends IQHandler implements ClusterEventListene
...
@@ -422,7 +422,7 @@ public class IQDiscoInfoHandler extends IQHandler implements ClusterEventListene
// Redirect the request to the disco info provider of the specified node
// Redirect the request to the disco info provider of the specified node
return
serverNodeProviders
.
get
(
node
).
getIdentities
(
name
,
node
,
senderJID
);
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
// Answer identity of the server
synchronized
(
identities
)
{
synchronized
(
identities
)
{
if
(
identities
.
isEmpty
())
{
if
(
identities
.
isEmpty
())
{
...
@@ -442,6 +442,9 @@ public class IQDiscoInfoHandler extends IQHandler implements ClusterEventListene
...
@@ -442,6 +442,9 @@ public class IQDiscoInfoHandler extends IQHandler implements ClusterEventListene
}
}
return
identities
.
iterator
();
return
identities
.
iterator
();
}
}
else
if
(
node
!=
null
)
{
return
XMPPServer
.
getInstance
().
getIQPEPHandler
().
getIdentities
(
name
,
node
,
senderJID
);
}
else
{
else
{
if
(
SessionManager
.
getInstance
().
isAnonymousRoute
(
name
))
{
if
(
SessionManager
.
getInstance
().
isAnonymousRoute
(
name
))
{
// Answer identity of an anonymous user.
// Answer identity of an anonymous user.
...
@@ -461,6 +464,9 @@ public class IQDiscoInfoHandler extends IQHandler implements ClusterEventListene
...
@@ -461,6 +464,9 @@ public class IQDiscoInfoHandler extends IQHandler implements ClusterEventListene
// Redirect the request to the disco info provider of the specified node
// Redirect the request to the disco info provider of the specified node
return
serverNodeProviders
.
get
(
node
).
getFeatures
(
name
,
node
,
senderJID
);
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
// Answer features of the server
return
new
HashSet
<>(
serverFeatures
.
keySet
()).
iterator
();
return
new
HashSet
<>(
serverFeatures
.
keySet
()).
iterator
();
}
}
...
@@ -472,14 +478,24 @@ public class IQDiscoInfoHandler extends IQHandler implements ClusterEventListene
...
@@ -472,14 +478,24 @@ public class IQDiscoInfoHandler extends IQHandler implements ClusterEventListene
// Redirect the request to the disco info provider of the specified node
// Redirect the request to the disco info provider of the specified node
return
serverNodeProviders
.
get
(
node
).
hasInfo
(
name
,
node
,
senderJID
);
return
serverNodeProviders
.
get
(
node
).
hasInfo
(
name
,
node
,
senderJID
);
}
}
if
(
name
!=
null
)
{
return
XMPPServer
.
getInstance
().
getIQPEPHandler
().
hasInfo
(
name
,
node
,
senderJID
);
}
// Unknown node
// Unknown node
return
false
;
return
false
;
}
}
try
{
try
{
// True if it is an info request of the server, a registered user or an
// 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
// anonymous user. We now support disco of user's bare JIDs
return
name
==
null
||
UserManager
.
getInstance
().
getUser
(
name
)
!=
null
||
if
(
name
==
null
)
return
true
;
SessionManager
.
getInstance
().
isAnonymousRoute
(
name
);
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
)
{
catch
(
UserNotFoundException
e
)
{
return
false
;
return
false
;
...
@@ -492,8 +508,11 @@ public class IQDiscoInfoHandler extends IQHandler implements ClusterEventListene
...
@@ -492,8 +508,11 @@ public class IQDiscoInfoHandler extends IQHandler implements ClusterEventListene
// Redirect the request to the disco info provider of the specified node
// Redirect the request to the disco info provider of the specified node
return
serverNodeProviders
.
get
(
node
).
getExtendedInfo
(
name
,
node
,
senderJID
);
return
serverNodeProviders
.
get
(
node
).
getExtendedInfo
(
name
,
node
,
senderJID
);
}
}
if
(
node
!=
null
&&
name
!=
null
)
{
return
XMPPServer
.
getInstance
().
getIQPEPHandler
().
getExtendedInfo
(
name
,
node
,
senderJID
);
}
return
null
;
return
null
;
}
}
};
};
}
}
}
}
\ No newline at end of file
src/java/org/jivesoftware/openfire/pep/IQPEPHandler.java
View file @
ca435745
...
@@ -16,10 +16,7 @@
...
@@ -16,10 +16,7 @@
package
org
.
jivesoftware
.
openfire
.
pep
;
package
org
.
jivesoftware
.
openfire
.
pep
;
import
java.util.ArrayList
;
import
java.util.*
;
import
java.util.Collections
;
import
java.util.Iterator
;
import
java.util.Map
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
...
@@ -30,18 +27,11 @@ import org.dom4j.QName;
...
@@ -30,18 +27,11 @@ import org.dom4j.QName;
import
org.jivesoftware.openfire.IQHandlerInfo
;
import
org.jivesoftware.openfire.IQHandlerInfo
;
import
org.jivesoftware.openfire.XMPPServer
;
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.*
;
import
org.jivesoftware.openfire.disco.ServerIdentitiesProvider
;
import
org.jivesoftware.openfire.disco.UserIdentitiesProvider
;
import
org.jivesoftware.openfire.disco.UserItemsProvider
;
import
org.jivesoftware.openfire.event.UserEventDispatcher
;
import
org.jivesoftware.openfire.event.UserEventDispatcher
;
import
org.jivesoftware.openfire.event.UserEventListener
;
import
org.jivesoftware.openfire.event.UserEventListener
;
import
org.jivesoftware.openfire.handler.IQHandler
;
import
org.jivesoftware.openfire.handler.IQHandler
;
import
org.jivesoftware.openfire.pubsub.CollectionNode
;
import
org.jivesoftware.openfire.pubsub.*
;
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.models.AccessModel
;
import
org.jivesoftware.openfire.pubsub.models.AccessModel
;
import
org.jivesoftware.openfire.roster.Roster
;
import
org.jivesoftware.openfire.roster.Roster
;
import
org.jivesoftware.openfire.roster.RosterEventDispatcher
;
import
org.jivesoftware.openfire.roster.RosterEventDispatcher
;
...
@@ -93,7 +83,7 @@ import org.xmpp.packet.Presence;
...
@@ -93,7 +83,7 @@ import org.xmpp.packet.Presence;
*/
*/
public
class
IQPEPHandler
extends
IQHandler
implements
ServerIdentitiesProvider
,
ServerFeaturesProvider
,
public
class
IQPEPHandler
extends
IQHandler
implements
ServerIdentitiesProvider
,
ServerFeaturesProvider
,
UserIdentitiesProvider
,
UserItemsProvider
,
PresenceEventListener
,
UserIdentitiesProvider
,
UserItemsProvider
,
PresenceEventListener
,
RosterEventListener
,
UserEventListener
{
RosterEventListener
,
UserEventListener
,
DiscoInfoProvider
{
private
static
final
Logger
Log
=
LoggerFactory
.
getLogger
(
IQPEPHandler
.
class
);
private
static
final
Logger
Log
=
LoggerFactory
.
getLogger
(
IQPEPHandler
.
class
);
...
@@ -655,6 +645,76 @@ public class IQPEPHandler extends IQHandler implements ServerIdentitiesProvider,
...
@@ -655,6 +645,76 @@ public class IQPEPHandler extends IQHandler implements ServerIdentitiesProvider,
// Do nothing
// 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
class
GetNotificationsOnInitialPresence
implements
Runnable
{
private
final
JID
availableSessionJID
;
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