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
Hide 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 @@
<html>
<head>
<title>
Broadcast
Plugin Changelog
</title>
<title>
XML Debugger
Plugin Changelog
</title>
<style
type=
"text/css"
>
BODY
{
font-size
:
100%
;
...
...
@@ -43,6 +43,11 @@
<h1>
XML Debugger Plugin Changelog
</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>
<ul>
<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 @@
<name>
Debugger Plugin
</name>
<description>
Prints XML traffic to the stdout (raw and interpreted XML)
</description>
<author>
Jive Software
</author>
<version>
1.
5
.0
</version>
<date>
10/12/2015
</date>
<version>
1.
6
.0
</version>
<date>
06/20/2016
</date>
<minServerVersion>
4.0.0
</minServerVersion>
<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;
import
org.jivesoftware.openfire.XMPPServer
;
import
org.jivesoftware.openfire.container.Plugin
;
import
org.jivesoftware.openfire.container.PluginManager
;
import
org.jivesoftware.openfire.container.PluginManagerListener
;
import
org.jivesoftware.openfire.interceptor.InterceptorManager
;
import
org.jivesoftware.openfire.spi.ConnectionManagerImpl
;
import
org.jivesoftware.util.JiveGlobals
;
...
...
@@ -49,30 +50,45 @@ public class DebuggerPlugin implements Plugin, PropertyEventListener {
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
ConnectionManagerImpl
connManager
=
(
ConnectionManagerImpl
)
XMPPServer
.
getInstance
().
getConnectionManager
();
defaultPortFilter
=
new
RawPrintFilter
(
"C2S"
);
SocketAcceptor
socketAcceptor
=
connManager
.
getSocketAcceptor
();
if
(
socketAcceptor
!=
null
)
{
socketAcceptor
.
getFilterChain
().
add
Before
(
"xmpp"
,
"rawDebugger"
,
defaultPortFilter
);
socketAcceptor
.
getFilterChain
().
add
First
(
"rawDebugger"
,
defaultPortFilter
);
}
oldPortFilter
=
new
RawPrintFilter
(
"SSL"
);
SocketAcceptor
sslAcceptor
=
connManager
.
getSSLSocketAcceptor
();
if
(
sslAcceptor
!=
null
)
{
sslAcceptor
.
getFilterChain
().
add
Before
(
"xmpp"
,
"rawDebugger"
,
oldPortFilter
);
sslAcceptor
.
getFilterChain
().
add
First
(
"rawDebugger"
,
oldPortFilter
);
}
componentPortFilter
=
new
RawPrintFilter
(
"ExComp"
);
SocketAcceptor
componentAcceptor
=
connManager
.
getComponentAcceptor
();
if
(
componentAcceptor
!=
null
)
{
componentAcceptor
.
getFilterChain
().
add
Before
(
"xmpp"
,
"rawDebugger"
,
componentPortFilter
);
componentAcceptor
.
getFilterChain
().
add
First
(
"rawDebugger"
,
componentPortFilter
);
}
multiplexerPortFilter
=
new
RawPrintFilter
(
"CM"
);
SocketAcceptor
multiplexerAcceptor
=
connManager
.
getMultiplexerSocketAcceptor
();
if
(
multiplexerAcceptor
!=
null
)
{
multiplexerAcceptor
.
getFilterChain
().
add
Before
(
"xmpp"
,
"rawDebugger"
,
multiplexerPortFilter
);
multiplexerAcceptor
.
getFilterChain
().
add
First
(
"rawDebugger"
,
multiplexerPortFilter
);
}
interpretedPrinter
=
new
InterpretedXMLPrinter
();
...
...
src/plugins/xmldebugger/src/java/org/jivesoftware/openfire/plugin/RawPrintFilter.java
View file @
27c5cc74
...
...
@@ -20,12 +20,12 @@
package
org
.
jivesoftware
.
openfire
.
plugin
;
import
java.nio.ByteBuffer
;
import
java.nio.CharBuffer
;
import
java.nio.charset.Charset
;
import
java.util.Collection
;
import
java.util.concurrent.ConcurrentLinkedQueue
;
import
org.apache.mina.core.buffer.IoBuffer
;
import
org.apache.mina.core.filterchain.IoFilterAdapter
;
import
org.apache.mina.core.session.IoSession
;
import
org.apache.mina.core.write.WriteRequest
;
...
...
@@ -51,29 +51,33 @@ public class RawPrintFilter extends IoFilterAdapter {
@Override
public
void
messageReceived
(
NextFilter
nextFilter
,
IoSession
session
,
Object
message
)
throws
Exception
{
// Decode the bytebuffer and print it to the stdout
if
(
enabled
&&
message
instanceof
ByteBuffer
)
{
ByteBuffer
byteBuffer
=
(
ByteBuffer
)
message
;
// Keep current position in the buffer
int
currentPos
=
byteBuffer
.
position
();
// Decode buffer
Charset
encoder
=
Charset
.
forName
(
"UTF-8"
);
CharBuffer
charBuffer
=
encoder
.
decode
(
byteBuffer
.
asReadOnlyBuffer
());
// Print buffer content
System
.
out
.
println
(
prefix
+
" - RECV ("
+
session
.
hashCode
()
+
"): "
+
charBuffer
);
// Reset to old position in the buffer
byteBuffer
.
position
(
currentPos
);
if
(
enabled
&&
message
instanceof
IoBuffer
)
{
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
int
currentPos
=
ioBuffer
.
position
();
// Decode buffer
CharBuffer
charBuffer
=
Charset
.
forName
(
"UTF-8"
).
decode
(
ioBuffer
.
buf
());
// Print buffer content
System
.
out
.
println
(
messagePrefix
(
session
,
receiveOrSend
)
+
": "
+
charBuffer
);
// Reset to old position in the buffer
ioBuffer
.
position
(
currentPos
);
}
private
String
messagePrefix
(
final
IoSession
session
,
final
String
messageType
)
{
return
prefix
+
" - "
+
messageType
+
String
.
format
(
" - (%1$11s)"
,
session
.
hashCode
());
}
@Override
public
void
messageSent
(
NextFilter
nextFilter
,
IoSession
session
,
WriteRequest
writeRequest
)
throws
Exception
{
if
(
enabled
&&
writeRequest
.
getMessage
()
instanceof
ByteBuffer
)
{
System
.
out
.
println
(
prefix
+
" - SENT ("
+
session
.
hashCode
()
+
"): "
+
Charset
.
forName
(
"UTF-8"
).
decode
(((
ByteBuffer
)
writeRequest
.
getMessage
()).
asReadOnlyBuffer
()));
if
(
enabled
&&
writeRequest
.
getMessage
()
instanceof
IoBuffer
)
{
logBuffer
(
session
,
(
IoBuffer
)
writeRequest
.
getMessage
(),
"SENT"
);
}
// Pass the message to the next filter
super
.
messageSent
(
nextFilter
,
session
,
writeRequest
);
}
...
...
@@ -99,7 +103,10 @@ public class RawPrintFilter extends IoFilterAdapter {
public
void
sessionCreated
(
NextFilter
nextFilter
,
IoSession
session
)
throws
Exception
{
// Keep track of sessions using this filter
sessions
.
add
(
session
);
if
(
enabled
)
{
// Print that a session was closed
System
.
out
.
println
(
messagePrefix
(
session
,
"OPEN"
));
}
super
.
sessionCreated
(
nextFilter
,
session
);
}
...
...
@@ -109,9 +116,8 @@ public class RawPrintFilter extends IoFilterAdapter {
sessions
.
remove
(
session
);
if
(
enabled
)
{
// Print that a session was closed
System
.
out
.
println
(
"CLOSED ("
+
session
.
hashCode
()
+
") "
);
System
.
out
.
println
(
messagePrefix
(
session
,
"CLSD"
)
);
}
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