public class SpamFilter extends BasicPageFilter
Please see the default editors/plain.jsp for examples on how the SpamFilter integrates with the editor system.
Changes by admin users are ignored in any case.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
PROP_AKISMET_API_KEY
The filter property name for specifying the Akismet API-key.
|
static java.lang.String |
PROP_BANTIME
The filter property name for specifying how long a host is banned.
|
static java.lang.String |
PROP_BLACKLIST
The filter property name for the attachment containing the blacklist.
|
static java.lang.String |
PROP_CAPTCHA
The filter property name for specifying which captcha technology should be used.
|
static java.lang.String |
PROP_ERRORPAGE
The filter property name for the page to which you are directed if Herb rejects your
edit.
|
static java.lang.String |
PROP_FILTERSTRATEGY
The filter property name for specifying which filter strategy should be used.
|
static java.lang.String |
PROP_IGNORE_AUTHENTICATED
The filter property name for specifying whether authenticated users should be ignored.
|
static java.lang.String |
PROP_MAXURLS
The filter property name for specifying how many URLs can any given edit contain.
|
static java.lang.String |
PROP_PAGECHANGES
The filter property name for specifying how many changes is any given IP address
allowed to do per minute.
|
static java.lang.String |
PROP_SIMILARCHANGES
The filter property name for specifying how many similar changes are allowed
before a host is banned.
|
static java.lang.String |
PROP_WORDLIST
The filter property name for specifying the page which contains the list of spamwords.
|
static java.lang.String |
STRATEGY_EAGER
The string specifying the "eager" strategy.
|
static java.lang.String |
STRATEGY_SCORE
The string specifying the "score" strategy.
|
m_engine
Constructor and Description |
---|
SpamFilter() |
Modifier and Type | Method and Description |
---|---|
static boolean |
checkHash(WikiContext context,
PageContext pageContext)
This method checks if the hash value is still valid, i.e.
|
static java.lang.String |
getBotFieldName()
Returns a static string which can be used to detect spambots which
just wildly fill in all the fields.
|
static java.lang.String |
getHashFieldName(HttpServletRequest request)
Returns the name of the hash field to be used in this request.
|
static java.lang.String |
getSpamHash(WikiPage page,
HttpServletRequest request)
This method is used to calculate an unique code when submitting the page
to detect edit conflicts.
|
void |
initialize(WikiEngine engine,
java.util.Properties properties)
If you override this, you should call super.initialize() first.
|
static java.lang.String |
insertInputFields(PageContext pageContext)
This helper method adds all the input fields to your editor that the SpamFilter requires
to check for spam.
|
boolean |
isValidUserProfile(WikiContext context,
UserProfile profile)
Checks whether the UserProfile matches certain checks.
|
java.lang.String |
preSave(WikiContext context,
java.lang.String content)
This method is called before the page has been saved to the PageProvider.
|
destroy, postSave, postTranslate, preTranslate
public static final java.lang.String PROP_WORDLIST
public static final java.lang.String PROP_ERRORPAGE
public static final java.lang.String PROP_PAGECHANGES
public static final java.lang.String PROP_SIMILARCHANGES
public static final java.lang.String PROP_BANTIME
public static final java.lang.String PROP_BLACKLIST
public static final java.lang.String PROP_MAXURLS
public static final java.lang.String PROP_AKISMET_API_KEY
public static final java.lang.String PROP_IGNORE_AUTHENTICATED
public static final java.lang.String PROP_CAPTCHA
public static final java.lang.String PROP_FILTERSTRATEGY
public static final java.lang.String STRATEGY_EAGER
public static final java.lang.String STRATEGY_SCORE
public void initialize(WikiEngine engine, java.util.Properties properties)
initialize
in interface PageFilter
initialize
in class BasicPageFilter
engine
- The WikiEngine whic owns this PageFilterproperties
- The properties ripped from filters.xml.public java.lang.String preSave(WikiContext context, java.lang.String content) throws RedirectException
preSave
in interface PageFilter
preSave
in class BasicPageFilter
context
- The WikiContextcontent
- The wikimarkup that the user just wanted to save.RedirectException
public static java.lang.String getBotFieldName()
public boolean isValidUserProfile(WikiContext context, UserProfile profile)
profile
- The profile to checkcontext
- The WikiContextpublic static final java.lang.String getSpamHash(WikiPage page, HttpServletRequest request)
page
- The WikiPage under editrequest
- The HTTP Requestpublic static final java.lang.String getHashFieldName(HttpServletRequest request)
request
- The page requestpublic static final boolean checkHash(WikiContext context, PageContext pageContext) throws java.io.IOException
This method puts a redirect to the http response field to page "SessionExpired" and logs the incident in the spam log (it may or may not be spam, but it's rather likely that it is).
context
- The WikiContextpageContext
- The JSP PageContext.java.io.IOException
- If redirection failspublic static final java.lang.String insertInputFields(PageContext pageContext)
pageContext
- The PageContextstSoftware Copyright © 2001-2014 stSoftware All Rights Reserved.