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
27c5cc74
Commit
27c5cc74
authored
Jul 04, 2016
by
Guus der Kinderen
Committed by
GitHub
Jul 04, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #610 from GregDThomas/OF-1152
OF-1152: Ensure that raw XML is logged;
parents
bfc13370
b227b3cb
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
27 deletions
+54
-27
changelog.html
src/plugins/xmldebugger/changelog.html
+6
-1
plugin.xml
src/plugins/xmldebugger/plugin.xml
+2
-2
DebuggerPlugin.java
...java/org/jivesoftware/openfire/plugin/DebuggerPlugin.java
+21
-5
RawPrintFilter.java
...java/org/jivesoftware/openfire/plugin/RawPrintFilter.java
+25
-19
No files found.
src/plugins/xmldebugger/changelog.html
View file @
27c5cc74
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
<html>
<html>
<head>
<head>
<title>
Broadcast
Plugin Changelog
</title>
<title>
XML Debugger
Plugin Changelog
</title>
<style
type=
"text/css"
>
<style
type=
"text/css"
>
BODY
{
BODY
{
font-size
:
100%
;
font-size
:
100%
;
...
@@ -43,6 +43,11 @@
...
@@ -43,6 +43,11 @@
<h1>
<h1>
XML Debugger Plugin Changelog
XML Debugger Plugin Changelog
</h1>
</h1>
<p><b>
1.6.0
</b>
-- June 20, 2016
</p>
<li>
[
<a
href=
'http://issues.igniterealtime.org/browse/OF-1152'
>
OF-1152
</a>
] - Ensure that the plugin prints raw XML.
</li>
<li>
Requires Openfire 4
</li>
<p><b>
1.5.0
</b>
-- October 12, 2015
</p>
<p><b>
1.5.0
</b>
-- October 12, 2015
</p>
<ul>
<ul>
<li>
[
<a
href=
'http://www.igniterealtime.org/issues/browse/OF-953'
>
OF-953
</a>
] - Updated JSP libraries.
</li>
<li>
[
<a
href=
'http://www.igniterealtime.org/issues/browse/OF-953'
>
OF-953
</a>
] - Updated JSP libraries.
</li>
...
...
src/plugins/xmldebugger/plugin.xml
View file @
27c5cc74
...
@@ -8,8 +8,8 @@
...
@@ -8,8 +8,8 @@
<name>
Debugger Plugin
</name>
<name>
Debugger Plugin
</name>
<description>
Prints XML traffic to the stdout (raw and interpreted XML)
</description>
<description>
Prints XML traffic to the stdout (raw and interpreted XML)
</description>
<author>
Jive Software
</author>
<author>
Jive Software
</author>
<version>
1.
5
.0
</version>
<version>
1.
6
.0
</version>
<date>
10/12/2015
</date>
<date>
06/20/2016
</date>
<minServerVersion>
4.0.0
</minServerVersion>
<minServerVersion>
4.0.0
</minServerVersion>
<adminconsole>
<adminconsole>
...
...
src/plugins/xmldebugger/src/java/org/jivesoftware/openfire/plugin/DebuggerPlugin.java
View file @
27c5cc74
...
@@ -27,6 +27,7 @@ import org.apache.mina.transport.socket.SocketAcceptor;
...
@@ -27,6 +27,7 @@ import org.apache.mina.transport.socket.SocketAcceptor;
import
org.jivesoftware.openfire.XMPPServer
;
import
org.jivesoftware.openfire.XMPPServer
;
import
org.jivesoftware.openfire.container.Plugin
;
import
org.jivesoftware.openfire.container.Plugin
;
import
org.jivesoftware.openfire.container.PluginManager
;
import
org.jivesoftware.openfire.container.PluginManager
;
import
org.jivesoftware.openfire.container.PluginManagerListener
;
import
org.jivesoftware.openfire.interceptor.InterceptorManager
;
import
org.jivesoftware.openfire.interceptor.InterceptorManager
;
import
org.jivesoftware.openfire.spi.ConnectionManagerImpl
;
import
org.jivesoftware.openfire.spi.ConnectionManagerImpl
;
import
org.jivesoftware.util.JiveGlobals
;
import
org.jivesoftware.util.JiveGlobals
;
...
@@ -49,30 +50,45 @@ public class DebuggerPlugin implements Plugin, PropertyEventListener {
...
@@ -49,30 +50,45 @@ public class DebuggerPlugin implements Plugin, PropertyEventListener {
private
InterpretedXMLPrinter
interpretedPrinter
;
private
InterpretedXMLPrinter
interpretedPrinter
;
public
void
initializePlugin
(
PluginManager
manager
,
File
pluginDirectory
)
{
public
void
initializePlugin
(
final
PluginManager
pluginManager
,
final
File
pluginDirectory
)
{
if
(
pluginManager
.
isExecuted
())
{
addInterceptors
();
}
else
{
pluginManager
.
addPluginManagerListener
(
new
PluginManagerListener
()
{
public
void
pluginsMonitored
()
{
// Stop listening for plugin events
pluginManager
.
removePluginManagerListener
(
this
);
// Start listeners
addInterceptors
();
}
});
}
}
private
void
addInterceptors
()
{
// Add filter to filter chain builder
// Add filter to filter chain builder
ConnectionManagerImpl
connManager
=
(
ConnectionManagerImpl
)
XMPPServer
.
getInstance
().
getConnectionManager
();
ConnectionManagerImpl
connManager
=
(
ConnectionManagerImpl
)
XMPPServer
.
getInstance
().
getConnectionManager
();
defaultPortFilter
=
new
RawPrintFilter
(
"C2S"
);
defaultPortFilter
=
new
RawPrintFilter
(
"C2S"
);
SocketAcceptor
socketAcceptor
=
connManager
.
getSocketAcceptor
();
SocketAcceptor
socketAcceptor
=
connManager
.
getSocketAcceptor
();
if
(
socketAcceptor
!=
null
)
{
if
(
socketAcceptor
!=
null
)
{
socketAcceptor
.
getFilterChain
().
add
Before
(
"xmpp"
,
"rawDebugger"
,
defaultPortFilter
);
socketAcceptor
.
getFilterChain
().
add
First
(
"rawDebugger"
,
defaultPortFilter
);
}
}
oldPortFilter
=
new
RawPrintFilter
(
"SSL"
);
oldPortFilter
=
new
RawPrintFilter
(
"SSL"
);
SocketAcceptor
sslAcceptor
=
connManager
.
getSSLSocketAcceptor
();
SocketAcceptor
sslAcceptor
=
connManager
.
getSSLSocketAcceptor
();
if
(
sslAcceptor
!=
null
)
{
if
(
sslAcceptor
!=
null
)
{
sslAcceptor
.
getFilterChain
().
add
Before
(
"xmpp"
,
"rawDebugger"
,
oldPortFilter
);
sslAcceptor
.
getFilterChain
().
add
First
(
"rawDebugger"
,
oldPortFilter
);
}
}
componentPortFilter
=
new
RawPrintFilter
(
"ExComp"
);
componentPortFilter
=
new
RawPrintFilter
(
"ExComp"
);
SocketAcceptor
componentAcceptor
=
connManager
.
getComponentAcceptor
();
SocketAcceptor
componentAcceptor
=
connManager
.
getComponentAcceptor
();
if
(
componentAcceptor
!=
null
)
{
if
(
componentAcceptor
!=
null
)
{
componentAcceptor
.
getFilterChain
().
add
Before
(
"xmpp"
,
"rawDebugger"
,
componentPortFilter
);
componentAcceptor
.
getFilterChain
().
add
First
(
"rawDebugger"
,
componentPortFilter
);
}
}
multiplexerPortFilter
=
new
RawPrintFilter
(
"CM"
);
multiplexerPortFilter
=
new
RawPrintFilter
(
"CM"
);
SocketAcceptor
multiplexerAcceptor
=
connManager
.
getMultiplexerSocketAcceptor
();
SocketAcceptor
multiplexerAcceptor
=
connManager
.
getMultiplexerSocketAcceptor
();
if
(
multiplexerAcceptor
!=
null
)
{
if
(
multiplexerAcceptor
!=
null
)
{
multiplexerAcceptor
.
getFilterChain
().
add
Before
(
"xmpp"
,
"rawDebugger"
,
multiplexerPortFilter
);
multiplexerAcceptor
.
getFilterChain
().
add
First
(
"rawDebugger"
,
multiplexerPortFilter
);
}
}
interpretedPrinter
=
new
InterpretedXMLPrinter
();
interpretedPrinter
=
new
InterpretedXMLPrinter
();
...
...
src/plugins/xmldebugger/src/java/org/jivesoftware/openfire/plugin/RawPrintFilter.java
View file @
27c5cc74
...
@@ -20,12 +20,12 @@
...
@@ -20,12 +20,12 @@
package
org
.
jivesoftware
.
openfire
.
plugin
;
package
org
.
jivesoftware
.
openfire
.
plugin
;
import
java.nio.ByteBuffer
;
import
java.nio.CharBuffer
;
import
java.nio.CharBuffer
;
import
java.nio.charset.Charset
;
import
java.nio.charset.Charset
;
import
java.util.Collection
;
import
java.util.Collection
;
import
java.util.concurrent.ConcurrentLinkedQueue
;
import
java.util.concurrent.ConcurrentLinkedQueue
;
import
org.apache.mina.core.buffer.IoBuffer
;
import
org.apache.mina.core.filterchain.IoFilterAdapter
;
import
org.apache.mina.core.filterchain.IoFilterAdapter
;
import
org.apache.mina.core.session.IoSession
;
import
org.apache.mina.core.session.IoSession
;
import
org.apache.mina.core.write.WriteRequest
;
import
org.apache.mina.core.write.WriteRequest
;
...
@@ -51,29 +51,33 @@ public class RawPrintFilter extends IoFilterAdapter {
...
@@ -51,29 +51,33 @@ public class RawPrintFilter extends IoFilterAdapter {
@Override
@Override
public
void
messageReceived
(
NextFilter
nextFilter
,
IoSession
session
,
Object
message
)
throws
Exception
{
public
void
messageReceived
(
NextFilter
nextFilter
,
IoSession
session
,
Object
message
)
throws
Exception
{
// Decode the bytebuffer and print it to the stdout
// Decode the bytebuffer and print it to the stdout
if
(
enabled
&&
message
instanceof
ByteBuffer
)
{
if
(
enabled
&&
message
instanceof
IoBuffer
)
{
ByteBuffer
byteBuffer
=
(
ByteBuffer
)
message
;
logBuffer
(
session
,
(
IoBuffer
)
message
,
"RECV"
);
}
// Pass the message to the next filter
super
.
messageReceived
(
nextFilter
,
session
,
message
);
}
private
void
logBuffer
(
final
IoSession
session
,
final
IoBuffer
ioBuffer
,
final
String
receiveOrSend
)
{
// Keep current position in the buffer
// Keep current position in the buffer
int
currentPos
=
byte
Buffer
.
position
();
int
currentPos
=
io
Buffer
.
position
();
// Decode buffer
// Decode buffer
Charset
encoder
=
Charset
.
forName
(
"UTF-8"
);
CharBuffer
charBuffer
=
Charset
.
forName
(
"UTF-8"
).
decode
(
ioBuffer
.
buf
());
CharBuffer
charBuffer
=
encoder
.
decode
(
byteBuffer
.
asReadOnlyBuffer
());
// Print buffer content
// Print buffer content
System
.
out
.
println
(
prefix
+
" - RECV ("
+
session
.
hashCode
()
+
")
: "
+
charBuffer
);
System
.
out
.
println
(
messagePrefix
(
session
,
receiveOrSend
)
+
"
: "
+
charBuffer
);
// Reset to old position in the buffer
// Reset to old position in the buffer
byte
Buffer
.
position
(
currentPos
);
io
Buffer
.
position
(
currentPos
);
}
}
// Pass the message to the next filter
super
.
messageReceived
(
nextFilter
,
session
,
message
);
private
String
messagePrefix
(
final
IoSession
session
,
final
String
messageType
)
{
return
prefix
+
" - "
+
messageType
+
String
.
format
(
" - (%1$11s)"
,
session
.
hashCode
());
}
}
@Override
@Override
public
void
messageSent
(
NextFilter
nextFilter
,
IoSession
session
,
WriteRequest
writeRequest
)
throws
Exception
{
public
void
messageSent
(
NextFilter
nextFilter
,
IoSession
session
,
WriteRequest
writeRequest
)
throws
Exception
{
if
(
enabled
&&
writeRequest
.
getMessage
()
instanceof
ByteBuffer
)
{
if
(
enabled
&&
writeRequest
.
getMessage
()
instanceof
IoBuffer
)
{
System
.
out
.
println
(
prefix
+
" - SENT ("
+
session
.
hashCode
()
+
"): "
+
logBuffer
(
session
,
(
IoBuffer
)
writeRequest
.
getMessage
(),
"SENT"
);
Charset
.
forName
(
"UTF-8"
).
decode
(((
ByteBuffer
)
writeRequest
.
getMessage
()).
asReadOnlyBuffer
()));
}
}
// Pass the message to the next filter
// Pass the message to the next filter
super
.
messageSent
(
nextFilter
,
session
,
writeRequest
);
super
.
messageSent
(
nextFilter
,
session
,
writeRequest
);
}
}
...
@@ -99,7 +103,10 @@ public class RawPrintFilter extends IoFilterAdapter {
...
@@ -99,7 +103,10 @@ public class RawPrintFilter extends IoFilterAdapter {
public
void
sessionCreated
(
NextFilter
nextFilter
,
IoSession
session
)
throws
Exception
{
public
void
sessionCreated
(
NextFilter
nextFilter
,
IoSession
session
)
throws
Exception
{
// Keep track of sessions using this filter
// Keep track of sessions using this filter
sessions
.
add
(
session
);
sessions
.
add
(
session
);
if
(
enabled
)
{
// Print that a session was closed
System
.
out
.
println
(
messagePrefix
(
session
,
"OPEN"
));
}
super
.
sessionCreated
(
nextFilter
,
session
);
super
.
sessionCreated
(
nextFilter
,
session
);
}
}
...
@@ -109,9 +116,8 @@ public class RawPrintFilter extends IoFilterAdapter {
...
@@ -109,9 +116,8 @@ public class RawPrintFilter extends IoFilterAdapter {
sessions
.
remove
(
session
);
sessions
.
remove
(
session
);
if
(
enabled
)
{
if
(
enabled
)
{
// Print that a session was closed
// Print that a session was closed
System
.
out
.
println
(
"CLOSED ("
+
session
.
hashCode
()
+
") "
);
System
.
out
.
println
(
messagePrefix
(
session
,
"CLSD"
)
);
}
}
super
.
sessionClosed
(
nextFilter
,
session
);
super
.
sessionClosed
(
nextFilter
,
session
);
}
}
}
}
\ No newline at end of file
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