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
e677f11a
Commit
e677f11a
authored
Nov 17, 2015
by
David Greene
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding PropertyListener support to AuditManagerImpl
parent
9545836b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
110 additions
and
25 deletions
+110
-25
AuditManagerImpl.java
...org/jivesoftware/openfire/audit/spi/AuditManagerImpl.java
+110
-25
No files found.
src/java/org/jivesoftware/openfire/audit/spi/AuditManagerImpl.java
View file @
e677f11a
...
...
@@ -21,6 +21,8 @@
package
org
.
jivesoftware
.
openfire
.
audit
.
spi
;
import
org.jivesoftware.util.JiveGlobals
;
import
org.jivesoftware.util.PropertyEventDispatcher
;
import
org.jivesoftware.util.PropertyEventListener
;
import
org.jivesoftware.openfire.XMPPServer
;
import
org.jivesoftware.openfire.audit.AuditManager
;
import
org.jivesoftware.openfire.audit.Auditor
;
...
...
@@ -37,7 +39,7 @@ import java.util.*;
/**
* Implementation of the AuditManager interface.
*/
public
class
AuditManagerImpl
extends
BasicModule
implements
AuditManager
{
public
class
AuditManagerImpl
extends
BasicModule
implements
AuditManager
,
PropertyEventListener
{
private
boolean
enabled
;
private
boolean
auditMessage
;
...
...
@@ -83,13 +85,7 @@ public class AuditManagerImpl extends BasicModule implements AuditManager {
public
void
setEnabled
(
boolean
enabled
)
{
this
.
enabled
=
enabled
;
JiveGlobals
.
setProperty
(
"xmpp.audit.active"
,
enabled
?
"true"
:
"false"
);
// Add or remove the auditor interceptor depending on the enabled status
if
(
enabled
)
{
InterceptorManager
.
getInstance
().
addInterceptor
(
interceptor
);
}
else
{
InterceptorManager
.
getInstance
().
removeInterceptor
(
interceptor
);
}
processEnabled
(
enabled
);
}
@Override
...
...
@@ -131,13 +127,7 @@ public class AuditManagerImpl extends BasicModule implements AuditManager {
@Override
public
void
setMaxDays
(
int
count
)
{
if
(
count
<
-
1
)
{
count
=
-
1
;
}
if
(
count
==
0
)
{
count
=
1
;
}
maxDays
=
count
;
maxDays
=
validateMaxDays
(
count
);
auditor
.
setMaxValues
(
maxTotalSize
,
maxFileSize
,
maxDays
);
JiveGlobals
.
setProperty
(
"xmpp.audit.days"
,
Integer
.
toString
(
count
));
}
...
...
@@ -280,13 +270,7 @@ public class AuditManagerImpl extends BasicModule implements AuditManager {
logTimeout
=
JiveGlobals
.
getIntProperty
(
"xmpp.audit.logtimeout"
,
DEFAULT_LOG_TIMEOUT
);
logDir
=
JiveGlobals
.
getProperty
(
"xmpp.audit.logdir"
,
JiveGlobals
.
getHomeDirectory
()
+
File
.
separator
+
"logs"
);
String
ignoreString
=
JiveGlobals
.
getProperty
(
"xmpp.audit.ignore"
,
""
);
// Decode the ignore list
StringTokenizer
tokenizer
=
new
StringTokenizer
(
ignoreString
,
", "
);
while
(
tokenizer
.
hasMoreTokens
())
{
String
username
=
tokenizer
.
nextToken
();
ignoreList
.
add
(
username
);
}
processIgnoreString
(
JiveGlobals
.
getProperty
(
"xmpp.audit.ignore"
,
""
));
auditor
=
new
AuditorImpl
(
this
);
auditor
.
setMaxValues
(
maxTotalSize
,
maxFileSize
,
maxDays
);
...
...
@@ -294,11 +278,39 @@ public class AuditManagerImpl extends BasicModule implements AuditManager {
auditor
.
setLogTimeout
(
logTimeout
);
interceptor
=
new
AuditorInterceptor
();
if
(
enabled
)
{
InterceptorManager
.
getInstance
().
addInterceptor
(
interceptor
);
}
processEnabled
(
enabled
);
PropertyEventDispatcher
.
addListener
(
this
);
}
private
void
processIgnoreString
(
String
ignoreString
)
{
ignoreList
.
clear
();
// Decode the ignore list
StringTokenizer
tokenizer
=
new
StringTokenizer
(
ignoreString
,
","
);
while
(
tokenizer
.
hasMoreTokens
())
{
String
username
=
tokenizer
.
nextToken
().
trim
();
ignoreList
.
add
(
username
);
}
}
private
void
processEnabled
(
boolean
enabled
)
{
// Add or remove the auditor interceptor depending on the enabled status
if
(
enabled
)
{
InterceptorManager
.
getInstance
().
addInterceptor
(
interceptor
);
}
else
{
InterceptorManager
.
getInstance
().
removeInterceptor
(
interceptor
);
}
}
private
int
validateMaxDays
(
int
count
)
{
if
(
count
<
-
1
)
{
count
=
-
1
;
}
if
(
count
==
0
)
{
count
=
1
;
}
return
count
;
}
@Override
public
void
stop
()
{
if
(
auditor
!=
null
)
{
...
...
@@ -306,6 +318,79 @@ public class AuditManagerImpl extends BasicModule implements AuditManager {
}
}
@Override
public
void
propertySet
(
String
property
,
Map
<
String
,
Object
>
params
)
{
String
value
=
(
String
)
params
.
get
(
"value"
);
switch
(
property
)
{
case
"xmpp.audit.active"
:
enabled
=
Boolean
.
parseBoolean
(
value
);
processEnabled
(
enabled
);
break
;
case
"xmpp.audit.message"
:
auditMessage
=
Boolean
.
parseBoolean
(
value
);
break
;
case
"xmpp.audit.presence"
:
auditPresence
=
Boolean
.
parseBoolean
(
value
);
break
;
case
"xmpp.audit.iq"
:
auditIQ
=
Boolean
.
parseBoolean
(
value
);
break
;
case
"xmpp.audit.xpath"
:
auditXPath
=
Boolean
.
parseBoolean
(
value
);
break
;
case
"xmpp.audit.totalsize"
:
maxTotalSize
=
parseIntegerOrDefault
(
value
,
MAX_TOTAL_SIZE
);
auditor
.
setMaxValues
(
maxTotalSize
,
maxFileSize
,
maxDays
);
break
;
case
"xmpp.audit.filesize"
:
maxFileSize
=
parseIntegerOrDefault
(
value
,
MAX_FILE_SIZE
);
auditor
.
setMaxValues
(
maxTotalSize
,
maxFileSize
,
maxDays
);
break
;
case
"xmpp.audit.days"
:
maxDays
=
validateMaxDays
(
parseIntegerOrDefault
(
value
,
MAX_DAYS
));
auditor
.
setMaxValues
(
maxTotalSize
,
maxFileSize
,
maxDays
);
break
;
case
"xmpp.audit.logtimeout"
:
logTimeout
=
parseIntegerOrDefault
(
value
,
DEFAULT_LOG_TIMEOUT
);
auditor
.
setLogTimeout
(
logTimeout
);
break
;
case
"xmpp.audit.logdir"
:
File
d
=
null
;
if
(
value
!=
null
&&
!
""
.
equals
(
value
.
trim
()))
{
d
=
new
File
(
value
);
}
logDir
=
(
d
==
null
||
!
d
.
exists
()
||
!
d
.
canRead
()
||
!
d
.
canWrite
()
||
!
d
.
isDirectory
())
?
JiveGlobals
.
getHomeDirectory
()
+
File
.
separator
+
"logs"
:
value
;
auditor
.
setLogDir
(
logDir
);
break
;
case
"xmpp.audit.ignore"
:
processIgnoreString
(
value
);
break
;
}
}
private
int
parseIntegerOrDefault
(
String
intValue
,
int
defaultValue
)
{
try
{
return
Integer
.
parseInt
(
intValue
);
}
catch
(
NumberFormatException
nfe
)
{
return
defaultValue
;
}
}
@Override
public
void
propertyDeleted
(
String
property
,
Map
<
String
,
Object
>
params
)
{
propertySet
(
property
,
Collections
.<
String
,
Object
>
emptyMap
());
}
@Override
public
void
xmlPropertySet
(
String
property
,
Map
<
String
,
Object
>
params
)
{
}
@Override
public
void
xmlPropertyDeleted
(
String
property
,
Map
<
String
,
Object
>
params
)
{
}
private
class
AuditorInterceptor
implements
PacketInterceptor
{
@Override
...
...
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