You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by ju...@apache.org on 2020/03/06 18:04:02 UTC

[jspwiki] branch master updated (70b6677 -> c0aa772)

This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git.


    from 70b6677  2.11.0-M7-git-11 : add rel="noreferrer" to target="_blank" links
     new 8f6d986  fix sonar issue + apply intellij suggested format and fixes
     new 781f35e  fix sonar issue
     new 9b40c19  JSPWIKI-303: move AdminBeanManager to o.a.w.ui.admin package, as it is not intended for the public api
     new dfd502e  JSPWIKI-303: move PluginManager back to o.a.w.plugin package
     new 6abfe2b  JSPWIKI-303: move FilterManager back to o.a.w.filters package
     new 5a95f81  remove empty o.a.w.api.engine package
     new f0205f6  rename + extract interface on (Base)ModuleManager
     new ff5b226  fix compilation problems
     new e07c798  DefaultPageManager doesn't need to be a module manager
     new 11ee436  decouple DefaultAdminBeanManager from specific module manager implementations
     new 7fc2476  move PrincipalComparator to the util module, with all the other non-jspwiki specific comparators
     new 67b36ce  use PrincipalComparator on #compareTo( Principal ) method
     new 2190448  replace lambda with method reference while streaming managers
     new 127c520  fix jsp compilation issues derived from moving the AdminBeanManager interface to another package
     new dabf3e1  use StandardCharsets.UTF_8 constant instead of hardcoded 'UTF-8'
     new a73d747  use Engine instead of WikiEngine on some javadocs
     new fdfd05d  add missing license
     new e688714  move isIPV4Address( String ) method from WikiSession to HttpUtil
     new 442402d  JSPWIKI-303: extract o.a.w.api.core.Session from o.a.w.WikiSession
     new f6fe504  JSPWIKI-303: begin to use Session instead of WikiSession (1)
     new dc3e9f2  JSPWIKI-303: begin to use Session instead of WikiSession (2)
     new 3357041  JSPWIKI-303: begin to use Session instead of WikiSession (3)
     new a205250  JSPWIKI-303: begin to use public API (Engine, Session) on JSPs
     new 78cee04  throw ProviderException instead of InternalWikiException
     new aec837e  JSPWIKI-303: use Session instead of WikiSession (1)
     new 8487770  JSPWIKI-303: use Session instead of WikiSession (2)
     new 8f25151  update cargo plugin to 1.7.10 and bump tomcat version from 8.5.51 to 9.0.31
     new b266b55  use repo1.maven.org instead of search.maven.org, as the latter redirects to the former, to download appbundler
     new 875552d  update tomcat server files from 8.5 to 9.0
     new 91ff2a3  update launchers to be based on tomcat 9.0.31
     new 0191302  update README.md to recommend Tomcat 9.x + link to configuration needed to run JSPWiki on Tomcat 8.x
     new 943704d  provide boolean isImageInlining and inlineImagePatterns to LinkParsingOperations#isImageLink(..)
     new dc4b44f  move test to its testee package
     new 0db9623  JSPWIKI-303: promote o.a.w.Release to o.a.w.api package
     new c0aa772  2.11.0-M7-git-12

The 35 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 ChangeLog.md                                       |  13 +
 README.md                                          |   7 +-
 .../java/org/apache/wiki/TranslationsCheck.java    |  46 +-
 .../src/main/java/org/apache/wiki/WikiContext.java |  18 +-
 .../src/main/java/org/apache/wiki/WikiEngine.java  |  20 +-
 .../src/main/java/org/apache/wiki/WikiSession.java | 587 +++++++--------------
 .../java/org/apache/wiki/{ => api}/Release.java    |   8 +-
 .../main/java/org/apache/wiki/api/core/Engine.java |  12 +-
 .../java/org/apache/wiki/api/core/Session.java     | 248 +++++++++
 .../java/org/apache/wiki/api/engine/package.html   |  36 --
 .../apache/wiki/api/plugin/ParserStagePlugin.java  |   2 +-
 .../apache/wiki/attachment/AttachmentServlet.java  |   3 +-
 .../apache/wiki/auth/AuthenticationManager.java    |  22 +-
 .../org/apache/wiki/auth/AuthorizationManager.java |  32 +-
 .../main/java/org/apache/wiki/auth/Authorizer.java |   8 +-
 .../wiki/auth/DefaultAuthenticationManager.java    |  23 +-
 .../wiki/auth/DefaultAuthorizationManager.java     |   9 +-
 .../org/apache/wiki/auth/DefaultUserManager.java   |  17 +-
 .../org/apache/wiki/auth/SecurityVerifier.java     |   6 +-
 .../java/org/apache/wiki/auth/SessionMonitor.java  | 135 +++--
 .../java/org/apache/wiki/auth/UserManager.java     |  26 +-
 .../java/org/apache/wiki/auth/WikiPrincipal.java   | 114 ++--
 .../apache/wiki/auth/acl/DefaultAclManager.java    |   2 +-
 .../wiki/auth/authorize/DefaultGroupManager.java   |   8 +-
 .../java/org/apache/wiki/auth/authorize/Group.java | 151 +++---
 .../apache/wiki/auth/authorize/GroupManager.java   |  18 +-
 .../auth/authorize/WebContainerAuthorizer.java     |  18 +-
 .../login/CookieAuthenticationLoginModule.java     |   2 +-
 .../apache/wiki/auth/user/DefaultUserProfile.java  |   3 +-
 .../org/apache/wiki/auth/user/UserDatabase.java    |   2 +-
 .../org/apache/wiki/auth/user/UserProfile.java     |   3 +-
 .../org/apache/wiki/auth/user/XMLUserDatabase.java | 417 +++++----------
 .../java/org/apache/wiki/event/WikiPageEvent.java  |  24 +-
 .../org/apache/wiki/event/WikiSecurityEvent.java   |   4 +-
 .../apache/wiki/filters/DefaultFilterManager.java  |  29 +-
 .../{api/engine => filters}/FilterManager.java     |  30 +-
 .../java/org/apache/wiki/filters/SpamFilter.java   |  42 +-
 .../java/org/apache/wiki/forms/FormOutput.java     |   2 +-
 .../{ModuleManager.java => BaseModuleManager.java} |  30 +-
 .../org/apache/wiki/modules/ModuleManager.java     |  82 +--
 .../org/apache/wiki/modules/WikiModuleInfo.java    |  28 +-
 .../org/apache/wiki/pages/DefaultPageManager.java  |  44 +-
 .../apache/wiki/parser/JSPWikiMarkupParser.java    | 169 ++----
 .../apache/wiki/parser/LinkParsingOperations.java  |  23 +-
 .../java/org/apache/wiki/parser/PluginContent.java |   2 +-
 .../apache/wiki/plugin/AbstractReferralPlugin.java |   3 +-
 .../apache/wiki/plugin/DefaultPluginManager.java   |   7 +-
 .../main/java/org/apache/wiki/plugin/Groups.java   |   5 +-
 .../java/org/apache/wiki/plugin/InsertPage.java    |  11 +-
 .../wiki/{api/engine => plugin}/PluginManager.java | 110 ++--
 .../org/apache/wiki/plugin/SessionsPlugin.java     |  81 ++-
 .../org/apache/wiki/plugin/TableOfContents.java    |   2 +-
 .../wiki/providers/AbstractFileProvider.java       |   3 +-
 .../wiki/render/DefaultRenderingManager.java       |   2 +-
 .../org/apache/wiki/render/RenderingManager.java   |   6 +-
 .../main/java/org/apache/wiki/rss/AtomFeed.java    |  16 +-
 .../main/java/org/apache/wiki/rss/RSS20Feed.java   |   2 +-
 .../java/org/apache/wiki/rss/RSSGenerator.java     |   3 +-
 .../apache/wiki/search/BasicSearchProvider.java    |  15 +-
 .../java/org/apache/wiki/search/SearchMatcher.java |  11 +-
 .../org/apache/wiki/tags/AdminBeanIteratorTag.java |   2 +-
 .../java/org/apache/wiki/tags/MessagesTag.java     |  77 ++-
 .../java/org/apache/wiki/tags/PermissionTag.java   |   4 +-
 .../main/java/org/apache/wiki/tags/PluginTag.java  |   6 +-
 .../java/org/apache/wiki/tags/UserCheckTag.java    |  49 +-
 .../java/org/apache/wiki/tags/UserNameTag.java     |   3 +-
 .../java/org/apache/wiki/tags/UserProfileTag.java  |  46 +-
 .../wiki/tasks/pages/PreSaveWikiPageTask.java      |   2 +-
 .../apache/wiki/tasks/pages/SaveWikiPageTask.java  |   2 +-
 .../org/apache/wiki/ui/DefaultEditorManager.java   |   4 +-
 .../org/apache/wiki/ui/DefaultTemplateManager.java |   4 +-
 .../java/org/apache/wiki/ui/EditorManager.java     |  14 +-
 .../java/org/apache/wiki/ui/InputValidator.java    |   4 +-
 .../main/java/org/apache/wiki/ui/Installer.java    |   3 +-
 .../java/org/apache/wiki/ui/TemplateManager.java   |  14 +-
 .../org/apache/wiki/ui/WikiRequestWrapper.java     |  25 +-
 .../java/org/apache/wiki/ui/WikiServletFilter.java |  19 +-
 .../{api/engine => ui/admin}/AdminBeanManager.java |   7 +-
 .../wiki/ui/admin/DefaultAdminBeanManager.java     |  15 +-
 .../org/apache/wiki/ui/admin/beans/CoreBean.java   |  31 +-
 .../org/apache/wiki/ui/admin/beans/FilterBean.java |   8 +-
 .../org/apache/wiki/ui/admin/beans/ModuleBean.java |   2 +-
 .../org/apache/wiki/ui/admin/beans/PluginBean.java |   8 +-
 .../wiki/ui/admin/beans/SearchManagerBean.java     |  46 +-
 .../org/apache/wiki/ui/admin/beans/UserBean.java   | 110 ++--
 .../java/org/apache/wiki/url/URLConstructor.java   |  10 +-
 .../wiki/variables/DefaultVariableManager.java     |  10 +-
 .../org/apache/wiki/workflow/DecisionQueue.java    | 112 ++--
 .../wiki/workflow/DefaultWorkflowManager.java      |   4 +-
 .../org/apache/wiki/workflow/WorkflowManager.java  |   6 +-
 .../org/apache/wiki/xmlrpc/MetaWeblogHandler.java  |   3 +-
 .../src/main/resources/ini/classmappings.xml       |   6 +-
 .../src/test/java/org/apache/wiki/ReleaseTest.java | 156 ------
 .../src/test/java/org/apache/wiki/TestEngine.java  |  49 +-
 .../test/java/org/apache/wiki/WikiEngineTest.java  |  11 +
 .../test/java/org/apache/wiki/WikiSessionTest.java | 108 ++--
 .../test/java/org/apache/wiki/api/ReleaseTest.java | 133 +++++
 .../wiki/auth/AuthenticationManagerTest.java       |  21 +-
 .../apache/wiki/auth/AuthorizationManagerTest.java |  76 +--
 .../java/org/apache/wiki/auth/TestAuthorizer.java  |  14 +-
 .../java/org/apache/wiki/auth/UserManagerTest.java |  14 +-
 .../java/org/apache/wiki/auth/acl/AclImplTest.java |  79 +--
 .../wiki/auth/authorize/GroupManagerTest.java      |  21 +-
 .../wiki/filters/DefaultFilterManagerTest.java     |   1 -
 .../java/org/apache/wiki/plugin/IfPluginTest.java  |  28 +-
 .../org/apache/wiki/plugin/PageViewPluginTest.java |   1 -
 .../wiki/plugin/RecentChangesPluginTest.java       |  14 +-
 .../wiki/plugin/ReferringPagesPluginTest.java      |  40 +-
 .../plugin/ReferringUndefinedPagesPluginTest.java  |  14 +-
 .../wiki/plugin/UndefinedPagesPluginTest.java      |   1 -
 .../apache/wiki/workflow/ApprovalWorkflowTest.java |   2 +-
 .../apache/wiki/workflow/DecisionQueueTest.java    |  35 +-
 .../wiki/markdown/MarkdownForJSPWikiExtension.java |  15 +-
 .../ExternalLinkAttributeProviderState.java        |  15 +-
 .../InterWikiLinkAttributeProviderState.java       |  14 +-
 .../JSPWikiLinkAttributeProvider.java              |  24 +-
 .../JSPWikiLinkAttributeProviderFactory.java       |  16 +-
 .../LocalLinkAttributeProviderState.java           |  14 +-
 .../ExternalLinkNodePostProcessorState.java        |  13 +-
 .../InterWikiLinkNodePostProcessorState.java       |  13 +-
 .../JSPWikiLinkNodePostProcessor.java              |  20 +-
 .../JSPWikiNodePostProcessorFactory.java           |  14 +-
 .../LocalLinkNodePostProcessorState.java           |  13 +-
 .../wiki/parser/markdown/MarkdownDocument.java     |   6 +-
 .../wiki/parser/markdown/MarkdownParser.java       |   2 +-
 .../wiki/render/markdown/MarkdownRenderer.java     |  17 +-
 .../{ => markdown}/MarkdownRendererTest.java       |  33 +-
 jspwiki-portable/build.xml                         |   2 +-
 .../tomcat/woas.app/Contents/Java/bootstrap.jar    | Bin 35204 -> 35071 bytes
 .../tomcat/woas.app/Contents/Java/tomcat-juli.jar  | Bin 49783 -> 47886 bytes
 .../src/overlay/launchers/tomcat/woas.exe          | Bin 3500245 -> 3564962 bytes
 .../src/overlay/tomcat/conf/catalina.properties    |  48 +-
 .../src/overlay/tomcat/conf/server.xml             |  87 ++-
 jspwiki-portable/src/overlay/tomcat/conf/web.xml   |  50 +-
 .../main/java/org/apache/wiki/util/HttpUtil.java   | 126 +++--
 .../util/comparators}/PrincipalComparator.java     |  21 +-
 .../java/org/apache/wiki/util/HttpUtilTest.java    |  50 ++
 .../util/comparators/PrincipalComparatorTest.java  |  32 +-
 jspwiki-war/src/main/webapp/Captcha.jsp            |   7 +-
 jspwiki-war/src/main/webapp/Comment.jsp            |   3 +-
 jspwiki-war/src/main/webapp/CookieError.jsp        |   6 +-
 jspwiki-war/src/main/webapp/Delete.jsp             |  30 +-
 jspwiki-war/src/main/webapp/DeleteGroup.jsp        |  10 +-
 jspwiki-war/src/main/webapp/Diff.jsp               |  22 +-
 jspwiki-war/src/main/webapp/Edit.jsp               |  30 +-
 jspwiki-war/src/main/webapp/EditGroup.jsp          |  15 +-
 jspwiki-war/src/main/webapp/Error.jsp              |   3 +-
 jspwiki-war/src/main/webapp/Group.jsp              |  26 +-
 jspwiki-war/src/main/webapp/Install.jsp            |   8 +-
 jspwiki-war/src/main/webapp/Login.jsp              |  14 +-
 jspwiki-war/src/main/webapp/LoginForm.jsp          |   6 +-
 jspwiki-war/src/main/webapp/Logout.jsp             |   8 +-
 jspwiki-war/src/main/webapp/LostPassword.jsp       |  16 +-
 jspwiki-war/src/main/webapp/Message.jsp            |   6 +-
 jspwiki-war/src/main/webapp/NewBlogEntry.jsp       |   3 +-
 jspwiki-war/src/main/webapp/NewGroup.jsp           |  21 +-
 jspwiki-war/src/main/webapp/PageInfo.jsp           |  11 +-
 jspwiki-war/src/main/webapp/PageModified.jsp       |  22 +-
 jspwiki-war/src/main/webapp/Preview.jsp            |  21 +-
 jspwiki-war/src/main/webapp/Rename.jsp             |  32 +-
 jspwiki-war/src/main/webapp/Search.jsp             |  31 +-
 jspwiki-war/src/main/webapp/SisterSites.jsp        |  17 +-
 jspwiki-war/src/main/webapp/Upload.jsp             |   9 +-
 jspwiki-war/src/main/webapp/UserPreferences.jsp    |  21 +-
 jspwiki-war/src/main/webapp/Wiki.jsp               |  13 +-
 jspwiki-war/src/main/webapp/Workflow.jsp           |  22 +-
 jspwiki-war/src/main/webapp/XHRHtml2Markup.jsp     |   6 +-
 .../src/main/webapp/admin/SecurityConfig.jsp       |  16 +-
 jspwiki-war/src/main/webapp/rss.jsp                |  49 +-
 .../main/webapp/templates/210/EditGroupContent.jsp |   4 +-
 .../src/main/webapp/templates/210/Favorites.jsp    |   3 +-
 .../src/main/webapp/templates/210/Footer.jsp       |   1 +
 .../src/main/webapp/templates/210/GroupContent.jsp |   2 +-
 .../src/main/webapp/templates/210/GroupTab.jsp     |   4 +-
 .../main/webapp/templates/210/NewGroupContent.jsp  |   2 +-
 .../webapp/templates/210/admin/AdminTemplate.jsp   |   3 +-
 .../webapp/templates/default/EditGroupContent.jsp  |   6 +-
 .../src/main/webapp/templates/default/Footer.jsp   |   2 +-
 .../src/main/webapp/templates/default/GroupTab.jsp |   5 +-
 .../templates/default/admin/AdminTemplate.jsp      |   3 +-
 pom.xml                                            |  10 +-
 181 files changed, 2611 insertions(+), 2859 deletions(-)
 rename jspwiki-main/src/main/java/org/apache/wiki/{ => api}/Release.java (97%)
 create mode 100644 jspwiki-main/src/main/java/org/apache/wiki/api/core/Session.java
 delete mode 100644 jspwiki-main/src/main/java/org/apache/wiki/api/engine/package.html
 rename jspwiki-main/src/main/java/org/apache/wiki/{api/engine => filters}/FilterManager.java (84%)
 copy jspwiki-main/src/main/java/org/apache/wiki/modules/{ModuleManager.java => BaseModuleManager.java} (67%)
 rename jspwiki-main/src/main/java/org/apache/wiki/{api/engine => plugin}/PluginManager.java (54%)
 rename jspwiki-main/src/main/java/org/apache/wiki/{api/engine => ui/admin}/AdminBeanManager.java (95%)
 delete mode 100644 jspwiki-main/src/test/java/org/apache/wiki/ReleaseTest.java
 create mode 100644 jspwiki-main/src/test/java/org/apache/wiki/api/ReleaseTest.java
 rename jspwiki-markdown/src/test/java/org/apache/wiki/render/{ => markdown}/MarkdownRendererTest.java (93%)
 mode change 100755 => 100644
 rename {jspwiki-main/src/main/java/org/apache/wiki/auth => jspwiki-util/src/main/java/org/apache/wiki/util/comparators}/PrincipalComparator.java (77%)
 create mode 100644 jspwiki-util/src/test/java/org/apache/wiki/util/HttpUtilTest.java
 copy jspwiki-main/src/test/java/org/apache/wiki/parser/MarkupParserTest.java => jspwiki-util/src/test/java/org/apache/wiki/util/comparators/PrincipalComparatorTest.java (54%)


[jspwiki] 19/35: JSPWIKI-303: extract o.a.w.api.core.Session from o.a.w.WikiSession

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git

commit 442402d3010310e000cd88b74748b9c3d83b804f
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Mar 4 20:18:57 2020 +0100

    JSPWIKI-303: extract o.a.w.api.core.Session from o.a.w.WikiSession
---
 .../src/main/java/org/apache/wiki/WikiSession.java | 583 +++++++--------------
 .../java/org/apache/wiki/api/core/Session.java     | 248 +++++++++
 2 files changed, 449 insertions(+), 382 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiSession.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiSession.java
index 39ac604..12e6f36 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiSession.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiSession.java
@@ -21,6 +21,7 @@ package org.apache.wiki;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.log4j.Logger;
 import org.apache.wiki.api.core.Engine;
+import org.apache.wiki.api.core.Session;
 import org.apache.wiki.auth.AuthenticationManager;
 import org.apache.wiki.auth.GroupPrincipal;
 import org.apache.wiki.auth.NoSuchPrincipalException;
@@ -33,81 +34,40 @@ import org.apache.wiki.auth.authorize.Role;
 import org.apache.wiki.auth.user.UserDatabase;
 import org.apache.wiki.auth.user.UserProfile;
 import org.apache.wiki.event.WikiEvent;
-import org.apache.wiki.event.WikiEventListener;
 import org.apache.wiki.event.WikiSecurityEvent;
+import org.apache.wiki.util.HttpUtil;
 
 import javax.security.auth.Subject;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpSession;
-import java.security.AccessControlException;
 import java.security.Principal;
-import java.security.PrivilegedAction;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedHashSet;
 import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
 
 /**
- * <p>Represents a long-running wiki session, with an associated user Principal, user Subject, and authentication status. This class
- * is initialized with minimal, default-deny values: authentication is set to <code>false</code>, and the user principal is set to
- * <code>null</code>.</p>
- * <p>The WikiSession class allows callers to:</p>
- * <ul>
- *   <li>Obtain the authentication status of the user via
- *     {@link #isAnonymous()} and {@link #isAuthenticated()}</li>
- *   <li>Query the session for Principals representing the
- *     user's identity via {@link #getLoginPrincipal()},
- *     {@link #getUserPrincipal()} and {@link #getPrincipals()}</li>
- *   <li>Store, retrieve and clear UI messages via
- *     {@link #addMessage(String)}, {@link #getMessages(String)}
- *     and {@link #clearMessages(String)}</li>
- * </ul>
- * <p>To keep track of the Principals each user posseses, each WikiSession stores a JAAS Subject. Various login processes add or
- * remove Principals when users authenticate or log out.</p>
- * <p>WikiSession implements the {@link org.apache.wiki.event.WikiEventListener} interface and listens for group add/change/delete
- * events fired by event sources the WikiSession is registered with. Normally, {@link org.apache.wiki.auth.AuthenticationManager}
- * registers each WikiSession with the {@link org.apache.wiki.auth.authorize.GroupManager} so it can catch group events. Thus, when
- * a user is added to a {@link org.apache.wiki.auth.authorize.Group}, a corresponding {@link org.apache.wiki.auth.GroupPrincipal} is
- * injected into the Subject's Principal set. Likewise, when the user is removed from the Group or the Group is deleted, the
- * GroupPrincipal is removed from the Subject. The effect that this strategy produces is extremely beneficial: when someone adds a user
- * to a wiki group, that user <em>immediately</em> gains the privileges associated with that group; he or she does not need to
- * re-authenticate.
- * </p>
+ * <p>Default implementation for {@link Session}.</p>
  * <p>In addition to methods for examining individual <code>WikiSession</code> objects, this class also contains a number of static
  * methods for managing WikiSessions for an entire wiki. These methods allow callers to find, query and remove WikiSession objects, and
  * to obtain a list of the current wiki session users.</p>
- * <p>WikiSession encloses a protected static class, {@link SessionMonitor}, to keep track of WikiSessions registered with each wiki.</p>
  */
-public final class WikiSession implements WikiEventListener {
-
-    /** An anonymous user's session status. */
-    public static final String  ANONYMOUS             = "anonymous";
-
-    /** An asserted user's session status. */
-    public static final String  ASSERTED              = "asserted";
-
-    /** An authenticated user's session status. */
-    public static final String  AUTHENTICATED         = "authenticated";
-
-    private static final int    ONE                   = 48;
-
-    private static final int    NINE                  = 57;
-
-    private static final int    DOT                   = 46;
+public final class WikiSession implements Session {
 
     private static final Logger log                   = Logger.getLogger( WikiSession.class );
 
     private static final String ALL                   = "*";
 
-    private static ThreadLocal<WikiSession> c_guestSession = new ThreadLocal<>();
+    private static ThreadLocal< Session > c_guestSession = new ThreadLocal<>();
 
     private final Subject       m_subject             = new Subject();
 
-    private final Map<String,Set<String>> m_messages  = new HashMap<>();
+    private final Map< String, Set< String > > m_messages  = new ConcurrentHashMap<>();
 
     /** The Engine that created this session. */
     private Engine              m_engine              = null;
@@ -142,24 +102,14 @@ public final class WikiSession implements WikiEventListener {
     private WikiSession() {
     }
 
-    /**
-     * Returns <code>true</code> if the user is considered asserted via a session cookie; that is, the Subject contains the Principal
-     * Role.ASSERTED.
-     *
-     * @return Returns <code>true</code> if the user is asserted
-     */
-    public boolean isAsserted()
-    {
+    /** {@inheritDoc} */
+    @Override
+    public boolean isAsserted() {
         return m_subject.getPrincipals().contains( Role.ASSERTED );
     }
 
-    /**
-     * Returns the authentication status of the user's session. The user is considered authenticated if the Subject contains the
-     * Principal Role.AUTHENTICATED. If this method determines that an earlier LoginModule did not inject Role.AUTHENTICATED, it
-     * will inject one if the user is not anonymous <em>and</em> not asserted.
-     *
-     * @return Returns <code>true</code> if the user is authenticated
-     */
+    /** {@inheritDoc} */
+    @Override
     public boolean isAuthenticated() {
         // If Role.AUTHENTICATED is in principals set, always return true.
         if ( m_subject.getPrincipals().contains( Role.AUTHENTICATED ) ) {
@@ -175,89 +125,41 @@ public final class WikiSession implements WikiEventListener {
         return false;
     }
 
-    /**
-     * <p>Determines whether the current session is anonymous. This will be true if any of these conditions are true:</p>
-     * <ul>
-     *   <li>The session's Principal set contains
-     *       {@link org.apache.wiki.auth.authorize.Role#ANONYMOUS}</li>
-     *   <li>The session's Principal set contains
-     *       {@link org.apache.wiki.auth.WikiPrincipal#GUEST}</li>
-     *   <li>The Principal returned by {@link #getUserPrincipal()} evaluates
-     *       to an IP address.</li>
-     * </ul>
-     * <p>The criteria above are listed in the order in which they are evaluated.</p>
-     * @return whether the current user's identity is equivalent to an IP address
-     */
+    /** {@inheritDoc} */
+    @Override
     public boolean isAnonymous() {
         final Set< Principal > principals = m_subject.getPrincipals();
         return principals.contains( Role.ANONYMOUS ) ||
                principals.contains( WikiPrincipal.GUEST ) ||
-               isIPV4Address( getUserPrincipal().getName() );
+               HttpUtil.isIPV4Address( getUserPrincipal().getName() );
     }
 
-    /**
-     * <p> Returns the Principal used to log in to an authenticated session. The login principal is determined by examining the
-     * Subject's Principal set for PrincipalWrappers or WikiPrincipals with type designator <code>LOGIN_NAME</code>; the first one
-     * found is the login principal. If one is not found, this method returns the first principal that isn't of type Role or
-     * GroupPrincipal. If neither of these conditions hold, this method returns {@link org.apache.wiki.auth.WikiPrincipal#GUEST}.
-     *
-     * @return the login Principal. If it is a PrincipalWrapper containing an externally-provided Principal, the object returned is the
-     * Principal, not the wrapper around it.
-     */
-    public Principal getLoginPrincipal()
-    {
+    /** {@inheritDoc} */
+    @Override
+    public Principal getLoginPrincipal() {
         return m_loginPrincipal;
     }
 
-    /**
-     * <p>Returns the primary user Principal associated with this session. The primary user principal is determined as follows:</p>
-     * <ol>
-     *     <li>If the Subject's Principal set contains WikiPrincipals, the first WikiPrincipal with type designator
-     *         <code>WIKI_NAME</code> or (alternatively) <code>FULL_NAME</code> is the primary Principal.</li>
-     *     <li>For all other cases, the first Principal in the Subject's principal collection that that isn't of type Role or
-     *         GroupPrincipal is the primary.</li>
-     * </ol>
-     * If no primary user Principal is found, this method returns {@link org.apache.wiki.auth.WikiPrincipal#GUEST}.
-     *
-     * @return the primary user Principal
-     */
-    public Principal getUserPrincipal()
-    {
+    /** {@inheritDoc} */
+    @Override
+    public Principal getUserPrincipal() {
         return m_userPrincipal;
     }
 
-    /**
-     *  Returns a cached Locale object for this user.  It's better to use WikiContext's corresponding getBundle() method, since that
-     *  will actually react if the user changes the locale in the middle, but if that's not available (or, for some reason, you need
-     *  the speed), this method can also be used.  The Locale expires when the WikiSession expires, and currently there is no way to
-     *  reset the Locale.
-     *
-     *  @return A cached Locale object
-     *  @since 2.5.96
-     */
-    public Locale getLocale()
-    {
+    /** {@inheritDoc} */
+    @Override
+    public Locale getLocale() {
         return m_cachedLocale;
     }
 
-    /**
-     * Adds a message to the generic list of messages associated with the session. These messages retain their order of insertion and
-     * remain until the {@link #clearMessages()} method is called.
-     *
-     * @param message the message to add; if <code>null</code> it is ignored.
-     */
-    public void addMessage( final String message )
-    {
+    /** {@inheritDoc} */
+    @Override
+    public void addMessage( final String message ) {
         addMessage( ALL, message );
     }
 
-    /**
-     * Adds a message to the specific set of messages associated with the session. These messages retain their order of insertion and
-     * remain until the {@link #clearMessages()} method is called.
-     *
-     * @param topic the topic to associate the message to;
-     * @param message the message to add
-     */
+    /** {@inheritDoc} */
+    @Override
     public void addMessage( final String topic, final String message ) {
         if ( topic == null ) {
             throw new IllegalArgumentException( "addMessage: topic cannot be null." );
@@ -266,19 +168,14 @@ public final class WikiSession implements WikiEventListener {
         messages.add( StringUtils.defaultString( message ) );
     }
 
-    /**
-     * Clears all messages associated with this session.
-     */
-    public void clearMessages()
-    {
+    /** {@inheritDoc} */
+    @Override
+    public void clearMessages() {
         m_messages.clear();
     }
 
-    /**
-     * Clears all messages associated with a session topic.
-     *
-     * @param topic the topic whose messages should be cleared.
-     */
+    /** {@inheritDoc} */
+    @Override
     public void clearMessages( final String topic ) {
         final Set< String > messages = m_messages.get( topic );
         if ( messages != null ) {
@@ -286,39 +183,24 @@ public final class WikiSession implements WikiEventListener {
         }
     }
 
-    /**
-     * Returns all generic messages associated with this session.
-     * The messages stored with the session persist throughout the
-     * session unless they have been reset with {@link #clearMessages()}.
-     * @return the current messages.
-     */
-    public String[] getMessages()
-    {
+    /** {@inheritDoc} */
+    @Override
+    public String[] getMessages() {
         return getMessages( ALL );
     }
 
-    /**
-     * Returns all messages associated with a session topic.
-     * The messages stored with the session persist throughout the
-     * session unless they have been reset with {@link #clearMessages(String)}.
-     * @return the current messages.
-     * @param topic The topic
-     */
+    /** {@inheritDoc} */
+    @Override
     public String[] getMessages( final String topic ) {
         final Set< String > messages = m_messages.get( topic );
         if( messages == null || messages.size() == 0 ) {
-            return new String[0];
+            return new String[ 0 ];
         }
-        return messages.toArray( new String[messages.size()] );
+        return messages.toArray( new String[ messages.size() ] );
     }
 
-    /**
-     * Returns all user Principals associated with this session. User principals are those in the Subject's principal collection that
-     * aren't of type Role or of type GroupPrincipal. This is a defensive copy.
-     *
-     * @return Returns the user principal
-     * @see org.apache.wiki.auth.AuthenticationManager#isUserPrincipal(Principal)
-     */
+    /** {@inheritDoc} */
+    @Override
     public Principal[] getPrincipals() {
         final ArrayList< Principal > principals = new ArrayList<>();
 
@@ -329,18 +211,11 @@ public final class WikiSession implements WikiEventListener {
             }
         }
 
-        return principals.toArray( new Principal[principals.size()] );
+        return principals.toArray( new Principal[ principals.size() ] );
     }
 
-    /**
-     * Returns an array of Principal objects that represents the groups and roles that the user associated with a WikiSession possesses.
-     * The array is built by iterating through the Subject's Principal set and extracting all Role and GroupPrincipal objects into a
-     * list. The list is returned as an array sorted in the natural order implied by each Principal's <code>getName</code> method. Note
-     * that this method does <em>not</em> consult the external Authorizer or GroupManager; it relies on the Principals that have been
-     * injected into the user's Subject at login time, or after group creation/modification/deletion.
-     *
-     * @return an array of Principal objects corresponding to the roles the Subject possesses
-     */
+    /** {@inheritDoc} */
+    @Override
     public Principal[] getRoles() {
         final Set< Principal > roles = new HashSet<>();
 
@@ -351,170 +226,150 @@ public final class WikiSession implements WikiEventListener {
         roles.addAll( m_subject.getPrincipals( GroupPrincipal.class ) );
 
         // Return a defensive copy
-        final Principal[] roleArray = roles.toArray( new Principal[roles.size()] );
+        final Principal[] roleArray = roles.toArray( new Principal[ roles.size() ] );
         Arrays.sort( roleArray, WikiPrincipal.COMPARATOR );
         return roleArray;
     }
 
-    /**
-     * Removes the wiki session associated with the user's HTTP request from the cache of wiki sessions, typically as part of a
-     * logout process.
-     *
-     * @param engine the wiki engine
-     * @param request the users's HTTP request
-     */
-    public static void removeWikiSession( final Engine engine, final HttpServletRequest request ) {
-        if ( engine == null || request == null ) {
-            throw new IllegalArgumentException( "Request or engine cannot be null." );
-        }
-        final SessionMonitor monitor = SessionMonitor.getInstance( engine );
-        monitor.remove( request.getSession() );
-    }
-
-    /**
-     * Returns <code>true</code> if the WikiSession's Subject possess a supplied Principal. This method eliminates the need to externally
-     * request and inspect the JAAS subject.
-     *
-     * @param principal the Principal to test
-     * @return the result
-     */
+    /** {@inheritDoc} */
+    @Override
     public boolean hasPrincipal( final Principal principal ) {
         return m_subject.getPrincipals().contains( principal );
     }
 
     /**
-     * Listens for WikiEvents generated by source objects such as the GroupManager. This method adds Principals to the private Subject
-     * managed by the WikiSession.
+     * Listens for WikiEvents generated by source objects such as the GroupManager, UserManager or AuthenticationManager. This method adds
+     * Principals to the private Subject managed by the WikiSession.
      *
-     * @see org.apache.wiki.event.WikiEventListener#actionPerformed(org.apache.wiki.event.WikiEvent)
+     * @see org.apache.wiki.event.WikiEventListener#actionPerformed(WikiEvent)
      */
     @Override
     public void actionPerformed( final WikiEvent event ) {
         if ( event instanceof WikiSecurityEvent ) {
             final WikiSecurityEvent e = (WikiSecurityEvent)event;
             if ( e.getTarget() != null ) {
-                switch (e.getType() ) {
-                    case WikiSecurityEvent.GROUP_ADD:
-                        final Group groupAdd = (Group)e.getTarget();
-                        if ( isInGroup( groupAdd ) ) {
-                            m_subject.getPrincipals().add( groupAdd.getPrincipal() );
-                        }
-                        break;
-                    case WikiSecurityEvent.GROUP_REMOVE:
-                        final Group group = (Group)e.getTarget();
-                        m_subject.getPrincipals().remove( group.getPrincipal() );
-                        break;
-                    case WikiSecurityEvent.GROUP_CLEAR_GROUPS:
-                        m_subject.getPrincipals().removeAll( m_subject.getPrincipals( GroupPrincipal.class ) );
-                        break;
-                    case WikiSecurityEvent.LOGIN_INITIATED:
-                        // Do nothing
-                        break;
-                    case WikiSecurityEvent.PRINCIPAL_ADD:
-                        final WikiSession targetPA = (WikiSession)e.getTarget();
-                        if ( this.equals( targetPA ) && m_status.equals(AUTHENTICATED) ) {
-                            final Set<Principal> principals = m_subject.getPrincipals();
-                            principals.add( ( Principal )e.getPrincipal() );
-                        }
-                        break;
-                    case WikiSecurityEvent.LOGIN_ANONYMOUS:
-                        final WikiSession targetLAN = (WikiSession)e.getTarget();
-                        if( this.equals( targetLAN ) ) {
-                            m_status = ANONYMOUS;
-
-                            // Set the login/user principals and login status
-                            final Set<Principal> principals = m_subject.getPrincipals();
-                            m_loginPrincipal = (Principal)e.getPrincipal();
-                            m_userPrincipal = m_loginPrincipal;
-
-                            // Add the login principal to the Subject, and set the built-in roles
-                            principals.clear();
-                            principals.add( m_loginPrincipal );
-                            principals.add( Role.ALL );
-                            principals.add( Role.ANONYMOUS );
+                switch( e.getType() ) {
+                case WikiSecurityEvent.GROUP_ADD:
+                    final Group groupAdd = ( Group )e.getTarget();
+                    if( isInGroup( groupAdd ) ) {
+                        m_subject.getPrincipals().add( groupAdd.getPrincipal() );
+                    }
+                    break;
+                case WikiSecurityEvent.GROUP_REMOVE:
+                    final Group group = ( Group )e.getTarget();
+                    m_subject.getPrincipals().remove( group.getPrincipal() );
+                    break;
+                case WikiSecurityEvent.GROUP_CLEAR_GROUPS:
+                    m_subject.getPrincipals().removeAll( m_subject.getPrincipals( GroupPrincipal.class ) );
+                    break;
+                case WikiSecurityEvent.LOGIN_INITIATED:
+                    // Do nothing
+                    break;
+                case WikiSecurityEvent.PRINCIPAL_ADD:
+                    final WikiSession targetPA = ( WikiSession )e.getTarget();
+                    if( this.equals( targetPA ) && m_status.equals( AUTHENTICATED ) ) {
+                        final Set< Principal > principals = m_subject.getPrincipals();
+                        principals.add( ( Principal )e.getPrincipal() );
+                    }
+                    break;
+                case WikiSecurityEvent.LOGIN_ANONYMOUS:
+                    final WikiSession targetLAN = ( WikiSession )e.getTarget();
+                    if( this.equals( targetLAN ) ) {
+                        m_status = ANONYMOUS;
+
+                        // Set the login/user principals and login status
+                        final Set< Principal > principals = m_subject.getPrincipals();
+                        m_loginPrincipal = ( Principal )e.getPrincipal();
+                        m_userPrincipal = m_loginPrincipal;
+
+                        // Add the login principal to the Subject, and set the built-in roles
+                        principals.clear();
+                        principals.add( m_loginPrincipal );
+                        principals.add( Role.ALL );
+                        principals.add( Role.ANONYMOUS );
+                    }
+                    break;
+                case WikiSecurityEvent.LOGIN_ASSERTED:
+                    final WikiSession targetLAS = ( WikiSession )e.getTarget();
+                    if( this.equals( targetLAS ) ) {
+                        m_status = ASSERTED;
+
+                        // Set the login/user principals and login status
+                        final Set< Principal > principals = m_subject.getPrincipals();
+                        m_loginPrincipal = ( Principal )e.getPrincipal();
+                        m_userPrincipal = m_loginPrincipal;
+
+                        // Add the login principal to the Subject, and set the built-in roles
+                        principals.clear();
+                        principals.add( m_loginPrincipal );
+                        principals.add( Role.ALL );
+                        principals.add( Role.ASSERTED );
+                    }
+                    break;
+                case WikiSecurityEvent.LOGIN_AUTHENTICATED:
+                    final WikiSession targetLAU = ( WikiSession )e.getTarget();
+                    if( this.equals( targetLAU ) ) {
+                        m_status = AUTHENTICATED;
+
+                        // Set the login/user principals and login status
+                        final Set< Principal > principals = m_subject.getPrincipals();
+                        m_loginPrincipal = ( Principal )e.getPrincipal();
+                        m_userPrincipal = m_loginPrincipal;
+
+                        // Add the login principal to the Subject, and set the built-in roles
+                        principals.clear();
+                        principals.add( m_loginPrincipal );
+                        principals.add( Role.ALL );
+                        principals.add( Role.AUTHENTICATED );
+
+                        // Add the user and group principals
+                        injectUserProfilePrincipals();  // Add principals for the user profile
+                        injectGroupPrincipals();  // Inject group principals
+                    }
+                    break;
+                case WikiSecurityEvent.PROFILE_SAVE:
+                    final WikiSession sourcePS = e.getSrc();
+                    if( this.equals( sourcePS ) ) {
+                        injectUserProfilePrincipals();  // Add principals for the user profile
+                        injectGroupPrincipals();  // Inject group principals
+                    }
+                    break;
+                case WikiSecurityEvent.PROFILE_NAME_CHANGED:
+                    // Refresh user principals based on new user profile
+                    final WikiSession sourcePNC = e.getSrc();
+                    if( this.equals( sourcePNC ) && m_status.equals( AUTHENTICATED ) ) {
+                        // To prepare for refresh, set the new full name as the primary principal
+                        final UserProfile[] profiles = ( UserProfile[] )e.getTarget();
+                        final UserProfile newProfile = profiles[ 1 ];
+                        if( newProfile.getFullname() == null ) {
+                            throw new IllegalStateException( "User profile FullName cannot be null." );
                         }
-                        break;
-                    case WikiSecurityEvent.LOGIN_ASSERTED:
-                        final WikiSession targetLAS = (WikiSession)e.getTarget();
-                        if ( this.equals( targetLAS ) ) {
-                            m_status = ASSERTED;
-
-                            // Set the login/user principals and login status
-                            final Set<Principal> principals = m_subject.getPrincipals();
-                            m_loginPrincipal = (Principal)e.getPrincipal();
-                            m_userPrincipal = m_loginPrincipal;
-
-                            // Add the login principal to the Subject, and set the built-in roles
-                            principals.clear();
-                            principals.add( m_loginPrincipal );
-                            principals.add( Role.ALL );
-                            principals.add( Role.ASSERTED );
-                        }
-                        break;
-                    case WikiSecurityEvent.LOGIN_AUTHENTICATED:
-                        final WikiSession targetLAU = (WikiSession)e.getTarget();
-                        if ( this.equals( targetLAU ) ) {
-                            m_status = AUTHENTICATED;
-
-                            // Set the login/user principals and login status
-                            final Set<Principal> principals = m_subject.getPrincipals();
-                            m_loginPrincipal = (Principal)e.getPrincipal();
-                            m_userPrincipal = m_loginPrincipal;
-
-                            // Add the login principal to the Subject, and set the built-in roles
-                            principals.clear();
-                            principals.add( m_loginPrincipal );
-                            principals.add( Role.ALL );
-                            principals.add( Role.AUTHENTICATED );
-
-                            // Add the user and group principals
-                            injectUserProfilePrincipals();  // Add principals for the user profile
-                            injectGroupPrincipals();  // Inject group principals
-                        }
-                        break;
-                    case WikiSecurityEvent.PROFILE_SAVE:
-                        final WikiSession sourcePS = e.getSrc();
-                        if ( this.equals( sourcePS ) ) {
-                            injectUserProfilePrincipals();  // Add principals for the user profile
-                            injectGroupPrincipals();  // Inject group principals
-                        }
-                        break;
-                    case WikiSecurityEvent.PROFILE_NAME_CHANGED:
-                        // Refresh user principals based on new user profile
-                        final WikiSession sourcePNC = e.getSrc();
-                        if ( this.equals( sourcePNC ) && m_status.equals(AUTHENTICATED) ) {
-                            // To prepare for refresh, set the new full name as the primary principal
-                            final UserProfile[] profiles = (UserProfile[])e.getTarget();
-                            final UserProfile newProfile = profiles[1];
-                            if ( newProfile.getFullname() == null ) {
-                                throw new IllegalStateException( "User profile FullName cannot be null." );
-                            }
-
-                            final Set<Principal> principals = m_subject.getPrincipals();
-                            m_loginPrincipal = new WikiPrincipal( newProfile.getLoginName() );
-
-                            // Add the login principal to the Subject, and set the built-in roles
-                            principals.clear();
-                            principals.add( m_loginPrincipal );
-                            principals.add( Role.ALL );
-                            principals.add( Role.AUTHENTICATED );
-
-                            // Add the user and group principals
-                            injectUserProfilePrincipals();  // Add principals for the user profile
-                            injectGroupPrincipals();  // Inject group principals
-                        }
-                        break;
 
-                    //  No action, if the event is not recognized.
-                    default: break;
+                        final Set< Principal > principals = m_subject.getPrincipals();
+                        m_loginPrincipal = new WikiPrincipal( newProfile.getLoginName() );
+
+                        // Add the login principal to the Subject, and set the built-in roles
+                        principals.clear();
+                        principals.add( m_loginPrincipal );
+                        principals.add( Role.ALL );
+                        principals.add( Role.AUTHENTICATED );
+
+                        // Add the user and group principals
+                        injectUserProfilePrincipals();  // Add principals for the user profile
+                        injectGroupPrincipals();  // Inject group principals
+                    }
+                    break;
+
+                //  No action, if the event is not recognized.
+                default:
+                    break;
                 }
             }
         }
     }
 
-    /**
-     * Invalidates the WikiSession and resets its Subject's Principals to the equivalent of a "guest session".
-     */
+    /** {@inheritDoc} */
+    @Override
     public void invalidate() {
         m_subject.getPrincipals().clear();
         m_subject.getPrincipals().add( WikiPrincipal.GUEST );
@@ -587,33 +442,47 @@ public final class WikiSession implements WikiEventListener {
         }
     }
 
-    /**
-     * <p>Returns the status of the wiki session as a text string. Valid values are:</p>
-     * <ul>
-     *   <li>{@link #AUTHENTICATED}</li>
-     *   <li>{@link #ASSERTED}</li>
-     *   <li>{@link #ANONYMOUS}</li>
-     * </ul>
-     * @return the user's session status
-     */
+    /** {@inheritDoc} */
+    @Override
     public String getStatus() {
         return m_status;
     }
 
+    /** {@inheritDoc} */
+    @Override
+    public Subject getSubject() {
+        return m_subject;
+    }
+
     /**
-     * <p>Static factory method that returns the WikiSession object associated with the current HTTP request. This method looks up
+     * Removes the wiki session associated with the user's HTTP request from the cache of wiki sessions, typically as part of a
+     * logout process.
+     *
+     * @param engine the wiki engine
+     * @param request the users's HTTP request
+     */
+    public static void removeWikiSession( final Engine engine, final HttpServletRequest request ) {
+        if ( engine == null || request == null ) {
+            throw new IllegalArgumentException( "Request or engine cannot be null." );
+        }
+        final SessionMonitor monitor = SessionMonitor.getInstance( engine );
+        monitor.remove( request.getSession() );
+    }
+
+    /**
+     * <p>Static factory method that returns the Session object associated with the current HTTP request. This method looks up
      * the associated HttpSession in an internal WeakHashMap and attempts to retrieve the WikiSession. If not found, one is created.
-     * This method is guaranteed to always return a WikiSession, although the authentication status is unpredictable until the user
+     * This method is guaranteed to always return a Session, although the authentication status is unpredictable until the user
      * attempts to log in. If the servlet request parameter is <code>null</code>, a synthetic {@link #guestSession(Engine)} is
      * returned.</p>
-     * <p>When a session is created, this method attaches a WikiEventListener to the GroupManager so that changes to groups are detected
-     * automatically.</p>
+     * <p>When a session is created, this method attaches a WikiEventListener to the GroupManager, UserManager and AuthenticationManager,
+     * so that changes to users, groups, logins, etc. are detected automatically.</p>
      *
-     * @param engine the wiki engine
+     * @param engine the engine
      * @param request the servlet request object
-     * @return the existing (or newly created) wiki session
+     * @return the existing (or newly created) session
      */
-    public static WikiSession getWikiSession( final Engine engine, final HttpServletRequest request ) {
+    public static Session getWikiSession( final Engine engine, final HttpServletRequest request ) {
         if ( request == null ) {
             if ( log.isDebugEnabled() ) {
                 log.debug( "Looking up WikiSession for NULL HttpRequest: returning guestSession()" );
@@ -640,7 +509,7 @@ public final class WikiSession implements WikiEventListener {
      * @param engine the wiki engine
      * @return the guest wiki session
      */
-    public static WikiSession guestSession( final Engine engine ) {
+    public static Session guestSession( final Engine engine ) {
         final WikiSession session = new WikiSession();
         session.m_engine = engine;
         session.invalidate();
@@ -664,8 +533,8 @@ public final class WikiSession implements WikiEventListener {
      *  @return A static WikiSession which is shared by all in this same Thread.
      */
     // FIXME: Should really use WeakReferences to clean away unused sessions.
-    private static WikiSession staticGuestSession( final Engine engine ) {
-        WikiSession session = c_guestSession.get();
+    private static Session staticGuestSession( final Engine engine ) {
+        Session session = c_guestSession.get();
         if( session == null ) {
             session = guestSession( engine );
             c_guestSession.set( session );
@@ -699,54 +568,4 @@ public final class WikiSession implements WikiEventListener {
         return monitor.userPrincipals();
     }
 
-    /**
-     * Wrapper for
-     * {@link javax.security.auth.Subject#doAsPrivileged(Subject, java.security.PrivilegedExceptionAction, java.security.AccessControlContext)}
-     * that executes an action with the privileges posssessed by a WikiSession's Subject. The action executes with a <code>null</code>
-     * AccessControlContext, which has the effect of running it "cleanly" without the AccessControlContexts of the caller.
-     *
-     * @param session the wiki session
-     * @param action the privileged action
-     * @return the result of the privileged action; may be <code>null</code>
-     * @throws java.security.AccessControlException if the action is not permitted by the security policy
-     */
-    public static Object doPrivileged( final WikiSession session, final PrivilegedAction<?> action ) throws AccessControlException {
-        return Subject.doAsPrivileged( session.m_subject, action, null );
-    }
-
-    /**
-     * Verifies whether a String represents an IPv4 address. The algorithm is
-     * extremely efficient and does not allocate any objects.
-     * @param name the address to test
-     * @return the result
-     */
-    protected static boolean isIPV4Address( final String name ) {
-        if ( name.charAt( 0 ) == DOT || name.charAt( name.length() - 1 ) == DOT ) {
-            return false;
-        }
-
-        final int[] addr = new int[]
-        { 0, 0, 0, 0 };
-        int currentOctet = 0;
-        for( int i = 0; i < name.length(); i++ ) {
-            final int ch = name.charAt( i );
-            final boolean isDigit = ch >= ONE && ch <= NINE;
-            final boolean isDot = ch == DOT;
-            if ( !isDigit && !isDot ) {
-                return false;
-            }
-            if( isDigit ) {
-                addr[currentOctet] = 10 * addr[currentOctet] + ( ch - ONE );
-                if ( addr[currentOctet] > 255 ) {
-                    return false;
-                }
-            } else if( name.charAt( i - 1 ) == DOT ) {
-                return false;
-            } else {
-                currentOctet++;
-            }
-        }
-        return  currentOctet == 3;
-    }
-
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/api/core/Session.java b/jspwiki-main/src/main/java/org/apache/wiki/api/core/Session.java
new file mode 100644
index 0000000..8dce0d8
--- /dev/null
+++ b/jspwiki-main/src/main/java/org/apache/wiki/api/core/Session.java
@@ -0,0 +1,248 @@
+/*
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+ */
+package org.apache.wiki.api.core;
+
+import org.apache.wiki.event.WikiEventListener;
+
+import javax.security.auth.Subject;
+import java.security.AccessControlException;
+import java.security.Principal;
+import java.security.PrivilegedAction;
+import java.util.Locale;
+
+
+/**
+ * <p>Represents a long-running wiki session, with an associated user Principal, user Subject, and authentication status. The sesion
+ * is initialized with minimal, default-deny values: authentication is set to <code>false</code>, and the user principal is set to
+ * <code>null</code>.</p>
+ * <p>The Session allows callers to:</p>
+ * <ul>
+ *   <li>Obtain the authentication status of the user via
+ *     {@link #isAnonymous()} and {@link #isAuthenticated()}</li>
+ *   <li>Query the session for Principals representing the
+ *     user's identity via {@link #getLoginPrincipal()},
+ *     {@link #getUserPrincipal()} and {@link #getPrincipals()}</li>
+ *   <li>Store, retrieve and clear UI messages via
+ *     {@link #addMessage(String)}, {@link #getMessages(String)}
+ *     and {@link #clearMessages(String)}</li>
+ * </ul>
+ * <p>To keep track of the Principals each user posseses, each Session stores a JAAS Subject. Various login processes add or
+ * remove Principals when users authenticate or log out.</p>
+ * <p>Session extends the {@link org.apache.wiki.event.WikiEventListener} interface and listens for group add/change/delete
+ * events fired by event sources the Session is registered with: {@link org.apache.wiki.auth.AuthenticationManager},
+ * {@link org.apache.wiki.auth.UserManager} and {@link org.apache.wiki.auth.authorize.GroupManager}, so it can catch group events. Thus,
+ * when a user is added to a {@link org.apache.wiki.auth.authorize.Group}, a corresponding {@link org.apache.wiki.auth.GroupPrincipal} is
+ * injected into the Subject's Principal set. Likewise, when the user is removed from the Group or the Group is deleted, the
+ * GroupPrincipal is removed from the Subject. The effect that this strategy produces is extremely beneficial: when someone adds a user
+ * to a wiki group, that user <em>immediately</em> gains the privileges associated with that group; he or she does not need to
+ * re-authenticate.
+ * </p>
+ * <p>In addition to methods for examining individual <code>Session</code> objects, this class also contains a number of static
+ * methods for managing WikiSessions for an entire wiki. These methods allow callers to find, query and remove WikiSession objects, and
+ * to obtain a list of the current wiki session users.</p>
+ */
+public interface Session extends WikiEventListener {
+
+    /** An anonymous user's session status. */
+    String  ANONYMOUS = "anonymous";
+
+    /** An asserted user's session status. */
+    String  ASSERTED = "asserted";
+
+    /** An authenticated user's session status. */
+    String  AUTHENTICATED = "authenticated";
+
+    /**
+     * Returns <code>true</code> if the user is considered asserted via a session cookie; that is, the Subject contains the Principal
+     * Role.ASSERTED.
+     *
+     * @return Returns <code>true</code> if the user is asserted
+     */
+    boolean isAsserted();
+
+    /**
+     * Returns the authentication status of the user's session. The user is considered authenticated if the Subject contains the
+     * Principal Role.AUTHENTICATED. If this method determines that an earlier LoginModule did not inject Role.AUTHENTICATED, it
+     * will inject one if the user is not anonymous <em>and</em> not asserted.
+     *
+     * @return Returns <code>true</code> if the user is authenticated
+     */
+    boolean isAuthenticated();
+
+    /**
+     * <p>Determines whether the current session is anonymous. This will be true if any of these conditions are true:</p>
+     * <ul>
+     *   <li>The session's Principal set contains {@link org.apache.wiki.auth.authorize.Role#ANONYMOUS}</li>
+     *   <li>The session's Principal set contains {@link org.apache.wiki.auth.WikiPrincipal#GUEST}</li>
+     *   <li>The Principal returned by {@link #getUserPrincipal()} evaluates to an IP address.</li>
+     * </ul>
+     * <p>The criteria above are listed in the order in which they are evaluated.</p>
+     * @return whether the current user's identity is equivalent to an IP address
+     */
+    boolean isAnonymous();
+
+    /**
+     * <p> Returns the Principal used to log in to an authenticated session. The login principal is determined by examining the
+     * Subject's Principal set for PrincipalWrappers or WikiPrincipals with type designator <code>LOGIN_NAME</code>; the first one
+     * found is the login principal. If one is not found, this method returns the first principal that isn't of type Role or
+     * GroupPrincipal. If neither of these conditions hold, this method returns
+     * {@link org.apache.wiki.auth.WikiPrincipal#GUEST}.
+     *
+     * @return the login Principal. If it is a PrincipalWrapper containing an externally-provided Principal, the object returned is the
+     * Principal, not the wrapper around it.
+     */
+    Principal getLoginPrincipal();
+
+    /**
+     * <p>Returns the primary user Principal associated with this session. The primary user principal is determined as follows:</p>
+     * <ol>
+     *     <li>If the Subject's Principal set contains WikiPrincipals, the first WikiPrincipal with type designator
+     *         <code>WIKI_NAME</code> or (alternatively) <code>FULL_NAME</code> is the primary Principal.</li>
+     *     <li>For all other cases, the first Principal in the Subject's principal collection that that isn't of type Role or
+     *         GroupPrincipal is the primary.</li>
+     * </ol>
+     * If no primary user Principal is found, this method returns {@link org.apache.wiki.auth.WikiPrincipal#GUEST}.
+     *
+     * @return the primary user Principal
+     */
+    Principal getUserPrincipal();
+
+    /**
+     *  Returns a cached Locale object for this user.  It's better to use WikiContext's corresponding getBundle() method, since that
+     *  will actually react if the user changes the locale in the middle, but if that's not available (or, for some reason, you need
+     *  the speed), this method can also be used.  The Locale expires when the WikiSession expires, and currently there is no way to
+     *  reset the Locale.
+     *
+     *  @return A cached Locale object
+     *  @since 2.5.96
+     */
+    Locale getLocale();
+
+    /**
+     * Adds a message to the generic list of messages associated with the session. These messages retain their order of insertion and
+     * remain until the {@link #clearMessages()} method is called.
+     *
+     * @param message the message to add; if <code>null</code> it is ignored.
+     */
+    void addMessage( String message );
+
+    /**
+     * Adds a message to the specific set of messages associated with the session. These messages retain their order of insertion and
+     * remain until the {@link #clearMessages()} method is called.
+     *
+     * @param topic the topic to associate the message to;
+     * @param message the message to add
+     */
+    void addMessage( String topic, String message );
+
+    /**
+     * Clears all messages associated with this session.
+     */
+    void clearMessages();
+
+    /**
+     * Clears all messages associated with a session topic.
+     *
+     * @param topic the topic whose messages should be cleared.
+     */
+    void clearMessages( String topic );
+
+    /**
+     * Returns all generic messages associated with this session. The messages stored with the session persist throughout the
+     * session unless they have been reset with {@link #clearMessages()}.
+     *
+     * @return the current messages.
+     */
+    String[] getMessages();
+
+    /**
+     * Returns all messages associated with a session topic. The messages stored with the session persist throughout the
+     * session unless they have been reset with {@link #clearMessages(String)}.
+     *
+     * @return the current messages.
+     * @param topic The topic
+     */
+    String[] getMessages( String topic );
+
+    /**
+     * Returns all user Principals associated with this session. User principals are those in the Subject's principal collection that
+     * aren't of type Role or of type GroupPrincipal. This is a defensive copy.
+     *
+     * @return Returns the user principal
+     * @see org.apache.wiki.auth.AuthenticationManager#isUserPrincipal(Principal)
+     */
+    Principal[] getPrincipals();
+
+    /**
+     * Returns an array of Principal objects that represents the groups and roles that the user associated with a WikiSession possesses.
+     * The array is built by iterating through the Subject's Principal set and extracting all Role and GroupPrincipal objects into a
+     * list. The list is returned as an array sorted in the natural order implied by each Principal's <code>getName</code> method. Note
+     * that this method does <em>not</em> consult the external Authorizer or GroupManager; it relies on the Principals that have been
+     * injected into the user's Subject at login time, or after group creation/modification/deletion.
+     *
+     * @return an array of Principal objects corresponding to the roles the Subject possesses
+     */
+    Principal[] getRoles();
+
+    /**
+     * Returns <code>true</code> if the WikiSession's Subject possess a supplied Principal. This method eliminates the need to externally
+     * request and inspect the JAAS subject.
+     *
+     * @param principal the Principal to test
+     * @return the result
+     */
+    boolean hasPrincipal( Principal principal );
+
+    /** Invalidates the WikiSession and resets its Subject's Principals to the equivalent of a "guest session". */
+    void invalidate();
+
+    /**
+     * <p>Returns the status of the wiki session as a text string. Valid values are:</p>
+     * <ul>
+     *   <li>{@link #AUTHENTICATED}</li>
+     *   <li>{@link #ASSERTED}</li>
+     *   <li>{@link #ANONYMOUS}</li>
+     * </ul>
+     *
+     * @return the user's session status
+     */
+    String getStatus();
+
+    /**
+     * Returns the {@link Subject} associated to the session.
+     *
+     * @return {@link Subject} associated to the session.
+     */
+    Subject getSubject();
+
+    /**
+     * Wrapper for {@link Subject#doAsPrivileged(Subject, PrivilegedAction, java.security.AccessControlContext)}
+     * that executes an action with the privileges posssessed by a WikiSession's Subject. The action executes with a <code>null</code>
+     * AccessControlContext, which has the effect of running it "cleanly" without the AccessControlContexts of the caller.
+     *
+     * @param session the wiki session
+     * @param action the privileged action
+     * @return the result of the privileged action; may be <code>null</code>
+     * @throws java.security.AccessControlException if the action is not permitted by the security policy
+     */
+    static Object doPrivileged( final Session session, final PrivilegedAction<?> action ) throws AccessControlException {
+        return Subject.doAsPrivileged( session.getSubject(), action, null );
+    }
+
+}


[jspwiki] 04/35: JSPWIKI-303: move PluginManager back to o.a.w.plugin package

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git

commit dfd502ef80c626bb2843f4bfc6a104cce4a5d0e1
Author: juanpablo <ju...@apache.org>
AuthorDate: Sun Mar 1 21:17:34 2020 +0100

    JSPWIKI-303: move PluginManager back to o.a.w.plugin package
    
    public plugin api is meant to develop new plugins, so it doesn't make sense to have the PluginManager on the o.a.w.api.engine package
---
 .../src/main/java/org/apache/wiki/WikiEngine.java  |   2 +-
 .../apache/wiki/api/plugin/ParserStagePlugin.java  |   2 +-
 .../java/org/apache/wiki/parser/PluginContent.java |   2 +-
 .../apache/wiki/plugin/DefaultPluginManager.java   |   1 -
 .../wiki/{api/engine => plugin}/PluginManager.java | 101 +++++++++------------
 .../wiki/ui/admin/DefaultAdminBeanManager.java     |   2 +-
 .../org/apache/wiki/ui/admin/beans/PluginBean.java |   8 +-
 .../src/main/resources/ini/classmappings.xml       |   2 +-
 .../org/apache/wiki/plugin/PageViewPluginTest.java |   1 -
 .../wiki/plugin/RecentChangesPluginTest.java       |  14 ++-
 .../wiki/plugin/ReferringPagesPluginTest.java      |  40 ++++----
 .../plugin/ReferringUndefinedPagesPluginTest.java  |  14 ++-
 .../wiki/plugin/UndefinedPagesPluginTest.java      |   1 -
 13 files changed, 83 insertions(+), 107 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
index f9c6a85..a090109 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
@@ -23,7 +23,6 @@ import org.apache.log4j.Logger;
 import org.apache.log4j.PropertyConfigurator;
 import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.engine.FilterManager;
-import org.apache.wiki.api.engine.PluginManager;
 import org.apache.wiki.api.exceptions.ProviderException;
 import org.apache.wiki.api.exceptions.WikiException;
 import org.apache.wiki.attachment.AttachmentManager;
@@ -40,6 +39,7 @@ import org.apache.wiki.event.WikiEventManager;
 import org.apache.wiki.event.WikiPageEvent;
 import org.apache.wiki.i18n.InternationalizationManager;
 import org.apache.wiki.pages.PageManager;
+import org.apache.wiki.plugin.PluginManager;
 import org.apache.wiki.references.ReferenceManager;
 import org.apache.wiki.render.RenderingManager;
 import org.apache.wiki.rss.RSSGenerator;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/api/plugin/ParserStagePlugin.java b/jspwiki-main/src/main/java/org/apache/wiki/api/plugin/ParserStagePlugin.java
index 1e38c5c..cea2144 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/api/plugin/ParserStagePlugin.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/api/plugin/ParserStagePlugin.java
@@ -23,7 +23,7 @@ import org.apache.wiki.WikiContext;
 import java.util.Map;
 
 /**
- *  Implements a Plugin interface for the parser stage.  Please see {@link org.apache.wiki.api.engine.PluginManager}
+ *  Implements a Plugin interface for the parser stage.  Please see {@link org.apache.wiki.plugin.PluginManager PluginManager}
  *  for further documentation.
  */
 public interface ParserStagePlugin {
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/parser/PluginContent.java b/jspwiki-main/src/main/java/org/apache/wiki/parser/PluginContent.java
index 506da58..cf81189 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/parser/PluginContent.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/parser/PluginContent.java
@@ -25,11 +25,11 @@ import org.apache.oro.text.regex.Perl5Matcher;
 import org.apache.wiki.InternalWikiException;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.api.core.Engine;
-import org.apache.wiki.api.engine.PluginManager;
 import org.apache.wiki.api.exceptions.PluginException;
 import org.apache.wiki.api.plugin.ParserStagePlugin;
 import org.apache.wiki.api.plugin.PluginElement;
 import org.apache.wiki.api.plugin.WikiPlugin;
+import org.apache.wiki.plugin.PluginManager;
 import org.apache.wiki.preferences.Preferences;
 import org.apache.wiki.variables.VariableManager;
 import org.jdom2.Text;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/DefaultPluginManager.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/DefaultPluginManager.java
index f07950f..5d7aecc 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/DefaultPluginManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/DefaultPluginManager.java
@@ -34,7 +34,6 @@ import org.apache.wiki.WikiContext;
 import org.apache.wiki.ajax.WikiAjaxDispatcherServlet;
 import org.apache.wiki.ajax.WikiAjaxServlet;
 import org.apache.wiki.api.core.Engine;
-import org.apache.wiki.api.engine.PluginManager;
 import org.apache.wiki.api.exceptions.PluginException;
 import org.apache.wiki.api.plugin.InitializablePlugin;
 import org.apache.wiki.api.plugin.WikiPlugin;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/api/engine/PluginManager.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/PluginManager.java
similarity index 60%
rename from jspwiki-main/src/main/java/org/apache/wiki/api/engine/PluginManager.java
rename to jspwiki-main/src/main/java/org/apache/wiki/plugin/PluginManager.java
index 7ed71ff..3a0b330 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/api/engine/PluginManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/PluginManager.java
@@ -16,19 +16,18 @@
     specific language governing permissions and limitations
     under the License.    
  */
-package org.apache.wiki.api.engine;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Map;
-import java.util.ResourceBundle;
+package org.apache.wiki.plugin;
 
 import org.apache.oro.text.regex.Pattern;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.api.exceptions.PluginException;
 import org.apache.wiki.api.plugin.WikiPlugin;
 import org.apache.wiki.modules.WikiModuleInfo;
-import org.apache.wiki.plugin.DefaultPluginManager.WikiPluginInfo;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Map;
+import java.util.ResourceBundle;
 
 
 public interface PluginManager {
@@ -42,18 +41,15 @@ public interface PluginManager {
     /** This is the default package to try in case the instantiation fails. */
     String DEFAULT_PACKAGE = "org.apache.wiki.plugin";
 
-    /**
-     *  The name of the body content.  Current value is "_body".
-     */
+    /** The name of the body content. Current value is "_body". */
     String PARAM_BODY      = "_body";
 
     /** The name of the command line content parameter. The value is "_cmdline". */
     String PARAM_CMDLINE   = "_cmdline";
 
     /**
-     *  The name of the parameter containing the start and end positions in the
-     *  read stream of the plugin text (stored as a two-element int[], start
-     *  and end resp.).
+     *  The name of the parameter containing the start and end positions in the read stream of the plugin text (stored as a two-element
+     *  int[], start and end resp.).
      */
     String PARAM_BOUNDS    = "_bounds";
 
@@ -68,8 +64,7 @@ public interface PluginManager {
     void enablePlugins( boolean enabled );
 
     /**
-     * Returns plugin execution status. If false, plugins are not
-     * executed when they are encountered on a WikiPage, and an
+     * Returns plugin execution status. If false, plugins are not executed when they are encountered on a WikiPage, and an
      * empty string is returned in their place.
      * 
      * @return True, if plugins are enabled; false otherwise.
@@ -91,80 +86,66 @@ public interface PluginManager {
     String getPluginSearchPath();
 
     /**
-     *  Executes a plugin class in the given context.
-     *  <P>Used to be private, but is public since 1.9.21.
-     *
-     *  @param context The current WikiContext.
-     *  @param classname The name of the class.  Can also be a
-     *  shortened version without the package name, since the class name is searched from the
-     *  package search path.
-     *
-     *  @param params A parsed map of key-value pairs.
+     * Executes a plugin class in the given context.
+     * <P>Used to be private, but is public since 1.9.21.
      *
-     *  @return Whatever the plugin returns.
+     * @param context The current WikiContext.
+     * @param classname The name of the class.  Can also be a shortened version without the package name, since the class name is
+     *                 searched from the package search path.
+     * @param params A parsed map of key-value pairs.
+     * @return Whatever the plugin returns.
+     * @throws PluginException If the plugin execution failed for some reason.
      *
-     *  @throws PluginException If the plugin execution failed for
-     *  some reason.
-     *
-     *  @since 2.0
+     * @since 2.0
      */
     String execute( WikiContext context, String classname, Map< String, String > params ) throws PluginException;
 
     /**
-     *  Parses plugin arguments.  Handles quotes and all other kewl stuff.
-     *
-     *  <h3>Special parameters</h3>
-     *  The plugin body is put into a special parameter defined by {@link #PARAM_BODY};
-     *  the plugin's command line into a parameter defined by {@link #PARAM_CMDLINE};
-     *  and the bounds of the plugin within the wiki page text by a parameter defined
-     *  by {@link #PARAM_BOUNDS}, whose value is stored as a two-element int[] array,
-     *  i.e., <tt>[start,end]</tt>.
+     * Parses plugin arguments.  Handles quotes and all other kewl stuff.
      *
-     * @param argstring The argument string to the plugin.  This is
-     *  typically a list of key-value pairs, using "'" to escape
-     *  spaces in strings, followed by an empty line and then the
-     *  plugin body.  In case the parameter is null, will return an
-     *  empty parameter list.
+     * <h3>Special parameters</h3>
+     * The plugin body is put into a special parameter defined by {@link #PARAM_BODY}; the plugin's command line into a parameter defined
+     * by {@link #PARAM_CMDLINE}; and the bounds of the plugin within the wiki page text by a parameter defined by {@link #PARAM_BOUNDS},
+     * whose value is stored as a two-element int[] array, i.e., <tt>[start,end]</tt>.
      *
+     * @param argstring The argument string to the plugin.  This is typically a list of key-value pairs, using "'" to escape
+     * spaces in strings, followed by an empty line and then the plugin body.  In case the parameter is null, will return an
+     * empty parameter list.
      * @return A parsed list of parameters.
-     *
      * @throws IOException If the parsing fails.
      */
     Map< String, String > parseArgs( String argstring ) throws IOException;
 
     /**
-     *  Parses a plugin.  Plugin commands are of the form:
-     *  [{INSERT myplugin WHERE param1=value1, param2=value2}]
-     *  myplugin may either be a class name or a plugin alias.
-     *  <P>
-     *  This is the main entry point that is used.
+     * Parses a plugin.  Plugin commands are of the form:
+     * {@code [{INSERT myplugin WHERE param1=value1, param2=value2}] }
+     * myplugin may either be a class name or a plugin alias.
+     * <P>
+     * This is the main entry point that is used.
      *
-     *  @param context The current WikiContext.
-     *  @param commandline The full command line, including plugin
-     *  name, parameters and body.
+     * @param context The current WikiContext.
+     * @param commandline The full command line, including plugin name, parameters and body.
+     * @return HTML as returned by the plugin, or possibly an error message.
      *
-     *  @return HTML as returned by the plugin, or possibly an error
-     *  message.
-     *  
-     *  @throws PluginException From the plugin itself, it propagates, waah!
+     * @throws PluginException From the plugin itself, it propagates, waah!
      */
     String execute( WikiContext context, String commandline ) throws PluginException;
 
     /**
-     * Returns a collection of modules currently managed by this ModuleManager.  Each
-     * entry is an instance of the {@link WikiModuleInfo} class.  This method should return something
-     * which is safe to iterate over, even if the underlying collection changes.
+     * Returns a collection of modules currently managed by this ModuleManager. Each entry is an instance of the {@link WikiModuleInfo}
+     * class. This method should return something which is safe to iterate over, even if the underlying collection changes.
      * 
      * @return A Collection of {@link WikiModuleInfo} instances.
      */
     Collection< WikiModuleInfo > modules();
 
     /**
-     * Returns the {@link WikiPluginInfo} information about the provided pluginName.
+     * Returns the {@link WikiModuleInfo} information about the provided pluginName.
+     *
      * @param pluginName
      * @return The wikiPluginInfo
      */
-    WikiPluginInfo getModuleInfo(String pluginName);
+    WikiModuleInfo getModuleInfo(String pluginName);
     
     /**
      * Creates a {@link WikiPlugin}.
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/DefaultAdminBeanManager.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/DefaultAdminBeanManager.java
index 5240be5..7c131b0 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/DefaultAdminBeanManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/DefaultAdminBeanManager.java
@@ -22,11 +22,11 @@ import org.apache.log4j.Logger;
 import org.apache.wiki.Release;
 import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.engine.FilterManager;
-import org.apache.wiki.api.engine.PluginManager;
 import org.apache.wiki.event.WikiEngineEvent;
 import org.apache.wiki.event.WikiEvent;
 import org.apache.wiki.event.WikiEventListener;
 import org.apache.wiki.modules.WikiModuleInfo;
+import org.apache.wiki.plugin.PluginManager;
 import org.apache.wiki.ui.EditorManager;
 import org.apache.wiki.ui.TemplateManager;
 import org.apache.wiki.ui.admin.beans.CoreBean;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/PluginBean.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/PluginBean.java
index 704567b..5cc95ca 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/PluginBean.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/PluginBean.java
@@ -19,9 +19,9 @@
 package org.apache.wiki.ui.admin.beans;
 
 import org.apache.wiki.api.core.Engine;
-import org.apache.wiki.api.engine.PluginManager;
 import org.apache.wiki.modules.WikiModuleInfo;
 import org.apache.wiki.plugin.DefaultPluginManager.WikiPluginInfo;
+import org.apache.wiki.plugin.PluginManager;
 import org.apache.wiki.util.XHTML;
 import org.apache.wiki.util.XhtmlUtil;
 import org.jdom2.Element;
@@ -39,14 +39,16 @@ public class PluginBean extends ModuleBean {
     /**
      * {@inheritDoc}
      */
-    @Override public String getTitle() {
+    @Override
+    public String getTitle() {
         return "Plugins";
     }
 
     /**
      * {@inheritDoc}
      */
-    @Override public int getType() {
+    @Override
+    public int getType() {
         return CORE;
     }
 
diff --git a/jspwiki-main/src/main/resources/ini/classmappings.xml b/jspwiki-main/src/main/resources/ini/classmappings.xml
index 8ef5164..acb5601 100644
--- a/jspwiki-main/src/main/resources/ini/classmappings.xml
+++ b/jspwiki-main/src/main/resources/ini/classmappings.xml
@@ -56,7 +56,7 @@
     <mappedClass>org.apache.wiki.filters.DefaultFilterManager</mappedClass>
   </mapping>
   <mapping>
-    <requestedClass>org.apache.wiki.api.engine.PluginManager</requestedClass>
+    <requestedClass>org.apache.wiki.plugin.PluginManager</requestedClass>
     <mappedClass>org.apache.wiki.plugin.DefaultPluginManager</mappedClass>
   </mapping>
   <mapping>
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/plugin/PageViewPluginTest.java b/jspwiki-main/src/test/java/org/apache/wiki/plugin/PageViewPluginTest.java
index 638732d..020bc93 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/plugin/PageViewPluginTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/plugin/PageViewPluginTest.java
@@ -22,7 +22,6 @@ import net.sf.ehcache.CacheManager;
 import org.apache.wiki.TestEngine;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiPage;
-import org.apache.wiki.api.engine.PluginManager;
 import org.apache.wiki.pages.PageManager;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Assertions;
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/plugin/RecentChangesPluginTest.java b/jspwiki-main/src/test/java/org/apache/wiki/plugin/RecentChangesPluginTest.java
index 4611bb6..fcc8f47 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/plugin/RecentChangesPluginTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/plugin/RecentChangesPluginTest.java
@@ -19,18 +19,16 @@ under the License.
 
 package org.apache.wiki.plugin;
 
-import java.util.Properties;
-
+import net.sf.ehcache.CacheManager;
 import org.apache.wiki.TestEngine;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiPage;
-import org.apache.wiki.api.engine.PluginManager;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
-import net.sf.ehcache.CacheManager;
+import java.util.Properties;
 
 public class RecentChangesPluginTest {
     Properties props = TestEngine.getTestProperties();
@@ -73,7 +71,7 @@ public class RecentChangesPluginTest {
     public void testSimple() throws Exception {
         context = new WikiContext(testEngine, new WikiPage(testEngine, "TestPage01"));
 
-        String res = manager.execute(context, "{INSERT org.apache.wiki.plugin.RecentChangesPlugin}");
+        final String res = manager.execute(context, "{INSERT org.apache.wiki.plugin.RecentChangesPlugin}");
 
         // we don't want to compare the complete html returned, but check if
         // certain Strings are present and other Strings are not present
@@ -92,7 +90,7 @@ public class RecentChangesPluginTest {
     public void testParmInClude() throws Exception {
         context = new WikiContext(testEngine, new WikiPage(testEngine, "TestPage02"));
 
-        String res = manager.execute( context,
+        final String res = manager.execute( context,
                                       "{INSERT org.apache.wiki.plugin.RecentChangesPlugin include='TestPage02*'}" );
 
         Assertions.assertTrue(res.contains("<table class=\"recentchanges\" cellpadding=\"4\">"));
@@ -110,7 +108,7 @@ public class RecentChangesPluginTest {
     public void testParmExClude() throws Exception {
         context = new WikiContext(testEngine, new WikiPage(testEngine, "TestPage03"));
 
-        String res = manager.execute( context,
+        final String res = manager.execute( context,
                                       "{INSERT org.apache.wiki.plugin.RecentChangesPlugin exclude='TestPage03*'}" );
 
         Assertions.assertTrue(res.contains("<table class=\"recentchanges\" cellpadding=\"4\">"));
@@ -128,7 +126,7 @@ public class RecentChangesPluginTest {
     public void testNoRecentChanges() throws Exception {
         context = new WikiContext(testEngine, new WikiPage(testEngine, "TestPage04"));
 
-        String res = manager.execute( context,
+        final String res = manager.execute( context,
                                       "{INSERT org.apache.wiki.plugin.RecentChangesPlugin since='-1'}" );
 
         Assertions.assertTrue( "<table class=\"recentchanges\" cellpadding=\"4\"></table>".equals( res ) );
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/plugin/ReferringPagesPluginTest.java b/jspwiki-main/src/test/java/org/apache/wiki/plugin/ReferringPagesPluginTest.java
index 46aaab9..cdf40fe 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/plugin/ReferringPagesPluginTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/plugin/ReferringPagesPluginTest.java
@@ -18,19 +18,19 @@
  */
 
 package org.apache.wiki.plugin;
-import java.text.SimpleDateFormat;
-import java.util.Properties;
 
 import org.apache.wiki.TestEngine;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiPage;
-import org.apache.wiki.api.engine.PluginManager;
 import org.apache.wiki.api.exceptions.PluginException;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
+import java.text.SimpleDateFormat;
+import java.util.Properties;
+
 public class ReferringPagesPluginTest
 {
     Properties props = TestEngine.getTestProperties();
@@ -71,12 +71,12 @@ public class ReferringPagesPluginTest
         engine.deleteTestPage( "Foobar7" );
     }
 
-    private String mkLink( String page )
+    private String mkLink( final String page )
     {
         return mkFullLink( page, page );
     }
 
-    private String mkFullLink( String page, String link )
+    private String mkFullLink( final String page, final String link )
     {
         return "<a class=\"wikipage\" href=\"/test/Wiki.jsp?page="+link+"\">"+page+"</a>";
     }
@@ -85,9 +85,9 @@ public class ReferringPagesPluginTest
     public void testSingleReferral()
         throws Exception
     {
-        WikiContext context2 = new WikiContext( engine, new WikiPage(engine, "Foobar") );
+        final WikiContext context2 = new WikiContext( engine, new WikiPage(engine, "Foobar") );
 
-        String res = manager.execute( context2,
+        final String res = manager.execute( context2,
                                       "{INSERT org.apache.wiki.plugin.ReferringPagesPlugin WHERE max=5}");
 
         Assertions.assertEquals( mkLink( "TestPage" )+"<br />",
@@ -98,7 +98,7 @@ public class ReferringPagesPluginTest
     public void testMaxReferences()
         throws Exception
     {
-        String res = manager.execute( context,
+        final String res = manager.execute( context,
                                       "{INSERT org.apache.wiki.plugin.ReferringPagesPlugin WHERE max=5}");
 
         int count = 0;
@@ -115,7 +115,7 @@ public class ReferringPagesPluginTest
         // there is one extra "<a" in the result
         Assertions.assertEquals( 5+1, count );
 
-        String expected = ">...and 2 more</a>";
+        final String expected = ">...and 2 more</a>";
         count =0;
         while( (index = res.indexOf(expected,index+1)) != -1 )
         {
@@ -128,9 +128,9 @@ public class ReferringPagesPluginTest
     public void testReferenceWidth()
         throws Exception
     {
-        WikiContext context2 = new WikiContext( engine, new WikiPage(engine, "Foobar") );
+        final WikiContext context2 = new WikiContext( engine, new WikiPage(engine, "Foobar") );
 
-        String res = manager.execute( context2,
+        final String res = manager.execute( context2,
                                       "{INSERT org.apache.wiki.plugin.ReferringPagesPlugin WHERE maxwidth=5}");
 
         Assertions.assertEquals( mkFullLink( "TestP...", "TestPage" )+"<br />",
@@ -141,7 +141,7 @@ public class ReferringPagesPluginTest
     public void testInclude()
         throws Exception
     {
-        String res = manager.execute( context,
+        final String res = manager.execute( context,
                                       "{ReferringPagesPlugin include='*7'}" );
 
         Assertions.assertTrue( res.indexOf("Foobar7") != -1, "7" );
@@ -156,7 +156,7 @@ public class ReferringPagesPluginTest
     public void testExclude()
         throws Exception
     {
-        String res = manager.execute( context, "{ReferringPagesPlugin exclude='*'}");
+        final String res = manager.execute( context, "{ReferringPagesPlugin exclude='*'}");
         Assertions.assertEquals( "...nobody", res );
     }
 
@@ -164,7 +164,7 @@ public class ReferringPagesPluginTest
     public void testExclude2()
         throws Exception
     {
-        String res = manager.execute( context,
+        final String res = manager.execute( context,
                                       "{ReferringPagesPlugin exclude='*7'}");
 
         Assertions.assertTrue( res.indexOf("Foobar7") == -1 );
@@ -174,7 +174,7 @@ public class ReferringPagesPluginTest
     public void testExclude3()
        throws Exception
     {
-        String res = manager.execute( context,
+        final String res = manager.execute( context,
                                       "{ReferringPagesPlugin exclude='*7,*5,*4'}");
 
         Assertions.assertTrue( res.indexOf("Foobar7") == -1, "7" );
@@ -196,22 +196,22 @@ public class ReferringPagesPluginTest
         Assertions.assertEquals("6",result);
 
         result = manager.execute(context, "{ReferringPagesPlugin,exclude='*7',show=count,showLastModified=true}");
-        String numberResult=result.substring(0,result.indexOf(" "));
+        final String numberResult=result.substring(0,result.indexOf(" "));
         Assertions.assertEquals("6",numberResult);
 
-        String dateString = result.substring(result.indexOf("(")+1,result.indexOf(")"));
+        final String dateString = result.substring(result.indexOf("(")+1,result.indexOf(")"));
         // the date should be parseable:
-        SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss dd-MMM-yyyy zzz", engine.newHttpRequest().getLocale());
+        final SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss dd-MMM-yyyy zzz", engine.newHttpRequest().getLocale());
         df.parse(dateString);
 
         // test if the proper exception is thrown:
-        String expectedExceptionString = "showLastModified=true is only valid if show=count is also specified";
+        final String expectedExceptionString = "showLastModified=true is only valid if show=count is also specified";
         String exceptionString = null;
         try
         {
             result = manager.execute(context, "{ReferringPagesPlugin,showLastModified=true}");
         }
-        catch (PluginException pe)
+        catch ( final PluginException pe)
         {
             exceptionString = pe.getMessage();
         }
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/plugin/ReferringUndefinedPagesPluginTest.java b/jspwiki-main/src/test/java/org/apache/wiki/plugin/ReferringUndefinedPagesPluginTest.java
index e852b5e..b217e57 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/plugin/ReferringUndefinedPagesPluginTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/plugin/ReferringUndefinedPagesPluginTest.java
@@ -19,18 +19,16 @@ under the License.
 
 package org.apache.wiki.plugin;
 
-import java.util.Properties;
-
+import net.sf.ehcache.CacheManager;
 import org.apache.wiki.TestEngine;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiPage;
-import org.apache.wiki.api.engine.PluginManager;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
-import net.sf.ehcache.CacheManager;
+import java.util.Properties;
 
 public class ReferringUndefinedPagesPluginTest {
     Properties props = TestEngine.getTestProperties();
@@ -69,7 +67,7 @@ public class ReferringUndefinedPagesPluginTest {
 	 */
     @Test
 	public void testSimple() throws Exception {
-		String res = manager.execute(context, "{INSERT ReferringUndefinedPagesPlugin}");
+		final String res = manager.execute(context, "{INSERT ReferringUndefinedPagesPlugin}");
 		Assertions.assertTrue(res.contains("href=\"/test/Wiki.jsp?page=TestPage01\""));
 	}
 
@@ -80,7 +78,7 @@ public class ReferringUndefinedPagesPluginTest {
 	 */
     @Test
 	public void testParmInClude() throws Exception {
-		String res = manager.execute(context, "{INSERT ReferringUndefinedPagesPlugin} include='TestPage02*'}");
+		final String res = manager.execute(context, "{INSERT ReferringUndefinedPagesPlugin} include='TestPage02*'}");
 		Assertions.assertFalse(res.contains("href=\"/test/Wiki.jsp?page=TestPage01\""));
 		Assertions.assertTrue(res.contains("href=\"/test/Wiki.jsp?page=TestPage02\""));
         Assertions.assertFalse(res.contains("href=\"/test/Wiki.jsp?page=TestPage03\""));
@@ -93,7 +91,7 @@ public class ReferringUndefinedPagesPluginTest {
      */
     @Test
     public void testParmExClude() throws Exception {
-        String res = manager.execute(context,"{INSERT ReferringUndefinedPagesPlugin} exclude='TestPage02*'}");
+        final String res = manager.execute(context,"{INSERT ReferringUndefinedPagesPlugin} exclude='TestPage02*'}");
 
         Assertions.assertTrue(res.contains("href=\"/test/Wiki.jsp?page=TestPage01\""));
         Assertions.assertFalse(res.contains("href=\"/test/Wiki.jsp?page=TestPage02\""));
@@ -107,7 +105,7 @@ public class ReferringUndefinedPagesPluginTest {
      */
     @Test
     public void testParmMax() throws Exception {
-        String res = manager.execute(context,"{INSERT ReferringUndefinedPagesPlugin} max='2'}");
+        final String res = manager.execute(context,"{INSERT ReferringUndefinedPagesPlugin} max='2'}");
 
         Assertions.assertTrue(res.contains("href=\"/test/Wiki.jsp?page=TestPage01\""));
         Assertions.assertTrue(res.contains("href=\"/test/Wiki.jsp?page=TestPage02\""));
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/plugin/UndefinedPagesPluginTest.java b/jspwiki-main/src/test/java/org/apache/wiki/plugin/UndefinedPagesPluginTest.java
index c63198a..1b0c938 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/plugin/UndefinedPagesPluginTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/plugin/UndefinedPagesPluginTest.java
@@ -23,7 +23,6 @@ import net.sf.ehcache.CacheManager;
 import org.apache.wiki.TestEngine;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiPage;
-import org.apache.wiki.api.engine.PluginManager;
 import org.apache.wiki.api.exceptions.PluginException;
 import org.apache.wiki.render.RenderingManager;
 import org.junit.jupiter.api.AfterEach;


[jspwiki] 21/35: JSPWIKI-303: begin to use Session instead of WikiSession (2)

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git

commit dc3e9f22ca168764bee2970a0c842b193cf01d98
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Mar 4 21:40:17 2020 +0100

    JSPWIKI-303: begin to use Session instead of WikiSession (2)
---
 .../java/org/apache/wiki/rss/RSSGenerator.java     |   3 +-
 .../java/org/apache/wiki/tags/MessagesTag.java     |  72 +++++--------
 .../java/org/apache/wiki/tags/PermissionTag.java   |   4 +-
 .../java/org/apache/wiki/tags/UserCheckTag.java    |   3 +-
 .../java/org/apache/wiki/tags/UserNameTag.java     |   3 +-
 .../java/org/apache/wiki/tags/UserProfileTag.java  |  38 ++-----
 .../java/org/apache/wiki/ui/InputValidator.java    |   4 +-
 .../main/java/org/apache/wiki/ui/Installer.java    |   3 +-
 .../org/apache/wiki/ui/admin/beans/UserBean.java   |  94 +++++++----------
 .../wiki/variables/DefaultVariableManager.java     |   4 +-
 .../org/apache/wiki/workflow/DecisionQueue.java    | 112 ++++++++-------------
 .../wiki/workflow/DefaultWorkflowManager.java      |   4 +-
 .../org/apache/wiki/workflow/WorkflowManager.java  |   6 +-
 .../org/apache/wiki/xmlrpc/MetaWeblogHandler.java  |   3 +-
 14 files changed, 138 insertions(+), 215 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/rss/RSSGenerator.java b/jspwiki-main/src/main/java/org/apache/wiki/rss/RSSGenerator.java
index 44730a8..84d84b1 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/rss/RSSGenerator.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/rss/RSSGenerator.java
@@ -24,6 +24,7 @@ import org.apache.wiki.WikiPage;
 import org.apache.wiki.WikiProvider;
 import org.apache.wiki.WikiSession;
 import org.apache.wiki.api.core.Engine;
+import org.apache.wiki.api.core.Session;
 import org.apache.wiki.attachment.Attachment;
 import org.apache.wiki.auth.AuthorizationManager;
 import org.apache.wiki.auth.permissions.PagePermission;
@@ -318,7 +319,7 @@ public class RSSGenerator {
 
         final Set< WikiPage > changed = m_engine.getManager( PageManager.class ).getRecentChanges();
 
-        final WikiSession session = WikiSession.guestSession( m_engine );
+        final Session session = WikiSession.guestSession( m_engine );
         int items = 0;
         for( final Iterator< WikiPage > i = changed.iterator(); i.hasNext() && items < 15; items++ ) {
             final WikiPage page = i.next();
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/MessagesTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/MessagesTag.java
index c770d66..2e8a20b 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/MessagesTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/MessagesTag.java
@@ -18,11 +18,11 @@
  */
 package org.apache.wiki.tags;
 
-import java.io.IOException;
-
-import org.apache.wiki.WikiSession;
+import org.apache.wiki.api.core.Session;
 import org.apache.wiki.util.TextUtil;
 
+import java.io.IOException;
+
 /**
  * Returns or clears the current messages associated with the user's wiki
  * session. This tag accepts four attributes: <ul> <li><code>action</code> -
@@ -37,80 +37,61 @@ import org.apache.wiki.util.TextUtil;
  * messages in; if not supplied, <code>information</code> is assumed</li></ul>
  * @since 2.3.54
  */
-public class MessagesTag extends WikiTagBase
-{
+public class MessagesTag extends WikiTagBase {
+
     private static final long   serialVersionUID = 0L;
 
     private String              m_action         = null;
-
     private String              m_prefix         = "";
-
     private String              m_topic          = null;
-
     private String              m_div            = "information";
 
     private static final String CLEAR            = "clear";
 
-    public void initTag()
-    {
+    @Override
+    public void initTag() {
         super.initTag();
         m_action = m_topic = null;
         m_prefix = "";
         m_div = "information";
     }
 
-
-    public void setTopic( String topic )
-    {
+    public void setTopic( final String topic ) {
         m_topic = topic;
     }
 
-    public void setPrefix( String prefix )
-    {
+    public void setPrefix( final String prefix ) {
         m_prefix = prefix;
     }
 
-    public void setDiv( String div )
-    {
+    public void setDiv( final String div ) {
         m_div = div;
     }
 
-    public void setAction( String action )
-    {
+    public void setAction( final String action ) {
         m_action = action.toLowerCase();
     }
 
-    public final int doWikiStartTag() throws IOException
-    {
-        WikiSession session = m_wikiContext.getWikiSession();
-        if ( CLEAR.equals( m_action ) )
-        {
-            if ( m_topic == null )
-            {
+    @Override
+    public final int doWikiStartTag() throws IOException {
+        final Session session = m_wikiContext.getWikiSession();
+        if( CLEAR.equals( m_action ) ) {
+            if( m_topic == null ) {
                 session.clearMessages();
-            }
-            else
-            {
+            } else {
                 session.clearMessages( m_topic );
             }
-        }
-        else
-        {
-            String[] messages = ( m_topic == null ) ? session.getMessages() : session.getMessages( m_topic );
-            if ( messages.length > 0 )
-            {
-            	StringBuilder sb = new StringBuilder();
-                if ( messages.length == 1 )
-                {
-                    sb.append( "<div class=\"" + m_div + "\">" + m_prefix + TextUtil.replaceEntities(messages[0]) + "</div>" );
-                }
-                else
-                {
+        } else {
+            final String[] messages = ( m_topic == null ) ? session.getMessages() : session.getMessages( m_topic );
+            if( messages.length > 0 ) {
+                final StringBuilder sb = new StringBuilder();
+                if( messages.length == 1 ) {
+                    sb.append( "<div class=\"" + m_div + "\">" + m_prefix + TextUtil.replaceEntities( messages[ 0 ] ) + "</div>" );
+                } else {
                     sb.append( "<div class=\"" + m_div + "\">" + m_prefix );
                     sb.append( "<ul>" );
-                    for( int i = 0; i < messages.length; i++ )
-                    {
-                        sb.append( "<li>" + TextUtil.replaceEntities(messages[i]) + "</li>" );
+                    for( int i = 0; i < messages.length; i++ ) {
+                        sb.append( "<li>" + TextUtil.replaceEntities( messages[ i ] ) + "</li>" );
                     }
                     sb.append( "</ul></div>" );
                 }
@@ -119,4 +100,5 @@ public class MessagesTag extends WikiTagBase
         }
         return SKIP_BODY;
     }
+
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/PermissionTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/PermissionTag.java
index e3f6c3d..aaf01ca 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/PermissionTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/PermissionTag.java
@@ -21,7 +21,7 @@ package org.apache.wiki.tags;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.WikiProvider;
-import org.apache.wiki.WikiSession;
+import org.apache.wiki.api.core.Session;
 import org.apache.wiki.auth.AuthorizationManager;
 import org.apache.wiki.auth.GroupPrincipal;
 import org.apache.wiki.auth.permissions.AllPermission;
@@ -103,7 +103,7 @@ public class PermissionTag extends WikiTagBase {
      *  @return true if granted, false if not
      */
     private boolean checkPermission( final String permission ) {
-        final WikiSession session        = m_wikiContext.getWikiSession();
+        final Session session            = m_wikiContext.getWikiSession();
         final WikiPage    page           = m_wikiContext.getPage();
         final AuthorizationManager mgr   = m_wikiContext.getEngine().getManager( AuthorizationManager.class );
         boolean gotPermission      = false;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/UserCheckTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/UserCheckTag.java
index 57fa5eb..42fd786 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/UserCheckTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/UserCheckTag.java
@@ -19,6 +19,7 @@
 package org.apache.wiki.tags;
 
 import org.apache.wiki.WikiSession;
+import org.apache.wiki.api.core.Session;
 import org.apache.wiki.auth.AuthenticationManager;
 
 /**
@@ -110,7 +111,7 @@ public class UserCheckTag extends WikiTagBase {
      */
     @Override
     public final int doWikiStartTag() {
-        final WikiSession session = m_wikiContext.getWikiSession();
+        final Session session = m_wikiContext.getWikiSession();
         final String status = session.getStatus();
         final AuthenticationManager mgr = m_wikiContext.getEngine().getManager( AuthenticationManager.class );
         final boolean containerAuth = mgr.isContainerAuthenticated();
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/UserNameTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/UserNameTag.java
index 9de5ee7..ee06f49 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/UserNameTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/UserNameTag.java
@@ -20,6 +20,7 @@ package org.apache.wiki.tags;
 
 import org.apache.wiki.WikiSession;
 import org.apache.wiki.api.core.Engine;
+import org.apache.wiki.api.core.Session;
 import org.apache.wiki.i18n.InternationalizationManager;
 import org.apache.wiki.preferences.Preferences;
 import org.apache.wiki.util.TextUtil;
@@ -47,7 +48,7 @@ public class UserNameTag extends WikiTagBase {
 
     @Override public final int doWikiStartTag() throws IOException {
         final Engine engine = m_wikiContext.getEngine();
-        final WikiSession wikiSession = WikiSession.getWikiSession(engine, (HttpServletRequest) pageContext.getRequest());
+        final Session wikiSession = WikiSession.getWikiSession(engine, (HttpServletRequest) pageContext.getRequest());
         final Principal user = wikiSession.getUserPrincipal();
 
         if( user != null ) {
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/UserProfileTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/UserProfileTag.java
index 7d6fa86..ab752d2 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/UserProfileTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/UserProfileTag.java
@@ -21,10 +21,10 @@ package org.apache.wiki.tags;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiSession;
 import org.apache.wiki.api.core.Engine;
+import org.apache.wiki.api.core.Session;
 import org.apache.wiki.auth.AuthenticationManager;
 import org.apache.wiki.auth.GroupPrincipal;
 import org.apache.wiki.auth.UserManager;
-import org.apache.wiki.auth.WikiSecurityException;
 import org.apache.wiki.auth.authorize.Role;
 import org.apache.wiki.auth.user.UserProfile;
 import org.apache.wiki.i18n.InternationalizationManager;
@@ -50,25 +50,22 @@ import java.util.ResourceBundle;
  * <li><code>email</code> - user's e-mail address</li>
  * <li><code>fullname</code> - user's full name</li>
  * <li><code>groups</code> - a sorted list of the groups a user belongs to</li>
- * <li><code>loginname</code> - user's login name. If the current user does not have
- * a profile, the user's login principal (such as one provided by a container
- * login module, user cookie, or anonyous IP address), will supply the login
- * name property</li>
+ * <li><code>loginname</code> - user's login name. If the current user does not have a profile, the user's login principal (such as one
+ * provided by a container login module, user cookie, or anonyous IP address), will supply the login name property</li>
  * <li><code>roles</code> - a sorted list of the roles a user possesses</li>
  * <li><code>wikiname</code> - user's wiki name</li>
  * <li><code>modified</code> - last modification date</li>
- * <li><code>exists</code> - evaluates the body of the tag if user's profile exists
- * in the user database
- * <li><code>new</code> - evaluates the body of the tag if user's profile does not
- * exist in the user database
- * <li><code>canChangeLoginName</code> - always true if custom auth used; also true for container auth
- * and current UserDatabase.isSharedWithContainer() is true.</li>
+ * <li><code>exists</code> - evaluates the body of the tag if user's profile exists in the user database</li>
+ * <li><code>new</code> - evaluates the body of the tag if user's profile does not exist in the user database</li>
+ * <li><code>canChangeLoginName</code> - always true if custom auth used; also true for container auth and current
+ * UserDatabase.isSharedWithContainer() is true.</li>
  * <li><code>canChangePassword</code> - always true if custom auth used; also true for container auth
  * and current UserDatabase.isSharedWithContainer() is true.</li>
  * </ul>
  * <p>In addition, the values <code>exists</code>, <code>new</code>, <code>canChangeLoginName</code>
  * and <code>canChangeLoginName</code> can also be prefixed with <code>!</code> to indicate the
  * negative condition (for example, <code>!exists</code>).</p>
+ *
  * @since 2.3
  */
 public class UserProfileTag extends WikiTagBase {
@@ -78,35 +75,20 @@ public class UserProfileTag extends WikiTagBase {
     public  static final String BLANK = "(not set)";
 
     private static final String CREATED   = "created";
-
     private static final String EMAIL     = "email";
-
     private static final String EXISTS    = "exists";
-
     private static final String NOT_EXISTS= "!exists";
-
     private static final String FULLNAME  = "fullname";
-
     private static final String GROUPS    = "groups";
-
     private static final String LOGINNAME = "loginname";
-
     private static final String MODIFIED  = "modified";
-
     private static final String NEW       = "new";
-
     private static final String NOT_NEW   = "!new";
-
     private static final String ROLES     = "roles";
-
     private static final String WIKINAME  = "wikiname";
-
     private static final String CHANGE_LOGIN_NAME     = "canchangeloginname";
-
     private static final String NOT_CHANGE_LOGIN_NAME = "!canchangeloginname";
-
     private static final String CHANGE_PASSWORD       = "canchangepassword";
-
     private static final String NOT_CHANGE_PASSWORD   = "!canchangepassword";
 
     private String             m_prop;
@@ -118,7 +100,7 @@ public class UserProfileTag extends WikiTagBase {
     }
 
     @Override
-    public final int doWikiStartTag() throws IOException, WikiSecurityException {
+    public final int doWikiStartTag() throws IOException {
         final UserManager manager = m_wikiContext.getEngine().getManager( UserManager.class );
         final UserProfile profile = manager.getUserProfile( m_wikiContext.getWikiSession() );
         String result = null;
@@ -149,7 +131,7 @@ public class UserProfileTag extends WikiTagBase {
                 //  Default back to the declared user name
                 //
                 final Engine engine = this.m_wikiContext.getEngine();
-                final WikiSession wikiSession = WikiSession.getWikiSession( engine, ( HttpServletRequest )pageContext.getRequest() );
+                final Session wikiSession = WikiSession.getWikiSession( engine, ( HttpServletRequest )pageContext.getRequest() );
                 final Principal user = wikiSession.getUserPrincipal();
 
                 if( user != null ) {
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/InputValidator.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/InputValidator.java
index 65534b9..13aa834 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/InputValidator.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/InputValidator.java
@@ -19,7 +19,7 @@
 package org.apache.wiki.ui;
 
 import org.apache.wiki.WikiContext;
-import org.apache.wiki.WikiSession;
+import org.apache.wiki.api.core.Session;
 import org.apache.wiki.i18n.InternationalizationManager;
 import org.apache.wiki.preferences.Preferences;
 
@@ -55,7 +55,7 @@ public final class InputValidator {
 
     private final String           m_form;
 
-    private final WikiSession      m_session;
+    private final Session          m_session;
 
     private final WikiContext      m_context;
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/Installer.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/Installer.java
index cad8a35..f6968d2 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/Installer.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/Installer.java
@@ -21,6 +21,7 @@ package org.apache.wiki.ui;
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiSession;
 import org.apache.wiki.api.core.Engine;
+import org.apache.wiki.api.core.Session;
 import org.apache.wiki.auth.NoSuchPrincipalException;
 import org.apache.wiki.auth.UserManager;
 import org.apache.wiki.auth.WikiPrincipal;
@@ -66,7 +67,7 @@ public class Installer {
     public static final String ADMIN_GROUP = "Admin";
     public static final String PROPFILENAME = "jspwiki-custom.properties" ;
     public static final String TMP_DIR = System.getProperty("java.io.tmpdir");
-    private final WikiSession m_session;
+    private final Session m_session;
     private final File m_propertyFile;
     private final Properties m_props;
     private final Engine m_engine;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/UserBean.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/UserBean.java
index 2d662c5..23c94b3 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/UserBean.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/UserBean.java
@@ -19,8 +19,8 @@
 package org.apache.wiki.ui.admin.beans;
 
 import org.apache.wiki.WikiContext;
-import org.apache.wiki.WikiSession;
 import org.apache.wiki.api.core.Engine;
+import org.apache.wiki.api.core.Session;
 import org.apache.wiki.auth.NoSuchPrincipalException;
 import org.apache.wiki.auth.UserManager;
 import org.apache.wiki.auth.WikiSecurityException;
@@ -33,30 +33,29 @@ import javax.servlet.http.HttpServletRequest;
 import java.util.Date;
 
 
-public class UserBean extends SimpleAdminBean
-{
-    public UserBean( final Engine engine ) throws NotCompliantMBeanException
-    {
+public class UserBean extends SimpleAdminBean {
+
+    public UserBean( final Engine engine ) throws NotCompliantMBeanException  {
         super();
     }
 
-    @Override public String[] getAttributeNames()
+    @Override
+    public String[] getAttributeNames()
     {
         return new String[0];
     }
 
     // FIXME: We don't yet support MBean for this kind of stuff.
-    @Override public String[] getMethodNames()
+    @Override
+    public String[] getMethodNames()
     {
         return new String[0];
     }
 
-
-
-    @Override public String doPost( final WikiContext context)
-    {
+    @Override
+    public String doPost( final WikiContext context ) {
         final HttpServletRequest request = context.getHttpRequest();
-        final WikiSession session = context.getWikiSession();
+        final Session session = context.getWikiSession();
         final UserManager mgr = context.getEngine().getManager( UserManager.class );
 
         final String loginid   = request.getParameter("loginid");
@@ -66,66 +65,49 @@ public class UserBean extends SimpleAdminBean
         final String password2 = request.getParameter("password2");
         final String email     = request.getParameter("email");
 
-
-        if( request.getParameter("action").equalsIgnoreCase("remove") )
-        {
-            try
-            {
-                mgr.getUserDatabase().deleteByLoginName(loginid);
-                session.addMessage("User profile "+loginid+" ("+fullname+") has been deleted");
-            }
-            catch ( final NoSuchPrincipalException e)
-            {
-                session.addMessage("User profile has already been removed");
-            }
-            catch ( final WikiSecurityException e)
-            {
-                session.addMessage("Security problem: "+e);
+        if( request.getParameter( "action" ).equalsIgnoreCase( "remove" ) ) {
+            try {
+                mgr.getUserDatabase().deleteByLoginName( loginid );
+                session.addMessage( "User profile " + loginid + " (" + fullname + ") has been deleted" );
+            } catch( final NoSuchPrincipalException e ) {
+                session.addMessage( "User profile has already been removed" );
+            } catch( final WikiSecurityException e ) {
+                session.addMessage( "Security problem: " + e );
             }
             return "";
         }
 
-
-        if( password != null && password.length() > 0 && !password.equals(password2) )
-        {
-            session.addMessage("Passwords do not match!");
+        if( password != null && password.length() > 0 && !password.equals( password2 ) ) {
+            session.addMessage( "Passwords do not match!" );
             return "";
         }
 
         final UserProfile p;
 
-        if( loginid.equals("--New--") )
-        {
+        if( loginid.equals( "--New--" ) ) {
             // Create new user
 
             p = mgr.getUserDatabase().newProfile();
             p.setCreated( new Date() );
-        }
-        else
-        {
-            try
-            {
+        } else {
+            try {
                 p = mgr.getUserDatabase().findByLoginName( loginid );
-            }
-            catch ( final NoSuchPrincipalException e)
-            {
-                session.addMessage("I could not find user profile "+loginid);
+            } catch( final NoSuchPrincipalException e ) {
+                session.addMessage( "I could not find user profile " + loginid );
                 return "";
             }
         }
 
-        p.setEmail(email);
-        p.setFullname(fullname);
-        if( password != null && password.length() > 0 ) p.setPassword(password);
-        p.setLoginName(loginname);
+        p.setEmail( email );
+        p.setFullname( fullname );
+        if( password != null && password.length() > 0 )
+            p.setPassword( password );
+        p.setLoginName( loginname );
 
-        try
-        {
+        try {
             mgr.getUserDatabase().save( p );
-        }
-        catch( final WikiSecurityException e )
-        {
-            session.addMessage("Unable to save "+e.getMessage());
+        } catch( final WikiSecurityException e ) {
+            session.addMessage( "Unable to save " + e.getMessage() );
         }
 
         session.addMessage("User profile has been updated");
@@ -133,13 +115,13 @@ public class UserBean extends SimpleAdminBean
         return "";
     }
 
-    @Override public String getTitle()
-    {
+    @Override
+    public String getTitle() {
         return "User administration";
     }
 
-    @Override public int getType()
-    {
+    @Override
+    public int getType() {
         return AdminBean.UNKNOWN;
     }
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/variables/DefaultVariableManager.java b/jspwiki-main/src/main/java/org/apache/wiki/variables/DefaultVariableManager.java
index 5764fcd..4858655 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/variables/DefaultVariableManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/variables/DefaultVariableManager.java
@@ -23,7 +23,7 @@ import org.apache.wiki.Release;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.WikiProvider;
-import org.apache.wiki.WikiSession;
+import org.apache.wiki.api.core.Session;
 import org.apache.wiki.api.exceptions.NoSuchVariableException;
 import org.apache.wiki.api.filters.PageFilter;
 import org.apache.wiki.attachment.AttachmentManager;
@@ -373,7 +373,7 @@ public class DefaultVariableManager implements VariableManager {
         }
 
         public String getLoginstatus() {
-            final WikiSession session = m_context.getWikiSession();
+            final Session session = m_context.getWikiSession();
             return Preferences.getBundle( m_context, InternationalizationManager.CORE_BUNDLE ).getString( "varmgr." + session.getStatus() );
         }
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/workflow/DecisionQueue.java b/jspwiki-main/src/main/java/org/apache/wiki/workflow/DecisionQueue.java
index 135ce56..12cc0c1 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/workflow/DecisionQueue.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/workflow/DecisionQueue.java
@@ -18,54 +18,46 @@
  */
 package org.apache.wiki.workflow;
 
+import org.apache.wiki.api.core.Session;
+import org.apache.wiki.api.exceptions.WikiException;
+
 import java.io.Serializable;
 import java.security.Principal;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.LinkedList;
 
-import org.apache.wiki.api.exceptions.WikiException;
-import org.apache.wiki.WikiSession;
-
 /**
- * Keeps a queue of pending Decisions that need to be acted on by named
- * Principals.
+ * Keeps a queue of pending Decisions that need to be acted on by named Principals.
  *
  * @since 2.5
  */
-public class DecisionQueue implements Serializable
-{
+public class DecisionQueue implements Serializable {
+
     private static final long serialVersionUID = -7172912793410302533L;
 
-    private LinkedList<Decision> m_queue = new LinkedList<Decision>();
+    private LinkedList< Decision > m_queue = new LinkedList<>();
 
     private volatile int m_next;
 
-    /**
-     * Constructs a new DecisionQueue.
-     */
-    public DecisionQueue()
-    {
+    /** Constructs a new DecisionQueue. */
+    public DecisionQueue() {
         m_next = 1000;
     }
 
     /**
-     * Adds a Decision to the DecisionQueue; also sets the Decision's unique
-     * identifier.
+     * Adds a Decision to the DecisionQueue; also sets the Decision's unique identifier.
      *
-     * @param decision
-     *            the Decision to add
+     * @param decision the Decision to add
      */
-    protected synchronized void add( Decision decision )
-    {
+    protected synchronized void add( final Decision decision ) {
         m_queue.addLast( decision );
         decision.setId( nextId() );
     }
 
     /**
-     * Protected method that returns all pending Decisions in the queue, in
-     * order of submission. If no Decisions are pending, this method returns a
-     * zero-length array.
+     * Protected method that returns all pending Decisions in the queue, in  order of submission. If no Decisions are pending, this
+     * method returns a zero-length array.
      *
      * @return the pending decisions 
      */
@@ -76,46 +68,37 @@ public class DecisionQueue implements Serializable
 
     /**
      * Protected method that removes a Decision from the queue.
+     *
      * @param decision the decision to remove
      */
-    protected synchronized void remove(Decision decision)
+    protected synchronized void remove( final Decision decision )
     {
         m_queue.remove( decision );
     }
 
     /**
-     * Returns a Collection representing the current Decisions that pertain to a
-     * users's WikiSession. The Decisions are obtained by iterating through the
-     * WikiSession's Principals and selecting those Decisions whose
-     * {@link Decision#getActor()} value match. If the wiki session is not
-     * authenticated, this method returns an empty Collection.
+     * Returns a Collection representing the current Decisions that pertain to a users's Session. The Decisions are obtained by iterating
+     * through the Session's Principals and selecting those Decisions whose {@link Decision#getActor()} value match. If the session
+     * is not authenticated, this method returns an empty Collection.
      *
-     * @param session
-     *            the wiki session
+     * @param session the wiki session
      * @return the collection of Decisions, which may be empty
      */
-    public Collection<Decision> getActorDecisions(WikiSession session)
-    {
-        ArrayList<Decision> decisions = new ArrayList<>();
-        if ( session.isAuthenticated() )
-        {
-            Principal[] principals = session.getPrincipals();
-            Principal[] rolePrincipals = session.getRoles();
-            for ( Decision decision : m_queue )
-            {
+    public Collection<Decision> getActorDecisions( final Session session ) {
+        final ArrayList< Decision > decisions = new ArrayList<>();
+        if( session.isAuthenticated() ) {
+            final Principal[] principals = session.getPrincipals();
+            final Principal[] rolePrincipals = session.getRoles();
+            for( final Decision decision : m_queue ) {
                 // Iterate through the Principal set
-                for ( Principal principal : principals )
-                {
-                    if ( principal.equals( decision.getActor() ) )
-                    {
+                for( final Principal principal : principals ) {
+                    if( principal.equals( decision.getActor() ) ) {
                         decisions.add( decision );
                     }
                 }
                 // Iterate through the Role set
-                for ( Principal principal : rolePrincipals )
-                {
-                    if ( principal.equals( decision.getActor() ) )
-                    {
+                for( final Principal principal : rolePrincipals ) {
+                    if( principal.equals( decision.getActor() ) ) {
                         decisions.add( decision );
                     }
                 }
@@ -125,41 +108,32 @@ public class DecisionQueue implements Serializable
     }
 
     /**
-     * Attempts to complete a Decision by calling
-     * {@link Decision#decide(Outcome)}. This will cause the Step immediately
-     * following the Decision (if any) to start. If the decision completes
-     * successfully, this method also removes the completed decision from the
+     * Attempts to complete a Decision by calling {@link Decision#decide(Outcome)}. This will cause the Step immediately following the
+     * Decision (if any) to start. If the decision completes successfully, this method also removes the completed decision from the
      * queue.
      *
      * @param decision the Decision for which the Outcome will be supplied
      * @param outcome the Outcome of the Decision
-     * @throws WikiException if the succeeding Step cannot start
-     * for any reason
+     * @throws WikiException if the succeeding Step cannot start for any reason
      */
-    public void decide( Decision decision, Outcome outcome ) throws WikiException
-    {
+    public void decide( final Decision decision, final Outcome outcome ) throws WikiException {
         decision.decide( outcome );
-        if ( decision.isCompleted() )
-        {
+        if ( decision.isCompleted() ) {
             remove( decision );
         }
 
-        // TODO: We should fire an event indicating the Outcome, and whether the
-        // Decision completed successfully
+        // TODO: We should fire an event indicating the Outcome, and whether the Decision completed successfully
     }
 
     /**
-     * Reassigns the owner of the Decision to a new owner. Under the covers,
-     * this method calls {@link Decision#reassign(Principal)}.
+     * Reassigns the owner of the Decision to a new owner. Under the covers, this method calls {@link Decision#reassign(Principal)}.
      *
      * @param decision the Decision to reassign
      * @param owner the new owner
      * @throws WikiException never
      */
-    public synchronized void reassign(Decision decision, Principal owner) throws WikiException
-    {
-        if (decision.isReassignable())
-        {
+    public synchronized void reassign( final Decision decision, final Principal owner ) throws WikiException {
+        if( decision.isReassignable() ) {
             decision.reassign( owner );
 
             // TODO: We should fire an event indicating the reassignment
@@ -169,14 +143,12 @@ public class DecisionQueue implements Serializable
     }
 
     /**
-     * Returns the next available unique identifier, which is subsequently
-     * incremented.
+     * Returns the next available unique identifier, which is subsequently incremented.
      *
      * @return the id
      */
-    private synchronized int nextId()
-    {
-        int current = m_next;
+    private synchronized int nextId() {
+        final int current = m_next;
         m_next++;
         return current;
     }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/workflow/DefaultWorkflowManager.java b/jspwiki-main/src/main/java/org/apache/wiki/workflow/DefaultWorkflowManager.java
index 5459d10..8ba0838 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/workflow/DefaultWorkflowManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/workflow/DefaultWorkflowManager.java
@@ -18,8 +18,8 @@
  */
 package org.apache.wiki.workflow;
 
-import org.apache.wiki.WikiSession;
 import org.apache.wiki.api.core.Engine;
+import org.apache.wiki.api.core.Session;
 import org.apache.wiki.api.exceptions.WikiException;
 import org.apache.wiki.auth.AuthorizationManager;
 import org.apache.wiki.auth.acl.UnresolvedPrincipal;
@@ -187,7 +187,7 @@ public class DefaultWorkflowManager implements WorkflowManager {
      * {@inheritDoc}
      */
     @Override
-    public List< Workflow > getOwnerWorkflows( final WikiSession session ) {
+    public List< Workflow > getOwnerWorkflows( final Session session ) {
         final List< Workflow > workflows = new ArrayList<>();
         if ( session.isAuthenticated() ) {
             final Principal[] sessionPrincipals = session.getPrincipals();
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/workflow/WorkflowManager.java b/jspwiki-main/src/main/java/org/apache/wiki/workflow/WorkflowManager.java
index 0322a21..6e803c0 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/workflow/WorkflowManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/workflow/WorkflowManager.java
@@ -18,8 +18,8 @@
  */
 package org.apache.wiki.workflow;
 
-import org.apache.wiki.WikiSession;
 import org.apache.wiki.api.core.Engine;
+import org.apache.wiki.api.core.Session;
 import org.apache.wiki.api.exceptions.WikiException;
 import org.apache.wiki.event.WikiEventListener;
 
@@ -139,12 +139,12 @@ public interface WorkflowManager extends WikiEventListener {
 
     /**
      * Returns the current workflows a wiki session owns. These are workflows whose {@link Workflow#getOwner()} method returns a Principal
-     * also possessed by the wiki session (see {@link org.apache.wiki.WikiSession#getPrincipals()}). If the wiki session is not
+     * also possessed by the wiki session (see {@link org.apache.wiki.api.core.Session#getPrincipals()}). If the wiki session is not
      * authenticated, this method returns an empty Collection.
      *
      * @param session the wiki session
      * @return the collection workflows the wiki session owns, which may be empty
      */
-    List< Workflow > getOwnerWorkflows( WikiSession session );
+    List< Workflow > getOwnerWorkflows( Session session );
 
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/MetaWeblogHandler.java b/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/MetaWeblogHandler.java
index 6145a94..fbd82a9 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/MetaWeblogHandler.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/MetaWeblogHandler.java
@@ -61,7 +61,8 @@ public class MetaWeblogHandler implements WikiRPCHandler {
     /**
      *  {@inheritDoc}
      */
-    @Override public void initialize( final WikiContext context )
+    @Override
+    public void initialize( final WikiContext context )
     {
         m_context = context;
     }


[jspwiki] 16/35: use Engine instead of WikiEngine on some javadocs

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git

commit a73d7472cb16e930544fd55cff97875c6af76c91
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Mar 4 15:45:47 2020 +0100

    use Engine instead of WikiEngine on some javadocs
---
 .../src/main/java/org/apache/wiki/render/RenderingManager.java |  6 +++---
 .../src/main/java/org/apache/wiki/search/SearchMatcher.java    |  2 +-
 .../src/main/java/org/apache/wiki/url/URLConstructor.java      | 10 ++++------
 3 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/render/RenderingManager.java b/jspwiki-main/src/main/java/org/apache/wiki/render/RenderingManager.java
index a459c16..0c1fdc1 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/render/RenderingManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/render/RenderingManager.java
@@ -36,7 +36,7 @@ import java.util.Properties;
 
 /**
  *  This class provides a facade towards the differing rendering routines.  You should use the routines in this manager
- *  instead of the ones in WikiEngine, if you don't want the different side effects to occur - such as WikiFilters.
+ *  instead of the ones in Engine, if you don't want the different side effects to occur - such as WikiFilters.
  *  <p>
  *  This class also manages a rendering cache, i.e. documents are stored between calls. You may control the cache by
  *  tweaking the ehcache.xml file.
@@ -66,7 +66,7 @@ public interface RenderingManager extends WikiEventListener, InternalModule {
      *  Looks for alternative WikiRenderers, initializes one, or the default
      *  XHTMLRenderer, for use.
      *
-     *  @param engine A WikiEngine instance.
+     *  @param engine A Engine instance.
      *  @param properties A list of properties to get parameters from.
      *  @throws WikiException If the manager could not be initialized.
      */
@@ -74,7 +74,7 @@ public interface RenderingManager extends WikiEventListener, InternalModule {
 
     /**
      *  Beautifies the title of the page by appending spaces in suitable places, if the user has so decreed in the properties when
-     *  constructing this WikiEngine.  However, attachment names are only beautified by the name.
+     *  constructing this Engine.  However, attachment names are only beautified by the name.
      *
      *  @param title The title to beautify
      *  @return A beautified title (or, if beautification is off, returns the title without modification)
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/search/SearchMatcher.java b/jspwiki-main/src/main/java/org/apache/wiki/search/SearchMatcher.java
index 1c2a4a4..f609615 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/search/SearchMatcher.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/search/SearchMatcher.java
@@ -41,7 +41,7 @@ public class SearchMatcher {
     /**
      *  Creates a new SearchMatcher.
      *  
-     *  @param engine The WikiEngine
+     *  @param engine The Engine
      *  @param queries A list of queries
      */
     public SearchMatcher( final Engine engine, final QueryItem[] queries ) {
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/url/URLConstructor.java b/jspwiki-main/src/main/java/org/apache/wiki/url/URLConstructor.java
index 862e275..e41f140 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/url/URLConstructor.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/url/URLConstructor.java
@@ -27,11 +27,9 @@ import java.util.Properties;
 
 
 /**
- *  Provides an interface through which JSPWiki constructs URLs.
- *  JSPWiki calls the methods of this interface whenever an URL
- *  that points to any JSPWiki internals is required.  For example,
- *  if you need to find an URL to the editor page for page "TextFormattingRules",
- *  you would call makeURL( WikiContext.EDIT, "TextFormattingRules", false, null );
+ *  Provides an interface through which JSPWiki constructs URLs. JSPWiki calls the methods of this interface whenever an URL
+ *  that points to any JSPWiki internals is required.  For example, if you need to find an URL to the editor page for page
+ *  "TextFormattingRules", you would call makeURL( WikiContext.EDIT, "TextFormattingRules", false, null );
  *
  *  @since 2.2
  */
@@ -40,7 +38,7 @@ public interface URLConstructor {
      *  Initializes.  Note that the engine is not fully initialized at this
      *  point, so don't do anything fancy here - use lazy init, if you have to.
      *
-     *  @param  engine The WikiEngine that this URLConstructor belongs to
+     *  @param  engine The Engine that this URLConstructor belongs to
      *  @param properties Properties used to initialize
      */
     void initialize( Engine engine, Properties properties );


[jspwiki] 27/35: update cargo plugin to 1.7.10 and bump tomcat version from 8.5.51 to 9.0.31

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git

commit 8f25151e5df0501eae9627630fab836fce47a680
Author: juanpablo <ju...@apache.org>
AuthorDate: Thu Mar 5 23:47:44 2020 +0100

    update cargo plugin to 1.7.10 and bump tomcat version from 8.5.51 to 9.0.31
---
 pom.xml | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/pom.xml b/pom.xml
index b3def41..17cbea8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -74,7 +74,7 @@
     <slf4j.version>1.7.30</slf4j.version>
     <stripes.version>1.7.0-async-beta</stripes.version>
     <tika.version>1.23</tika.version>
-    <tomcat.version>8.5.51</tomcat.version>
+    <tomcat.version>9.0.31</tomcat.version>
     <wro4j.version>1.8.0</wro4j.version>
     <xmlrpc.version>2.0.1</xmlrpc.version>
 
@@ -100,7 +100,7 @@
     <plugin.jspc.version>3.1.0</plugin.jspc.version>
     <plugin.checksum.version>1.8</plugin.checksum.version>
     <plugin.jslint.version>1.0.1</plugin.jslint.version>
-    <plugin.cargo.version>1.7.9</plugin.cargo.version>
+    <plugin.cargo.version>1.7.10</plugin.cargo.version>
     <plugin.clirr.version>2.8</plugin.clirr.version>
     <plugin.cobertura.version>2.7</plugin.cobertura.version>
     <plugin.sonar.version>3.7.0.1746</plugin.sonar.version>
@@ -682,11 +682,11 @@
           <configuration>
             <container>
               <!-- https://codehaus-cargo.github.io/cargo/Maven2+Plugin+Reference+Guide.html#Maven2PluginReferenceGuide-container -->
-              <containerId>tomcat8x</containerId>
+              <containerId>tomcat9x</containerId>
               <zipUrlInstaller>
                 <url>https://repo1.maven.org/maven2/org/apache/tomcat/tomcat/${tomcat.version}/tomcat-${tomcat.version}.zip</url>
               </zipUrlInstaller>
-              <output>${project.build.directory}/tomcat8x/logs/container.log</output>
+              <output>${project.build.directory}/tomcat9x/logs/container.log</output>
               <systemProperties>
                 <user.language>en</user.language>
                 <user.region>US</user.region>
@@ -694,7 +694,7 @@
             </container>
             <configuration>
               <type>standalone</type>
-              <home>${project.build.directory}/tomcat8x</home>
+              <home>${project.build.directory}/tomcat9x</home>
               <properties>
                 <cargo.servlet.port>8080</cargo.servlet.port>
                 <cargo.jvmargs>-XX:MaxPermSize=512m -Xms256m -Xmx3072m -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 -XX:+DisableExplicitGC -Xverify:none -Djava.awt.headless=true</cargo.jvmargs>


[jspwiki] 15/35: use StandardCharsets.UTF_8 constant instead of hardcoded 'UTF-8'

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git

commit dabf3e1595f9c3cddf697e7ce672c497649aac3a
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Mar 4 15:45:15 2020 +0100

    use StandardCharsets.UTF_8 constant instead of hardcoded 'UTF-8'
---
 .../org/apache/wiki/auth/login/CookieAuthenticationLoginModule.java     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/login/CookieAuthenticationLoginModule.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/login/CookieAuthenticationLoginModule.java
index 9d93be4..791ce01 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/login/CookieAuthenticationLoginModule.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/login/CookieAuthenticationLoginModule.java
@@ -123,7 +123,7 @@ public class CookieAuthenticationLoginModule extends AbstractLoginModule {
 
                 if( cookieFile != null && cookieFile.exists() && cookieFile.canRead() ) {
 
-                    try( final Reader in = new BufferedReader( new InputStreamReader( new FileInputStream( cookieFile ), "UTF-8" ) ) ) {
+                    try( final Reader in = new BufferedReader( new InputStreamReader( new FileInputStream( cookieFile ), StandardCharsets.UTF_8 ) ) ) {
                         final String username = FileUtil.readContents( in );
 
                         if( log.isDebugEnabled() ) {


[jspwiki] 01/35: fix sonar issue + apply intellij suggested format and fixes

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git

commit 8f6d986f6a26ea2467321c1289a244369d7b32a1
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Feb 28 23:40:56 2020 +0100

    fix sonar issue + apply intellij suggested format and fixes
---
 .../org/apache/wiki/auth/user/XMLUserDatabase.java | 417 +++++++--------------
 1 file changed, 130 insertions(+), 287 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/user/XMLUserDatabase.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/user/XMLUserDatabase.java
index 3357407..ab518c0 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/user/XMLUserDatabase.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/user/XMLUserDatabase.java
@@ -42,6 +42,7 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStreamWriter;
 import java.io.Serializable;
+import java.nio.charset.StandardCharsets;
 import java.security.Principal;
 import java.text.DateFormat;
 import java.text.ParseException;
@@ -53,10 +54,8 @@ import java.util.SortedSet;
 import java.util.TreeSet;
 
 /**
- * <p>Manages {@link DefaultUserProfile} objects using XML files for persistence.
- * Passwords are hashed using SHA1. User entries are simple <code>&lt;user&gt;</code>
- * elements under the root. User profile properties are attributes of the
- * element. For example:</p>
+ * <p>Manages {@link DefaultUserProfile} objects using XML files for persistence. Passwords are hashed using SHA1. User entries are simple
+ * <code>&lt;user&gt;</code> elements under the root. User profile properties are attributes of the element. For example:</p>
  * <blockquote><code>
  * &lt;users&gt;<br/>
  * &nbsp;&nbsp;&lt;user loginName="janne" fullName="Janne Jalkanen"<br/>
@@ -72,63 +71,36 @@ import java.util.TreeSet;
 //        if two people add new accounts right after each other from different wikis.
 public class XMLUserDatabase extends AbstractUserDatabase {
 
-    /**
-     * The jspwiki.properties property specifying the file system location of
-     * the user database.
-     */
+    /** The jspwiki.properties property specifying the file system location of the user database. */
     public static final String  PROP_USERDATABASE = "jspwiki.xmlUserDatabaseFile";
-
     private static final String DEFAULT_USERDATABASE = "userdatabase.xml";
-
     private static final String ATTRIBUTES_TAG    = "attributes";
-
     private static final String CREATED           = "created";
-
     private static final String EMAIL             = "email";
-
     private static final String FULL_NAME         = "fullName";
-
     private static final String LOGIN_NAME        = "loginName";
-
     private static final String LAST_MODIFIED     = "lastModified";
-
     private static final String LOCK_EXPIRY       = "lockExpiry";
-
     private static final String PASSWORD          = "password";
-
     private static final String UID               = "uid";
-
     private static final String USER_TAG          = "user";
-
     private static final String WIKI_NAME         = "wikiName";
-
     private static final String DATE_FORMAT       = "yyyy.MM.dd 'at' HH:mm:ss:SSS z";
-
     private Document            c_dom             = null;
-
     private File                c_file            = null;
 
-    /**
-     * Looks up and deletes the first {@link UserProfile} in the user database
-     * that matches a profile having a given login name. If the user database
-     * does not contain a user with a matching attribute, throws a
-     * {@link NoSuchPrincipalException}.
-     * @param loginName the login name of the user profile that shall be deleted
-     */
-    @Override public synchronized void deleteByLoginName( final String loginName ) throws NoSuchPrincipalException, WikiSecurityException
-    {
-        if ( c_dom == null )
-        {
+    /** {@inheritDoc} */
+    @Override
+    public synchronized void deleteByLoginName( final String loginName ) throws NoSuchPrincipalException, WikiSecurityException {
+        if( c_dom == null ) {
             throw new WikiSecurityException( "FATAL: database does not exist" );
         }
 
         final NodeList users = c_dom.getDocumentElement().getElementsByTagName( USER_TAG );
-        for( int i = 0; i < users.getLength(); i++ )
-        {
-            final Element user = (Element) users.item( i );
-            if ( user.getAttribute( LOGIN_NAME ).equals( loginName ) )
-            {
-                c_dom.getDocumentElement().removeChild(user);
+        for( int i = 0; i < users.getLength(); i++ ) {
+            final Element user = ( Element )users.item( i );
+            if( user.getAttribute( LOGIN_NAME ).equals( loginName ) ) {
+                c_dom.getDocumentElement().removeChild( user );
 
                 // Commit to disk
                 saveDOM();
@@ -138,121 +110,58 @@ public class XMLUserDatabase extends AbstractUserDatabase {
         throw new NoSuchPrincipalException( "Not in database: " + loginName );
     }
 
-    /**
-     * Looks up and returns the first {@link UserProfile}in the user database
-     * that matches a profile having a given e-mail address. If the user
-     * database does not contain a user with a matching attribute, throws a
-     * {@link NoSuchPrincipalException}.
-     * @param index the e-mail address of the desired user profile
-     * @return the user profile
-     * @see org.apache.wiki.auth.user.UserDatabase#findByEmail(String)
-     */
-    @Override public UserProfile findByEmail( final String index ) throws NoSuchPrincipalException
-    {
-        final UserProfile profile = findByAttribute( EMAIL, index );
-        if ( profile != null )
-        {
-            return profile;
-        }
-        throw new NoSuchPrincipalException( "Not in database: " + index );
+    /** {@inheritDoc} */
+    @Override
+    public UserProfile findByEmail( final String index ) throws NoSuchPrincipalException {
+        return findBy( EMAIL, index );
     }
 
-    /**
-     * Looks up and returns the first {@link UserProfile}in the user database
-     * that matches a profile having a given full name. If the user database
-     * does not contain a user with a matching attribute, throws a
-     * {@link NoSuchPrincipalException}.
-     * @param index the fill name of the desired user profile
-     * @return the user profile
-     * @see org.apache.wiki.auth.user.UserDatabase#findByFullName(java.lang.String)
-     */
-    @Override public UserProfile findByFullName( final String index ) throws NoSuchPrincipalException
-    {
-        final UserProfile profile = findByAttribute( FULL_NAME, index );
-        if ( profile != null )
-        {
-            return profile;
-        }
-        throw new NoSuchPrincipalException( "Not in database: " + index );
+    /** {@inheritDoc} */
+    @Override
+    public UserProfile findByFullName( final String index ) throws NoSuchPrincipalException {
+        return findBy( FULL_NAME, index );
     }
 
-    /**
-     * Looks up and returns the first {@link UserProfile}in the user database
-     * that matches a profile having a given login name. If the user database
-     * does not contain a user with a matching attribute, throws a
-     * {@link NoSuchPrincipalException}.
-     * @param index the login name of the desired user profile
-     * @return the user profile
-     * @see org.apache.wiki.auth.user.UserDatabase#findByLoginName(java.lang.String)
-     */
-    @Override public UserProfile findByLoginName( final String index ) throws NoSuchPrincipalException
-    {
-        final UserProfile profile = findByAttribute( LOGIN_NAME, index );
-        if ( profile != null )
-        {
-            return profile;
-        }
-        throw new NoSuchPrincipalException( "Not in database: " + index );
+    /** {@inheritDoc} */
+    @Override
+    public UserProfile findByLoginName( final String index ) throws NoSuchPrincipalException {
+        return findBy( LOGIN_NAME, index );
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    @Override public UserProfile findByUid( final String uid ) throws NoSuchPrincipalException
-    {
-        final UserProfile profile = findByAttribute( UID, uid );
-        if ( profile != null )
-        {
-            return profile;
-        }
-        throw new NoSuchPrincipalException( "Not in database: " + uid );
+    /** {@inheritDoc} */
+    @Override
+    public UserProfile findByUid( final String uid ) throws NoSuchPrincipalException {
+        return findBy( UID, uid );
     }
 
-    /**
-     * Looks up and returns the first {@link UserProfile}in the user database
-     * that matches a profile having a given wiki name. If the user database
-     * does not contain a user with a matching attribute, throws a
-     * {@link NoSuchPrincipalException}.
-     * @param index the wiki name of the desired user profile
-     * @return the user profile
-     * @see org.apache.wiki.auth.user.UserDatabase#findByWikiName(java.lang.String)
-     */
-    @Override public UserProfile findByWikiName( final String index ) throws NoSuchPrincipalException
-    {
-        final UserProfile profile = findByAttribute( WIKI_NAME, index );
-        if ( profile != null )
-        {
+    /** {@inheritDoc} */
+    @Override
+    public UserProfile findByWikiName( final String index ) throws NoSuchPrincipalException {
+        return findBy( WIKI_NAME, index );
+    }
+
+    public UserProfile findBy( final String attr, final String value ) throws NoSuchPrincipalException {
+        final UserProfile profile = findByAttribute( attr, value );
+        if ( profile != null ) {
             return profile;
         }
-        throw new NoSuchPrincipalException( "Not in database: " + index );
+        throw new NoSuchPrincipalException( "Not in database: " + value );
     }
 
-    /**
-     * Returns all WikiNames that are stored in the UserDatabase
-     * as an array of WikiPrincipal objects. If the database does not
-     * contain any profiles, this method will return a zero-length
-     * array.
-     * @return the WikiNames
-     * @throws WikiSecurityException In case things fail.
-     */
-    @Override public Principal[] getWikiNames() throws WikiSecurityException
-    {
-        if ( c_dom == null )
-        {
+    /** {@inheritDoc} */
+    @Override
+    public Principal[] getWikiNames() throws WikiSecurityException {
+        if ( c_dom == null ) {
             throw new IllegalStateException( "FATAL: database does not exist" );
         }
-        final SortedSet<Principal> principals = new TreeSet<>();
+        final SortedSet< Principal > principals = new TreeSet<>();
         final NodeList users = c_dom.getElementsByTagName( USER_TAG );
-        for( int i = 0; i < users.getLength(); i++ )
-        {
+        for( int i = 0; i < users.getLength(); i++ ) {
             final Element user = (Element) users.item( i );
             final String wikiName = user.getAttribute( WIKI_NAME );
-            if ( wikiName == null )
-            {
+            if( wikiName == null ) {
                 log.warn( "Detected null wiki name in XMLUserDataBase. Check your user database." );
-            }
-            else
-            {
+            } else {
                 final Principal principal = new WikiPrincipal( wikiName, WikiPrincipal.WIKI_NAME );
                 principals.add( principal );
             }
@@ -260,14 +169,9 @@ public class XMLUserDatabase extends AbstractUserDatabase {
         return principals.toArray( new Principal[principals.size()] );
     }
 
-    /**
-     * Initializes the user database based on values from a Properties object.
-     * The properties object must contain a file path to the XML database file
-     * whose key is {@link #PROP_USERDATABASE}.
-     * @see org.apache.wiki.auth.user.UserDatabase#initialize(org.apache.wiki.api.core.Engine, java.util.Properties)
-     * @throws NoRequiredPropertyException if the user database cannot be located, parsed, or opened
-     */
-    @Override public void initialize( final Engine engine, final Properties props ) throws NoRequiredPropertyException {
+    /** {@inheritDoc} */
+    @Override
+    public void initialize( final Engine engine, final Properties props ) throws NoRequiredPropertyException {
         final File defaultFile;
         if( engine.getRootPath() == null ) {
             log.warn( "Cannot identify JSPWiki root path" );
@@ -325,11 +229,11 @@ public class XMLUserDatabase extends AbstractUserDatabase {
 
     private void saveDOM() throws WikiSecurityException {
         if( c_dom == null ) {
-            log.fatal( "User database doesn't exist in memory." );
+            throw new IllegalStateException( "FATAL: database does not exist" );
         }
 
         final File newFile = new File( c_file.getAbsolutePath() + ".new" );
-        try( final BufferedWriter io = new BufferedWriter( new OutputStreamWriter( new FileOutputStream( newFile ), "UTF-8" ) ) ) {
+        try( final BufferedWriter io = new BufferedWriter( new OutputStreamWriter( new FileOutputStream( newFile ), StandardCharsets.UTF_8 ) ) ) {
 
             // Write the file header and document root
             io.write( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" );
@@ -409,12 +313,13 @@ public class XMLUserDatabase extends AbstractUserDatabase {
     }
 
     /**
+     * {@inheritDoc}
+     *
      * @see org.apache.wiki.auth.user.UserDatabase#rename(String, String)
      */
-    @Override public synchronized void rename( final String loginName, final String newName) throws NoSuchPrincipalException, DuplicateUserException, WikiSecurityException
-    {
-        if ( c_dom == null )
-        {
+    @Override
+    public synchronized void rename( final String loginName, final String newName) throws NoSuchPrincipalException, DuplicateUserException, WikiSecurityException {
+        if( c_dom == null ) {
             log.fatal( "Could not rename profile '" + loginName + "'; database does not exist" );
             throw new IllegalStateException( "FATAL: database does not exist" );
         }
@@ -424,27 +329,21 @@ public class XMLUserDatabase extends AbstractUserDatabase {
         final UserProfile profile = findByLoginName( loginName );
 
         // Get user with the proposed name; if found, it's a collision
-        try
-        {
+        try {
             final UserProfile otherProfile = findByLoginName( newName );
-            if ( otherProfile != null )
-            {
+            if( otherProfile != null ) {
                 throw new DuplicateUserException( "security.error.cannot.rename", newName );
             }
-        }
-        catch ( final NoSuchPrincipalException e )
-        {
+        } catch( final NoSuchPrincipalException e ) {
             // Good! That means it's safe to save using the new name
         }
 
         // Find the user with the old login id attribute, and change it
         final NodeList users = c_dom.getElementsByTagName( USER_TAG );
-        for( int i = 0; i < users.getLength(); i++ )
-        {
-            final Element user = (Element) users.item( i );
-            if ( user.getAttribute( LOGIN_NAME ).equals( loginName ) )
-            {
-            	final DateFormat c_format = new SimpleDateFormat( DATE_FORMAT );
+        for( int i = 0; i < users.getLength(); i++ ) {
+            final Element user = ( Element )users.item( i );
+            if( user.getAttribute( LOGIN_NAME ).equals( loginName ) ) {
+                final DateFormat c_format = new SimpleDateFormat( DATE_FORMAT );
                 final Date modDate = new Date( System.currentTimeMillis() );
                 setAttribute( user, LOGIN_NAME, newName );
                 setAttribute( user, LAST_MODIFIED, c_format.format( modDate ) );
@@ -458,18 +357,10 @@ public class XMLUserDatabase extends AbstractUserDatabase {
         saveDOM();
     }
 
-    /**
-     * Saves a {@link UserProfile}to the user database, overwriting the
-     * existing profile if it exists. The user name under which the profile
-     * should be saved is returned by the supplied profile's
-     * {@link UserProfile#getLoginName()}method.
-     * @param profile the user profile to save
-     * @throws WikiSecurityException if the profile cannot be saved
-     */
-    @Override public synchronized void save( final UserProfile profile ) throws WikiSecurityException
-    {
-        if ( c_dom == null )
-        {
+    /** {@inheritDoc} */
+    @Override
+    public synchronized void save( final UserProfile profile ) throws WikiSecurityException {
+        if ( c_dom == null ) {
             log.fatal( "Could not save profile " + profile + " database does not exist" );
             throw new IllegalStateException( "FATAL: database does not exist" );
         }
@@ -480,11 +371,9 @@ public class XMLUserDatabase extends AbstractUserDatabase {
         final String index = profile.getLoginName();
         final NodeList users = c_dom.getElementsByTagName( USER_TAG );
         Element user = null;
-        for( int i = 0; i < users.getLength(); i++ )
-        {
-            final Element currentUser = (Element) users.item( i );
-            if ( currentUser.getAttribute( LOGIN_NAME ).equals( index ) )
-            {
+        for( int i = 0; i < users.getLength(); i++ ) {
+            final Element currentUser = ( Element )users.item( i );
+            if( currentUser.getAttribute( LOGIN_NAME ).equals( index ) ) {
                 user = currentUser;
                 break;
             }
@@ -493,8 +382,7 @@ public class XMLUserDatabase extends AbstractUserDatabase {
         boolean isNew = false;
 
         final Date modDate = new Date( System.currentTimeMillis() );
-        if( user == null )
-        {
+        if( user == null ) {
             // Create new user node
             profile.setCreated( modDate );
             log.info( "Creating new user " + index );
@@ -502,13 +390,10 @@ public class XMLUserDatabase extends AbstractUserDatabase {
             c_dom.getDocumentElement().appendChild( user );
             setAttribute( user, CREATED, c_format.format( profile.getCreated() ) );
             isNew = true;
-        }
-        else
-        {
+        } else {
             // To update existing user node, delete old attributes first...
             final NodeList attributes = user.getElementsByTagName( ATTRIBUTES_TAG );
-            for ( int i = 0; i < attributes.getLength(); i++ )
-            {
+            for( int i = 0; i < attributes.getLength(); i++ ) {
                 user.removeChild( attributes.item( i ) );
             }
         }
@@ -524,35 +409,28 @@ public class XMLUserDatabase extends AbstractUserDatabase {
 
         // Hash and save the new password if it's different from old one
         final String newPassword = profile.getPassword();
-        if ( newPassword != null && !newPassword.equals( "" ) )
-        {
+        if( newPassword != null && !newPassword.equals( "" ) ) {
             final String oldPassword = user.getAttribute( PASSWORD );
-            if ( !oldPassword.equals( newPassword ) )
-            {
+            if( !oldPassword.equals( newPassword ) ) {
                 setAttribute( user, PASSWORD, getHash( newPassword ) );
             }
         }
 
         // Save the attributes as as Base64 string
-        if ( profile.getAttributes().size() > 0 )
-        {
-            try
-            {
+        if( profile.getAttributes().size() > 0 ) {
+            try {
                 final String encodedAttributes = Serializer.serializeToBase64( profile.getAttributes() );
                 final Element attributes = c_dom.createElement( ATTRIBUTES_TAG );
                 user.appendChild( attributes );
                 final Text value = c_dom.createTextNode( encodedAttributes );
                 attributes.appendChild( value );
-            }
-            catch ( final IOException e )
-            {
+            } catch( final IOException e ) {
                 throw new WikiSecurityException( "Could not save user profile attribute. Reason: " + e.getMessage(), e );
             }
         }
 
         // Set the profile timestamps
-        if ( isNew )
-        {
+        if( isNew ) {
             profile.setCreated( modDate );
         }
         profile.setLastModified( modDate );
@@ -562,50 +440,43 @@ public class XMLUserDatabase extends AbstractUserDatabase {
     }
 
     /**
-     * Private method that returns the first {@link UserProfile}matching a
-     * &lt;user&gt; element's supplied attribute. This method will also
+     * Private method that returns the first {@link UserProfile}matching a &lt;user&gt; element's supplied attribute. This method will also
      * set the UID if it has not yet been set.
+     *
      * @param matchAttribute
      * @param index
      * @return the profile, or <code>null</code> if not found
      */
-    private UserProfile findByAttribute( final String matchAttribute, String index )
-    {
-        if ( c_dom == null )
-        {
+    private UserProfile findByAttribute( final String matchAttribute, String index ) {
+        if ( c_dom == null ) {
             throw new IllegalStateException( "FATAL: database does not exist" );
         }
 
         checkForRefresh();
-
         final NodeList users = c_dom.getElementsByTagName( USER_TAG );
-
-        if( users == null ) return null;
+        if( users == null ) {
+            return null;
+        }
 
         // check if we have to do a case insensitive compare
         boolean caseSensitiveCompare = true;
-        if (matchAttribute.equals(EMAIL))
-        {
+        if (matchAttribute.equals(EMAIL)) {
             caseSensitiveCompare = false;
         }
 
-        for( int i = 0; i < users.getLength(); i++ )
-        {
+        for( int i = 0; i < users.getLength(); i++ ) {
             final Element user = (Element) users.item( i );
             String userAttribute = user.getAttribute( matchAttribute );
-            if (!caseSensitiveCompare)
-            {
+            if( !caseSensitiveCompare ) {
                 userAttribute = StringUtils.lowerCase(userAttribute);
                 index = StringUtils.lowerCase(index);
             }
-            if ( userAttribute.equals( index ) )
-            {
+            if( userAttribute.equals( index ) ) {
                 final UserProfile profile = newProfile();
 
                 // Parse basic attributes
                 profile.setUid( user.getAttribute( UID ) );
-                if ( profile.getUid() == null || profile.getUid().length() == 0 )
-                {
+                if( profile.getUid() == null || profile.getUid().length() == 0 ) {
                     profile.setUid( generateUid( this ) );
                 }
                 profile.setLoginName( user.getAttribute( LOGIN_NAME ) );
@@ -621,28 +492,21 @@ public class XMLUserDatabase extends AbstractUserDatabase {
 
                 // Is the profile locked?
                 final String lockExpiry = user.getAttribute( LOCK_EXPIRY );
-                if ( lockExpiry == null || lockExpiry.length() == 0 )
-                {
+                if( lockExpiry == null || lockExpiry.length() == 0 ) {
                     profile.setLockExpiry( null );
-                }
-                else
-                {
+                } else {
                     profile.setLockExpiry( new Date( Long.parseLong( lockExpiry ) ) );
                 }
 
                 // Extract all of the user's attributes (should only be one attributes tag, but you never know!)
                 final NodeList attributes = user.getElementsByTagName( ATTRIBUTES_TAG );
-                for ( int j = 0; j < attributes.getLength(); j++ )
-                {
-                    final Element attribute = (Element)attributes.item( j );
+                for( int j = 0; j < attributes.getLength(); j++ ) {
+                    final Element attribute = ( Element )attributes.item( j );
                     final String serializedMap = extractText( attribute );
-                    try
-                    {
-                        final Map<String,? extends Serializable> map = Serializer.deserializeFromBase64( serializedMap );
+                    try {
+                        final Map< String, ? extends Serializable > map = Serializer.deserializeFromBase64( serializedMap );
                         profile.getAttributes().putAll( map );
-                    }
-                    catch ( final IOException e )
-                    {
+                    } catch( final IOException e ) {
                         log.error( "Could not parse user profile attributes!", e );
                     }
                 }
@@ -655,21 +519,18 @@ public class XMLUserDatabase extends AbstractUserDatabase {
 
     /**
      * Extracts all of the text nodes that are immediate children of an Element.
+     *
      * @param element the base element
      * @return the text nodes that are immediate children of the base element, concatenated together
      */
-    private String extractText( final Element element )
-    {
+    private String extractText( final Element element ) {
         String text = "";
-        if ( element.getChildNodes().getLength() > 0 )
-        {
+        if( element.getChildNodes().getLength() > 0 ) {
             final NodeList children = element.getChildNodes();
-            for ( int k = 0; k < children.getLength(); k++ )
-            {
+            for( int k = 0; k < children.getLength(); k++ ) {
                 final Node child = children.item( k );
-                if ( child.getNodeType() == Node.TEXT_NODE )
-                {
-                    text = text + ((Text)child).getData();
+                if( child.getNodeType() == Node.TEXT_NODE ) {
+                    text = text + ( ( Text )child ).getData();
                 }
             }
         }
@@ -677,57 +538,43 @@ public class XMLUserDatabase extends AbstractUserDatabase {
     }
 
     /**
-     *  Tries to parse a date using the default format - then, for backwards
-     *  compatibility reasons, tries the platform default.
+     *  Tries to parse a date using the default format - then, for backwards compatibility reasons, tries the platform default.
      *
      *  @param profile
      *  @param date
      *  @return A parsed date, or null, if both parse attempts fail.
      */
-    private Date parseDate( final UserProfile profile, final String date )
-    {
-        try
-        {
-        	final DateFormat c_format = new SimpleDateFormat( DATE_FORMAT );
+    private Date parseDate( final UserProfile profile, final String date ) {
+        try {
+            final DateFormat c_format = new SimpleDateFormat( DATE_FORMAT );
             return c_format.parse( date );
-        }
-        catch( final ParseException e )
-        {
-            try
-            {
+        } catch( final ParseException e ) {
+            try {
                 return DateFormat.getDateTimeInstance().parse( date );
-            }
-            catch ( final ParseException e2)
-            {
-                log.warn("Could not parse 'created' or 'lastModified' "
-                    + "attribute for "
-                    + " profile '" + profile.getLoginName() + "'."
-                    + " It may have been tampered with." );
+            } catch( final ParseException e2 ) {
+                log.warn( "Could not parse 'created' or 'lastModified' attribute for profile '" + profile.getLoginName() + "'." +
+                          " It may have been tampered with.", e2 );
             }
         }
         return null;
     }
 
     /**
-     * After loading the DOM, this method sanity-checks the dates in the DOM and makes
-     * sure they are formatted properly. This is sort-of hacky, but it should work.
+     * After loading the DOM, this method sanity-checks the dates in the DOM and makes sure they are formatted properly. This is sort-of
+     * hacky, but it should work.
      */
-    private void sanitizeDOM()
-    {
-        if ( c_dom == null )
-        {
+    private void sanitizeDOM() {
+        if( c_dom == null ) {
             throw new IllegalStateException( "FATAL: database does not exist" );
         }
 
         final NodeList users = c_dom.getElementsByTagName( USER_TAG );
-        for( int i = 0; i < users.getLength(); i++ )
-        {
-            final Element user = (Element) users.item( i );
+        for( int i = 0; i < users.getLength(); i++ ) {
+            final Element user = ( Element )users.item( i );
 
             // Sanitize UID (and generate a new one if one does not exist)
             String uid = user.getAttribute( UID ).trim();
-            if ( uid == null || uid.length() == 0 || "-1".equals( uid ) )
-            {
+            if( uid == null || uid.length() == 0 || "-1".equals( uid ) ) {
                 uid = String.valueOf( generateUid( this ) );
                 user.setAttribute( UID, uid );
             }
@@ -737,24 +584,18 @@ public class XMLUserDatabase extends AbstractUserDatabase {
             String created = user.getAttribute( CREATED );
             String modified = user.getAttribute( LAST_MODIFIED );
             final DateFormat c_format = new SimpleDateFormat( DATE_FORMAT );
-            try
-            {
+            try {
                 created = c_format.format( c_format.parse( created ) );
                 modified = c_format.format( c_format.parse( modified ) );
-                user.setAttribute( CREATED,  created );
-                user.setAttribute( LAST_MODIFIED,  modified );
-            }
-            catch( final ParseException e )
-            {
-                try
-                {
+                user.setAttribute( CREATED, created );
+                user.setAttribute( LAST_MODIFIED, modified );
+            } catch( final ParseException e ) {
+                try {
                     created = c_format.format( DateFormat.getDateTimeInstance().parse( created ) );
                     modified = c_format.format( DateFormat.getDateTimeInstance().parse( modified ) );
-                    user.setAttribute( CREATED,  created );
-                    user.setAttribute( LAST_MODIFIED,  modified );
-                }
-                catch ( final ParseException e2 )
-                {
+                    user.setAttribute( CREATED, created );
+                    user.setAttribute( LAST_MODIFIED, modified );
+                } catch( final ParseException e2 ) {
                     log.warn( "Could not parse 'created' or 'lastModified' attribute for profile '" + loginName + "'."
                             + " It may have been tampered with." );
                 }
@@ -764,6 +605,7 @@ public class XMLUserDatabase extends AbstractUserDatabase {
 
     /**
      * Private method that sets an attribute value for a supplied DOM element.
+     *
      * @param element the element whose attribute is to be set
      * @param attribute the name of the attribute to set
      * @param value the desired attribute value
@@ -773,4 +615,5 @@ public class XMLUserDatabase extends AbstractUserDatabase {
             element.setAttribute( attribute, value );
         }
     }
+
 }
\ No newline at end of file


[jspwiki] 35/35: 2.11.0-M7-git-12

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git

commit c0aa7727d456ef6287547a77b1e063b3020acdcf
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Mar 6 19:02:33 2020 +0100

    2.11.0-M7-git-12
---
 ChangeLog.md                                                | 13 +++++++++++++
 jspwiki-main/src/main/java/org/apache/wiki/api/Release.java |  2 +-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/ChangeLog.md b/ChangeLog.md
index 6590212..7737012 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -17,6 +17,19 @@ specific language governing permissions and limitations
 under the License.
 -->
 
+**2020-03-06  Juan Pablo Santos (juanpablo AT apache DOT org)**
+
+* _2.11.0-M7-git-12_
+
+* [JSPWIKI-303](https://issues.apache.org/jira/browse/JSPWIKI-303): JSPWiki-API library creation
+    * Extracted `o.a.w.api.core.Session` from `o.a.w.WikiSession`, and use it throughout the code
+    * Removed `o.a.w.api.engine` package, moving the interfaces there to their appropiate packages.
+    * Promote `o.a.w.Release` to the `o.a.w.api` package
+
+* Internal classes' refactors in order to break some class / packages cycles.
+
+* Updated Tomcat to 9.0.31 in order to get JDK 8 level to compile and run JSPs when using the Cargo 
+  plugin. Baseline is still servlet 3.1 (i.e.: Tomcat 8.x), though.
 
 **2002-03-04  Dirk Frederickx (brushed AT apache DOT org)**
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/api/Release.java b/jspwiki-main/src/main/java/org/apache/wiki/api/Release.java
index 4bd4ab5..995eab0 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/api/Release.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/api/Release.java
@@ -69,7 +69,7 @@ public final class Release {
      *  <p>
      *  If the build identifier is empty, it is not added.
      */
-    public static final String     BUILD         = "git-11";
+    public static final String     BUILD         = "git-12";
 
     /**
      *  This is the generic version string you should use when printing out the version.  It is of


[jspwiki] 14/35: fix jsp compilation issues derived from moving the AdminBeanManager interface to another package

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git

commit 127c520d5810048142b0dec3587e4e253fb1a0fc
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Mar 4 12:57:10 2020 +0100

    fix jsp compilation issues derived from moving the AdminBeanManager interface to another package
---
 jspwiki-war/src/main/webapp/templates/210/admin/AdminTemplate.jsp     | 3 +--
 jspwiki-war/src/main/webapp/templates/default/admin/AdminTemplate.jsp | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/jspwiki-war/src/main/webapp/templates/210/admin/AdminTemplate.jsp b/jspwiki-war/src/main/webapp/templates/210/admin/AdminTemplate.jsp
index df45f38..5d60314 100644
--- a/jspwiki-war/src/main/webapp/templates/210/admin/AdminTemplate.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/admin/AdminTemplate.jsp
@@ -19,7 +19,6 @@
 
 <%@ page import="java.util.*" %>
 <%@ page import="org.apache.wiki.*" %>
-<%@ page import="org.apache.wiki.api.engine.AdminBeanManager" %>
 <%@ page import="org.apache.wiki.ui.*" %>
 <%@ page import="org.apache.wiki.ui.admin.*" %>
 <%@ page errorPage="/Error.jsp" %>
@@ -42,7 +41,7 @@ in your <code>jspwiki.properties</code> file.</div>
 <%
     WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
     WikiContext ctx = WikiContext.findContext(pageContext);
-    AdminBeanManager mgr = wiki.getAdminBeanManager();
+    AdminBeanManager mgr = wiki.getManager( AdminBeanManager.class );
  %>
 
 <wiki:TabbedSection defaultTab="${param['tab-admin']}">
diff --git a/jspwiki-war/src/main/webapp/templates/default/admin/AdminTemplate.jsp b/jspwiki-war/src/main/webapp/templates/default/admin/AdminTemplate.jsp
index 333b3ad..777273d 100644
--- a/jspwiki-war/src/main/webapp/templates/default/admin/AdminTemplate.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/admin/AdminTemplate.jsp
@@ -19,7 +19,6 @@
 
 <%@ page import="java.util.*" %>
 <%@ page import="org.apache.wiki.*" %>
-<%@ page import="org.apache.wiki.api.engine.AdminBeanManager" %>
 <%@ page import="org.apache.wiki.ui.*" %>
 <%@ page import="org.apache.wiki.ui.admin.*" %>
 <%@ page errorPage="/Error.jsp" %>
@@ -42,7 +41,7 @@ in your <code>jspwiki.properties</code> file.</div>
 <%
     WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
     WikiContext ctx = WikiContext.findContext(pageContext);
-    AdminBeanManager mgr = wiki.getAdminBeanManager();
+    AdminBeanManager mgr = wiki.getManager( AdminBeanManager.class );
  %>
 
 <div class="tabs admin">


[jspwiki] 11/35: move PrincipalComparator to the util module, with all the other non-jspwiki specific comparators

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git

commit 7fc2476c1a0e8557631b7d102571e4235cbd1b41
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Mar 4 12:54:27 2020 +0100

    move PrincipalComparator to the util module, with all the other non-jspwiki specific comparators
---
 .../java/org/apache/wiki/auth/SessionMonitor.java  |  1 +
 .../apache/wiki/auth/acl/DefaultAclManager.java    |  2 +-
 .../util/comparators}/PrincipalComparator.java     | 21 ++++++++---------
 .../util/comparators/PrincipalComparatorTest.java  | 26 ++++++++++++++++++++++
 4 files changed, 39 insertions(+), 11 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/SessionMonitor.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/SessionMonitor.java
index be81313..52f8e54 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/SessionMonitor.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/SessionMonitor.java
@@ -24,6 +24,7 @@ import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.event.WikiEventListener;
 import org.apache.wiki.event.WikiEventManager;
 import org.apache.wiki.event.WikiSecurityEvent;
+import org.apache.wiki.util.comparators.PrincipalComparator;
 
 import javax.servlet.http.HttpSession;
 import javax.servlet.http.HttpSessionEvent;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/acl/DefaultAclManager.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/acl/DefaultAclManager.java
index f847444..6833631 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/acl/DefaultAclManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/acl/DefaultAclManager.java
@@ -25,13 +25,13 @@ import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.exceptions.ProviderException;
 import org.apache.wiki.attachment.Attachment;
 import org.apache.wiki.auth.AuthorizationManager;
-import org.apache.wiki.auth.PrincipalComparator;
 import org.apache.wiki.auth.WikiSecurityException;
 import org.apache.wiki.auth.permissions.PagePermission;
 import org.apache.wiki.auth.permissions.PermissionFactory;
 import org.apache.wiki.pages.PageLock;
 import org.apache.wiki.pages.PageManager;
 import org.apache.wiki.render.RenderingManager;
+import org.apache.wiki.util.comparators.PrincipalComparator;
 
 import java.security.Permission;
 import java.security.Principal;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/PrincipalComparator.java b/jspwiki-util/src/main/java/org/apache/wiki/util/comparators/PrincipalComparator.java
similarity index 77%
rename from jspwiki-main/src/main/java/org/apache/wiki/auth/PrincipalComparator.java
rename to jspwiki-util/src/main/java/org/apache/wiki/util/comparators/PrincipalComparator.java
index 8fb4843..ba97d92 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/PrincipalComparator.java
+++ b/jspwiki-util/src/main/java/org/apache/wiki/util/comparators/PrincipalComparator.java
@@ -1,4 +1,4 @@
-/* 
+/*
     Licensed to the Apache Software Foundation (ASF) under one
     or more contributor license agreements.  See the NOTICE file
     distributed with this work for additional information
@@ -16,33 +16,34 @@
     specific language governing permissions and limitations
     under the License.  
  */
-package org.apache.wiki.auth;
+package org.apache.wiki.util.comparators;
 
 import java.io.Serializable;
 import java.security.Principal;
 import java.text.Collator;
 import java.util.Comparator;
 
+
 /**
- * Comparator class for sorting objects of type Principal.
- * Used for sorting arrays or collections of Principals.
+ * Comparator class for sorting objects of type Principal. Used for sorting arrays or collections of Principals.
+ *
  * @since 2.3
  */
-public class PrincipalComparator
-    implements Comparator<Principal>, Serializable
-{
+public class PrincipalComparator implements Comparator< Principal >, Serializable {
+
     private static final long serialVersionUID = 1L;
 
     /**
      * Compares two Principal objects.
+     *
      * @param o1 the first Principal
      * @param o2 the second Principal
      * @return the result of the comparison
      * @see java.util.Comparator#compare(Object, Object)
      */
-    public int compare( Principal o1, Principal o2 )
-    {
-        Collator collator = Collator.getInstance();
+    @Override
+    public int compare( final Principal o1, final Principal o2 ) {
+        final Collator collator = Collator.getInstance();
         return collator.compare( o1.getName(), o2.getName() );
     }
 
diff --git a/jspwiki-util/src/test/java/org/apache/wiki/util/comparators/PrincipalComparatorTest.java b/jspwiki-util/src/test/java/org/apache/wiki/util/comparators/PrincipalComparatorTest.java
new file mode 100644
index 0000000..dfbf187
--- /dev/null
+++ b/jspwiki-util/src/test/java/org/apache/wiki/util/comparators/PrincipalComparatorTest.java
@@ -0,0 +1,26 @@
+package org.apache.wiki.util.comparators;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+import java.security.Principal;
+
+
+public class PrincipalComparatorTest {
+
+    @Test
+    public void testComparatorOrder() {
+        final Principal p1 = () -> "a";
+        final Principal p2 = () -> "b";
+        final PrincipalComparator pc = new PrincipalComparator();
+
+        Assertions.assertEquals( -1, pc.compare( p1, p2 ) );
+        Assertions.assertEquals( 0, pc.compare( p1, p1 ) );
+        Assertions.assertEquals( 1, pc.compare( p2, p1 ) );
+
+        Assertions.assertThrows( NullPointerException.class, () -> pc.compare( null, p1  ) );
+        Assertions.assertThrows( NullPointerException.class, () -> pc.compare( p1, null  ) );
+        Assertions.assertThrows( NullPointerException.class, () -> pc.compare( null, null  ) );
+    }
+
+}


[jspwiki] 03/35: JSPWIKI-303: move AdminBeanManager to o.a.w.ui.admin package, as it is not intended for the public api

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git

commit 9b40c193674fc5c4eb643d3cb9d9fd1c01dc9b8d
Author: juanpablo <ju...@apache.org>
AuthorDate: Sun Mar 1 14:20:56 2020 +0100

    JSPWIKI-303: move AdminBeanManager to o.a.w.ui.admin package, as it is not intended for the public api
---
 jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java         | 2 +-
 .../org/apache/wiki/{api/engine => ui/admin}/AdminBeanManager.java | 7 +++----
 .../java/org/apache/wiki/ui/admin/DefaultAdminBeanManager.java     | 1 -
 jspwiki-main/src/main/resources/ini/classmappings.xml              | 2 +-
 4 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
index 8b4aca4..f9c6a85 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
@@ -22,7 +22,6 @@ import org.apache.commons.lang3.StringUtils;
 import org.apache.log4j.Logger;
 import org.apache.log4j.PropertyConfigurator;
 import org.apache.wiki.api.core.Engine;
-import org.apache.wiki.api.engine.AdminBeanManager;
 import org.apache.wiki.api.engine.FilterManager;
 import org.apache.wiki.api.engine.PluginManager;
 import org.apache.wiki.api.exceptions.ProviderException;
@@ -50,6 +49,7 @@ import org.apache.wiki.tasks.TasksManager;
 import org.apache.wiki.ui.CommandResolver;
 import org.apache.wiki.ui.EditorManager;
 import org.apache.wiki.ui.TemplateManager;
+import org.apache.wiki.ui.admin.AdminBeanManager;
 import org.apache.wiki.ui.progress.ProgressManager;
 import org.apache.wiki.url.URLConstructor;
 import org.apache.wiki.util.ClassUtil;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/api/engine/AdminBeanManager.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/AdminBeanManager.java
similarity index 95%
rename from jspwiki-main/src/main/java/org/apache/wiki/api/engine/AdminBeanManager.java
rename to jspwiki-main/src/main/java/org/apache/wiki/ui/admin/AdminBeanManager.java
index 3855337..af22757 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/api/engine/AdminBeanManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/AdminBeanManager.java
@@ -17,12 +17,11 @@
     under the License.  
  */
 
-package org.apache.wiki.api.engine;
-
-import java.util.List;
+package org.apache.wiki.ui.admin;
 
 import org.apache.wiki.event.WikiEvent;
-import org.apache.wiki.ui.admin.AdminBean;
+
+import java.util.List;
 
 public interface AdminBeanManager {
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/DefaultAdminBeanManager.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/DefaultAdminBeanManager.java
index 6045a15..5240be5 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/DefaultAdminBeanManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/DefaultAdminBeanManager.java
@@ -21,7 +21,6 @@ package org.apache.wiki.ui.admin;
 import org.apache.log4j.Logger;
 import org.apache.wiki.Release;
 import org.apache.wiki.api.core.Engine;
-import org.apache.wiki.api.engine.AdminBeanManager;
 import org.apache.wiki.api.engine.FilterManager;
 import org.apache.wiki.api.engine.PluginManager;
 import org.apache.wiki.event.WikiEngineEvent;
diff --git a/jspwiki-main/src/main/resources/ini/classmappings.xml b/jspwiki-main/src/main/resources/ini/classmappings.xml
index a1817fb..8ef5164 100644
--- a/jspwiki-main/src/main/resources/ini/classmappings.xml
+++ b/jspwiki-main/src/main/resources/ini/classmappings.xml
@@ -60,7 +60,7 @@
     <mappedClass>org.apache.wiki.plugin.DefaultPluginManager</mappedClass>
   </mapping>
   <mapping>
-    <requestedClass>org.apache.wiki.api.engine.AdminBeanManager</requestedClass>
+    <requestedClass>org.apache.wiki.ui.admin.AdminBeanManager</requestedClass>
     <mappedClass>org.apache.wiki.ui.admin.DefaultAdminBeanManager</mappedClass>
   </mapping>
   <mapping>


[jspwiki] 22/35: JSPWIKI-303: begin to use Session instead of WikiSession (3)

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git

commit 33570413b6f34167cfc4d9474e166b7fa5f7eb60
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Mar 4 21:40:53 2020 +0100

    JSPWIKI-303: begin to use Session instead of WikiSession (3)
---
 .../src/test/java/org/apache/wiki/TestEngine.java  |  45 ++++-----
 .../test/java/org/apache/wiki/WikiSessionTest.java | 108 ++++++++++-----------
 .../wiki/auth/AuthenticationManagerTest.java       |  21 ++--
 .../apache/wiki/auth/AuthorizationManagerTest.java |  76 +++++----------
 .../java/org/apache/wiki/auth/TestAuthorizer.java  |  14 ++-
 .../java/org/apache/wiki/auth/UserManagerTest.java |  14 +--
 .../java/org/apache/wiki/auth/acl/AclImplTest.java |  79 +++++++--------
 .../wiki/auth/authorize/GroupManagerTest.java      |  21 ++--
 .../java/org/apache/wiki/plugin/IfPluginTest.java  |  28 ++----
 .../apache/wiki/workflow/DecisionQueueTest.java    |  35 +++----
 10 files changed, 200 insertions(+), 241 deletions(-)

diff --git a/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java b/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java
index 7178bdd..e83b1b5 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java
@@ -24,6 +24,7 @@ import net.sourceforge.stripes.mock.MockHttpSession;
 import net.sourceforge.stripes.mock.MockServletContext;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.log4j.Logger;
+import org.apache.wiki.api.core.Session;
 import org.apache.wiki.api.exceptions.ProviderException;
 import org.apache.wiki.api.exceptions.WikiException;
 import org.apache.wiki.attachment.Attachment;
@@ -57,9 +58,9 @@ public class TestEngine extends WikiEngine
 {
     static Logger log = Logger.getLogger( TestEngine.class );
 
-    private WikiSession m_adminWikiSession = null;
-    private WikiSession m_janneWikiSession = null;
-    private WikiSession m_guestWikiSession = null;
+    private Session m_adminWikiSession = null;
+    private Session m_janneWikiSession = null;
+    private Session m_guestWikiSession = null;
 
     // combined properties file (jspwiki.properties + custom override, if any)
     private static Properties combinedProperties = null;
@@ -70,12 +71,12 @@ public class TestEngine extends WikiEngine
      * @return the wiki session
      * @throws WikiSecurityException
      */
-    public WikiSession adminSession() throws WikiSecurityException
+    public Session adminSession() throws WikiSecurityException
     {
         if ( m_adminWikiSession == null )
         {
             // Set up long-running admin session
-            HttpServletRequest request = newHttpRequest();
+            final HttpServletRequest request = newHttpRequest();
             m_adminWikiSession = WikiSession.getWikiSession( this, request );
             this.getAuthenticationManager().login( m_adminWikiSession, request,
                                                    Users.ADMIN,
@@ -89,12 +90,12 @@ public class TestEngine extends WikiEngine
      * For testing purposes, obviously.
      * @return the wiki session
      */
-    public WikiSession guestSession()
+    public Session guestSession()
     {
         if ( m_guestWikiSession == null )
         {
             // Set up guest session
-            HttpServletRequest request = newHttpRequest();
+            final HttpServletRequest request = newHttpRequest();
             m_guestWikiSession = WikiSession.getWikiSession( this, request );
         }
         return m_guestWikiSession;
@@ -106,12 +107,12 @@ public class TestEngine extends WikiEngine
      * @return the wiki session
      * @throws WikiSecurityException
      */
-    public WikiSession janneSession() throws WikiSecurityException
+    public Session janneSession() throws WikiSecurityException
     {
         if ( m_janneWikiSession == null )
         {
             // Set up a test Janne session
-            HttpServletRequest request = newHttpRequest();
+            final HttpServletRequest request = newHttpRequest();
             m_janneWikiSession = WikiSession.getWikiSession( this, request );
             this.getAuthenticationManager().login( m_janneWikiSession, request, Users.JANNE, Users.JANNE_PASS );
         }
@@ -134,11 +135,11 @@ public class TestEngine extends WikiEngine
         this( getTestProperties() );
     }
 
-    public TestEngine( Properties props ) throws WikiException {
+    public TestEngine( final Properties props ) throws WikiException {
         super( createServletContext( "test" ), "test", cleanTestProps( props ) );
 
         // Stash the WikiEngine in the servlet context
-        ServletContext servletContext = this.getServletContext();
+        final ServletContext servletContext = this.getServletContext();
         servletContext.setAttribute("org.apache.wiki.WikiEngine", this);
     }
 
@@ -172,8 +173,8 @@ public class TestEngine extends WikiEngine
      * @param path the path relative to the wiki context, for example "/Wiki.jsp"
      * @return the new request
      */
-    public MockHttpServletRequest newHttpRequest( String path ) {
-        MockHttpServletRequest request = new MockHttpServletRequest( "/JSPWiki", path ) {
+    public MockHttpServletRequest newHttpRequest( final String path ) {
+        final MockHttpServletRequest request = new MockHttpServletRequest( "/JSPWiki", path ) {
             @Override
             public ServletContext getServletContext() { // stripes mock returns null
                 return new MockServletContext( "/JSPWiki" ) {
@@ -198,9 +199,9 @@ public class TestEngine extends WikiEngine
             properties = getTestProperties();
         }
 
-        String workdir = properties.getProperty( WikiEngine.PROP_WORKDIR );
+        final String workdir = properties.getProperty( WikiEngine.PROP_WORKDIR );
         if ( workdir != null ) {
-            File f = new File( workdir );
+            final File f = new File( workdir );
 
             if (f.exists() && f.isDirectory() && new File( f, "refmgr.ser" ).exists()) {
                 // System.out.println( "Deleting " + f.getAbsolutePath() );
@@ -218,9 +219,9 @@ public class TestEngine extends WikiEngine
             properties = getTestProperties();
         }
 
-        String wikidir = properties.getProperty( AbstractFileProvider.PROP_PAGEDIR );
+        final String wikidir = properties.getProperty( AbstractFileProvider.PROP_PAGEDIR );
         if ( wikidir != null ) {
-            File f = new File( wikidir );
+            final File f = new File( wikidir );
 
             if (f.exists() && f.isDirectory()) {
                 deleteAll( f );
@@ -234,12 +235,12 @@ public class TestEngine extends WikiEngine
         }
         // better to make a copy via putAll instead of Properties(properties)
         // constructor, see http://stackoverflow.com/a/2004900
-        Properties propCopy = new Properties();
+        final Properties propCopy = new Properties();
         propCopy.putAll(combinedProperties);
         return propCopy;
     }
 
-    public static final Properties getTestProperties(String customPropFile) {
+    public static final Properties getTestProperties( final String customPropFile) {
         return PropertyReader.getCombinedProperties(customPropFile);
     }
 /*
@@ -260,17 +261,17 @@ public class TestEngine extends WikiEngine
     /**
      *  Deletes all files under this directory, and does them recursively.
      */
-    public static void deleteAll( File file )
+    public static void deleteAll( final File file )
     {
         if( file != null )
         {
             if( file.isDirectory() )
             {
-                File[] files = file.listFiles();
+                final File[] files = file.listFiles();
 
                 if( files != null )
                 {
-                    for (File file2 : files) {
+                    for ( final File file2 : files) {
                         if( file2.isDirectory() )
                         {
                             deleteAll(file2);
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/WikiSessionTest.java b/jspwiki-main/src/test/java/org/apache/wiki/WikiSessionTest.java
index 24ce6a7..1fea90b 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/WikiSessionTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/WikiSessionTest.java
@@ -17,12 +17,14 @@
     under the License.
  */
 package org.apache.wiki;
+
 import net.sourceforge.stripes.mock.MockFilterChain;
 import net.sourceforge.stripes.mock.MockFilterConfig;
 import net.sourceforge.stripes.mock.MockHttpServletRequest;
 import net.sourceforge.stripes.mock.MockHttpServletResponse;
 import net.sourceforge.stripes.mock.MockServletContext;
 import org.apache.commons.lang3.ArrayUtils;
+import org.apache.wiki.api.core.Session;
 import org.apache.wiki.api.exceptions.WikiException;
 import org.apache.wiki.auth.AuthenticationManager;
 import org.apache.wiki.auth.Users;
@@ -58,14 +60,14 @@ public class WikiSessionTest
     @BeforeEach
     public void setUp() throws Exception
     {
-        Properties props = TestEngine.getTestProperties();
+        final Properties props = TestEngine.getTestProperties();
         m_engine = new TestEngine( props );
     }
 
     @Test
     public void testRoles() throws Exception
     {
-        WikiSession session;
+        Session session;
         Principal[] principals;
 
         // Test roles for guest session
@@ -113,23 +115,10 @@ public class WikiSessionTest
     }
 
     @Test
-    public void testIsIPAddress()
-    {
-        Assertions.assertFalse( WikiSession.isIPV4Address( "Me" ) );
-        Assertions.assertFalse( WikiSession.isIPV4Address( "Guest" ) );
-        Assertions.assertTrue( WikiSession.isIPV4Address( "127.0.0.1" ) );
-        Assertions.assertFalse( WikiSession.isIPV4Address( "1207.0.0.1" ) );
-        Assertions.assertFalse( WikiSession.isIPV4Address( "127..0.1" ) );
-        Assertions.assertFalse( WikiSession.isIPV4Address( "1207.0.0." ) );
-        Assertions.assertFalse( WikiSession.isIPV4Address( ".0.0.1" ) );
-        Assertions.assertFalse( WikiSession.isIPV4Address( "..." ) );
-    }
-
-    @Test
     public void testIPAddress() throws ServletException, IOException
     {
-        MockHttpServletRequest request;
-        WikiSession wikiSession;
+        final MockHttpServletRequest request;
+        final Session wikiSession;
 
         // A naked HTTP request without userPrincipal/remoteUser should be anonymous
         request = m_engine.newHttpRequest();
@@ -142,8 +131,8 @@ public class WikiSessionTest
     @Test
     public void testUserPrincipal() throws ServletException, IOException
     {
-        MockHttpServletRequest request;
-        WikiSession wikiSession;
+        final MockHttpServletRequest request;
+        final Session wikiSession;
 
         // Changing the UserPrincipal value should cause the user to be authenticated...
         request = m_engine.newHttpRequest();
@@ -157,13 +146,13 @@ public class WikiSessionTest
     @Test
     public void testAssertionCookie() throws ServletException, IOException
     {
-        MockHttpServletRequest request;
-        WikiSession wikiSession;
+        final MockHttpServletRequest request;
+        final Session wikiSession;
 
         // Adding the magic "assertion cookie" should  set asserted status.
         request = m_engine.newHttpRequest();
         request.setUserPrincipal( null );
-        String cookieName = CookieAssertionLoginModule.PREFS_COOKIE_NAME;
+        final String cookieName = CookieAssertionLoginModule.PREFS_COOKIE_NAME;
         request.setCookies( new Cookie[] { new Cookie( cookieName, "FredFlintstone" ) } );
         runSecurityFilter(m_engine, request);
         wikiSession = WikiSession.getWikiSession( m_engine, request );
@@ -174,15 +163,15 @@ public class WikiSessionTest
     @Test
     public void testAuthenticationCookieDefaults() throws ServletException, IOException
     {
-        MockHttpServletRequest request;
-        WikiSession wikiSession;
+        final MockHttpServletRequest request;
+        final Session wikiSession;
 
         // Set the authentication cookie first
         MockHttpServletResponse response = new MockHttpServletResponse();
         CookieAuthenticationLoginModule.setLoginCookie( m_engine, response, "Fred Flintstone" );
-        Cookie[] cookies = response.getCookies();
+        final Cookie[] cookies = response.getCookies();
         Assertions.assertEquals(1, cookies.length);
-        String uid = cookies[0].getValue();
+        final String uid = cookies[0].getValue();
 
         // Adding the magic "authentication cookie" should NOT count as authenticated in the default case
         // (because cookie authentication is OFF).
@@ -203,19 +192,19 @@ public class WikiSessionTest
     @Test
     public void testAuthenticationCookieWhenOn() throws WikiException, ServletException, IOException
     {
-        Properties props = TestEngine.getTestProperties();
+        final Properties props = TestEngine.getTestProperties();
         props.setProperty( AuthenticationManager.PROP_ALLOW_COOKIE_AUTH, "true");
         m_engine = new TestEngine( props );
 
-        MockHttpServletRequest request;
-        WikiSession wikiSession;
+        final MockHttpServletRequest request;
+        final Session wikiSession;
 
         // Set the authentication cookie first
         MockHttpServletResponse response = new MockHttpServletResponse();
         CookieAuthenticationLoginModule.setLoginCookie( m_engine, response, "Fred Flintstone" );
-        Cookie[] cookies = response.getCookies();
+        final Cookie[] cookies = response.getCookies();
         Assertions.assertEquals(1, cookies.length);
-        String uid = cookies[0].getValue();
+        final String uid = cookies[0].getValue();
 
         // Adding the magic "authentication cookie" should count as authenticated
         request = m_engine.newHttpRequest();
@@ -238,16 +227,16 @@ public class WikiSessionTest
      * @return the new session
      * @throws Exception
      */
-    public static WikiSession anonymousSession( TestEngine engine ) throws Exception
+    public static Session anonymousSession( final TestEngine engine ) throws Exception
     {
         // Build anon session
-        MockHttpServletRequest request = engine.newHttpRequest();
+        final MockHttpServletRequest request = engine.newHttpRequest();
 
         // Log in
         runSecurityFilter( engine, request );
 
         // Make sure the user is actually anonymous
-        WikiSession session = WikiSession.getWikiSession( engine, request );
+        final Session session = WikiSession.getWikiSession( engine, request );
         if ( !session.isAnonymous() )
         {
             throw new IllegalStateException( "Session is not anonymous." );
@@ -255,12 +244,12 @@ public class WikiSessionTest
         return session;
     }
 
-    public static WikiSession assertedSession( TestEngine engine, String name ) throws Exception
+    public static Session assertedSession( final TestEngine engine, final String name ) throws Exception
     {
         return assertedSession( engine, name, new Principal[0] );
     }
 
-    public static WikiSession assertedSession( TestEngine engine, String name, Principal[] roles ) throws Exception
+    public static Session assertedSession( final TestEngine engine, final String name, final Principal[] roles ) throws Exception
     {
         // We can use cookies right?
         if ( !engine.getAuthenticationManager().allowsCookieAssertions() )
@@ -269,8 +258,8 @@ public class WikiSessionTest
         }
 
         // Build anon session
-        MockHttpServletRequest request = engine.newHttpRequest();
-        Set<String> r = new HashSet<String>();
+        final MockHttpServletRequest request = engine.newHttpRequest();
+        final Set<String> r = new HashSet<>();
         for ( int i = 0; i < roles.length; i++ )
         {
             r.add( roles[i].getName() );
@@ -278,32 +267,31 @@ public class WikiSessionTest
         request.setRoles( r );
 
         // Set cookie
-        Cookie cookie = new Cookie( CookieAssertionLoginModule.PREFS_COOKIE_NAME, name );
+        final Cookie cookie = new Cookie( CookieAssertionLoginModule.PREFS_COOKIE_NAME, name );
         request.setCookies( new Cookie[] { cookie } );
 
         // Log in
         runSecurityFilter(engine, request);
 
         // Make sure the user is actually asserted
-        WikiSession session = WikiSession.getWikiSession( engine, request );
-        return session;
+        return WikiSession.getWikiSession( engine, request );
     }
 
-    public static WikiSession adminSession( TestEngine engine ) throws Exception
+    public static Session adminSession( final TestEngine engine ) throws Exception
     {
         return authenticatedSession( engine, Users.ADMIN, Users.ADMIN_PASS );
     }
 
-    public static WikiSession authenticatedSession( TestEngine engine, String id, String password ) throws Exception
+    public static Session authenticatedSession( final TestEngine engine, final String id, final String password ) throws Exception
     {
         // Build anon session
-        MockHttpServletRequest request = engine.newHttpRequest();
+        final MockHttpServletRequest request = engine.newHttpRequest();
 
         // Log in as anon
         runSecurityFilter(engine, request);
 
         // Log in the user with credentials
-        WikiSession session = WikiSession.getWikiSession( engine, request );
+        final Session session = WikiSession.getWikiSession( engine, request );
         engine.getAuthenticationManager().login( session, request, id, password );
 
         // Make sure the user is actually authenticated
@@ -314,11 +302,11 @@ public class WikiSessionTest
         return session;
     }
 
-    public static WikiSession containerAuthenticatedSession( TestEngine engine, String id, Principal[] roles ) throws Exception
+    public static Session containerAuthenticatedSession( final TestEngine engine, final String id, final Principal[] roles ) throws Exception
     {
         // Build container session
-        MockHttpServletRequest request = engine.newHttpRequest();
-        Set<String> r = new HashSet<String>();
+        final MockHttpServletRequest request = engine.newHttpRequest();
+        final Set<String> r = new HashSet<>();
         for ( int i = 0; i < roles.length; i++ )
         {
             r.add( roles[i].getName() );
@@ -330,7 +318,7 @@ public class WikiSessionTest
         runSecurityFilter(engine,request);
 
         // Make sure the user is actually authenticated
-        WikiSession session = WikiSession.getWikiSession( engine, request );
+        final Session session = WikiSession.getWikiSession( engine, request );
         if ( !session.isAuthenticated() )
         {
             throw new IllegalStateException( "Could not log in authenticated user '" + id + "'" );
@@ -346,22 +334,22 @@ public class WikiSessionTest
      * @throws ServletException
      * @throws IOException
      */
-    private static void runSecurityFilter(WikiEngine engine, HttpServletRequest request) throws ServletException, IOException
+    private static void runSecurityFilter( final WikiEngine engine, final HttpServletRequest request) throws ServletException, IOException
     {
         // Create a mock servlet context and stash the wiki engine in it
-        ServletContext servletCtx = new MockServletContext( "JSPWiki" );
+        final ServletContext servletCtx = new MockServletContext( "JSPWiki" );
         servletCtx.setAttribute( "org.apache.wiki.WikiEngine", engine );
 
         // Create a mock filter configuration and add the servlet context we just created
-        MockFilterConfig filterConfig = new MockFilterConfig();
+        final MockFilterConfig filterConfig = new MockFilterConfig();
         filterConfig.setFilterName( "WikiServletFilter" );
         filterConfig.setServletContext( servletCtx );
 
         // Create the security filter and run the request  through it
-        Filter filter = new WikiServletFilter();
-        MockFilterChain chain = new MockFilterChain();
+        final Filter filter = new WikiServletFilter();
+        final MockFilterChain chain = new MockFilterChain();
         chain.addFilter( filter );
-        Servlet servlet = new MockServlet();
+        final Servlet servlet = new MockServlet();
         chain.setServlet( servlet );
         filter.init(filterConfig);
         filter.doFilter(request, null, chain );
@@ -371,24 +359,28 @@ public class WikiSessionTest
     {
         private ServletConfig m_config;
 
+        @Override
         public void destroy() { }
 
+        @Override
         public ServletConfig getServletConfig()
         {
             return m_config;
         }
 
+        @Override
         public String getServletInfo()
         {
             return "Mock servlet";
         }
 
-        public void init( ServletConfig config ) throws ServletException
-        {
+        @Override
+        public void init( final ServletConfig config ) throws ServletException {
             m_config = config;
         }
 
-        public void service( ServletRequest request, ServletResponse response ) throws ServletException, IOException { }
+        @Override
+        public void service( final ServletRequest request, final ServletResponse response ) throws ServletException, IOException {}
     }
 
 }
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/auth/AuthenticationManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/auth/AuthenticationManagerTest.java
index 0c1a106..b8da2f6 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/auth/AuthenticationManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/auth/AuthenticationManagerTest.java
@@ -23,6 +23,7 @@ import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiSession;
 import org.apache.wiki.WikiSessionTest;
 import org.apache.wiki.api.core.Engine;
+import org.apache.wiki.api.core.Session;
 import org.apache.wiki.auth.authorize.Group;
 import org.apache.wiki.auth.authorize.GroupManager;
 import org.apache.wiki.auth.authorize.Role;
@@ -56,18 +57,22 @@ public class AuthenticationManagerTest {
             return null;
         }
 
-        @Override public Principal[] getRoles() {
+        @Override
+        public Principal[] getRoles() {
             return m_roles;
         }
 
-        @Override public void initialize( final Engine engine, final Properties props ) throws WikiSecurityException {
+        @Override
+        public void initialize( final Engine engine, final Properties props ) throws WikiSecurityException {
         }
 
-        @Override public boolean isUserInRole( final HttpServletRequest request, final Principal role ) {
+        @Override
+        public boolean isUserInRole( final HttpServletRequest request, final Principal role ) {
             return request != null && "ContainerRole".equals( role.getName() );
         }
 
-        @Override public boolean isUserInRole( final WikiSession session, final Principal role ) {
+        @Override
+        public boolean isUserInRole( final Session session, final Principal role ) {
             return session != null && "AuthorizerRole".equals( role.getName() );
         }
     }
@@ -78,7 +83,7 @@ public class AuthenticationManagerTest {
 
     private GroupManager m_groupMgr;
 
-    private WikiSession m_session;
+    private Session m_session;
 
     @BeforeEach
     public void setUp() throws Exception {
@@ -101,7 +106,7 @@ public class AuthenticationManagerTest {
         m_engine = new TestEngine( props );
 
         // Start a session without any container roles: DummyAuthorizer should ALWAYS allow AuthorizerRole
-        WikiSession session = WikiSessionTest.authenticatedSession( m_engine, Users.JANNE, Users.JANNE_PASS );
+        Session session = WikiSessionTest.authenticatedSession( m_engine, Users.JANNE, Users.JANNE_PASS );
         Assertions.assertTrue( session.hasPrincipal( Role.ALL ) );
         Assertions.assertTrue( session.hasPrincipal( Role.AUTHENTICATED ) );
         Assertions.assertTrue( session.hasPrincipal( new WikiPrincipal( Users.JANNE, WikiPrincipal.LOGIN_NAME ) ) );
@@ -170,7 +175,7 @@ public class AuthenticationManagerTest {
 
     @Test
     public void testLoginCustom() throws Exception {
-        final WikiSession session = WikiSessionTest.authenticatedSession( m_engine, Users.JANNE, Users.JANNE_PASS );
+        final Session session = WikiSessionTest.authenticatedSession( m_engine, Users.JANNE, Users.JANNE_PASS );
         Assertions.assertTrue( session.hasPrincipal( Role.ALL ) );
         Assertions.assertTrue( session.hasPrincipal( Role.AUTHENTICATED ) );
         Assertions.assertTrue( session.hasPrincipal( new WikiPrincipal( Users.JANNE, WikiPrincipal.LOGIN_NAME ) ) );
@@ -190,7 +195,7 @@ public class AuthenticationManagerTest {
 
         // Log in 'janne' and verify there are 5 principals in the subject
         // (ALL, AUTHENTICATED, login, fullname, wikiname Principals)
-        final WikiSession session = WikiSession.guestSession( m_engine );
+        final Session session = WikiSession.guestSession( m_engine );
         m_auth.login( session, null, Users.JANNE, Users.JANNE_PASS );
         Assertions.assertEquals( 3, session.getPrincipals().length );
         Assertions.assertEquals( 2, session.getRoles().length );
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/auth/AuthorizationManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/auth/AuthorizationManagerTest.java
index 096315c..1b673b8 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/auth/AuthorizationManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/auth/AuthorizationManagerTest.java
@@ -21,8 +21,8 @@ package org.apache.wiki.auth;
 import org.apache.commons.lang3.ArrayUtils;
 import org.apache.wiki.TestEngine;
 import org.apache.wiki.WikiPage;
-import org.apache.wiki.WikiSession;
 import org.apache.wiki.WikiSessionTest;
+import org.apache.wiki.api.core.Session;
 import org.apache.wiki.api.exceptions.ProviderException;
 import org.apache.wiki.api.exceptions.WikiException;
 import org.apache.wiki.attachment.Attachment;
@@ -56,7 +56,7 @@ public class AuthorizationManagerTest
 
     private GroupManager         m_groupMgr;
 
-    private WikiSession          m_session;
+    private Session m_session;
 
     private static class TestPrincipal implements Principal
     {
@@ -102,10 +102,8 @@ public class AuthorizationManagerTest
         m_engine.saveText( "TestDefaultPage", "Foo" );
         final Permission view = PermissionFactory.getPagePermission( "*:TestDefaultPage", "view" );
         final Permission edit = PermissionFactory.getPagePermission( "*:TestDefaultPage", "edit" );
-        WikiSession session;
-
         // Alice is asserted
-        session = WikiSessionTest.assertedSession( m_engine, Users.ALICE );
+        Session session = WikiSessionTest.assertedSession( m_engine, Users.ALICE );
         Assertions.assertTrue( m_auth.checkPermission( session, view ), "Alice view" );
         Assertions.assertTrue( m_auth.checkPermission( session, edit ), "Alice edit" );
 
@@ -115,24 +113,19 @@ public class AuthorizationManagerTest
         Assertions.assertTrue( m_auth.checkPermission( session, edit ), "Bob edit" );
 
         // Delete the test page
-        try
-        {
+        try {
             m_engine.getManager( PageManager.class ).deletePage( "TestDefaultPage" );
-        }
-        catch( final ProviderException e )
-        {
+        } catch( final ProviderException e ) {
             Assertions.fail( e.getMessage() );
         }
     }
 
     @Test
-    public void testGetRoles() throws Exception
-    {
-        WikiSession session;
+    public void testGetRoles() throws Exception {
         Principal[] principals;
 
         // Create a new "asserted" session for Bob
-        session = WikiSessionTest.assertedSession( m_engine, Users.BOB );
+        Session session = WikiSessionTest.assertedSession( m_engine, Users.BOB );
 
         // Set up a group without Bob in it
         Group test = m_groupMgr.parseGroup( "Test", "Alice \n Charlie", true );
@@ -181,10 +174,7 @@ public class AuthorizationManagerTest
         final Role engineering = new Role( "Engineering" );
         final Role finance = new Role( "Finance" );
         final Principal admin = new GroupPrincipal( "Admin" );
-        final WikiSession session = WikiSessionTest.assertedSession(
-                m_engine,
-                Users.ALICE,
-                new Principal[] { it, engineering, admin } );
+        final Session session = WikiSessionTest.assertedSession( m_engine, Users.ALICE, new Principal[] { it, engineering, admin } );
 
         // Create two groups: Alice should be part of group Bar, but not Foo
         final Group fooGroup = m_groupMgr.parseGroup( "Foo", "", true );
@@ -229,10 +219,7 @@ public class AuthorizationManagerTest
         final Role engineering = new Role( "Engineering" );
         final Role finance = new Role( "Finance" );
         final Principal admin = new GroupPrincipal( "Admin" );
-        final WikiSession session = WikiSessionTest.containerAuthenticatedSession(
-                m_engine,
-                Users.ALICE,
-                new Principal[] { it, engineering, admin } );
+        final Session session = WikiSessionTest.containerAuthenticatedSession( m_engine, Users.ALICE, new Principal[] { it, engineering, admin } );
 
         // Create two groups: Alice should be part of group Bar, but not Foo
         final Group fooGroup = m_groupMgr.parseGroup( "Foo", "", true );
@@ -285,8 +272,7 @@ public class AuthorizationManagerTest
         final Permission edit = PermissionFactory.getPagePermission( p, "edit" );
 
         // Create authenticated session with user 'Alice', who can read & edit (in ACL)
-        WikiSession session;
-        session = WikiSessionTest.authenticatedSession( m_engine, Users.ALICE, Users.ALICE_PASS );
+        Session session = WikiSessionTest.authenticatedSession( m_engine, Users.ALICE, Users.ALICE_PASS );
         Assertions.assertTrue( m_auth.checkPermission( session, view ), "Alice view Test/test1.txt" );
         Assertions.assertTrue( m_auth.checkPermission( session, edit ), "Alice view Test/test1.txt" );
 
@@ -317,8 +303,7 @@ public class AuthorizationManagerTest
         final Permission edit = PermissionFactory.getPagePermission( p, "edit" );
 
         // Create session with user 'Alice', who can read (in ACL)
-        WikiSession session;
-        session = WikiSessionTest.authenticatedSession( m_engine, Users.ALICE, Users.ALICE_PASS );
+        Session session = WikiSessionTest.authenticatedSession( m_engine, Users.ALICE, Users.ALICE_PASS );
         Assertions.assertTrue( m_auth.checkPermission( session, view ), "Foo view Test" );
         Assertions.assertFalse( m_auth.checkPermission( session, edit ),"Foo !edit Test" );
 
@@ -341,7 +326,7 @@ public class AuthorizationManagerTest
         final Role finance = new Role( "Finance" );
 
         // Create Group1 with Alice in it, Group2 without
-        WikiSession session = WikiSessionTest.adminSession( m_engine );
+        Session session = WikiSessionTest.adminSession( m_engine );
         final Group g1 = m_groupMgr.parseGroup( "Group1", "Alice", true );
         m_groupMgr.setGroup( session, g1 );
         final Principal group1 = g1.getPrincipal();
@@ -398,7 +383,7 @@ public class AuthorizationManagerTest
         final Role finance = new Role( "Finance" );
 
         // Create Group1 with Alice in it, Group2 without
-        WikiSession session = WikiSessionTest.adminSession( m_engine );
+        Session session = WikiSessionTest.adminSession( m_engine );
         final Group g1 = m_groupMgr.parseGroup( "Group1", "Alice", true );
         m_groupMgr.setGroup( session, g1 );
         final Principal group1 = g1.getPrincipal();
@@ -458,8 +443,7 @@ public class AuthorizationManagerTest
         final Permission edit = PermissionFactory.getPagePermission( p, "edit" );
 
         // Create session with authenticated user 'Alice', who can read & edit (in ACL)
-        WikiSession session;
-        session = WikiSessionTest.authenticatedSession( m_engine, Users.ALICE, Users.ALICE_PASS );
+        Session session = WikiSessionTest.authenticatedSession( m_engine, Users.ALICE, Users.ALICE_PASS );
         Assertions.assertTrue( m_auth.checkPermission( session, view ), "Alice view Test" );
         Assertions.assertTrue( m_auth.checkPermission( session, edit ), "Alice edit Test" );
 
@@ -580,8 +564,7 @@ public class AuthorizationManagerTest
         final Permission edit = PermissionFactory.getPagePermission( p, "edit" );
 
         // Create session with authenticated user 'Alice', who can read & edit
-        WikiSession session;
-        session = WikiSessionTest.authenticatedSession( m_engine, Users.ALICE, Users.ALICE_PASS );
+        Session session = WikiSessionTest.authenticatedSession( m_engine, Users.ALICE, Users.ALICE_PASS );
         Assertions.assertTrue( m_auth.checkPermission( session, view ), "Alice view Test" );
         Assertions.assertTrue( m_auth.checkPermission( session, edit ), "Alice edit Test" );
 
@@ -591,20 +574,16 @@ public class AuthorizationManagerTest
         Assertions.assertFalse( m_auth.checkPermission( session, edit ), "Bob !edit Test" );
 
         // Cleanup
-        try
-        {
+        try {
             m_engine.getManager( PageManager.class ).deletePage( "Test" );
-        }
-        catch( final ProviderException e )
-        {
+        } catch( final ProviderException e ) {
             Assertions.fail( e.getMessage() );
         }
     }
 
     @Test
-    public void testStaticPermission() throws Exception
-    {
-        WikiSession s = WikiSessionTest.anonymousSession( m_engine );
+    public void testStaticPermission() throws Exception {
+        Session s = WikiSessionTest.anonymousSession( m_engine );
         Assertions.assertTrue( m_auth.checkStaticPermission( s, PagePermission.VIEW ), "Anonymous view" );
         Assertions.assertTrue( m_auth.checkStaticPermission( s, PagePermission.EDIT ), "Anonymous edit" );
         Assertions.assertTrue( m_auth.checkStaticPermission( s, PagePermission.COMMENT ), "Anonymous comment" );
@@ -660,27 +639,20 @@ public class AuthorizationManagerTest
     }
 
     @Test
-    public void testAdminView()
-       throws Exception
-    {
+    public void testAdminView() throws Exception {
         m_engine.saveText( "TestDefaultPage", "Foo [{ALLOW view FooBar}]" );
 
         final Principal admin = new GroupPrincipal( "Admin" );
-        final WikiSession session = WikiSessionTest.containerAuthenticatedSession(
-                m_engine,
-                Users.ALICE,
-                new Principal[] { admin } );
+        final Session session = WikiSessionTest.containerAuthenticatedSession( m_engine, Users.ALICE, new Principal[] { admin } );
 
         Assertions.assertTrue( m_auth.checkPermission( session, new AllPermission( m_engine.getApplicationName() ) ), "Alice has AllPermission" );
         Assertions.assertTrue( m_auth.checkPermission( session, new PagePermission("TestDefaultPage","view") ), "Alice cannot read" );
     }
 
     @Test
-    public void testAdminView2() throws Exception
-    {
+    public void testAdminView2() throws Exception {
         m_engine.saveText( "TestDefaultPage", "Foo [{ALLOW view FooBar}]" );
-
-        final WikiSession session = WikiSessionTest.adminSession(m_engine);
+        final Session session = WikiSessionTest.adminSession(m_engine);
 
         Assertions.assertTrue( m_auth.checkPermission( session, new AllPermission( m_engine.getApplicationName() ) ), "Alice has AllPermission" );
         Assertions.assertTrue( m_auth.checkPermission( session, new PagePermission("TestDefaultPage","view") ),"Alice cannot read" );
@@ -700,7 +672,7 @@ public class AuthorizationManagerTest
         m_groupMgr = m_engine.getGroupManager();
         m_session = WikiSessionTest.adminSession( m_engine );
 
-        WikiSession s = WikiSessionTest.anonymousSession( m_engine );
+        Session s = WikiSessionTest.anonymousSession( m_engine );
         Assertions.assertFalse( m_auth.checkStaticPermission( s, PagePermission.VIEW ), "Anonymous view" );
         Assertions.assertFalse( m_auth.checkStaticPermission( s, PagePermission.EDIT ), "Anonymous edit" );
         Assertions.assertFalse( m_auth.checkStaticPermission( s, PagePermission.COMMENT ), "Anonymous comment" );
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/auth/TestAuthorizer.java b/jspwiki-main/src/test/java/org/apache/wiki/auth/TestAuthorizer.java
index 5b272e7..7e1ef75 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/auth/TestAuthorizer.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/auth/TestAuthorizer.java
@@ -18,8 +18,8 @@
  */
 package org.apache.wiki.auth;
 
-import org.apache.wiki.WikiSession;
 import org.apache.wiki.api.core.Engine;
+import org.apache.wiki.api.core.Session;
 import org.apache.wiki.auth.authorize.Role;
 import org.apache.wiki.auth.authorize.WebAuthorizer;
 
@@ -47,19 +47,22 @@ public class TestAuthorizer implements WebAuthorizer {
         super();
     }
 
-    @Override public Principal findRole( final String role )
+    @Override
+    public Principal findRole( final String role )
     {
         return null;
     }
 
-    @Override public void initialize( final Engine engine, final Properties props ) {
+    @Override
+    public void initialize( final Engine engine, final Properties props ) {
     }
 
     /**
      * Returns an array of Principal objects containing five elements: Role "Admin", Role.AUTHENTICATED, Role "IT", Role "Finance" and
      * Role "Engineering."
      */
-    @Override public Principal[] getRoles()
+    @Override
+    public Principal[] getRoles()
     {
         return m_roles;
     }
@@ -67,7 +70,8 @@ public class TestAuthorizer implements WebAuthorizer {
     /**
      * Returns <code>true</code> if the WikiSession's Subject contains a particular role principal.
      */
-    @Override public boolean isUserInRole( final WikiSession session, final Principal role ) {
+    @Override
+    public boolean isUserInRole( final Session session, final Principal role ) {
         if ( session == null || role == null ) {
             return false;
         }
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/auth/UserManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/auth/UserManagerTest.java
index 0cd9264..3473e81 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/auth/UserManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/auth/UserManagerTest.java
@@ -21,8 +21,8 @@ package org.apache.wiki.auth;
 import org.apache.commons.lang3.ArrayUtils;
 import org.apache.wiki.TestEngine;
 import org.apache.wiki.WikiPage;
-import org.apache.wiki.WikiSession;
 import org.apache.wiki.WikiSessionTest;
+import org.apache.wiki.api.core.Session;
 import org.apache.wiki.auth.authorize.Group;
 import org.apache.wiki.auth.authorize.GroupManager;
 import org.apache.wiki.auth.permissions.PermissionFactory;
@@ -107,7 +107,7 @@ public class UserManagerTest {
         final int oldPageCount = pageManager.getTotalPageCount();
 
         // Setup Step 1: create a new user with random name
-        final WikiSession session = m_engine.guestSession();
+        final Session session = m_engine.guestSession();
         final long now = System.currentTimeMillis();
         final String oldLogin = "TestLogin" + now;
         final String oldName = "Test User " + now;
@@ -151,7 +151,7 @@ public class UserManagerTest {
         Assertions.assertNull( p.getAcl().getEntry( new WikiPrincipal( newLogin ) ) );
         Assertions.assertNull( p.getAcl().getEntry( new WikiPrincipal( newName ) ) );
         Assertions.assertTrue( authManager.checkPermission( session, PermissionFactory.getPagePermission( p, "view" ) ), "Test User view page" );
-        final WikiSession bobSession = WikiSessionTest.authenticatedSession( m_engine, Users.BOB, Users.BOB_PASS );
+        final Session bobSession = WikiSessionTest.authenticatedSession( m_engine, Users.BOB, Users.BOB_PASS );
         Assertions.assertFalse( authManager.checkPermission( bobSession, PermissionFactory.getPagePermission( p, "view" ) ), "Bob !view page" );
 
         // Setup Step 4: change the user name in the profile and see what happens
@@ -269,7 +269,7 @@ public class UserManagerTest {
         final int oldUserCount = m_db.getWikiNames().length;
 
         // Create a new user with random name
-        final WikiSession session = m_engine.guestSession();
+        final Session session = m_engine.guestSession();
         final String loginName = "TestUser" + String.valueOf( System.currentTimeMillis() );
         UserProfile profile = m_db.newProfile();
         profile.setEmail( "jspwiki.tests@mailinator.com" );
@@ -296,7 +296,7 @@ public class UserManagerTest {
         final int oldUserCount = m_db.getWikiNames().length;
 
         // Create a new user with random name
-        final WikiSession session = m_engine.guestSession();
+        final Session session = m_engine.guestSession();
         final String loginName = "TestUser" + String.valueOf( System.currentTimeMillis() );
         final UserProfile profile = m_db.newProfile();
         profile.setEmail( "jspwiki.tests@mailinator.com" );
@@ -347,7 +347,7 @@ public class UserManagerTest {
         final int oldUserCount = m_db.getWikiNames().length;
 
         // Create a new user with random name
-        final WikiSession session = m_engine.guestSession();
+        final Session session = m_engine.guestSession();
         final String loginName = "TestUser" + String.valueOf( System.currentTimeMillis() );
         final UserProfile profile = m_db.newProfile();
         profile.setEmail( "jspwiki.tests@mailinator.com" );
@@ -392,7 +392,7 @@ public class UserManagerTest {
         final int oldUserCount = m_db.getWikiNames().length;
 
         // Create a new user with random name
-        final WikiSession session = m_engine.guestSession();
+        final Session session = m_engine.guestSession();
         final String loginName = "TestUser" + String.valueOf( System.currentTimeMillis() );
         final UserProfile profile = m_db.newProfile();
         profile.setEmail( "jspwiki.tests@mailinator.com" );
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/auth/acl/AclImplTest.java b/jspwiki-main/src/test/java/org/apache/wiki/auth/acl/AclImplTest.java
index 41c2e5a..4a072ea 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/auth/acl/AclImplTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/auth/acl/AclImplTest.java
@@ -17,19 +17,10 @@
     under the License.
  */
 package org.apache.wiki.auth.acl;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.security.Principal;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
 
 import org.apache.wiki.TestEngine;
-import org.apache.wiki.WikiSession;
 import org.apache.wiki.WikiSessionTest;
+import org.apache.wiki.api.core.Session;
 import org.apache.wiki.auth.GroupPrincipal;
 import org.apache.wiki.auth.WikiPrincipal;
 import org.apache.wiki.auth.authorize.Group;
@@ -40,6 +31,16 @@ import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.security.Principal;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
 public class AclImplTest
 {
     private AclImpl m_acl;
@@ -50,7 +51,7 @@ public class AclImplTest
 
     private GroupManager m_groupMgr;
 
-    private WikiSession m_session;
+    private Session m_session;
 
     /**
      * We setup the following rules: Alice = may view Bob = may view, may edit
@@ -61,37 +62,37 @@ public class AclImplTest
     public void setUp() throws Exception
     {
 
-        Properties props = TestEngine.getTestProperties();
-        TestEngine engine  = new TestEngine( props );
+        final Properties props = TestEngine.getTestProperties();
+        final TestEngine engine  = new TestEngine( props );
         m_groupMgr = engine.getGroupManager();
         m_session = WikiSessionTest.adminSession( engine );
 
         m_acl = new AclImpl();
         m_aclGroup = new AclImpl();
-        m_groups = new HashMap<String, Group>();
-        Principal uAlice = new WikiPrincipal( "Alice" );
-        Principal uBob = new WikiPrincipal( "Bob" );
-        Principal uCharlie = new WikiPrincipal( "Charlie" );
-        Principal uDave = new WikiPrincipal( "Dave" );
+        m_groups = new HashMap<>();
+        final Principal uAlice = new WikiPrincipal( "Alice" );
+        final Principal uBob = new WikiPrincipal( "Bob" );
+        final Principal uCharlie = new WikiPrincipal( "Charlie" );
+        final Principal uDave = new WikiPrincipal( "Dave" );
 
         //  Alice can view
-        AclEntry ae = new AclEntryImpl();
+        final AclEntry ae = new AclEntryImpl();
         ae.addPermission( PagePermission.VIEW );
         ae.setPrincipal( uAlice );
 
         //  Charlie can view
-        AclEntry ae2 = new AclEntryImpl();
+        final AclEntry ae2 = new AclEntryImpl();
         ae2.addPermission( PagePermission.VIEW );
         ae2.setPrincipal( uCharlie );
 
         //  Bob can view and edit (and by implication, comment)
-        AclEntry ae3 = new AclEntryImpl();
+        final AclEntry ae3 = new AclEntryImpl();
         ae3.addPermission( PagePermission.VIEW );
         ae3.addPermission( PagePermission.EDIT );
         ae3.setPrincipal( uBob );
 
         // Dave can view and comment
-        AclEntry ae4 = new AclEntryImpl();
+        final AclEntry ae4 = new AclEntryImpl();
         ae4.addPermission( PagePermission.VIEW );
         ae4.addPermission( PagePermission.COMMENT );
         ae4.setPrincipal( uDave );
@@ -103,22 +104,22 @@ public class AclImplTest
         m_acl.addEntry( ae4 );
 
         // Foo group includes Alice and Bob
-        Group foo = m_groupMgr.parseGroup( "FooGroup", "", true );
+        final Group foo = m_groupMgr.parseGroup( "FooGroup", "", true );
         m_groupMgr.setGroup( m_session, foo );
         foo.add( uAlice );
         foo.add( uBob );
-        AclEntry ag1 = new AclEntryImpl();
+        final AclEntry ag1 = new AclEntryImpl();
         ag1.setPrincipal( foo.getPrincipal() );
         ag1.addPermission( PagePermission.EDIT );
         m_aclGroup.addEntry( ag1 );
         m_groups.put( "FooGroup", foo );
 
         // Bar group includes Bob and Charlie
-        Group bar = m_groupMgr.parseGroup( "BarGroup", "", true );
+        final Group bar = m_groupMgr.parseGroup( "BarGroup", "", true );
         m_groupMgr.setGroup( m_session, bar );
         bar.add( uBob );
         bar.add( uCharlie );
-        AclEntry ag2 = new AclEntryImpl();
+        final AclEntry ag2 = new AclEntryImpl();
         ag2.setPrincipal( bar.getPrincipal() );
         ag2.addPermission( PagePermission.VIEW );
         m_aclGroup.addEntry( ag2 );
@@ -132,7 +133,7 @@ public class AclImplTest
         m_groupMgr.removeGroup( "BarGroup" );
     }
 
-    private boolean inArray( Object[] array, Object key )
+    private boolean inArray( final Object[] array, final Object key )
     {
         for( int i = 0; i < array.length; i++ )
         {
@@ -144,14 +145,14 @@ public class AclImplTest
         return false;
     }
 
-    private boolean inGroup( Object[] array, Principal key )
+    private boolean inGroup( final Object[] array, final Principal key )
     {
         for( int i = 0; i < array.length; i++ )
         {
             if ( array[i] instanceof GroupPrincipal )
             {
-                String groupName = ((GroupPrincipal)array[i]).getName();
-                Group group = m_groups.get( groupName );
+                final String groupName = ((GroupPrincipal)array[i]).getName();
+                final Group group = m_groups.get( groupName );
                 if ( group != null && group.isMember( key ) )
                 {
                     return true;
@@ -165,7 +166,7 @@ public class AclImplTest
     public void testAlice()
     {
         // Alice should be able to view but not edit or comment
-        Principal wup = new WikiPrincipal( "Alice" );
+        final Principal wup = new WikiPrincipal( "Alice" );
         Assertions.assertTrue( inArray( m_acl.findPrincipals( PagePermission.VIEW ), wup ) );
         Assertions.assertFalse( inArray( m_acl.findPrincipals( PagePermission.EDIT ), wup ) );
         Assertions.assertFalse( inArray( m_acl.findPrincipals( PagePermission.COMMENT ), wup ) );
@@ -175,7 +176,7 @@ public class AclImplTest
     public void testBob()
     {
         // Bob should be able to view, edit, and comment but not delete
-        Principal wup = new WikiPrincipal( "Bob" );
+        final Principal wup = new WikiPrincipal( "Bob" );
         Assertions.assertTrue( inArray( m_acl.findPrincipals( PagePermission.VIEW ), wup ) );
         Assertions.assertTrue( inArray( m_acl.findPrincipals( PagePermission.EDIT ), wup ) );
         Assertions.assertTrue( inArray( m_acl.findPrincipals( PagePermission.COMMENT ), wup ) );
@@ -186,7 +187,7 @@ public class AclImplTest
     public void testCharlie()
     {
         // Charlie should be able to view, but not edit, comment or delete
-        Principal wup = new WikiPrincipal( "Charlie" );
+        final Principal wup = new WikiPrincipal( "Charlie" );
         Assertions.assertTrue( inArray( m_acl.findPrincipals( PagePermission.VIEW ), wup ) );
         Assertions.assertFalse( inArray( m_acl.findPrincipals( PagePermission.EDIT ), wup ) );
         Assertions.assertFalse( inArray( m_acl.findPrincipals( PagePermission.COMMENT ), wup ) );
@@ -197,7 +198,7 @@ public class AclImplTest
     public void testDave()
     {
         // Dave should be able to view and comment but not edit or delete
-        Principal wup = new WikiPrincipal( "Dave" );
+        final Principal wup = new WikiPrincipal( "Dave" );
         Assertions.assertTrue( inArray( m_acl.findPrincipals( PagePermission.VIEW ), wup ) );
         Assertions.assertFalse( inArray( m_acl.findPrincipals( PagePermission.EDIT ), wup ) );
         Assertions.assertTrue( inArray( m_acl.findPrincipals( PagePermission.COMMENT ), wup ) );
@@ -235,19 +236,19 @@ public class AclImplTest
     @Test
     public void testSerialization() throws IOException, ClassNotFoundException
     {
-        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        final ByteArrayOutputStream out = new ByteArrayOutputStream();
 
-        ObjectOutputStream out2 = new ObjectOutputStream(out);
+        final ObjectOutputStream out2 = new ObjectOutputStream(out);
 
         out2.writeObject( m_acl );
 
         out2.close();
 
-        byte[] stuff = out.toByteArray();
+        final byte[] stuff = out.toByteArray();
 
-        ObjectInputStream in = new ObjectInputStream( new ByteArrayInputStream(stuff) );
+        final ObjectInputStream in = new ObjectInputStream( new ByteArrayInputStream(stuff) );
 
-        AclImpl newacl = (AclImpl) in.readObject();
+        final AclImpl newacl = (AclImpl) in.readObject();
         Assertions.assertEquals( newacl.toString(), m_acl.toString() );
     }
 
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/auth/authorize/GroupManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/auth/authorize/GroupManagerTest.java
index 252d01a..25d9dc0 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/auth/authorize/GroupManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/auth/authorize/GroupManagerTest.java
@@ -17,10 +17,11 @@
     under the License.
  */
 package org.apache.wiki.auth.authorize;
+
 import org.apache.commons.lang3.ArrayUtils;
 import org.apache.wiki.TestEngine;
-import org.apache.wiki.WikiSession;
 import org.apache.wiki.WikiSessionTest;
+import org.apache.wiki.api.core.Session;
 import org.apache.wiki.api.exceptions.WikiException;
 import org.apache.wiki.auth.GroupPrincipal;
 import org.apache.wiki.auth.NoSuchPrincipalException;
@@ -45,12 +46,12 @@ public class GroupManagerTest
 
     private SecurityEventTrap m_trap = new SecurityEventTrap();
 
-    private WikiSession       m_session;
+    private Session m_session;
 
     @BeforeEach
     public void setUp() throws Exception
     {
-        Properties props = TestEngine.getTestProperties();
+        final Properties props = TestEngine.getTestProperties();
 
         m_engine = new TestEngine( props );
         m_groupMgr = m_engine.getGroupManager();
@@ -63,7 +64,7 @@ public class GroupManagerTest
             m_groupMgr.removeGroup( "Test2" );
             m_groupMgr.removeGroup( "Test3" );
         }
-        catch ( NoSuchPrincipalException e )
+        catch ( final NoSuchPrincipalException e )
         {
             // It's not a problem if we can't find the principals...
         }
@@ -112,7 +113,7 @@ public class GroupManagerTest
     @Test
     public void testGetRoles()
     {
-        Principal[] roles = m_groupMgr.getRoles();
+        final Principal[] roles = m_groupMgr.getRoles();
         Assertions.assertTrue( ArrayUtils.contains( roles, new GroupPrincipal( "Test" ) ), "Found Test" );
         Assertions.assertTrue( ArrayUtils.contains( roles, new GroupPrincipal( "Test2" ) ), "Found Test2" );
         Assertions.assertTrue( ArrayUtils.contains( roles, new GroupPrincipal( "Test3" ) ), "Found Test3" );
@@ -121,10 +122,8 @@ public class GroupManagerTest
     @Test
     public void testGroupMembership() throws Exception
     {
-        WikiSession s;
-
         // Anonymous; should belong to NO groups
-        s = WikiSessionTest.anonymousSession( m_engine );
+        Session s = WikiSessionTest.anonymousSession( m_engine );
         Assertions.assertFalse( m_groupMgr.isUserInRole( s, new GroupPrincipal( "Test" ) ) );
         Assertions.assertFalse( m_groupMgr.isUserInRole( s, new GroupPrincipal( "Test2" ) ) );
         Assertions.assertFalse( m_groupMgr.isUserInRole( s, new GroupPrincipal( "Test3" ) ) );
@@ -181,7 +180,7 @@ public class GroupManagerTest
         {
             m_groupMgr.removeGroup( "Events" );
         }
-        catch ( NoSuchPrincipalException e )
+        catch ( final NoSuchPrincipalException e )
         {
             // It's not a problem if we get here...
         }
@@ -189,14 +188,14 @@ public class GroupManagerTest
 
         Group group = m_groupMgr.parseGroup( "Events", "", true );
         m_groupMgr.setGroup( m_session, group );
-        WikiSecurityEvent event;
+        final WikiSecurityEvent event;
         group = m_groupMgr.getGroup( "Events" );
         group.add( new WikiPrincipal( "Alice" ) );
         group.add( new WikiPrincipal( "Bob" ) );
         group.add( new WikiPrincipal( "Charlie" ) );
 
         // We should see a GROUP_ADD event
-        WikiSecurityEvent[] events = m_trap.events();
+        final WikiSecurityEvent[] events = m_trap.events();
         Assertions.assertEquals( 1, events.length );
         event = events[0];
         Assertions.assertEquals( m_groupMgr, event.getSrc() );
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/plugin/IfPluginTest.java b/jspwiki-main/src/test/java/org/apache/wiki/plugin/IfPluginTest.java
index 81b9240..1afd5a9 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/plugin/IfPluginTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/plugin/IfPluginTest.java
@@ -23,6 +23,7 @@ import org.apache.wiki.TestEngine;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.WikiSession;
+import org.apache.wiki.api.core.Session;
 import org.apache.wiki.api.exceptions.WikiException;
 import org.apache.wiki.auth.Users;
 import org.apache.wiki.pages.PageManager;
@@ -47,15 +48,10 @@ public class IfPluginTest {
      * @return {@link WikiContext} associated to given {@link WikiPage}.
      * @throws WikiException problems while logging in.
      */
-    WikiContext getJanneBasedWikiContextFor( final WikiPage page ) throws WikiException
-    {
+    WikiContext getJanneBasedWikiContextFor( final WikiPage page ) throws WikiException {
         final MockHttpServletRequest request = testEngine.newHttpRequest();
-        final WikiSession session =  WikiSession.getWikiSession( testEngine, request );
-        testEngine.getAuthenticationManager().login( session,
-                                                     request,
-                                                     Users.JANNE,
-                                                     Users.JANNE_PASS );
-
+        final Session session =  WikiSession.getWikiSession( testEngine, request );
+        testEngine.getAuthenticationManager().login( session, request, Users.JANNE, Users.JANNE_PASS );
         return new WikiContext( testEngine, request, page );
     }
 
@@ -67,9 +63,7 @@ public class IfPluginTest {
     @Test
     public void testIfPluginUserAllowed() throws WikiException
     {
-        final String src = "[{IfPlugin user='Janne Jalkanen'\n" +
-        		     "\n" +
-        		     "Content visible for Janne Jalkanen}]";
+        final String src = "[{IfPlugin user='Janne Jalkanen'\n\nContent visible for Janne Jalkanen}]";
         final String expected = "<p>Content visible for Janne Jalkanen</p>\n";
 
         testEngine.saveText( "Test", src );
@@ -88,9 +82,7 @@ public class IfPluginTest {
     @Test
     public void testIfPluginUserNotAllowed() throws WikiException
     {
-        final String src = "[{IfPlugin user='!Janne Jalkanen'\n" +
-                     "\n" +
-                     "Content NOT visible for Janne Jalkanen}]";
+        final String src = "[{IfPlugin user='!Janne Jalkanen'\n\nContent NOT visible for Janne Jalkanen}]";
         final String expected = "\n";
 
         testEngine.saveText( "Test", src );
@@ -108,9 +100,7 @@ public class IfPluginTest {
      */
     @Test
     public void testIfPluginIPAllowed() throws WikiException {
-        final String src = "[{IfPlugin ip='127.0.0.1'\n" +
-                     "\n" +
-                     "Content visible for 127.0.0.1}]";
+        final String src = "[{IfPlugin ip='127.0.0.1'\n\nContent visible for 127.0.0.1}]";
         final String expected = "<p>Content visible for 127.0.0.1</p>\n";
 
         testEngine.saveText( "Test", src );
@@ -128,9 +118,7 @@ public class IfPluginTest {
      */
     @Test
     public void testIfPluginIPNotAllowed() throws WikiException {
-        final String src = "[{IfPlugin ip='!127.0.0.1'\n" +
-                     "\n" +
-                     "Content NOT visible for 127.0.0.1}]";
+        final String src = "[{IfPlugin ip='!127.0.0.1'\n\nContent NOT visible for 127.0.0.1}]";
         final String expected = "\n";
 
         testEngine.saveText( "Test", src );
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/workflow/DecisionQueueTest.java b/jspwiki-main/src/test/java/org/apache/wiki/workflow/DecisionQueueTest.java
index a19241b..cb34b85 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/workflow/DecisionQueueTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/workflow/DecisionQueueTest.java
@@ -18,22 +18,19 @@
  */
 package org.apache.wiki.workflow;
 
+import org.apache.wiki.TestEngine;
+import org.apache.wiki.api.core.Session;
+import org.apache.wiki.api.exceptions.WikiException;
+import org.apache.wiki.auth.GroupPrincipal;
+import org.apache.wiki.auth.WikiPrincipal;
+import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
-
 import org.junit.jupiter.api.Test;
 
 import java.security.Principal;
 import java.util.Collection;
 import java.util.Properties;
 
-import org.junit.jupiter.api.Assertions;
-
-import org.apache.wiki.TestEngine;
-import org.apache.wiki.WikiSession;
-import org.apache.wiki.api.exceptions.WikiException;
-import org.apache.wiki.auth.GroupPrincipal;
-import org.apache.wiki.auth.WikiPrincipal;
-
 public class DecisionQueueTest
 {
 
@@ -49,15 +46,15 @@ public class DecisionQueueTest
 
     Decision d3;
 
-    WikiSession janneSession;
+    Session janneSession;
 
-    WikiSession adminSession;
+    Session adminSession;
 
     @BeforeEach
     public void setUp() throws Exception
     {
 
-        Properties props = TestEngine.getTestProperties();
+        final Properties props = TestEngine.getTestProperties();
         m_engine = new TestEngine(props);
         m_queue = m_engine.getWorkflowManager().getDecisionQueue();
         adminSession = m_engine.adminSession();
@@ -75,7 +72,7 @@ public class DecisionQueueTest
     @Test
     public void testAdd()
     {
-        Decision[] decisions = m_queue.decisions();
+        final Decision[] decisions = m_queue.decisions();
         Assertions.assertEquals(d1, decisions[0]);
         Assertions.assertEquals(d2, decisions[1]);
         Assertions.assertEquals(d3, decisions[2]);
@@ -142,7 +139,7 @@ public class DecisionQueueTest
     @Test
     public void testDecisions()
     {
-        Decision[] decisions = m_queue.decisions();
+        final Decision[] decisions = m_queue.decisions();
         Assertions.assertEquals(3, decisions.length);
         Assertions.assertEquals(d1, decisions[0]);
         Assertions.assertEquals(d2, decisions[1]);
@@ -162,7 +159,7 @@ public class DecisionQueueTest
     @Test
     public void testDecisionWorkflow() throws WikiException
     {
-        Principal janne = janneSession.getUserPrincipal();
+        final Principal janne = janneSession.getUserPrincipal();
 
         // Clean out the queue first
         m_queue.remove(d1);
@@ -172,9 +169,9 @@ public class DecisionQueueTest
         // Create a workflow with 3 steps, with a Decision for Janne in the middle
         w = new Workflow("workflow.key", new WikiPrincipal("Owner1"));
         w.setWorkflowManager(m_engine.getWorkflowManager());
-        Step startTask = new TaskTest.NormalTask(w);
-        Step endTask = new TaskTest.NormalTask(w);
-        Decision decision = new SimpleDecision(w, "decision.Actor1Decision", janne);
+        final Step startTask = new TaskTest.NormalTask(w);
+        final Step endTask = new TaskTest.NormalTask(w);
+        final Decision decision = new SimpleDecision(w, "decision.Actor1Decision", janne);
         startTask.addSuccessor(Outcome.STEP_COMPLETE, decision);
         decision.addSuccessor(Outcome.DECISION_APPROVE, endTask);
         w.setFirstStep(startTask);
@@ -186,7 +183,7 @@ public class DecisionQueueTest
         // Verify that it's also in Janne's DecisionQueue
         Collection< Decision > decisions = m_queue.getActorDecisions(janneSession);
         Assertions.assertEquals(1, decisions.size());
-        Decision d = (Decision)decisions.iterator().next();
+        final Decision d = (Decision)decisions.iterator().next();
         Assertions.assertEquals(decision, d);
 
         // Make Decision, and verify that it's gone from the queue


[jspwiki] 26/35: JSPWIKI-303: use Session instead of WikiSession (2)

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git

commit 8487770254086e34a29fd9b6737d2a74381baf5b
Author: juanpablo <ju...@apache.org>
AuthorDate: Thu Mar 5 17:18:21 2020 +0100

    JSPWIKI-303: use Session instead of WikiSession (2)
---
 .../org/apache/wiki/event/WikiSecurityEvent.java   |  4 +-
 .../apache/wiki/plugin/AbstractReferralPlugin.java |  3 +-
 .../java/org/apache/wiki/plugin/InsertPage.java    | 11 +--
 .../org/apache/wiki/plugin/SessionsPlugin.java     | 81 ++++++++--------------
 .../apache/wiki/search/BasicSearchProvider.java    | 15 ++--
 .../java/org/apache/wiki/search/SearchMatcher.java |  9 ++-
 .../java/org/apache/wiki/tags/MessagesTag.java     | 11 +--
 .../java/org/apache/wiki/tags/UserCheckTag.java    | 46 +++++-------
 .../java/org/apache/wiki/tags/UserProfileTag.java  |  8 +--
 .../org/apache/wiki/ui/WikiRequestWrapper.java     | 25 ++++---
 .../java/org/apache/wiki/ui/WikiServletFilter.java | 19 ++---
 .../wiki/ui/admin/beans/SearchManagerBean.java     | 46 ++++++------
 .../org/apache/wiki/ui/admin/beans/UserBean.java   | 16 ++---
 .../src/test/java/org/apache/wiki/TestEngine.java  |  4 +-
 14 files changed, 140 insertions(+), 158 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/event/WikiSecurityEvent.java b/jspwiki-main/src/main/java/org/apache/wiki/event/WikiSecurityEvent.java
index 94a633c..f57a56b 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/event/WikiSecurityEvent.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/event/WikiSecurityEvent.java
@@ -83,7 +83,7 @@ public final class WikiSecurityEvent extends WikiEvent {
     /** When a user logs out. */
     public static final int   LOGOUT                   = 44;
 
-    /** When a Principal should be added to the WikiSession */
+    /** When a Principal should be added to the Session */
     public static final int PRINCIPAL_ADD               = 35;
 
     /** When a session expires. */
@@ -187,6 +187,7 @@ public final class WikiSecurityEvent extends WikiEvent {
      *
      * @see java.lang.Object#toString()
      */
+    @Override
     public String toString() {
         final StringBuilder msg = new StringBuilder();
         msg.append( "WikiSecurityEvent." );
@@ -233,6 +234,7 @@ public final class WikiSecurityEvent extends WikiEvent {
      *
      * @return a String description of the type
      */
+    @Override
     public String getTypeDescription() {
         switch ( getType() ) {
             case LOGIN_AUTHENTICATED:       return "login authenticated";
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/AbstractReferralPlugin.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/AbstractReferralPlugin.java
index 69d5ca3..5d552e4 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/AbstractReferralPlugin.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/AbstractReferralPlugin.java
@@ -443,7 +443,8 @@ public abstract class AbstractReferralPlugin implements WikiPlugin
             m_length = length;
         }
 
-        @Override public String mutate( final WikiContext context, final String text ) {
+        @Override
+        public String mutate( final WikiContext context, final String text ) {
             if( text.length() > m_length ) {
                 return text.substring( 0, m_length ) + "...";
             }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/InsertPage.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/InsertPage.java
index e341041..2cca1b4 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/InsertPage.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/InsertPage.java
@@ -155,15 +155,10 @@ public class InsertPage
                 //
                 String cookieName = "";
 
-                if( showOnce )
-                {
-                    cookieName = ONCE_COOKIE +
-                                 TextUtil.urlEncodeUTF8( page.getName() )
-                                         .replaceAll( "\\+", "%20" );
+                if( showOnce ) {
+                    cookieName = ONCE_COOKIE + TextUtil.urlEncodeUTF8( page.getName() ).replaceAll( "\\+", "%20" );
 
-                    if( HttpUtil.retrieveCookieValue( context.getHttpRequest(),
-                                                      cookieName ) != null )
-                    {
+                    if( HttpUtil.retrieveCookieValue( context.getHttpRequest(), cookieName ) != null ) {
                         return "";  //silent exit
                     }
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/SessionsPlugin.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/SessionsPlugin.java
index aba5a0b..b8df39a 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/SessionsPlugin.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/SessionsPlugin.java
@@ -19,102 +19,81 @@
 package org.apache.wiki.plugin;
 
 import org.apache.wiki.WikiContext;
-import org.apache.wiki.WikiSession;
 import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.exceptions.PluginException;
 import org.apache.wiki.api.plugin.WikiPlugin;
+import org.apache.wiki.auth.SessionMonitor;
 import org.apache.wiki.util.TextUtil;
 
 import java.security.Principal;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
 
 /**
- *  <p>Displays information about active wiki sessions. The parameter
- *  <code>property</code> specifies what information is displayed.
+ *  <p>Displays information about active wiki sessions. The parameter <code>property</code> specifies what information is displayed.
  *  If omitted, the number of sessions is returned.
  *
  *  <p>Parameters : </p>
  *  <ul>
  *  <li><b>property</b> - specify what output to display, valid values are:</li>
  *  <ul>
- *    <li><code>users</code> - returns a comma-separated list of
- *    users</li>
- *    <li><code>distinctUsers</code> - will only show
- *    distinct users.
+ *    <li><code>users</code> - returns a comma-separated list of users</li>
+ *    <li><code>distinctUsers</code> - will only show distinct users.</li>
  *  </ul>
  *  </ul>
  *  @since 2.3.84
  */
-public class SessionsPlugin
-    implements WikiPlugin
-{
+public class SessionsPlugin implements WikiPlugin {
+
     /** The parameter name for setting the property value. */
     public static final String PARAM_PROP = "property";
 
     /**
      *  {@inheritDoc}
      */
-    @Override public String execute( final WikiContext context, final Map<String, String> params )
-        throws PluginException
-    {
+    @Override
+    public String execute( final WikiContext context, final Map<String, String> params ) throws PluginException {
         final Engine engine = context.getEngine();
         final String prop = params.get( PARAM_PROP );
 
-        if ( "users".equals( prop ) )
-        {
-            final Principal[] principals = WikiSession.userPrincipals( engine );
+        if( "users".equals( prop ) ) {
+            final Principal[] principals = SessionMonitor.getInstance( engine ).userPrincipals();
             final StringBuilder s = new StringBuilder();
-            for ( int i = 0; i < principals.length; i++ )
-            {
-                s.append(principals[i].getName() + ", ");
+            for( final Principal principal : principals ) {
+                s.append( principal.getName() ).append( ", " );
             }
             // remove the last comma and blank :
-            return TextUtil.replaceEntities( s.substring(0, s.length() - (s.length() > 2 ? 2 : 0) ) );
+            return TextUtil.replaceEntities( s.substring( 0, s.length() - ( s.length() > 2 ? 2 : 0 ) ) );
         }
 
-        //
-        // show each user session only once (with a counter that indicates the
-        // number of sessions for each user)
-        if ("distinctUsers".equals(prop))
-        {
-            final Principal[] principals = WikiSession.userPrincipals(engine);
-            // we do not assume that the principals are sorted, so first count
-            // them :
-            final HashMap<String,Integer> distinctPrincipals = new HashMap<>();
-            for (int i = 0; i < principals.length; i++)
-            {
-                final String principalName = principals[i].getName();
+        // show each user session only once (with a counter that indicates the number of sessions for each user)
+        if( "distinctUsers".equals( prop ) ) {
+            final Principal[] principals = SessionMonitor.getInstance( engine ).userPrincipals();
+            // we do not assume that the principals are sorted, so first count them :
+            final HashMap< String, Integer > distinctPrincipals = new HashMap<>();
+            for( final Principal principal : principals ) {
+                final String principalName = principal.getName();
 
-                if (distinctPrincipals.containsKey(principalName))
-                {
+                if( distinctPrincipals.containsKey( principalName ) ) {
                     // we already have an entry, increase the counter:
-                    int numSessions = distinctPrincipals.get(principalName).intValue();
+                    int numSessions = distinctPrincipals.get( principalName );
                     // store the new value:
-                    distinctPrincipals.put(principalName, ++numSessions);
-                }
-                else
-                {
+                    distinctPrincipals.put( principalName, ++numSessions );
+                } else {
                     // first time we see this entry, add entry to HashMap with value 1
-                    distinctPrincipals.put(principalName, 1);
+                    distinctPrincipals.put( principalName, 1 );
                 }
             }
-            //
-            //
+
             final StringBuilder s = new StringBuilder();
-            final Iterator<Map.Entry<String, Integer>> entries = distinctPrincipals.entrySet().iterator();
-            while (entries.hasNext())
-            {
-                final Map.Entry<String, Integer> entry = entries.next();
-                s.append( entry.getKey() + "(" + entry.getValue().toString() + "), " );
+            for( final Map.Entry< String, Integer > entry : distinctPrincipals.entrySet() ) {
+                s.append( entry.getKey() ).append( "(" ).append( entry.getValue().toString() ).append( "), " );
             }
             // remove the last comma and blank :
-            //if (s.length() >= 2) return s.substring(0,    s.length() - 2);
-            return TextUtil.replaceEntities( s.substring(0, s.length() - (s.length() > 2 ? 2 : 0) ) );
+            return TextUtil.replaceEntities( s.substring( 0, s.length() - ( s.length() > 2 ? 2 : 0 ) ) );
 
         }
 
-        return String.valueOf( WikiSession.sessions( engine ) );
+        return String.valueOf( SessionMonitor.getInstance( engine ).sessions() );
     }
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/search/BasicSearchProvider.java b/jspwiki-main/src/main/java/org/apache/wiki/search/BasicSearchProvider.java
index 981294f..c7139b7 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/search/BasicSearchProvider.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/search/BasicSearchProvider.java
@@ -52,19 +52,22 @@ public class BasicSearchProvider implements SearchProvider {
     /**
      *  {@inheritDoc}
      */
-    @Override public void initialize( final Engine engine, final Properties props ) throws NoRequiredPropertyException, IOException {
+    @Override
+    public void initialize( final Engine engine, final Properties props ) throws NoRequiredPropertyException, IOException {
         m_engine = engine;
     }
 
     /**
      *  {@inheritDoc}
      */
-    @Override public void pageRemoved( final WikiPage page ) {}
+    @Override
+    public void pageRemoved( final WikiPage page ) {}
 
     /**
      *  {@inheritDoc}
      */
-    @Override public void reindexPage( final WikiPage page ) {}
+    @Override
+    public void reindexPage( final WikiPage page ) {}
 
     /**
      *  Parses a query into something that we can use.
@@ -175,14 +178,16 @@ public class BasicSearchProvider implements SearchProvider {
     /**
      *  {@inheritDoc}
      */
-    @Override public Collection< SearchResult > findPages( final String query, final WikiContext wikiContext ) {
+    @Override
+    public Collection< SearchResult > findPages( final String query, final WikiContext wikiContext ) {
         return findPages( parseQuery( query ), wikiContext );
     }
 
     /**
      *  {@inheritDoc}
      */
-    @Override public String getProviderInfo() {
+    @Override
+    public String getProviderInfo() {
         return "BasicSearchProvider";
     }
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/search/SearchMatcher.java b/jspwiki-main/src/main/java/org/apache/wiki/search/SearchMatcher.java
index f609615..c9db833 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/search/SearchMatcher.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/search/SearchMatcher.java
@@ -134,7 +134,8 @@ public class SearchMatcher {
          *  Returns Wikipage for this result.
          *  @return WikiPage
          */
-        @Override public WikiPage getPage() {
+        @Override
+        public WikiPage getPage() {
             return m_page;
         }
 
@@ -143,7 +144,8 @@ public class SearchMatcher {
          *  
          *  @return Score from 0+
          */
-        @Override public int getScore() {
+        @Override
+        public int getScore() {
             return m_score;
         }
 
@@ -152,7 +154,8 @@ public class SearchMatcher {
          *  
          *  @return an empty array
          */
-        @Override public String[] getContexts() {
+        @Override
+        public String[] getContexts() {
             // Unimplemented
             return new String[0];
         }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/MessagesTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/MessagesTag.java
index 2e8a20b..a3a75f6 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/MessagesTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/MessagesTag.java
@@ -86,12 +86,15 @@ public class MessagesTag extends WikiTagBase {
             if( messages.length > 0 ) {
                 final StringBuilder sb = new StringBuilder();
                 if( messages.length == 1 ) {
-                    sb.append( "<div class=\"" + m_div + "\">" + m_prefix + TextUtil.replaceEntities( messages[ 0 ] ) + "</div>" );
+                    sb.append( "<div class=\"" ).append( m_div ).append( "\">" )
+                      .append( m_prefix )
+                      .append( TextUtil.replaceEntities( messages[ 0 ] ) )
+                      .append( "</div>" );
                 } else {
-                    sb.append( "<div class=\"" + m_div + "\">" + m_prefix );
+                    sb.append( "<div class=\"" ).append( m_div ).append( "\">" ).append( m_prefix );
                     sb.append( "<ul>" );
-                    for( int i = 0; i < messages.length; i++ ) {
-                        sb.append( "<li>" + TextUtil.replaceEntities( messages[ i ] ) + "</li>" );
+                    for( final String message : messages ) {
+                        sb.append( "<li>" ).append( TextUtil.replaceEntities( message ) ).append( "</li>" );
                     }
                     sb.append( "</ul></div>" );
                 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/UserCheckTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/UserCheckTag.java
index 42fd786..ced9aae 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/UserCheckTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/UserCheckTag.java
@@ -18,44 +18,30 @@
  */
 package org.apache.wiki.tags;
 
-import org.apache.wiki.WikiSession;
 import org.apache.wiki.api.core.Session;
 import org.apache.wiki.auth.AuthenticationManager;
 
 /**
- *  Includes the content if an user check validates.  This has
- *  been considerably enhanced for 2.2.  The possibilities for the "status"-argument are:
+ *  Includes the content if an user check validates.  This has been considerably enhanced for 2.2.  The possibilities for the
+ *  "status"-argument are:
  *
  * <ul>
- * <li>"anonymous"     - the body of the tag is included 
- *                       if the user is completely unknown (no cookie, no password)</li>
- * <li>"asserted"      - the body of the tag is included 
- *                       if the user has either been named by a cookie, but
- *                       not been authenticated.</li>
- * <li>"authenticated" - the body of the tag is included 
- *                       if the user is validated either through the container,
- *                       or by our own authentication.</li>
- * <li>"assertionsAllowed"
- *                     - the body of the tag is included 
- *                       if wiki allows identities to be asserted using cookies.</li>
- * <li>"assertionsNotAllowed"
- *                     - the body of the tag is included 
- *                       if wiki does <i>not</i> allow identities to 
- *                       be asserted using cookies.</li>
- * <li>"containerAuth" - the body of the tag is included 
- *                       if the user is validated through the container.</li>
- * <li>"customAuth"    - the body of the tag is included 
- *                       if the user is validated through our own authentication.</li>
- * <li>"known"         - if the user is not anonymous</li>                      
- * <li>"notAuthenticated"
- *                     - the body of the tag is included 
- *                       if the user is not yet authenticated.</li>
+ * <li>"anonymous"            - the body of the tag is included if the user is completely unknown (no cookie, no password)</li>
+ * <li>"asserted"             - the body of the tag is included if the user has either been named by a cookie, but not been authenticated.</li>
+ * <li>"authenticated"        - the body of the tag is included if the user is validated either through the container, or by our own authentication.</li>
+ * <li>"assertionsAllowed"    - the body of the tag is included if wiki allows identities to be asserted using cookies.</li>
+ * <li>"assertionsNotAllowed" - the body of the tag is included if wiki does <i>not</i> allow identities to be asserted using cookies.</li>
+ * <li>"containerAuth"        - the body of the tag is included if the user is validated through the container.</li>
+ * <li>"customAuth"           - the body of the tag is included if the user is validated through our own authentication.</li>
+ * <li>"known"                - if the user is not anonymous</li>
+ * <li>"notAuthenticated"     - the body of the tag is included if the user is not yet authenticated.</li>
  * </ul>
  *
  *  If the old "exists" -argument is used, it corresponds as follows:
  *  <p>
  *  <tt>exists="true" ==> status="known"<br>
  *  <tt>exists="false" ==> status="unknown"<br>
+ *  </p>
  *
  *  It is NOT a good idea to use BOTH of the arguments.
  *
@@ -120,17 +106,17 @@ public class UserCheckTag extends WikiTagBase {
         if( m_status != null ) {
             switch( m_status ) {
             case ANONYMOUS:
-                if( status.equals( WikiSession.ANONYMOUS ) ) {
+                if( status.equals( Session.ANONYMOUS ) ) {
                     return EVAL_BODY_INCLUDE;
                 }
                 break;
             case AUTHENTICATED:
-                if( status.equals( WikiSession.AUTHENTICATED ) ) {
+                if( status.equals( Session.AUTHENTICATED ) ) {
                     return EVAL_BODY_INCLUDE;
                 }
                 break;
             case ASSERTED:
-                if( status.equals( WikiSession.ASSERTED ) ) {
+                if( status.equals( Session.ASSERTED ) ) {
                     return EVAL_BODY_INCLUDE;
                 }
                 break;
@@ -160,7 +146,7 @@ public class UserCheckTag extends WikiTagBase {
                 }
                 return SKIP_BODY;
             case NOT_AUTHENTICATED:
-                if( !status.equals( WikiSession.AUTHENTICATED ) ) {
+                if( !status.equals( Session.AUTHENTICATED ) ) {
                     return EVAL_BODY_INCLUDE;
                 }
                 break;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/UserProfileTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/UserProfileTag.java
index ab752d2..f019c85 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/UserProfileTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/UserProfileTag.java
@@ -163,8 +163,8 @@ public class UserProfileTag extends WikiTagBase {
 
     /**
      * Returns a sorted list of the {@link org.apache.wiki.auth.authorize.Group} objects a user possesses
-     * in his or her WikiSession. The result is computed by consulting
-     * {@link org.apache.wiki.WikiSession#getRoles()}
+     * in his or her Session. The result is computed by consulting
+     * {@link org.apache.wiki.api.core.Session#getRoles()}
      * and extracting those that are of type Group.
      * @return the list of groups, sorted by name
      */
@@ -198,8 +198,8 @@ public class UserProfileTag extends WikiTagBase {
 
     /**
      * Returns a sorted list of the {@link org.apache.wiki.auth.authorize.Role} objects a user possesses
-     * in his or her WikiSession. The result is computed by consulting
-     * {@link org.apache.wiki.WikiSession#getRoles()}
+     * in his or her Session. The result is computed by consulting
+     * {@link org.apache.wiki.api.core.Session#getRoles()}
      * and extracting those that are of type Role.
      * @return the list of roles, sorted by name
      */
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiRequestWrapper.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiRequestWrapper.java
index 5abfd26..64104ec 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiRequestWrapper.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiRequestWrapper.java
@@ -18,8 +18,8 @@
  */
 package org.apache.wiki.ui;
 
-import org.apache.wiki.WikiSession;
 import org.apache.wiki.api.core.Engine;
+import org.apache.wiki.api.core.Session;
 import org.apache.wiki.auth.SessionMonitor;
 import org.apache.wiki.auth.authorize.Role;
 
@@ -35,7 +35,7 @@ import java.security.Principal;
  */
 public class WikiRequestWrapper extends HttpServletRequestWrapper {
 
-    private final WikiSession m_session;
+    private final Session m_session;
 
     /**
      * Constructs a new wrapped request.
@@ -46,17 +46,18 @@ public class WikiRequestWrapper extends HttpServletRequestWrapper {
     public WikiRequestWrapper( final Engine engine, final HttpServletRequest request ) {
         super( request );
 
-        // Get and stash a reference to the current WikiSession
+        // Get and stash a reference to the current Session
         m_session = SessionMonitor.getInstance( engine ).find( request.getSession() );
     }
 
     /**
      * Returns the remote user for the HTTP request, taking into account both container and JSPWiki custom authentication status.
      * Specifically, if the wrapped request contains a remote user, this method returns that remote user. Otherwise, if the user's
-     * WikiSession is an authenticated session (that is, {@link WikiSession#isAuthenticated()} returns <code>true</code>,
-     * this method returns the name of the principal returned by {@link WikiSession#getLoginPrincipal()}.
+     * Session is an authenticated session (that is, {@link Session#isAuthenticated()} returns <code>true</code>,
+     * this method returns the name of the principal returned by {@link Session#getLoginPrincipal()}.
      */
-    @Override public String getRemoteUser() {
+    @Override
+    public String getRemoteUser() {
         if( super.getRemoteUser() != null ) {
             return super.getRemoteUser();
         }
@@ -70,10 +71,11 @@ public class WikiRequestWrapper extends HttpServletRequestWrapper {
     /**
      * Returns the user principal for the HTTP request, taking into account both container and JSPWiki custom authentication status.
      * Specifically, if the wrapped request contains a user principal, this method returns that principal. Otherwise, if the user's
-     * WikiSession is an authenticated session (that is, {@link WikiSession#isAuthenticated()} returns
-     * <code>true</code>, this method returns the value of {@link WikiSession#getLoginPrincipal()}.
+     * Session is an authenticated session (that is, {@link Session#isAuthenticated()} returns
+     * <code>true</code>, this method returns the value of {@link Session#getLoginPrincipal()}.
      */
-    @Override public Principal getUserPrincipal() {
+    @Override
+    public Principal getUserPrincipal() {
         if( super.getUserPrincipal() != null ) {
             return super.getUserPrincipal();
         }
@@ -88,9 +90,10 @@ public class WikiRequestWrapper extends HttpServletRequestWrapper {
      * Determines whether the current user possesses a supplied role, taking into account both container and JSPWIki custom authentication
      * status. Specifically, if the wrapped request shows that the user possesses the role, this method returns <code>true</code>. If not,
      * this method iterates through the built-in Role objects (<em>e.g.</em>, ANONYMOUS, ASSERTED, AUTHENTICATED) returned by
-     * {@link WikiSession#getRoles()} and checks to see if any of these principals' names match the supplied role.
+     * {@link Session#getRoles()} and checks to see if any of these principals' names match the supplied role.
      */
-    @Override public boolean isUserInRole( final String role ) {
+    @Override
+    public boolean isUserInRole( final String role ) {
         final boolean hasContainerRole = super.isUserInRole(role);
         if( hasContainerRole ) {
             return true;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiServletFilter.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiServletFilter.java
index 39ff442..9b98604 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiServletFilter.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiServletFilter.java
@@ -22,8 +22,8 @@ import org.apache.log4j.Logger;
 import org.apache.log4j.NDC;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
-import org.apache.wiki.WikiSession;
 import org.apache.wiki.api.core.Engine;
+import org.apache.wiki.api.core.Session;
 import org.apache.wiki.auth.AuthenticationManager;
 import org.apache.wiki.auth.SessionMonitor;
 import org.apache.wiki.auth.WikiSecurityException;
@@ -42,7 +42,7 @@ import java.io.PrintWriter;
 
 /**
  * Filter that verifies that the {@link org.apache.wiki.api.core.Engine} is running, and sets the authentication status for the user's
- * WikiSession. Each HTTP request processed by this filter is wrapped by a {@link WikiRequestWrapper}. The wrapper's primary responsibility
+ * Session. Each HTTP request processed by this filter is wrapped by a {@link WikiRequestWrapper}. The wrapper's primary responsibility
  * is to return the correct <code>userPrincipal</code> and <code>remoteUser</code> for authenticated JSPWiki users (whether authenticated
  * by container or by JSPWiki's custom system). The wrapper's other responsibility is to incorporate JSPWiki built-in roles
  * into the role-checking algorithm for {@link  HttpServletRequest#isUserInRole(String)}. Just before the request is wrapped, the method
@@ -68,7 +68,8 @@ public class WikiServletFilter implements Filter {
      * @param config The FilterConfig.
      * @throws ServletException If a Engine cannot be started.
      */
-    @Override public void init( final FilterConfig config ) throws ServletException {
+    @Override
+    public void init( final FilterConfig config ) throws ServletException {
         final ServletContext context = config.getServletContext();
 
         // TODO REMOVEME when resolving JSPWIKI-129
@@ -82,12 +83,13 @@ public class WikiServletFilter implements Filter {
     /**
      * Destroys the WikiServletFilter.
      */
-    @Override public void destroy() {
+    @Override
+    public void destroy() {
     }
 
     /**
     * Checks that the Engine is running ok, wraps the current HTTP request, and sets the correct authentication state for the users's
-    * WikiSession. First, the method {@link org.apache.wiki.auth.AuthenticationManager#login(HttpServletRequest)}
+    * Session. First, the method {@link org.apache.wiki.auth.AuthenticationManager#login(HttpServletRequest)}
     * executes, which sets the authentication state. Then, the request is wrapped with a
     * {@link WikiRequestWrapper}.
     * @param request the current HTTP request object
@@ -96,7 +98,8 @@ public class WikiServletFilter implements Filter {
     * @throws ServletException if {@link org.apache.wiki.auth.AuthenticationManager#login(HttpServletRequest)} fails for any reason
     * @throws IOException If writing to the servlet response fails. 
     */
-    @Override public void doFilter( final ServletRequest request, final ServletResponse response, final FilterChain chain ) throws IOException, ServletException {
+    @Override
+    public void doFilter( final ServletRequest request, final ServletResponse response, final FilterChain chain ) throws IOException, ServletException {
         //  Sanity check; it might be true in some conditions, but we need to know where.
         if( chain == null ) {
             throw new ServletException("FilterChain is null, even if it should not be.  Please report this to the jspwiki development team.");
@@ -125,10 +128,10 @@ public class WikiServletFilter implements Filter {
         httpRequest.setCharacterEncoding( m_engine.getContentEncoding().displayName() );
         
         if ( !isWrapped( request ) ) {
-            // Prepare the WikiSession
+            // Prepare the Session
             try {
                 m_engine.getManager( AuthenticationManager.class ).login( httpRequest );
-                final WikiSession wikiSession = SessionMonitor.getInstance( m_engine ).find( httpRequest.getSession() );
+                final Session wikiSession = SessionMonitor.getInstance( m_engine ).find( httpRequest.getSession() );
                 httpRequest = new WikiRequestWrapper( m_engine, httpRequest );
                 if ( log.isDebugEnabled() ) {
                     log.debug( "Executed security filters for user=" + wikiSession.getLoginPrincipal().getName() + ", path=" + httpRequest.getRequestURI() );
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/SearchManagerBean.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/SearchManagerBean.java
index 98b6988..6ec3f71 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/SearchManagerBean.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/SearchManagerBean.java
@@ -33,46 +33,44 @@ import java.util.Collection;
 
 
 /**
- *  The SearchManagerBean is a simple AdminBean interface
- *  to the SearchManager.  It currently can be used to force
- *  a reload of all of the pages.
+ * The SearchManagerBean is a simple AdminBean interface to the SearchManager.  It currently can be used to force a reload of all of the pages.
  *
  *  @since 2.6
  */
-public class SearchManagerBean extends SimpleAdminBean
-{
-    private static final String PROGRESS_ID = "searchmanagerbean.reindexer";
+public class SearchManagerBean extends SimpleAdminBean {
 
+    private static final String PROGRESS_ID = "searchmanagerbean.reindexer";
     private static final String[] METHODS = { "reload" };
 
     // private static Logger log = Logger.getLogger( SearchManagerBean.class );
 
     private WikiBackgroundThread m_updater;
 
-    public SearchManagerBean( final Engine engine) throws NotCompliantMBeanException
-    {
+    public SearchManagerBean( final Engine engine ) throws NotCompliantMBeanException {
         super();
-        initialize(engine);
+        initialize( engine );
     }
 
-    @Override public String[] getAttributeNames()
+    @Override
+    public String[] getAttributeNames()
     {
         return new String[0];
     }
 
-    @Override public String[] getMethodNames()
+    @Override
+    public String[] getMethodNames()
     {
         return METHODS;
     }
 
-    @Override public String getTitle()
+    @Override
+    public String getTitle()
     {
         return "Search manager";
     }
 
     /**
-     *  Starts a background thread which goes through all the pages and adds them
-     *  to the reindex queue.
+     *  Starts a background thread which goes through all the pages and adds them to the reindex queue.
      *  <p>
      *  This method prevents itself from being called twice.
      */
@@ -83,13 +81,15 @@ public class SearchManagerBean extends SimpleAdminBean
                 int m_count;
                 int m_max;
 
-                @Override public void startupTask() throws Exception {
+                @Override
+                public void startupTask() throws Exception {
                     super.startupTask();
 
                     setName( "Reindexer started" );
                 }
 
-                @Override public void backgroundTask() throws Exception {
+                @Override
+                public void backgroundTask() throws Exception {
                     final Collection< WikiPage > allPages = m_engine.getManager( PageManager.class ).getAllPages();
 
                     final SearchManager mgr = m_engine.getManager( SearchManager.class );
@@ -97,11 +97,11 @@ public class SearchManagerBean extends SimpleAdminBean
 
                     final ProgressItem pi = new ProgressItem() {
 
-                        @Override public int getProgress() {
+                        @Override
+                        public int getProgress() {
                             return 100 * m_count / m_max;
                         }
                     };
-
                     m_engine.getManager( ProgressManager.class ).startProgress( pi, PROGRESS_ID );
 
                     for( final WikiPage page : allPages ) {
@@ -120,12 +120,13 @@ public class SearchManagerBean extends SimpleAdminBean
         }
     }
 
-    @Override public int getType()
-    {
+    @Override
+    public int getType() {
         return CORE;
     }
 
-    @Override public String doGet( final WikiContext context ) {
+    @Override
+    public String doGet( final WikiContext context ) {
         if( m_updater != null ) {
             return "Update already in progress ("+ context.getEngine().getManager( ProgressManager.class ).getProgress(PROGRESS_ID)+ "%)";
         }
@@ -134,7 +135,8 @@ public class SearchManagerBean extends SimpleAdminBean
                "<div class='description'>Forces JSPWiki search engine to reindex all pages.  Use this if you think some pages are not being found even if they should.</div>";
     }
 
-    @Override public String doPost( final WikiContext context ) {
+    @Override
+    public String doPost( final WikiContext context ) {
         final String val = context.getHttpParameter( "searchmanagerbean-reload" );
         if( val != null ) {
             reload();
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/UserBean.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/UserBean.java
index 23c94b3..3574ba1 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/UserBean.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/UserBean.java
@@ -57,13 +57,12 @@ public class UserBean extends SimpleAdminBean {
         final HttpServletRequest request = context.getHttpRequest();
         final Session session = context.getWikiSession();
         final UserManager mgr = context.getEngine().getManager( UserManager.class );
-
-        final String loginid   = request.getParameter("loginid");
-        final String loginname = request.getParameter("loginname");
-        final String fullname  = request.getParameter("fullname");
-        final String password  = request.getParameter("password");
-        final String password2 = request.getParameter("password2");
-        final String email     = request.getParameter("email");
+        final String loginid = request.getParameter( "loginid" );
+        final String loginname = request.getParameter( "loginname" );
+        final String fullname = request.getParameter( "fullname" );
+        final String password = request.getParameter( "password" );
+        final String password2 = request.getParameter( "password2" );
+        final String email = request.getParameter( "email" );
 
         if( request.getParameter( "action" ).equalsIgnoreCase( "remove" ) ) {
             try {
@@ -100,8 +99,9 @@ public class UserBean extends SimpleAdminBean {
 
         p.setEmail( email );
         p.setFullname( fullname );
-        if( password != null && password.length() > 0 )
+        if( password != null && password.length() > 0 ) {
             p.setPassword( password );
+        }
         p.setLoginName( loginname );
 
         try {
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java b/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java
index e83b1b5..980d01e 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java
@@ -378,7 +378,7 @@ public class TestEngine extends WikiEngine
     public void saveText( final String pageName, final String content ) throws WikiException {
         // Build new request and associate our admin session
         final MockHttpServletRequest request = newHttpRequest();
-        final WikiSession wikiSession = SessionMonitor.getInstance( this ).find( request.getSession() );
+        final Session wikiSession = SessionMonitor.getInstance( this ).find( request.getSession() );
         this.getAuthenticationManager().login( wikiSession, request, Users.ADMIN, Users.ADMIN_PASS );
 
         // Create page and wiki context
@@ -390,7 +390,7 @@ public class TestEngine extends WikiEngine
     public void saveTextAsJanne( final String pageName, final String content ) throws WikiException {
         // Build new request and associate our Janne session
         final MockHttpServletRequest request = newHttpRequest();
-        final WikiSession wikiSession = SessionMonitor.getInstance( this ).find( request.getSession() );
+        final Session wikiSession = SessionMonitor.getInstance( this ).find( request.getSession() );
         this.getAuthenticationManager().login( wikiSession, request, Users.JANNE, Users.JANNE_PASS );
 
         // Create page and wiki context


[jspwiki] 02/35: fix sonar issue

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git

commit 781f35ecc814858d3ed913cad97844ec527876f8
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Feb 28 23:41:28 2020 +0100

    fix sonar issue
---
 .../java/org/apache/wiki/filters/SpamFilter.java   | 42 ++++++++--------------
 1 file changed, 14 insertions(+), 28 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/filters/SpamFilter.java b/jspwiki-main/src/main/java/org/apache/wiki/filters/SpamFilter.java
index 109eb6f..12c42aa 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/filters/SpamFilter.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/filters/SpamFilter.java
@@ -71,6 +71,7 @@ import java.util.Properties;
 import java.util.Random;
 import java.util.StringTokenizer;
 import java.util.Vector;
+import java.util.concurrent.ThreadLocalRandom;
 
 
 /**
@@ -122,20 +123,18 @@ public class SpamFilter extends BasicPageFilter {
     private static final String LISTVAR = "spamwords";
     private static final String LISTIPVAR = "ips";
 
-    /** The filter property name for specifying the page which contains the list of spamwords.
-     *  Value is <tt>{@value}</tt>. */
+    private static final Random RANDOM = ThreadLocalRandom.current();
+
+    /** The filter property name for specifying the page which contains the list of spamwords. Value is <tt>{@value}</tt>. */
     public static final String  PROP_WORDLIST              = "wordlist";
 
-    /** The filter property name for specifying the page which contains the list of IPs to ban.
-     *  Value is <tt>{@value}</tt>. */
+    /** The filter property name for specifying the page which contains the list of IPs to ban. Value is <tt>{@value}</tt>. */
     public static final String  PROP_IPLIST                = "IPlist";
 
-    /** The filter property name for specifying the maximum page name length.
-     *  Value is <tt>{@value}</tt>. */
+    /** The filter property name for specifying the maximum page name length.  Value is <tt>{@value}</tt>. */
     public static final String  PROP_MAX_PAGENAME_LENGTH   = "maxpagenamelength";
 
-    /** The filter property name for the page to which you are directed if Herb rejects your
-     *  edit.  Value is <tt>{@value}</tt>. */
+    /** The filter property name for the page to which you are directed if Herb rejects your edit.  Value is <tt>{@value}</tt>. */
     public static final String  PROP_ERRORPAGE             = "errorpage";
     
     /** The filter property name for specifying how many changes is any given IP address
@@ -143,9 +142,7 @@ public class SpamFilter extends BasicPageFilter {
      */
     public static final String  PROP_PAGECHANGES           = "pagechangesinminute";
     
-    /** The filter property name for specifying how many similar changes are allowed
-     *  before a host is banned.  Value is <tt>{@value}</tt>.
-     */
+    /** The filter property name for specifying how many similar changes are allowed before a host is banned.  Value is <tt>{@value}</tt>. */
     public static final String  PROP_SIMILARCHANGES        = "similarchanges";
     
     /** The filter property name for specifying how long a host is banned.  Value is <tt>{@value}</tt>.*/
@@ -154,8 +151,7 @@ public class SpamFilter extends BasicPageFilter {
     /** The filter property name for the attachment containing the blacklist.  Value is <tt>{@value}</tt>.*/
     public static final String  PROP_BLACKLIST             = "blacklist";
     
-    /** The filter property name for specifying how many URLs can any given edit contain.  
-     *  Value is <tt>{@value}</tt> */
+    /** The filter property name for specifying how many URLs can any given edit contain. Value is <tt>{@value}</tt> */
     public static final String  PROP_MAXURLS               = "maxurls";
     
     /** The filter property name for specifying the Akismet API-key.  Value is <tt>{@value}</tt>. */
@@ -195,26 +191,19 @@ public class SpamFilter extends BasicPageFilter {
     private static  Logger  c_spamlog = Logger.getLogger( "SpamLog" );
     private static  Logger  log = Logger.getLogger( SpamFilter.class );
 
-
     private Vector<Host>    m_temporaryBanList = new Vector<>();
 
     private int             m_banTime = 60; // minutes
 
     private Vector<Host>    m_lastModifications = new Vector<>();
 
-    /**
-     *  How many times a single IP address can change a page per minute?
-     */
+    /** How many times a single IP address can change a page per minute? */
     private int             m_limitSinglePageChanges = 5;
 
-    /**
-     *  How many times can you add the exact same string to a page?
-     */
+    /** How many times can you add the exact same string to a page? */
     private int             m_limitSimilarChanges = 2;
 
-    /**
-     *  How many URLs can be added at maximum.
-     */
+    /** How many URLs can be added at maximum. */
     private int             m_maxUrls = 10;
 
     private Pattern         m_urlPattern;
@@ -227,9 +216,7 @@ public class SpamFilter extends BasicPageFilter {
     /** The limit at which we consider something to be spam. */
     private int             m_scoreLimit = 1;
 
-    /**
-     * If set to true, will ignore anyone who is in Authenticated role.
-     */
+    /** If set to true, will ignore anyone who is in Authenticated role. */
     private boolean         m_ignoreAuthenticated = false;
 
     private boolean         m_stopAtFirstMatch = true;
@@ -892,9 +879,8 @@ public class SpamFilter extends BasicPageFilter {
      */
     private static String getUniqueID() {
         final StringBuilder sb = new StringBuilder();
-        final Random rand = new Random();
         for( int i = 0; i < 6; i++ ) {
-            final char x = ( char )( 'A' + rand.nextInt( 26 ) );
+            final char x = ( char )( 'A' + RANDOM.nextInt( 26 ) );
             sb.append( x );
         }
 


[jspwiki] 32/35: provide boolean isImageInlining and inlineImagePatterns to LinkParsingOperations#isImageLink(..)

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git

commit 943704d1a0cb475ab0ec0c1506574dc1a0578915
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Mar 6 17:50:07 2020 +0100

    provide boolean isImageInlining and inlineImagePatterns to LinkParsingOperations#isImageLink(..)
    
    in order to break a package cycle between o.a.w.render and o.a.w.parser
---
 .../apache/wiki/parser/JSPWikiMarkupParser.java    | 169 +++++++--------------
 .../apache/wiki/parser/LinkParsingOperations.java  |  23 +--
 .../wiki/markdown/MarkdownForJSPWikiExtension.java |  15 +-
 .../ExternalLinkAttributeProviderState.java        |  15 +-
 .../InterWikiLinkAttributeProviderState.java       |  14 +-
 .../JSPWikiLinkAttributeProvider.java              |  24 ++-
 .../JSPWikiLinkAttributeProviderFactory.java       |  16 +-
 .../LocalLinkAttributeProviderState.java           |  14 +-
 .../ExternalLinkNodePostProcessorState.java        |  13 +-
 .../InterWikiLinkNodePostProcessorState.java       |  13 +-
 .../JSPWikiLinkNodePostProcessor.java              |  20 ++-
 .../JSPWikiNodePostProcessorFactory.java           |  14 +-
 .../LocalLinkNodePostProcessorState.java           |  13 +-
 .../wiki/parser/markdown/MarkdownDocument.java     |   6 +-
 .../wiki/parser/markdown/MarkdownParser.java       |   2 +-
 .../wiki/render/markdown/MarkdownRenderer.java     |  17 ++-
 16 files changed, 218 insertions(+), 170 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/parser/JSPWikiMarkupParser.java b/jspwiki-main/src/main/java/org/apache/wiki/parser/JSPWikiMarkupParser.java
index 23eee96..e2a18cc 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/parser/JSPWikiMarkupParser.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/parser/JSPWikiMarkupParser.java
@@ -958,32 +958,26 @@ public class JSPWikiMarkupParser extends MarkupParser {
      * @param url
      * @return An anchor Element containing the link.
      */
-    private Element makeDirectURILink( String url )
-    {
+    private Element makeDirectURILink( String url ) {
         final Element result;
         String last = null;
 
-        if( url.endsWith(",") || url.endsWith(".") )
-        {
-            last = url.substring( url.length()-1 );
-            url  = url.substring( 0, url.length()-1 );
+        if( url.endsWith( "," ) || url.endsWith( "." ) ) {
+            last = url.substring( url.length() - 1 );
+            url = url.substring( 0, url.length() - 1 );
         }
 
         callMutatorChain( m_externalLinkMutatorChain, url );
 
-        if( m_linkParsingOperations.isImageLink( url ) )
-        {
-            result = handleImageLink( StringUtils.replace(url,"&amp;","&"), url, false );
-        }
-        else
-        {
-            result = makeLink( EXTERNAL, StringUtils.replace(url,"&amp;","&"), url, null, null );
+        if( m_linkParsingOperations.isImageLink( url, isImageInlining(), getInlineImagePatterns() ) ) {
+            result = handleImageLink( StringUtils.replace( url, "&amp;", "&" ), url, false );
+        } else {
+            result = makeLink( EXTERNAL, StringUtils.replace( url, "&amp;", "&" ), url, null, null );
             addElement( outlinkImage() );
         }
 
-        if( last != null )
-        {
-            m_plainTextBuf.append(last);
+        if( last != null ) {
+            m_plainTextBuf.append( last );
         }
 
         return result;
@@ -1101,9 +1095,8 @@ public class JSPWikiMarkupParser extends MarkupParser {
      *  very useful if you want to emit HTML directly into the stream.
      *
      */
-    private void disableOutputEscaping()
-    {
-        addElement( new ProcessingInstruction(Result.PI_DISABLE_OUTPUT_ESCAPING, "") );
+    private void disableOutputEscaping() {
+        addElement( new ProcessingInstruction( Result.PI_DISABLE_OUTPUT_ESCAPING, "" ) );
     }
 
     /**
@@ -1111,7 +1104,7 @@ public class JSPWikiMarkupParser extends MarkupParser {
      */
     private Element handleHyperlinks( String linktext, final int pos ) {
         final ResourceBundle rb = Preferences.getBundle( m_context, InternationalizationManager.CORE_BUNDLE );
-        final StringBuilder sb = new StringBuilder(linktext.length()+80);
+        final StringBuilder sb = new StringBuilder( linktext.length() + 80 );
 
         if( m_linkParsingOperations.isAccessRule( linktext ) ) {
             return handleAccessRule( linktext );
@@ -1121,28 +1114,19 @@ public class JSPWikiMarkupParser extends MarkupParser {
             return handleMetadata( linktext );
         }
 
-        if( m_linkParsingOperations.isPluginLink( linktext ) )
-        {
-            try
-            {
+        if( m_linkParsingOperations.isPluginLink( linktext ) ) {
+            try {
                 final PluginContent pluginContent = PluginContent.parsePluginLine( m_context, linktext, pos );
-                //
-                //  This might sometimes fail, especially if there is something which looks
-                //  like a plugin invocation but is really not.
-                //
-                if( pluginContent != null )
-                {
-                    addElement( pluginContent );
 
+                // This might sometimes fail, especially if there is something which looks like a plugin invocation but is really not.
+                if( pluginContent != null ) {
+                    addElement( pluginContent );
                     pluginContent.executeParse( m_context );
                 }
-            }
-            catch( final PluginException e )
-            {
+            } catch( final PluginException e ) {
                 log.info( m_context.getRealPage().getWiki() + " : " + m_context.getRealPage().getName() + " - Failed to insert plugin: " + e.getMessage() );
                 //log.info( "Root cause:",e.getRootThrowable() );
-                if( !m_wysiwygEditorMode )
-                {
+                if( !m_wysiwygEditorMode ) {
                     final ResourceBundle rbPlugin = Preferences.getBundle( m_context, WikiPlugin.CORE_PLUGINS_RESOURCEBUNDLE );
                     return addElement( makeError( MessageFormat.format( rbPlugin.getString( "plugin.error.insertionfailed" ),
                     		                                            m_context.getRealPage().getWiki(),
@@ -1154,10 +1138,9 @@ public class JSPWikiMarkupParser extends MarkupParser {
             return m_currentElement;
         }
 
-        try
-        {
-            final LinkParser.Link link = m_linkParser.parse(linktext);
-            linktext       = link.getText();
+        try {
+            final LinkParser.Link link = m_linkParser.parse( linktext );
+            linktext = link.getText();
             String linkref = link.getReference();
 
             //
@@ -1167,33 +1150,23 @@ public class JSPWikiMarkupParser extends MarkupParser {
             //
             //  In many cases these are the same.  [linktext|linkref].
             //
-            if( m_linkParsingOperations.isVariableLink( linktext ) )
-            {
-                final Content el = new VariableContent(linktext);
+            if( m_linkParsingOperations.isVariableLink( linktext ) ) {
+                final Content el = new VariableContent( linktext );
 
                 addElement( el );
-            }
-            else if( m_linkParsingOperations.isExternalLink( linkref ) )
-            {
+            } else if( m_linkParsingOperations.isExternalLink( linkref ) ) {
                 // It's an external link, out of this Wiki
 
                 callMutatorChain( m_externalLinkMutatorChain, linkref );
 
-                if( m_linkParsingOperations.isImageLink( linkref ) )
-                {
+                if( m_linkParsingOperations.isImageLink( linkref, isImageInlining(), getInlineImagePatterns() ) ) {
                     handleImageLink( linkref, linktext, link.hasReference() );
-                }
-                else
-                {
+                } else {
                     makeLink( EXTERNAL, linkref, linktext, null, link.getAttributes() );
                     addElement( outlinkImage() );
                 }
-            }
-            else if( link.isInterwikiLink() )
-            {
-                // It's an interwiki link
-                // InterWiki links also get added to external link chain
-                // after the links have been resolved.
+            } else if( link.isInterwikiLink() ) {
+                // It's an interwiki link; InterWiki links also get added to external link chain after the links have been resolved.
 
                 // FIXME: There is an interesting issue here:  We probably should
                 //        URLEncode the wikiPage, but we can't since some of the
@@ -1202,81 +1175,57 @@ public class JSPWikiMarkupParser extends MarkupParser {
                 //        is using, so you'll have to write the entire name as it appears
                 //        in the URL.  Bugger.
 
-                final String extWiki  = link.getExternalWiki();
+                final String extWiki = link.getExternalWiki();
                 final String wikiPage = link.getExternalWikiPage();
 
-                if( m_wysiwygEditorMode )
-                {
+                if( m_wysiwygEditorMode ) {
                     makeLink( INTERWIKI, extWiki + ":" + wikiPage, linktext, null, link.getAttributes() );
-                }
-                else
-                {
+                } else {
                     String urlReference = m_engine.getInterWikiURL( extWiki );
 
-                    if( urlReference != null )
-                    {
+                    if( urlReference != null ) {
                         urlReference = TextUtil.replaceString( urlReference, "%s", wikiPage );
                         urlReference = callMutatorChain( m_externalLinkMutatorChain, urlReference );
 
-                        if( m_linkParsingOperations.isImageLink(urlReference) )
-                        {
+                        if( m_linkParsingOperations.isImageLink( urlReference, isImageInlining(), getInlineImagePatterns() ) ) {
                             handleImageLink( urlReference, linktext, link.hasReference() );
-                        }
-                        else
-                        {
+                        } else {
                             makeLink( INTERWIKI, urlReference, linktext, null, link.getAttributes() );
                         }
 
-                        if( m_linkParsingOperations.isExternalLink(urlReference) )
-                        {
+                        if( m_linkParsingOperations.isExternalLink( urlReference ) ) {
                             addElement( outlinkImage() );
                         }
-                    }
-                    else
-                    {
-                        final Object[] args = { escapeHTMLEntities(extWiki) };
+                    } else {
+                        final Object[] args = { escapeHTMLEntities( extWiki ) };
 
                         addElement( makeError( MessageFormat.format( rb.getString( "markupparser.error.nointerwikiref" ), args ) ) );
                     }
                 }
-            }
-            else if( linkref.startsWith("#") )
-            {
+            } else if( linkref.startsWith( "#" ) ) {
                 // It defines a local footnote
                 makeLink( LOCAL, linkref, linktext, null, link.getAttributes() );
-            }
-            else if( TextUtil.isNumber( linkref ) )
-            {
+            } else if( TextUtil.isNumber( linkref ) ) {
                 // It defines a reference to a local footnote
                 makeLink( LOCALREF, linkref, linktext, null, link.getAttributes() );
-            }
-            else
-            {
-                int hashMark = -1;
+            } else {
+                final int hashMark;
 
-                //
-                //  Internal wiki link, but is it an attachment link?
-                //
+                // Internal wiki link, but is it an attachment link?
                 String attachment = m_engine.getManager( AttachmentManager.class ).getAttachmentInfoName( m_context, linkref );
-                if( attachment != null )
-                {
+                if( attachment != null ) {
                     callMutatorChain( m_attachmentLinkMutatorChain, attachment );
 
-                    if( m_linkParsingOperations.isImageLink( linkref ) )
-                    {
+                    if( m_linkParsingOperations.isImageLink( linkref, isImageInlining(), getInlineImagePatterns() ) ) {
                         attachment = m_context.getURL( WikiContext.ATTACH, attachment );
                         sb.append( handleImageLink( attachment, linktext, link.hasReference() ) );
-                    }
-                    else
-                    {
+                    } else {
                         makeLink( ATTACHMENT, attachment, linktext, null, link.getAttributes() );
                     }
-                }
-                else if( (hashMark = linkref.indexOf('#')) != -1 )
-                {
+                } else if( ( hashMark = linkref.indexOf( '#' ) ) != -1 ) {
                     // It's an internal Wiki link, but to a named section
 
-                    final String namedSection = linkref.substring( hashMark+1 );
+                    final String namedSection = linkref.substring( hashMark + 1 );
                     linkref = linkref.substring( 0, hashMark );
 
                     linkref = MarkupParser.cleanLink( linkref );
@@ -1285,15 +1234,13 @@ public class JSPWikiMarkupParser extends MarkupParser {
 
                     final String matchedLink = m_linkParsingOperations.linkIfExists( linkref );
                     if( matchedLink != null ) {
-                        String sectref = "section-"+m_engine.encodeName(matchedLink+"-"+wikifyLink(namedSection));
-                        sectref = sectref.replace('%', '_');
+                        String sectref = "section-" + m_engine.encodeName( matchedLink + "-" + wikifyLink( namedSection ) );
+                        sectref = sectref.replace( '%', '_' );
                         makeLink( READ, matchedLink, linktext, sectref, link.getAttributes() );
                     } else {
                         makeLink( EDIT, linkref, linktext, null, link.getAttributes() );
                     }
-                }
-                else
-                {
+                } else {
                     // It's an internal Wiki link
                     linkref = MarkupParser.cleanLink( linkref );
 
@@ -1307,14 +1254,12 @@ public class JSPWikiMarkupParser extends MarkupParser {
                     }
                 }
             }
-        }
-        catch( final ParseException e )
-        {
-            log.info("Parser failure: ",e);
-            final Object[] args = { e.getMessage() };
-            addElement( makeError( MessageFormat.format( rb.getString( "markupparser.error.parserfailure" ), args ) ) );
-        }
 
+    } catch( final ParseException e ) {
+        log.info( "Parser failure: ", e );
+        final Object[] args = { e.getMessage() };
+        addElement( makeError( MessageFormat.format( rb.getString( "markupparser.error.parserfailure" ), args ) ) );
+    }
         return m_currentElement;
     }
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/parser/LinkParsingOperations.java b/jspwiki-main/src/main/java/org/apache/wiki/parser/LinkParsingOperations.java
index 8102e73..51263ef 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/parser/LinkParsingOperations.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/parser/LinkParsingOperations.java
@@ -23,7 +23,6 @@ import org.apache.oro.text.regex.Pattern;
 import org.apache.oro.text.regex.Perl5Matcher;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.api.exceptions.ProviderException;
-import org.apache.wiki.render.RenderingManager;
 
 import java.util.Arrays;
 import java.util.Comparator;
@@ -41,13 +40,11 @@ public class LinkParsingOperations {
     private final WikiContext wikiContext;
 
     /**
-     *  This list contains all IANA registered URI protocol
-     *  types as of September 2004 + a few well-known extra types.
+     *  This list contains all IANA registered URI protocol types as of September 2004 + a few well-known extra types.
      *
      *  JSPWiki recognises all of them as external links.
      *
-     *  This array is sorted during class load, so you can just dump
-     *  here whatever you want in whatever order you want.
+     *  This array is sorted during class load, so you can just dump here whatever you want in whatever order you want.
      */
     static final String[] EXTERNAL_LINKS = {
         "http:", "ftp:", "https:", "mailto:",
@@ -83,8 +80,7 @@ public class LinkParsingOperations {
     /**
      *  Returns true if the link is really command to insert a plugin.
      *  <P>
-     *  Currently we just check if the link starts with "{INSERT",
-     *  or just plain "{" but not "{$".
+     *  Currently we just check if the link starts with "{INSERT", or just plain "{" but not "{$".
      *
      *  @param link Link text, i.e. the contents of text between [].
      *  @return True, if this link seems to be a command to insert a plugin here.
@@ -135,8 +131,7 @@ public class LinkParsingOperations {
     }
 
     /**
-     * Figures out if a link is an off-site link.  This recognizes
-     * the most common protocols by checking how it starts.
+     * Figures out if a link is an off-site link.  This recognizes the most common protocols by checking how it starts.
      *
      * @param page The link to check.
      * @return true, if this is a link outside of this wiki.
@@ -149,15 +144,11 @@ public class LinkParsingOperations {
     }
 
     /**
-     *  Matches the given link to the list of image name patterns to
-     *  determine whether it should be treated as an inline image or not.
+     *  Matches the given link to the list of image name patterns to determine whether it should be treated as an inline image or not.
      */
-    public boolean isImageLink( String link ) {
-        if( wikiContext.getEngine().getManager( RenderingManager.class ).getParser( wikiContext, link ).isImageInlining() ) {
+    public boolean isImageLink( String link, final boolean isImageInlining, final List< Pattern > inlineImagePatterns ) {
+        if( isImageInlining ) {
             link = link.toLowerCase();
-            final List< Pattern > inlineImagePatterns = wikiContext.getEngine().getManager( RenderingManager.class )
-            	                                                   .getParser( wikiContext, link ).getInlineImagePatterns();
-
             for( final Pattern p : inlineImagePatterns ) {
                 if( new Perl5Matcher().matches( link, p ) ) {
                     return true;
diff --git a/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/MarkdownForJSPWikiExtension.java b/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/MarkdownForJSPWikiExtension.java
index b7cec13..cc93a62 100755
--- a/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/MarkdownForJSPWikiExtension.java
+++ b/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/MarkdownForJSPWikiExtension.java
@@ -21,11 +21,14 @@ package org.apache.wiki.markdown;
 import com.vladsch.flexmark.html.HtmlRenderer;
 import com.vladsch.flexmark.parser.Parser;
 import com.vladsch.flexmark.util.data.MutableDataHolder;
+import org.apache.oro.text.regex.Pattern;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.markdown.extensions.jspwikilinks.attributeprovider.JSPWikiLinkAttributeProviderFactory;
 import org.apache.wiki.markdown.extensions.jspwikilinks.postprocessor.JSPWikiNodePostProcessorFactory;
 import org.apache.wiki.markdown.renderer.JSPWikiNodeRendererFactory;
 
+import java.util.List;
+
 
 /**
  * Flexmark entry point to bootstrap JSPWiki extensions.
@@ -33,9 +36,15 @@ import org.apache.wiki.markdown.renderer.JSPWikiNodeRendererFactory;
 public class MarkdownForJSPWikiExtension implements Parser.ParserExtension, HtmlRenderer.HtmlRendererExtension {
 
 	private final WikiContext context;
+	private final boolean isImageInlining;
+	private final List< Pattern > inlineImagePatterns;
 
-	public MarkdownForJSPWikiExtension( final WikiContext context ) {
+	public MarkdownForJSPWikiExtension( final WikiContext context,
+										final boolean isImageInlining,
+										final List< Pattern > inlineImagePatterns ) {
 		this.context = context;
+		this.isImageInlining = isImageInlining;
+		this.inlineImagePatterns = inlineImagePatterns;
 	}
 
 	/**
@@ -58,7 +67,7 @@ public class MarkdownForJSPWikiExtension implements Parser.ParserExtension, Html
 	@Override
 	public void extend( final HtmlRenderer.Builder rendererBuilder, final String rendererType ) {
 	    rendererBuilder.nodeRendererFactory( new JSPWikiNodeRendererFactory( context ) );
-        rendererBuilder.attributeProviderFactory( new JSPWikiLinkAttributeProviderFactory( context ) );
+        rendererBuilder.attributeProviderFactory( new JSPWikiLinkAttributeProviderFactory( context, isImageInlining, inlineImagePatterns ) );
 	}
 
     /**
@@ -66,7 +75,7 @@ public class MarkdownForJSPWikiExtension implements Parser.ParserExtension, Html
 	 */
 	@Override
 	public void extend( final Parser.Builder parserBuilder ) {
-	    parserBuilder.postProcessorFactory( new JSPWikiNodePostProcessorFactory( context, parserBuilder ) );
+	    parserBuilder.postProcessorFactory( new JSPWikiNodePostProcessorFactory( context, parserBuilder, isImageInlining, inlineImagePatterns ) );
 	}
 
 }
diff --git a/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/attributeprovider/ExternalLinkAttributeProviderState.java b/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/attributeprovider/ExternalLinkAttributeProviderState.java
index 9add6de..76dc98e 100755
--- a/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/attributeprovider/ExternalLinkAttributeProviderState.java
+++ b/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/attributeprovider/ExternalLinkAttributeProviderState.java
@@ -19,12 +19,14 @@
 package org.apache.wiki.markdown.extensions.jspwikilinks.attributeprovider;
 
 import com.vladsch.flexmark.util.ast.Node;
+import com.vladsch.flexmark.util.html.Attributes;
+import org.apache.oro.text.regex.Pattern;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.markdown.nodes.JSPWikiLink;
 import org.apache.wiki.parser.LinkParsingOperations;
 import org.apache.wiki.parser.MarkupParser;
 
-import com.vladsch.flexmark.util.html.Attributes;
+import java.util.List;
 
 
 /**
@@ -36,11 +38,18 @@ public class ExternalLinkAttributeProviderState implements NodeAttributeProvider
     private final boolean m_useRelNofollow;
     private final WikiContext wikiContext;
     private final LinkParsingOperations linkOperations;
+    private final boolean isImageInlining;
+    private final List< Pattern > inlineImagePatterns;
 
-    public ExternalLinkAttributeProviderState( final WikiContext wikiContext, final boolean hasRef ) {
+    public ExternalLinkAttributeProviderState( final WikiContext wikiContext,
+                                               final boolean hasRef,
+                                               final boolean isImageInlining,
+                                               final List< Pattern > inlineImagePatterns ) {
         this.hasRef = hasRef;
         this.wikiContext = wikiContext;
         this.linkOperations = new LinkParsingOperations( wikiContext );
+        this.isImageInlining = isImageInlining;
+        this.inlineImagePatterns = inlineImagePatterns;
         this.m_useRelNofollow = wikiContext.getBooleanWikiProperty( MarkupParser.PROP_USERELNOFOLLOW, false );
     }
 
@@ -51,7 +60,7 @@ public class ExternalLinkAttributeProviderState implements NodeAttributeProvider
      */
     @Override
     public void setAttributes( final Attributes attributes, final JSPWikiLink link ) {
-        if( linkOperations.isImageLink( link.getUrl().toString() ) ) {
+        if( linkOperations.isImageLink( link.getUrl().toString(), isImageInlining, inlineImagePatterns ) ) {
             new ImageLinkAttributeProviderState( wikiContext, link.getText().toString(), hasRef ).setAttributes( attributes, link );
         } else {
             attributes.replaceValue( "class", MarkupParser.CLASS_EXTERNAL );
diff --git a/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/attributeprovider/InterWikiLinkAttributeProviderState.java b/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/attributeprovider/InterWikiLinkAttributeProviderState.java
index 4de92d6..7138720 100755
--- a/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/attributeprovider/InterWikiLinkAttributeProviderState.java
+++ b/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/attributeprovider/InterWikiLinkAttributeProviderState.java
@@ -21,12 +21,15 @@ package org.apache.wiki.markdown.extensions.jspwikilinks.attributeprovider;
 import com.vladsch.flexmark.ast.Link;
 import com.vladsch.flexmark.util.ast.Node;
 import com.vladsch.flexmark.util.html.Attributes;
+import org.apache.oro.text.regex.Pattern;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.markdown.nodes.JSPWikiLink;
 import org.apache.wiki.parser.LinkParsingOperations;
 import org.apache.wiki.parser.MarkupParser;
 import org.apache.wiki.util.TextUtil;
 
+import java.util.List;
+
 
 /**
  * {@link NodeAttributeProviderState} which sets the attributes for interwiki links.
@@ -37,11 +40,18 @@ public class InterWikiLinkAttributeProviderState implements NodeAttributeProvide
     private final boolean m_wysiwygEditorMode;
     private final WikiContext wikiContext;
     private final LinkParsingOperations linkOperations;
+    private final boolean isImageInlining;
+    private final List< Pattern > inlineImagePatterns;
 
-    public InterWikiLinkAttributeProviderState( final WikiContext wikiContext, final boolean hasRef ) {
+    public InterWikiLinkAttributeProviderState( final WikiContext wikiContext,
+                                                final boolean hasRef,
+                                                final boolean isImageInlining,
+                                                final List< Pattern > inlineImagePatterns ) {
         this.hasRef = hasRef;
         this.wikiContext = wikiContext;
         this.linkOperations = new LinkParsingOperations( wikiContext );
+        this.isImageInlining = isImageInlining;
+        this.inlineImagePatterns = inlineImagePatterns;
         final Boolean wysiwygVariable = ( Boolean )wikiContext.getVariable( WikiContext.VAR_WYSIWYG_EDITOR_MODE );
         m_wysiwygEditorMode = wysiwygVariable != null ? wysiwygVariable : false;
     }
@@ -58,7 +68,7 @@ public class InterWikiLinkAttributeProviderState implements NodeAttributeProvide
             String urlReference = wikiContext.getEngine().getInterWikiURL( refAndPage[ 0 ] );
             if( urlReference != null ) {
                 urlReference = TextUtil.replaceString( urlReference, "%s", refAndPage[ 1 ] );
-                if( linkOperations.isImageLink( urlReference ) ) {
+                if( linkOperations.isImageLink( urlReference, isImageInlining, inlineImagePatterns ) ) {
                     new ImageLinkAttributeProviderState( wikiContext, urlReference, hasRef ).setAttributes( attributes, link );
                 } else {
                     setInterWikiLinkAttrs( attributes, link, urlReference );
diff --git a/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/attributeprovider/JSPWikiLinkAttributeProvider.java b/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/attributeprovider/JSPWikiLinkAttributeProvider.java
index 45a91a3..4d8ba7e 100755
--- a/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/attributeprovider/JSPWikiLinkAttributeProvider.java
+++ b/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/attributeprovider/JSPWikiLinkAttributeProvider.java
@@ -18,16 +18,18 @@
  */
 package org.apache.wiki.markdown.extensions.jspwikilinks.attributeprovider;
 
+import com.vladsch.flexmark.html.AttributeProvider;
+import com.vladsch.flexmark.html.renderer.AttributablePart;
+import com.vladsch.flexmark.util.ast.Node;
+import com.vladsch.flexmark.util.html.Attributes;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.oro.text.regex.Pattern;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.markdown.nodes.JSPWikiLink;
 import org.apache.wiki.parser.LinkParsingOperations;
 import org.apache.wiki.util.TextUtil;
 
-import com.vladsch.flexmark.html.AttributeProvider;
-import com.vladsch.flexmark.html.renderer.AttributablePart;
-import com.vladsch.flexmark.util.ast.Node;
-import com.vladsch.flexmark.util.html.Attributes;
+import java.util.List;
 
 
 /**
@@ -39,10 +41,16 @@ public class JSPWikiLinkAttributeProvider implements AttributeProvider {
 
     protected final WikiContext wikiContext;
     protected final LinkParsingOperations linkOperations;
+    private final boolean isImageInlining;
+    private final List< Pattern > inlineImagePatterns;
 
-    public JSPWikiLinkAttributeProvider( final WikiContext wikiContext ) {
+    public JSPWikiLinkAttributeProvider( final WikiContext wikiContext,
+                                         final boolean isImageInlining,
+                                         final List< Pattern > inlineImagePatterns ) {
         this.wikiContext = wikiContext;
         this.linkOperations = new LinkParsingOperations( wikiContext );
+        this.isImageInlining = isImageInlining;
+        this.inlineImagePatterns = inlineImagePatterns;
     }
 
     /**
@@ -56,15 +64,15 @@ public class JSPWikiLinkAttributeProvider implements AttributeProvider {
             final JSPWikiLink link = ( JSPWikiLink )node;
             final NodeAttributeProviderState< JSPWikiLink > linkState;
             if( linkOperations.isExternalLink( link.getWikiLink() ) ) {
-                linkState = new ExternalLinkAttributeProviderState( wikiContext, link.hasRef() );
+                linkState = new ExternalLinkAttributeProviderState( wikiContext, link.hasRef(), isImageInlining, inlineImagePatterns );
             } else if( linkOperations.isInterWikiLink( link.getWikiLink() ) ) {
-                linkState = new InterWikiLinkAttributeProviderState( wikiContext, link.hasRef() );
+                linkState = new InterWikiLinkAttributeProviderState( wikiContext, link.hasRef(), isImageInlining, inlineImagePatterns );
             } else if( StringUtils.startsWith( link.getWikiLink(), "#" ) ) {
                 linkState = new LocalFootnoteLinkAttributeProviderState( wikiContext );
             } else if( TextUtil.isNumber( link.getWikiLink() ) ) {
                 linkState = new LocalFootnoteRefLinkAttributeProviderState( wikiContext );
             } else {
-                linkState = new LocalLinkAttributeProviderState( wikiContext, link.hasRef() );
+                linkState = new LocalLinkAttributeProviderState( wikiContext, link.hasRef(), isImageInlining, inlineImagePatterns );
             }
             linkState.setAttributes( attributes, link );
         }
diff --git a/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/attributeprovider/JSPWikiLinkAttributeProviderFactory.java b/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/attributeprovider/JSPWikiLinkAttributeProviderFactory.java
index 1a0d6d9..c61a6fc 100755
--- a/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/attributeprovider/JSPWikiLinkAttributeProviderFactory.java
+++ b/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/attributeprovider/JSPWikiLinkAttributeProviderFactory.java
@@ -18,12 +18,14 @@
  */
 package org.apache.wiki.markdown.extensions.jspwikilinks.attributeprovider;
 
-import org.apache.wiki.WikiContext;
-
 import com.vladsch.flexmark.html.AttributeProvider;
 import com.vladsch.flexmark.html.AttributeProviderFactory;
 import com.vladsch.flexmark.html.IndependentAttributeProviderFactory;
 import com.vladsch.flexmark.html.renderer.LinkResolverContext;
+import org.apache.oro.text.regex.Pattern;
+import org.apache.wiki.WikiContext;
+
+import java.util.List;
 
 
 /**
@@ -32,9 +34,15 @@ import com.vladsch.flexmark.html.renderer.LinkResolverContext;
 public class JSPWikiLinkAttributeProviderFactory extends IndependentAttributeProviderFactory {
 
     final WikiContext wikiContext;
+    private final boolean isImageInlining;
+    private final List< Pattern > inlineImagePatterns;
 
-    public JSPWikiLinkAttributeProviderFactory( final WikiContext wikiContext ) {
+    public JSPWikiLinkAttributeProviderFactory( final WikiContext wikiContext,
+                                                final boolean isImageInlining,
+                                                final List< Pattern > inlineImagePatterns ) {
         this.wikiContext = wikiContext;
+        this.isImageInlining = isImageInlining;
+        this.inlineImagePatterns = inlineImagePatterns;
     }
 
     /**
@@ -44,7 +52,7 @@ public class JSPWikiLinkAttributeProviderFactory extends IndependentAttributePro
      */
     @Override
     public AttributeProvider apply( final LinkResolverContext context ) {
-        return new JSPWikiLinkAttributeProvider( wikiContext );
+        return new JSPWikiLinkAttributeProvider( wikiContext, isImageInlining, inlineImagePatterns );
     }
 
 }
diff --git a/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/attributeprovider/LocalLinkAttributeProviderState.java b/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/attributeprovider/LocalLinkAttributeProviderState.java
index 48c749c..add256b 100755
--- a/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/attributeprovider/LocalLinkAttributeProviderState.java
+++ b/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/attributeprovider/LocalLinkAttributeProviderState.java
@@ -21,12 +21,15 @@ package org.apache.wiki.markdown.extensions.jspwikilinks.attributeprovider;
 import com.vladsch.flexmark.util.ast.Node;
 import com.vladsch.flexmark.util.html.Attributes;
 import com.vladsch.flexmark.util.sequence.CharSubSequence;
+import org.apache.oro.text.regex.Pattern;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.attachment.AttachmentManager;
 import org.apache.wiki.markdown.nodes.JSPWikiLink;
 import org.apache.wiki.parser.LinkParsingOperations;
 import org.apache.wiki.parser.MarkupParser;
 
+import java.util.List;
+
 
 /**
  * {@link NodeAttributeProviderState} which sets the attributes for local links.
@@ -36,11 +39,18 @@ public class LocalLinkAttributeProviderState implements NodeAttributeProviderSta
     private final boolean hasRef;
     private final WikiContext wikiContext;
     private final LinkParsingOperations linkOperations;
+    private final boolean isImageInlining;
+    private final List< Pattern > inlineImagePatterns;
 
-    public LocalLinkAttributeProviderState( final WikiContext wikiContext, final boolean hasRef ) {
+    public LocalLinkAttributeProviderState( final WikiContext wikiContext,
+                                            final boolean hasRef,
+                                            final boolean isImageInlining,
+                                            final List< Pattern > inlineImagePatterns ) {
         this.hasRef = hasRef;
         this.wikiContext = wikiContext;
         this.linkOperations = new LinkParsingOperations( wikiContext );
+        this.isImageInlining = isImageInlining;
+        this.inlineImagePatterns = inlineImagePatterns;
     }
 
     /**
@@ -53,7 +63,7 @@ public class LocalLinkAttributeProviderState implements NodeAttributeProviderSta
         final int hashMark = link.getUrl().toString().indexOf( '#' );
         final String attachment = wikiContext.getEngine().getManager( AttachmentManager.class ).getAttachmentInfoName( wikiContext, link.getWikiLink() );
         if( attachment != null ) {
-            if( !linkOperations.isImageLink( link.getUrl().toString() ) ) {
+            if( !linkOperations.isImageLink( link.getUrl().toString(), isImageInlining, inlineImagePatterns ) ) {
                 attributes.replaceValue( "class", MarkupParser.CLASS_ATTACHMENT );
                 final String attlink = wikiContext.getURL( WikiContext.ATTACH, link.getWikiLink() );
                 attributes.replaceValue( "href", attlink );
diff --git a/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/postprocessor/ExternalLinkNodePostProcessorState.java b/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/postprocessor/ExternalLinkNodePostProcessorState.java
index 3e8dac8..bd2ee43 100755
--- a/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/postprocessor/ExternalLinkNodePostProcessorState.java
+++ b/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/postprocessor/ExternalLinkNodePostProcessorState.java
@@ -21,11 +21,14 @@ package org.apache.wiki.markdown.extensions.jspwikilinks.postprocessor;
 import com.vladsch.flexmark.util.ast.Node;
 import com.vladsch.flexmark.util.ast.NodeTracker;
 import com.vladsch.flexmark.util.sequence.CharSubSequence;
+import org.apache.oro.text.regex.Pattern;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.markdown.nodes.JSPWikiLink;
 import org.apache.wiki.parser.LinkParsingOperations;
 import org.apache.wiki.parser.MarkupParser;
 
+import java.util.List;
+
 
 /**
  * {@link NodePostProcessorState} which further post processes external links.
@@ -34,11 +37,17 @@ public class ExternalLinkNodePostProcessorState implements NodePostProcessorStat
 
     private final WikiContext wikiContext;
     private final LinkParsingOperations linkOperations;
+    private final boolean isImageInlining;
+    private final List< Pattern > inlineImagePatterns;
     private boolean m_useOutlinkImage = true;
 
-    public ExternalLinkNodePostProcessorState( final WikiContext wikiContext ) {
+    public ExternalLinkNodePostProcessorState( final WikiContext wikiContext,
+                                               final boolean isImageInlining,
+                                               final List< Pattern > inlineImagePatterns ) {
         this.wikiContext = wikiContext;
         this.linkOperations = new LinkParsingOperations( wikiContext );
+        this.isImageInlining = isImageInlining;
+        this.inlineImagePatterns = inlineImagePatterns;
         this.m_useOutlinkImage = wikiContext.getBooleanWikiProperty( MarkupParser.PROP_USEOUTLINKIMAGE, m_useOutlinkImage );
     }
 
@@ -49,7 +58,7 @@ public class ExternalLinkNodePostProcessorState implements NodePostProcessorStat
      */
     @Override
     public void process( final NodeTracker state, final JSPWikiLink link ) {
-        if( linkOperations.isImageLink( link.getUrl().toString() ) ) {
+        if( linkOperations.isImageLink( link.getUrl().toString(), isImageInlining, inlineImagePatterns ) ) {
             new ImageLinkNodePostProcessorState( wikiContext, link.getUrl().toString(), link.hasRef() ).process( state, link );
         } else {
             link.setUrl( CharSubSequence.of( link.getUrl().toString() ) );
diff --git a/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/postprocessor/InterWikiLinkNodePostProcessorState.java b/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/postprocessor/InterWikiLinkNodePostProcessorState.java
index 39a1252..340cf65 100755
--- a/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/postprocessor/InterWikiLinkNodePostProcessorState.java
+++ b/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/postprocessor/InterWikiLinkNodePostProcessorState.java
@@ -23,6 +23,7 @@ import com.vladsch.flexmark.util.ast.Node;
 import com.vladsch.flexmark.util.ast.NodeTracker;
 import com.vladsch.flexmark.util.sequence.CharSubSequence;
 import org.apache.log4j.Logger;
+import org.apache.oro.text.regex.Pattern;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.i18n.InternationalizationManager;
 import org.apache.wiki.markdown.nodes.JSPWikiLink;
@@ -32,6 +33,7 @@ import org.apache.wiki.preferences.Preferences;
 import org.apache.wiki.util.TextUtil;
 
 import java.text.MessageFormat;
+import java.util.List;
 import java.util.ResourceBundle;
 
 
@@ -43,13 +45,20 @@ public class InterWikiLinkNodePostProcessorState implements NodePostProcessorSta
     private static final Logger LOG = Logger.getLogger( InterWikiLinkNodePostProcessorState.class );
     private final WikiContext wikiContext;
     private final LinkParsingOperations linkOperations;
+    private final boolean isImageInlining;
+    private final List< Pattern > inlineImagePatterns;
     private final Document document;
     private final boolean m_wysiwygEditorMode;
     private boolean m_useOutlinkImage = true;
 
-    public InterWikiLinkNodePostProcessorState( final WikiContext wikiContext, final Document document ) {
+    public InterWikiLinkNodePostProcessorState( final WikiContext wikiContext,
+                                                final Document document,
+                                                final boolean isImageInlining,
+                                                final List< Pattern > inlineImagePatterns ) {
         this.wikiContext = wikiContext;
         this.linkOperations = new LinkParsingOperations( wikiContext );
+        this.isImageInlining = isImageInlining;
+        this.inlineImagePatterns = inlineImagePatterns;
         this.document = document;
         this.m_useOutlinkImage = wikiContext.getBooleanWikiProperty( MarkupParser.PROP_USEOUTLINKIMAGE, m_useOutlinkImage );
         final Boolean wysiwygVariable = ( Boolean )wikiContext.getVariable( WikiContext.VAR_WYSIWYG_EDITOR_MODE );
@@ -68,7 +77,7 @@ public class InterWikiLinkNodePostProcessorState implements NodePostProcessorSta
             String urlReference = wikiContext.getEngine().getInterWikiURL( refAndPage[ 0 ] );
             if( urlReference != null ) {
                 urlReference = TextUtil.replaceString( urlReference, "%s", refAndPage[ 1 ] );
-                if( linkOperations.isImageLink( urlReference ) ) {
+                if( linkOperations.isImageLink( urlReference, isImageInlining, inlineImagePatterns ) ) {
                     new ImageLinkNodePostProcessorState( wikiContext, urlReference, link.hasRef() ).process( state, link );
                 } else {
                     link.setUrl( CharSubSequence.of( urlReference ) );
diff --git a/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/postprocessor/JSPWikiLinkNodePostProcessor.java b/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/postprocessor/JSPWikiLinkNodePostProcessor.java
index 2aba7de..0ee69f1 100755
--- a/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/postprocessor/JSPWikiLinkNodePostProcessor.java
+++ b/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/postprocessor/JSPWikiLinkNodePostProcessor.java
@@ -25,12 +25,15 @@ import com.vladsch.flexmark.util.ast.Document;
 import com.vladsch.flexmark.util.ast.Node;
 import com.vladsch.flexmark.util.ast.NodeTracker;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.oro.text.regex.Pattern;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.markdown.nodes.JSPWikiLink;
 import org.apache.wiki.parser.LinkParsingOperations;
 import org.apache.wiki.parser.MarkupParser;
 import org.apache.wiki.util.TextUtil;
 
+import java.util.List;
+
 
 /**
  * {@link NodePostProcessor} to convert {@link Link}s into {@link JSPWikiLink}s.
@@ -41,13 +44,20 @@ public class JSPWikiLinkNodePostProcessor extends NodePostProcessor {
 
     protected final WikiContext m_context;
     protected final LinkParsingOperations linkOperations;
+    private final boolean isImageInlining;
+    private final List< Pattern > inlineImagePatterns;
     protected boolean m_useOutlinkImage = true;
     protected final Document document;
 
-    public JSPWikiLinkNodePostProcessor( final WikiContext m_context, final Document document ) {
+    public JSPWikiLinkNodePostProcessor( final WikiContext m_context,
+                                         final Document document,
+                                         final boolean isImageInlining,
+                                         final List< Pattern > inlineImagePatterns ) {
         this.m_context = m_context;
         this.document = document;
         linkOperations = new LinkParsingOperations( m_context );
+        this.isImageInlining = isImageInlining;
+        this.inlineImagePatterns = inlineImagePatterns;
         m_useOutlinkImage = m_context.getBooleanWikiProperty( MarkupParser.PROP_USEOUTLINKIMAGE, m_useOutlinkImage );
     }
 
@@ -71,15 +81,15 @@ public class JSPWikiLinkNodePostProcessor extends NodePostProcessor {
             } else if( linkOperations.isVariableLink( link.getUrl().toString() ) ) {
                 linkPostProcessor = new VariableLinkNodePostProcessorState( m_context );
             } else if( linkOperations.isExternalLink( link.getUrl().toString() ) ) {
-                linkPostProcessor = new ExternalLinkNodePostProcessorState( m_context );
+                linkPostProcessor = new ExternalLinkNodePostProcessorState( m_context, isImageInlining, inlineImagePatterns );
             } else if( linkOperations.isInterWikiLink( link.getUrl().toString() ) ) {
-                linkPostProcessor = new InterWikiLinkNodePostProcessorState( m_context, document );
+                linkPostProcessor = new InterWikiLinkNodePostProcessorState( m_context, document, isImageInlining, inlineImagePatterns );
             } else if( StringUtils.startsWith( link.getUrl().toString(), "#" ) ) {
                 linkPostProcessor = new LocalFootnoteLinkNodePostProcessorState( m_context );
             } else if( TextUtil.isNumber( link.getUrl().toString() ) ) {
                 linkPostProcessor = new LocalFootnoteRefLinkNodePostProcessorState( m_context );
             } else {
-                linkPostProcessor = new LocalLinkNodePostProcessorState( m_context );
+                linkPostProcessor = new LocalLinkNodePostProcessorState( m_context, isImageInlining, inlineImagePatterns );
             }
             linkPostProcessor.process( state, link );
         }
@@ -95,7 +105,7 @@ public class JSPWikiLinkNodePostProcessor extends NodePostProcessor {
 
         if( previous != null ) {
             previous.insertAfter( link );
-        } else {
+        } else if( parent != null ) {
             parent.appendChild( link );
         }
 
diff --git a/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/postprocessor/JSPWikiNodePostProcessorFactory.java b/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/postprocessor/JSPWikiNodePostProcessorFactory.java
index 889d80d..d929240 100755
--- a/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/postprocessor/JSPWikiNodePostProcessorFactory.java
+++ b/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/postprocessor/JSPWikiNodePostProcessorFactory.java
@@ -23,8 +23,11 @@ import com.vladsch.flexmark.parser.block.NodePostProcessor;
 import com.vladsch.flexmark.parser.block.NodePostProcessorFactory;
 import com.vladsch.flexmark.util.ast.Document;
 import com.vladsch.flexmark.util.data.DataHolder;
+import org.apache.oro.text.regex.Pattern;
 import org.apache.wiki.WikiContext;
 
+import java.util.List;
+
 
 /**
  * Simple {@link NodePostProcessorFactory} to instantiate {@link JSPWikiLinkNodePostProcessor}s.
@@ -32,11 +35,18 @@ import org.apache.wiki.WikiContext;
 public class JSPWikiNodePostProcessorFactory extends NodePostProcessorFactory {
 
     private final WikiContext m_context;
+    private final boolean isImageInlining;
+    private final List< Pattern > inlineImagePatterns;
 
-    public JSPWikiNodePostProcessorFactory( final WikiContext m_context, final DataHolder options ) {
+    public JSPWikiNodePostProcessorFactory( final WikiContext m_context,
+                                            final DataHolder options,
+                                            final boolean isImageInlining,
+                                            final List< Pattern > inlineImagePatterns ) {
         super( true );
         addNodes( Link.class ); // needs to be called before create( Document )
         this.m_context = m_context;
+        this.isImageInlining = isImageInlining;
+        this.inlineImagePatterns = inlineImagePatterns;
     }
 
     /**
@@ -44,7 +54,7 @@ public class JSPWikiNodePostProcessorFactory extends NodePostProcessorFactory {
      */
     @Override
     public NodePostProcessor apply( final Document document ) {
-        return new JSPWikiLinkNodePostProcessor( m_context, document );
+        return new JSPWikiLinkNodePostProcessor( m_context, document, isImageInlining, inlineImagePatterns );
     }
 
 }
diff --git a/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/postprocessor/LocalLinkNodePostProcessorState.java b/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/postprocessor/LocalLinkNodePostProcessorState.java
index 0e1629a..b1eca9e 100755
--- a/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/postprocessor/LocalLinkNodePostProcessorState.java
+++ b/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/extensions/jspwikilinks/postprocessor/LocalLinkNodePostProcessorState.java
@@ -22,12 +22,15 @@ import com.vladsch.flexmark.ast.HtmlInline;
 import com.vladsch.flexmark.util.ast.Node;
 import com.vladsch.flexmark.util.ast.NodeTracker;
 import com.vladsch.flexmark.util.sequence.CharSubSequence;
+import org.apache.oro.text.regex.Pattern;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.attachment.AttachmentManager;
 import org.apache.wiki.markdown.nodes.JSPWikiLink;
 import org.apache.wiki.parser.LinkParsingOperations;
 import org.apache.wiki.parser.MarkupParser;
 
+import java.util.List;
+
 
 /**
  * {@link NodePostProcessorState} which further post processes local links.
@@ -36,10 +39,16 @@ public class LocalLinkNodePostProcessorState implements NodePostProcessorState<
 
     private final WikiContext wikiContext;
     private final LinkParsingOperations linkOperations;
+    private final boolean isImageInlining;
+    private final List< Pattern > inlineImagePatterns;
 
-    public LocalLinkNodePostProcessorState( final WikiContext wikiContext ) {
+    public LocalLinkNodePostProcessorState( final WikiContext wikiContext,
+                                            final boolean isImageInlining,
+                                            final List< Pattern > inlineImagePatterns ) {
         this.wikiContext = wikiContext;
         this.linkOperations = new LinkParsingOperations( wikiContext );
+        this.isImageInlining = isImageInlining;
+        this.inlineImagePatterns = inlineImagePatterns;
     }
 
     /**
@@ -52,7 +61,7 @@ public class LocalLinkNodePostProcessorState implements NodePostProcessorState<
         final int hashMark = link.getUrl().toString().indexOf( '#' );
         final String attachment = wikiContext.getEngine().getManager( AttachmentManager.class ).getAttachmentInfoName( wikiContext, link.getUrl().toString() );
         if( attachment != null  ) {
-            if( !linkOperations.isImageLink( link.getUrl().toString() ) ) {
+            if( !linkOperations.isImageLink( link.getUrl().toString(), isImageInlining, inlineImagePatterns ) ) {
                 final String attlink = wikiContext.getURL( WikiContext.ATTACH, link.getUrl().toString() );
                 link.setUrl( CharSubSequence.of( attlink ) );
                 link.removeChildren();
diff --git a/jspwiki-markdown/src/main/java/org/apache/wiki/parser/markdown/MarkdownDocument.java b/jspwiki-markdown/src/main/java/org/apache/wiki/parser/markdown/MarkdownDocument.java
index e441a0a..17eb5fa 100755
--- a/jspwiki-markdown/src/main/java/org/apache/wiki/parser/markdown/MarkdownDocument.java
+++ b/jspwiki-markdown/src/main/java/org/apache/wiki/parser/markdown/MarkdownDocument.java
@@ -25,6 +25,7 @@ import com.vladsch.flexmark.parser.ParserEmulationProfile;
 import com.vladsch.flexmark.util.ast.Node;
 import com.vladsch.flexmark.util.data.MutableDataSet;
 import com.vladsch.flexmark.util.misc.Extension;
+import org.apache.oro.text.regex.Pattern;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.markdown.MarkdownForJSPWikiExtension;
@@ -32,6 +33,7 @@ import org.apache.wiki.parser.JSPWikiMarkupParser;
 import org.apache.wiki.parser.WikiDocument;
 
 import java.util.Arrays;
+import java.util.List;
 
 
 /**
@@ -58,12 +60,12 @@ public class MarkdownDocument extends WikiDocument {
 	 * @param context current wikicontext
 	 * @return configuration options for MarkdownRenderers.
 	 */
-	public static MutableDataSet options( final WikiContext context ) {
+	public static MutableDataSet options( final WikiContext context, final boolean isImageInlining, final List< Pattern > inlineImagePatterns ) {
 		final MutableDataSet options = new MutableDataSet();
 		options.setFrom( ParserEmulationProfile.COMMONMARK );
 		// align style of Markdown's footnotes extension with jspwiki footnotes refs
 		options.set( FootnoteExtension.FOOTNOTE_LINK_REF_CLASS, JSPWikiMarkupParser.CLASS_FOOTNOTE_REF );
-		options.set( Parser.EXTENSIONS, Arrays.asList( new Extension[] { new MarkdownForJSPWikiExtension( context ),
+		options.set( Parser.EXTENSIONS, Arrays.asList( new Extension[] { new MarkdownForJSPWikiExtension( context, isImageInlining, inlineImagePatterns ),
 		                                                                 FootnoteExtension.create(),
 		                                                                 TocExtension.create() } ) );
 		return options;
diff --git a/jspwiki-markdown/src/main/java/org/apache/wiki/parser/markdown/MarkdownParser.java b/jspwiki-markdown/src/main/java/org/apache/wiki/parser/markdown/MarkdownParser.java
index d36647b..2c69f09 100755
--- a/jspwiki-markdown/src/main/java/org/apache/wiki/parser/markdown/MarkdownParser.java
+++ b/jspwiki-markdown/src/main/java/org/apache/wiki/parser/markdown/MarkdownParser.java
@@ -43,7 +43,7 @@ public class MarkdownParser extends MarkupParser {
             context.getEngine().getManager( AuthorizationManager.class ) == null ) {
             disableAccessRules();
         }
-        parser = Parser.builder( MarkdownDocument.options( context ) ).build();
+        parser = Parser.builder( MarkdownDocument.options( context, isImageInlining(), getInlineImagePatterns() ) ).build();
     }
 
     /**
diff --git a/jspwiki-markdown/src/main/java/org/apache/wiki/render/markdown/MarkdownRenderer.java b/jspwiki-markdown/src/main/java/org/apache/wiki/render/markdown/MarkdownRenderer.java
index bf13633..1400b61 100755
--- a/jspwiki-markdown/src/main/java/org/apache/wiki/render/markdown/MarkdownRenderer.java
+++ b/jspwiki-markdown/src/main/java/org/apache/wiki/render/markdown/MarkdownRenderer.java
@@ -18,14 +18,18 @@
  */
 package org.apache.wiki.render.markdown;
 
-import java.io.IOException;
-
+import com.vladsch.flexmark.html.HtmlRenderer;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.oro.text.regex.Pattern;
 import org.apache.wiki.WikiContext;
+import org.apache.wiki.parser.MarkupParser;
 import org.apache.wiki.parser.WikiDocument;
 import org.apache.wiki.parser.markdown.MarkdownDocument;
+import org.apache.wiki.render.RenderingManager;
 import org.apache.wiki.render.WikiRenderer;
 
-import com.vladsch.flexmark.html.HtmlRenderer;
+import java.io.IOException;
+import java.util.List;
 
 
 /**
@@ -37,7 +41,12 @@ public class MarkdownRenderer extends WikiRenderer {
 
 	public MarkdownRenderer( final WikiContext context, final WikiDocument doc ) {
 		super( context, doc );
-		renderer = HtmlRenderer.builder( MarkdownDocument.options( context ) ).build();
+		final MarkupParser mp = context.getEngine()
+				                       .getManager( RenderingManager.class )
+				                       .getParser( context, StringUtils.defaultString( doc.getPageData() ) );
+		final boolean isImageInlining = mp.isImageInlining();
+		final List< Pattern > inlineImagePatterns = mp.getInlineImagePatterns();
+		renderer = HtmlRenderer.builder( MarkdownDocument.options( context, isImageInlining, inlineImagePatterns ) ).build();
 	}
 
 	/**


[jspwiki] 23/35: JSPWIKI-303: begin to use public API (Engine, Session) on JSPs

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git

commit a20525043037c1f5a664825138ab88f6a7d494b8
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Mar 4 21:41:41 2020 +0100

    JSPWIKI-303: begin to use public API (Engine, Session) on JSPs
---
 jspwiki-war/src/main/webapp/Captcha.jsp            |  7 ++--
 jspwiki-war/src/main/webapp/Comment.jsp            |  3 +-
 jspwiki-war/src/main/webapp/CookieError.jsp        |  6 ++-
 jspwiki-war/src/main/webapp/Delete.jsp             | 30 ++++++-------
 jspwiki-war/src/main/webapp/DeleteGroup.jsp        | 10 +++--
 jspwiki-war/src/main/webapp/Diff.jsp               | 22 ++++------
 jspwiki-war/src/main/webapp/Edit.jsp               | 30 +++++++------
 jspwiki-war/src/main/webapp/EditGroup.jsp          | 15 +++----
 jspwiki-war/src/main/webapp/Error.jsp              |  3 +-
 jspwiki-war/src/main/webapp/Group.jsp              | 26 +++++-------
 jspwiki-war/src/main/webapp/Install.jsp            |  8 ++--
 jspwiki-war/src/main/webapp/Login.jsp              | 14 ++++---
 jspwiki-war/src/main/webapp/LoginForm.jsp          |  6 ++-
 jspwiki-war/src/main/webapp/Logout.jsp             |  8 ++--
 jspwiki-war/src/main/webapp/LostPassword.jsp       | 16 ++++---
 jspwiki-war/src/main/webapp/Message.jsp            |  6 ++-
 jspwiki-war/src/main/webapp/NewBlogEntry.jsp       |  3 +-
 jspwiki-war/src/main/webapp/NewGroup.jsp           | 21 +++++-----
 jspwiki-war/src/main/webapp/PageInfo.jsp           | 11 ++---
 jspwiki-war/src/main/webapp/PageModified.jsp       | 22 +++++-----
 jspwiki-war/src/main/webapp/Preview.jsp            | 21 ++++------
 jspwiki-war/src/main/webapp/Rename.jsp             | 32 +++++++-------
 jspwiki-war/src/main/webapp/Search.jsp             | 31 ++++++--------
 jspwiki-war/src/main/webapp/SisterSites.jsp        | 17 ++++----
 jspwiki-war/src/main/webapp/Upload.jsp             |  9 ++--
 jspwiki-war/src/main/webapp/UserPreferences.jsp    | 21 ++++++----
 jspwiki-war/src/main/webapp/Wiki.jsp               | 13 +++---
 jspwiki-war/src/main/webapp/Workflow.jsp           | 22 +++++-----
 jspwiki-war/src/main/webapp/XHRHtml2Markup.jsp     |  6 ++-
 .../src/main/webapp/admin/SecurityConfig.jsp       | 16 ++++---
 jspwiki-war/src/main/webapp/rss.jsp                | 49 +++++++++++-----------
 .../main/webapp/templates/210/EditGroupContent.jsp |  4 +-
 .../src/main/webapp/templates/210/GroupContent.jsp |  2 +-
 .../src/main/webapp/templates/210/GroupTab.jsp     |  4 +-
 .../main/webapp/templates/210/NewGroupContent.jsp  |  2 +-
 .../webapp/templates/default/EditGroupContent.jsp  |  6 +--
 .../src/main/webapp/templates/default/GroupTab.jsp |  5 +--
 37 files changed, 274 insertions(+), 253 deletions(-)

diff --git a/jspwiki-war/src/main/webapp/Captcha.jsp b/jspwiki-war/src/main/webapp/Captcha.jsp
index cc61882..152f86d 100644
--- a/jspwiki-war/src/main/webapp/Captcha.jsp
+++ b/jspwiki-war/src/main/webapp/Captcha.jsp
@@ -21,6 +21,8 @@
 <%@ page import="org.apache.commons.httpclient.*" %>
 <%@ page import="org.apache.commons.httpclient.methods.*" %>
 <%@ page import="org.apache.wiki.*" %>
+<%@ page import="org.apache.wiki.api.core.*" %>
+<%@ page import="org.apache.wiki.auth.AuthorizationManager" %>
 <%@ page import="org.apache.wiki.preferences.Preferences" %>
 <%@ page import="org.apache.wiki.util.*" %>
 <%@ page import="org.apache.wiki.ui.EditorManager" %>
@@ -35,12 +37,11 @@
     Logger log = Logger.getLogger("JSPWiki");
 %>
 <%
-    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    Engine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context and check for authorization
     WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.VIEW );
-    if(!wiki.getAuthorizationManager().hasAccess( wikiContext, response )) return;
+    if(!wiki.getManager( AuthorizationManager.class ).hasAccess( wikiContext, response )) return;
     String pagereq = wikiContext.getName();
-
     String reqPage = TextUtil.replaceEntities( request.getParameter( "page" ) );
     String content = TextUtil.replaceEntities( request.getParameter( "text" ) );
 
diff --git a/jspwiki-war/src/main/webapp/Comment.jsp b/jspwiki-war/src/main/webapp/Comment.jsp
index 071eea6..7cfc58b 100644
--- a/jspwiki-war/src/main/webapp/Comment.jsp
+++ b/jspwiki-war/src/main/webapp/Comment.jsp
@@ -22,6 +22,7 @@
 <%@ page import="java.text.SimpleDateFormat" %>
 <%@ page import="org.apache.wiki.util.HttpUtil" %>
 <%@ page import="org.apache.wiki.*" %>
+<%@ page import="org.apache.wiki.api.core.*" %>
 <%@ page import="org.apache.wiki.api.exceptions.RedirectException" %>
 <%@ page import="org.apache.wiki.filters.SpamFilter" %>
 <%@ page import="org.apache.wiki.htmltowiki.HtmlStringToWikiTranslator" %>
@@ -68,7 +69,7 @@
     String pagereq = wikiContext.getName();
 
     ResourceBundle rb = Preferences.getBundle( wikiContext, "CoreResources" );
-    WikiSession wikiSession = wikiContext.getWikiSession();
+    Session wikiSession = wikiContext.getWikiSession();
     String storedUser = wikiSession.getUserPrincipal().getName();
 
     if( wikiSession.isAnonymous() ) {
diff --git a/jspwiki-war/src/main/webapp/CookieError.jsp b/jspwiki-war/src/main/webapp/CookieError.jsp
index b7cf4d7..20e188f 100755
--- a/jspwiki-war/src/main/webapp/CookieError.jsp
+++ b/jspwiki-war/src/main/webapp/CookieError.jsp
@@ -18,14 +18,16 @@
 --%>
 
 <%@ page import="org.apache.wiki.*" %>
+<%@ page import="org.apache.wiki.api.core.*" %>
+<%@ page import="org.apache.wiki.ui.TemplateManager" %>
 <%@ taglib prefix="wiki" uri="http://jspwiki.apache.org/tags" %>
 
 <%
-    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    Engine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context; authorization check not needed
     WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.VIEW );
  
     // Set the content type and include the response content
     response.setContentType("text/html; charset="+wiki.getContentEncoding() );
-    String contentPage = wiki.getTemplateManager().findJSP( pageContext, wikiContext.getTemplate(), "CookieErrorTemplate.jsp" );
+    String contentPage = wiki.getManager( TemplateManager.class ).findJSP( pageContext, wikiContext.getTemplate(), "CookieErrorTemplate.jsp" );
 %><wiki:Include page="<%=contentPage%>" />
diff --git a/jspwiki-war/src/main/webapp/Delete.jsp b/jspwiki-war/src/main/webapp/Delete.jsp
index f2bfbda..ebb1e04 100644
--- a/jspwiki-war/src/main/webapp/Delete.jsp
+++ b/jspwiki-war/src/main/webapp/Delete.jsp
@@ -17,15 +17,19 @@
     under the License.
 --%>
 
+<%@ page import="java.util.*" %>
 <%@ page import="org.apache.log4j.*" %>
 <%@ page import="org.apache.wiki.*" %>
-<%@ page import="org.apache.wiki.util.HttpUtil" %>
+<%@ page import="org.apache.wiki.api.core.*" %>
+<%@ page import="org.apache.wiki.attachment.Attachment" %>
+<%@ page import="org.apache.wiki.auth.AuthorizationManager" %>
+<%@ page import="org.apache.wiki.pages.PageManager" %>
+<%@ page import="org.apache.wiki.preferences.Preferences" %>
 <%@ page import="org.apache.wiki.tags.BreadcrumbsTag" %>
 <%@ page import="org.apache.wiki.tags.BreadcrumbsTag.FixedQueue" %>
-<%@ page import="java.util.*" %>
+<%@ page import="org.apache.wiki.ui.TemplateManager" %>
+<%@ page import="org.apache.wiki.util.HttpUtil" %>
 <%@ page import="org.apache.wiki.util.TextUtil" %>
-<%@ page import="org.apache.wiki.attachment.Attachment" %>
-<%@ page import="org.apache.wiki.preferences.Preferences" %>
 <%@ page errorPage="/Error.jsp" %>
 <%@ taglib uri="http://jspwiki.apache.org/tags" prefix="wiki" %>
 
@@ -34,10 +38,10 @@
 %>
 
 <%
-    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    Engine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context and check for authorization
     WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.DELETE );
-    if( !wiki.getAuthorizationManager().hasAccess( wikiContext, response ) ) return;
+    if( !wiki.getManager( AuthorizationManager.class ).hasAccess( wikiContext, response ) ) return;
     if( wikiContext.getCommand().getTarget() == null ) {
         response.sendRedirect( wikiContext.getURL( wikiContext.getRequestContext(), wikiContext.getName() ) );
         return;
@@ -45,7 +49,7 @@
     String pagereq = wikiContext.getName();
 
     WikiPage wikipage      = wikiContext.getPage();
-    WikiPage latestversion = wiki.getPageManager().getPage( pagereq );
+    WikiPage latestversion = wiki.getManager( PageManager.class ).getPage( pagereq );
 
     String delete = request.getParameter( "delete" );
     String deleteall = request.getParameter( "delete-all" );
@@ -65,7 +69,7 @@
     {
         log.info("Deleting page "+pagereq+". User="+request.getRemoteUser()+", host="+HttpUtil.getRemoteAddress(request) );
 
-        wiki.getPageManager().deletePage( pagereq );
+        wiki.getManager( PageManager.class ).deletePage( pagereq );
 
         FixedQueue trail = (FixedQueue) session.getAttribute( BreadcrumbsTag.BREADCRUMBTRAIL_KEY );
         if( trail != null )
@@ -89,17 +93,15 @@
             {
                 int version = Integer.parseInt( paramName.substring(7) );
 
-                WikiPage p = wiki.getPageManager().getPage( pagereq, version );
+                WikiPage p = wiki.getManager( PageManager.class ).getPage( pagereq, version );
 
                 log.debug("Deleting version "+version);
-                wiki.getPageManager().deleteVersion( p );
+                wiki.getManager( PageManager.class ).deleteVersion( p );
             }
         }
 
         response.sendRedirect(
-            TextUtil.replaceString(
-                wiki.getURL( WikiContext.VIEW, redirTo, "tab=" + request.getParameter( "tab" ) ),"&amp;","&"
-            )
+            TextUtil.replaceString( wiki.getURL( WikiContext.VIEW, redirTo, "tab=" + request.getParameter( "tab" ) ),"&amp;","&" )
         );
 
 
@@ -109,6 +111,6 @@
     // Set the content type and include the response content
     // FIXME: not so.
     response.setContentType("text/html; charset="+wiki.getContentEncoding() );
-    String contentPage = wiki.getTemplateManager().findJSP( pageContext, wikiContext.getTemplate(), "EditTemplate.jsp" );
+    String contentPage = wiki.getManager( TemplateManager.class ).findJSP( pageContext, wikiContext.getTemplate(), "EditTemplate.jsp" );
 %><wiki:Include page="<%=contentPage%>" />
 
diff --git a/jspwiki-war/src/main/webapp/DeleteGroup.jsp b/jspwiki-war/src/main/webapp/DeleteGroup.jsp
index 9f38ae6..5f1c158 100644
--- a/jspwiki-war/src/main/webapp/DeleteGroup.jsp
+++ b/jspwiki-war/src/main/webapp/DeleteGroup.jsp
@@ -19,6 +19,8 @@
 
 <%@ page import="org.apache.log4j.*" %>
 <%@ page import="org.apache.wiki.*" %>
+<%@ page import="org.apache.wiki.api.core.*" %>
+<%@ page import="org.apache.wiki.auth.AuthorizationManager" %>
 <%@ page import="org.apache.wiki.auth.NoSuchPrincipalException" %>
 <%@ page import="org.apache.wiki.auth.WikiSecurityException" %>
 <%@ page import="org.apache.wiki.auth.authorize.GroupManager" %>
@@ -31,13 +33,13 @@
 %>
 
 <%
-    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    Engine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context and check for authorization
     WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.DELETE_GROUP );
-    if(!wiki.getAuthorizationManager().hasAccess( wikiContext, response )) return;
+    if(!wiki.getManager( AuthorizationManager.class ).hasAccess( wikiContext, response )) return;
 
-    WikiSession wikiSession = wikiContext.getWikiSession();
-    GroupManager groupMgr = wiki.getGroupManager();
+    Session wikiSession = wikiContext.getWikiSession();
+    GroupManager groupMgr = wiki.getManager( GroupManager.class );
     String name = request.getParameter( "group" );
 
     if ( name == null )
diff --git a/jspwiki-war/src/main/webapp/Diff.jsp b/jspwiki-war/src/main/webapp/Diff.jsp
index c9b8adf..38c653b 100644
--- a/jspwiki-war/src/main/webapp/Diff.jsp
+++ b/jspwiki-war/src/main/webapp/Diff.jsp
@@ -19,10 +19,12 @@
 
 <%@ page import="org.apache.log4j.*" %>
 <%@ page import="org.apache.wiki.*" %>
-<%@ page import="org.apache.wiki.util.HttpUtil" %>
+<%@ page import="org.apache.wiki.api.core.*" %>
+<%@ page import="org.apache.wiki.auth.AuthorizationManager" %>
 <%@ page import="org.apache.wiki.preferences.Preferences" %>
-<%@ page import="org.apache.wiki.util.*" %>
 <%@ page import="org.apache.wiki.tags.InsertDiffTag" %>
+<%@ page import="org.apache.wiki.ui.TemplateManager" %>
+<%@ page import="org.apache.wiki.util.*" %>
 <%@ page errorPage="/Error.jsp" %>
 <%@ taglib uri="http://jspwiki.apache.org/tags" prefix="wiki" %>
 
@@ -31,10 +33,10 @@
 %>
 
 <%
-    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    Engine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context and check for authorization
     WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.DIFF );
-    if( !wiki.getAuthorizationManager().hasAccess( wikiContext, response ) ) return;
+    if( !wiki.getManager( AuthorizationManager.class ).hasAccess( wikiContext, response ) ) return;
     if( wikiContext.getCommand().getTarget() == null ) {
         response.sendRedirect( wikiContext.getURL( wikiContext.getRequestContext(), wikiContext.getName() ) );
         return;
@@ -81,19 +83,13 @@
         }
     }
 
-    pageContext.setAttribute( InsertDiffTag.ATTR_OLDVERSION,
-                              new Integer(ver1),
-                              PageContext.REQUEST_SCOPE );
-    pageContext.setAttribute( InsertDiffTag.ATTR_NEWVERSION,
-                              new Integer(ver2),
-                              PageContext.REQUEST_SCOPE );
+    pageContext.setAttribute( InsertDiffTag.ATTR_OLDVERSION, new Integer(ver1), PageContext.REQUEST_SCOPE );
+    pageContext.setAttribute( InsertDiffTag.ATTR_NEWVERSION, new Integer(ver2), PageContext.REQUEST_SCOPE );
 
     // log.debug("Request for page diff for '"+pagereq+"' from "+HttpUtil.getRemoteAddress(request)+" by "+request.getRemoteUser()+".  R1="+ver1+", R2="+ver2 );
 
     // Set the content type and include the response content
     response.setContentType("text/html; charset="+wiki.getContentEncoding() );
-    String contentPage = wiki.getTemplateManager().findJSP( pageContext,
-                                                            wikiContext.getTemplate(),
-                                                            "ViewTemplate.jsp" );
+    String contentPage = wiki.getManager( TemplateManager.class ).findJSP( pageContext, wikiContext.getTemplate(), "ViewTemplate.jsp" );
 %><wiki:Include page="<%=contentPage%>" />
 <% } finally { w.exitState(); } %>
\ No newline at end of file
diff --git a/jspwiki-war/src/main/webapp/Edit.jsp b/jspwiki-war/src/main/webapp/Edit.jsp
index fbcd6ea..a885d22 100644
--- a/jspwiki-war/src/main/webapp/Edit.jsp
+++ b/jspwiki-war/src/main/webapp/Edit.jsp
@@ -20,13 +20,17 @@
 <%@ page import="org.apache.log4j.*" %>
 <%@ page import="java.util.*" %>
 <%@ page import="org.apache.wiki.*" %>
-<%@ page import="org.apache.wiki.util.HttpUtil" %>
+<%@ page import="org.apache.wiki.api.core.*" %>
 <%@ page import="org.apache.wiki.api.exceptions.RedirectException" %>
+<%@ page import="org.apache.wiki.auth.AuthorizationManager" %>
+<%@ page import="org.apache.wiki.util.HttpUtil" %>
 <%@ page import="org.apache.wiki.filters.SpamFilter" %>
 <%@ page import="org.apache.wiki.htmltowiki.HtmlStringToWikiTranslator" %>
 <%@ page import="org.apache.wiki.pages.PageLock" %>
+<%@ page import="org.apache.wiki.pages.PageManager" %>
 <%@ page import="org.apache.wiki.preferences.Preferences" %>
 <%@ page import="org.apache.wiki.ui.EditorManager" %>
+<%@ page import="org.apache.wiki.ui.TemplateManager" %>
 <%@ page import="org.apache.wiki.util.TextUtil" %>
 <%@ page import="org.apache.wiki.workflow.DecisionRequiredException" %>
 <%@ page errorPage="/Error.jsp" %>
@@ -47,10 +51,10 @@
 %>
 
 <%
-    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    Engine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context and check for authorization
     WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.EDIT );
-    if( !wiki.getAuthorizationManager().hasAccess( wikiContext, response ) ) {
+    if( !wiki.getManager( AuthorizationManager.class ).hasAccess( wikiContext, response ) ) {
         return;
     }
     if( wikiContext.getCommand().getTarget() == null ) {
@@ -59,7 +63,7 @@
     }
     String pagereq = wikiContext.getName();
 
-    WikiSession wikiSession = wikiContext.getWikiSession();
+    Session wikiSession = wikiContext.getWikiSession();
     String user = wikiSession.getUserPrincipal().getName();
     String action  = request.getParameter("action");
     String ok      = request.getParameter("ok");
@@ -87,7 +91,7 @@
     }
 
     WikiPage wikipage = wikiContext.getPage();
-    WikiPage latestversion = wiki.getPageManager().getPage( pagereq );
+    WikiPage latestversion = wiki.getManager( PageManager.class ).getPage( pagereq );
 
     if( latestversion == null ) {
         latestversion = wikiContext.getPage();
@@ -140,8 +144,8 @@
         //
         //  We expire ALL locks at this moment, simply because someone has already broken it.
         //
-        PageLock lock = wiki.getPageManager().getCurrentLock( wikipage );
-        wiki.getPageManager().unlockPage( lock );
+        PageLock lock = wiki.getManager( PageManager.class ).getCurrentLock( wikipage );
+        wiki.getManager( PageManager.class ).unlockPage( lock );
         session.removeAttribute( "lock-"+pagereq );
 
         //
@@ -181,11 +185,11 @@
             }
 
             if( append != null ) {
-                StringBuffer pageText = new StringBuffer(wiki.getPageManager().getText( pagereq ));
+                StringBuffer pageText = new StringBuffer(wiki.getManager( PageManager.class ).getText( pagereq ));
                 pageText.append( text );
-                wiki.getPageManager().saveText( wikiContext, pageText.toString() );
+                wiki.getManager( PageManager.class ).saveText( wikiContext, pageText.toString() );
             } else {
-                wiki.getPageManager().saveText( wikiContext, text );
+                wiki.getManager( PageManager.class ).saveText( wikiContext, text );
             }
         } catch( DecisionRequiredException ex ) {
         	String redirect = wikiContext.getURL(WikiContext.VIEW,"ApprovalRequiredForPageChanges");
@@ -225,7 +229,7 @@
         log.debug("Cancelled editing "+pagereq);
         PageLock lock = (PageLock) session.getAttribute( "lock-"+pagereq );
         if( lock != null ) {
-            wiki.getPageManager().unlockPage( lock );
+            wiki.getManager( PageManager.class ).unlockPage( lock );
             session.removeAttribute( "lock-"+pagereq );
         }
         response.sendRedirect( wikiContext.getViewURL(pagereq) );
@@ -249,11 +253,11 @@
     //
     //  Attempt to lock the page.
     //
-    PageLock lock = wiki.getPageManager().lockPage( wikipage, user );
+    PageLock lock = wiki.getManager( PageManager.class ).lockPage( wikipage, user );
     if( lock != null ) {
         session.setAttribute( "lock-"+pagereq, lock );
     }
 
-    String contentPage = wiki.getTemplateManager().findJSP( pageContext, wikiContext.getTemplate(), "EditTemplate.jsp" );
+    String contentPage = wiki.getManager( TemplateManager.class ).findJSP( pageContext, wikiContext.getTemplate(), "EditTemplate.jsp" );
 
 %><wiki:Include page="<%=contentPage%>" />
\ No newline at end of file
diff --git a/jspwiki-war/src/main/webapp/EditGroup.jsp b/jspwiki-war/src/main/webapp/EditGroup.jsp
index 8f573fb..6690982 100644
--- a/jspwiki-war/src/main/webapp/EditGroup.jsp
+++ b/jspwiki-war/src/main/webapp/EditGroup.jsp
@@ -19,10 +19,13 @@
 
 <%@ page import="org.apache.log4j.*" %>
 <%@ page import="org.apache.wiki.*" %>
+<%@ page import="org.apache.wiki.api.core.*" %>
+<%@ page import="org.apache.wiki.auth.AuthorizationManager" %>
 <%@ page import="org.apache.wiki.auth.WikiSecurityException" %>
 <%@ page import="org.apache.wiki.auth.authorize.Group" %>
 <%@ page import="org.apache.wiki.auth.authorize.GroupManager" %>
 <%@ page import="org.apache.wiki.preferences.Preferences" %>
+<%@ page import="org.apache.wiki.ui.TemplateManager" %>
 <%@ page errorPage="/Error.jsp" %>
 <%@ taglib uri="http://jspwiki.apache.org/tags" prefix="wiki" %>
 <%! 
@@ -30,14 +33,14 @@
 %>
 
 <%
-    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    Engine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context and check for authorization
     WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.EDIT_GROUP );
-    if(!wiki.getAuthorizationManager().hasAccess( wikiContext, response )) return;
+    if(!wiki.getManager( AuthorizationManager.class ).hasAccess( wikiContext, response )) return;
     
     // Extract the current user, group name, members and action attributes
-    WikiSession wikiSession = wikiContext.getWikiSession();
-    GroupManager groupMgr = wiki.getGroupManager();
+    Session wikiSession = wikiContext.getWikiSession();
+    GroupManager groupMgr = wiki.getManager( GroupManager.class );
     Group group = null;
     try 
     {
@@ -78,9 +81,7 @@
         
     // Set the content type and include the response content
     response.setContentType("text/html; charset="+wiki.getContentEncoding() );
-    String contentPage = wiki.getTemplateManager().findJSP( pageContext,
-                                                            wikiContext.getTemplate(),
-                                                            "EditTemplate.jsp" );
+    String contentPage = wiki.getManager( TemplateManager.class ).findJSP( pageContext, wikiContext.getTemplate(), "EditTemplate.jsp" );
 
 %><wiki:Include page="<%=contentPage%>" />
 
diff --git a/jspwiki-war/src/main/webapp/Error.jsp b/jspwiki-war/src/main/webapp/Error.jsp
index 86f3e76..90346fc 100644
--- a/jspwiki-war/src/main/webapp/Error.jsp
+++ b/jspwiki-war/src/main/webapp/Error.jsp
@@ -20,13 +20,14 @@
 <%@ page isErrorPage="true" %>
 <%@ page import="org.apache.log4j.*" %>
 <%@ page import="org.apache.wiki.*" %>
+<%@ page import="org.apache.wiki.api.core.Engine" %>
 <%@ page import="org.apache.wiki.util.FileUtil" %>
 <%@ taglib uri="http://jspwiki.apache.org/tags" prefix="wiki" %>
 <%!
     Logger log = Logger.getLogger("JSPWiki");
 %>
 <%
-    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    Engine wiki = WikiEngine.getInstance( getServletConfig() );
     WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.ERROR );
     String pagereq = wikiContext.getName();
 
diff --git a/jspwiki-war/src/main/webapp/Group.jsp b/jspwiki-war/src/main/webapp/Group.jsp
index 5fa3a32..307e13a 100644
--- a/jspwiki-war/src/main/webapp/Group.jsp
+++ b/jspwiki-war/src/main/webapp/Group.jsp
@@ -19,11 +19,14 @@
 
 <%@ page import="org.apache.log4j.*" %>
 <%@ page import="org.apache.wiki.*" %>
+<%@ page import="org.apache.wiki.api.core.*" %>
+<%@ page import="org.apache.wiki.auth.AuthorizationManager" %>
 <%@ page import="org.apache.wiki.auth.NoSuchPrincipalException" %>
 <%@ page import="org.apache.wiki.auth.WikiSecurityException" %>
 <%@ page import="org.apache.wiki.auth.authorize.Group" %>
 <%@ page import="org.apache.wiki.auth.authorize.GroupManager" %>
 <%@ page import="org.apache.wiki.preferences.Preferences" %>
+<%@ page import="org.apache.wiki.ui.TemplateManager" %>
 <%@ page errorPage="/Error.jsp" %>
 <%@ taglib uri="http://jspwiki.apache.org/tags" prefix="wiki" %>
 <%!
@@ -31,34 +34,27 @@
 %>
 
 <%
-    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    Engine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context and check for authorization
     WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.VIEW_GROUP );
-    if(!wiki.getAuthorizationManager().hasAccess( wikiContext, response )) return;
+    if(!wiki.getManager( AuthorizationManager.class ).hasAccess( wikiContext, response )) return;
     
     // Extract the current user, group name, members
-    WikiSession wikiSession = wikiContext.getWikiSession();
-    GroupManager groupMgr = wiki.getGroupManager();
+    Session wikiSession = wikiContext.getWikiSession();
+    GroupManager groupMgr = wiki.getManager( GroupManager.class );
     Group group = null;
-    try 
-    {
+    try {
         group = groupMgr.parseGroup( wikiContext, false );
         pageContext.setAttribute ( "Group", group, PageContext.REQUEST_SCOPE );
-    }
-    catch ( NoSuchPrincipalException e )
-    {
+    } catch ( NoSuchPrincipalException e ) {
         // New group; let GroupContent print out the message...
-    }
-    catch ( WikiSecurityException e )
-    {
+    } catch ( WikiSecurityException e ) {
         wikiSession.addMessage( GroupManager.MESSAGES_KEY, e.getMessage() );
     }
     
     // Set the content type and include the response content
     response.setContentType("text/html; charset="+wiki.getContentEncoding() );
-    String contentPage = wiki.getTemplateManager().findJSP( pageContext,
-                                                            wikiContext.getTemplate(),
-                                                            "ViewTemplate.jsp" );
+    String contentPage = wiki.getManager( TemplateManager.class ).findJSP( pageContext, wikiContext.getTemplate(), "ViewTemplate.jsp" );
 
 %><wiki:Include page="<%=contentPage%>" />
 
diff --git a/jspwiki-war/src/main/webapp/Install.jsp b/jspwiki-war/src/main/webapp/Install.jsp
index 1f87580..1ac30dc 100644
--- a/jspwiki-war/src/main/webapp/Install.jsp
+++ b/jspwiki-war/src/main/webapp/Install.jsp
@@ -20,7 +20,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <%@ taglib uri="http://jspwiki.apache.org/tags" prefix="wiki" %>
 <%@ page import="org.apache.wiki.*" %>
+<%@ page import="org.apache.wiki.api.core.*" %>
 <%@ page import="org.apache.wiki.auth.AuthenticationManager" %>
+<%@ page import="org.apache.wiki.auth.AuthorizationManager" %>
 <%@ page import="org.apache.wiki.preferences.Preferences" %>
 <%@ page import="org.apache.wiki.ui.Installer" %>
 <%@ page import="org.apache.log4j.*" %>
@@ -34,13 +36,13 @@
 %>
 
 <%
-WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+Engine wiki = WikiEngine.getInstance( getServletConfig() );
 // Create wiki context and check for authorization
 WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.INSTALL );
-if(!wiki.getAuthorizationManager().hasAccess( wikiContext, response )) return;
+if(!wiki.getManager( AuthorizationManager.class ).hasAccess( wikiContext, response )) return;
 
 Installer installer = new Installer( request, config );
-WikiSession wikiSession = wikiContext.getWikiSession();
+Session wikiSession = wikiContext.getWikiSession();
 
 // Parse the existing properties
 installer.parseProperties();
diff --git a/jspwiki-war/src/main/webapp/Login.jsp b/jspwiki-war/src/main/webapp/Login.jsp
index 38313fb..0bf8605 100644
--- a/jspwiki-war/src/main/webapp/Login.jsp
+++ b/jspwiki-war/src/main/webapp/Login.jsp
@@ -21,12 +21,14 @@
 <%@ page import="java.util.*" %>
 <%@ page import="org.apache.log4j.*" %>
 <%@ page import="org.apache.wiki.*" %>
+<%@ page import="org.apache.wiki.api.core.*" %>
 <%@ page import="org.apache.wiki.auth.*" %>
 <%@ page import="org.apache.wiki.auth.login.CookieAssertionLoginModule" %>
 <%@ page import="org.apache.wiki.auth.login.CookieAuthenticationLoginModule" %>
 <%@ page import="org.apache.wiki.auth.user.DuplicateUserException" %>
 <%@ page import="org.apache.wiki.auth.user.UserProfile" %>
 <%@ page import="org.apache.wiki.i18n.InternationalizationManager" %>
+<%@ page import="org.apache.wiki.pages.PageManager" %>
 <%@ page import="org.apache.wiki.preferences.Preferences" %>
 <%@ page import="org.apache.wiki.workflow.DecisionRequiredException" %>
 <%@ page errorPage="/Error.jsp" %>
@@ -35,11 +37,11 @@
     Logger log = Logger.getLogger("JSPWiki");
 %>
 <%
-    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
-    AuthenticationManager mgr = wiki.getAuthenticationManager();
+    Engine wiki = WikiEngine.getInstance( getServletConfig() );
+    AuthenticationManager mgr = wiki.getManager( AuthenticationManager.class );
     WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.LOGIN );
     pageContext.setAttribute( WikiContext.ATTR_CONTEXT, wikiContext, PageContext.REQUEST_SCOPE );
-    WikiSession wikiSession = wikiContext.getWikiSession();
+    Session wikiSession = wikiContext.getWikiSession();
     ResourceBundle rb = Preferences.getBundle( wikiContext, "CoreResources" );
 
     // Set the redirect-page variable if one was passed as a parameter
@@ -51,7 +53,7 @@
 
     // Are we saving the profile?
     if( "saveProfile".equals(request.getParameter("action")) ) {
-        UserManager userMgr = wiki.getUserManager();
+        UserManager userMgr = wiki.getManager( UserManager.class );
         UserProfile profile = userMgr.parseProfile( wikiContext );
          
         // Validate the profile
@@ -64,7 +66,7 @@
                 CookieAssertionLoginModule.setUserCookie( response, profile.getFullname() );
             } catch( DuplicateUserException due ) {
                 // User collision! (full name or wiki name already taken)
-                wikiSession.addMessage( "profile", wiki.getInternationalizationManager()
+                wikiSession.addMessage( "profile", wiki.getManager( InternationalizationManager.class )
                 		                               .get( InternationalizationManager.CORE_BUNDLE,
                 		                            		 Preferences.getLocale( wikiContext ), 
                 		                            		 due.getMessage(), due.getArgs() ) );
@@ -150,7 +152,7 @@
 
         // If wiki page was "Login", redirect to main, otherwise use the page supplied
         String redirectPage = request.getParameter( "redirect" );
-        if( !wiki.getPageManager().wikiPageExists( redirectPage ) ) {
+        if( !wiki.getManager( PageManager.class ).wikiPageExists( redirectPage ) ) {
            redirectPage = wiki.getFrontPage();
         }
         String viewUrl = ( "Login".equals( redirectPage ) ) ? "Wiki.jsp" : wikiContext.getViewURL( redirectPage );
diff --git a/jspwiki-war/src/main/webapp/LoginForm.jsp b/jspwiki-war/src/main/webapp/LoginForm.jsp
index d918357..0c58899 100644
--- a/jspwiki-war/src/main/webapp/LoginForm.jsp
+++ b/jspwiki-war/src/main/webapp/LoginForm.jsp
@@ -19,6 +19,8 @@
 
 <%@ page import="org.apache.log4j.*" %>
 <%@ page import="org.apache.wiki.*" %>
+<%@ page import="org.apache.wiki.api.core.*" %>
+<%@ page import="org.apache.wiki.ui.TemplateManager" %>
 <%@ page errorPage="/Error.jsp" %>
 <%@ taglib uri="http://jspwiki.apache.org/tags" prefix="wiki" %>
 <%!
@@ -34,7 +36,7 @@
 
 %>
 <%
-    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    Engine wiki = WikiEngine.getInstance( getServletConfig() );
     // Retrieve the Login page context, then go and find the login form
 
     WikiContext wikiContext = (WikiContext) pageContext.getAttribute( WikiContext.ATTR_CONTEXT, PageContext.REQUEST_SCOPE );
@@ -46,7 +48,7 @@
     }
     
     response.setContentType("text/html; charset="+wiki.getContentEncoding() );
-    String contentPage = wiki.getTemplateManager().findJSP( pageContext, wikiContext.getTemplate(), "ViewTemplate.jsp" );
+    String contentPage = wiki.getManager( TemplateManager.class ).findJSP( pageContext, wikiContext.getTemplate(), "ViewTemplate.jsp" );
                                                             
     log.debug("Login template content is: " + contentPage);
     
diff --git a/jspwiki-war/src/main/webapp/Logout.jsp b/jspwiki-war/src/main/webapp/Logout.jsp
index ac1142c..6a4a247 100644
--- a/jspwiki-war/src/main/webapp/Logout.jsp
+++ b/jspwiki-war/src/main/webapp/Logout.jsp
@@ -17,12 +17,14 @@
     under the License.  
 --%>
 
-<%@page import="org.apache.wiki.auth.login.CookieAuthenticationLoginModule"%>
 <%@page import="org.apache.wiki.WikiEngine" %>
+<%@page import="org.apache.wiki.api.core.Engine" %>
+<%@page import="org.apache.wiki.auth.AuthenticationManager" %>
 <%@page import="org.apache.wiki.auth.login.CookieAssertionLoginModule" %>
+<%@page import="org.apache.wiki.auth.login.CookieAuthenticationLoginModule"%>
 <%
-  WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
-  wiki.getAuthenticationManager().logout( request );
+  Engine wiki = WikiEngine.getInstance( getServletConfig() );
+  wiki.getManager( AuthenticationManager.class ).logout( request );
 
   // Clear the user cookie
   CookieAssertionLoginModule.clearUserCookie( response );
diff --git a/jspwiki-war/src/main/webapp/LostPassword.jsp b/jspwiki-war/src/main/webapp/LostPassword.jsp
index b5ce908..0dee9b9 100644
--- a/jspwiki-war/src/main/webapp/LostPassword.jsp
+++ b/jspwiki-war/src/main/webapp/LostPassword.jsp
@@ -23,10 +23,14 @@
 <%@ page import="javax.servlet.jsp.jstl.fmt.*"%>
 <%@ page import="org.apache.log4j.*"%>
 <%@ page import="org.apache.wiki.*"%>
+<%@ page import="org.apache.wiki.api.core.Engine"%>
+<%@ page import="org.apache.wiki.api.core.Session"%>
 <%@ page import="org.apache.wiki.auth.*"%>
 <%@ page import="org.apache.wiki.auth.user.*"%>
 <%@ page import="org.apache.wiki.i18n.*"%>
 <%@ page import="org.apache.wiki.preferences.Preferences" %>
+<%@ page import="org.apache.wiki.ui.TemplateManager" %>
+<%@ page import="org.apache.wiki.url.URLConstructor"%>
 <%@ page import="org.apache.wiki.util.*"%>
 <%@ page errorPage="/Error.jsp"%>
 <%@ taglib uri="http://jspwiki.apache.org/tags" prefix="wiki" %>
@@ -34,10 +38,10 @@
 
     String message = null;
 
-    public boolean resetPassword( WikiEngine wiki, HttpServletRequest request, ResourceBundle rb ) {
+    public boolean resetPassword( Engine wiki, HttpServletRequest request, ResourceBundle rb ) {
         // Reset pw for account name
         String name = request.getParameter( "name" );
-        UserDatabase userDatabase = wiki.getUserManager().getUserDatabase();
+        UserDatabase userDatabase = wiki.getManager( UserManager.class ).getUserDatabase();
         boolean success = false;
 
         try {
@@ -61,7 +65,7 @@
             // Try sending email first, as that is more likely to fail.
 
             Object[] args = { profile.getLoginName(), randomPassword, request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort() +
-                             wiki.getURLConstructor().makeURL( WikiContext.NONE, "Login.jsp", "" ), wiki.getApplicationName() };
+                             wiki.getManager( URLConstructor.class ).makeURL( WikiContext.NONE, "Login.jsp", "" ), wiki.getApplicationName() };
 
             String mailMessage = MessageFormat.format( rb.getString( "lostpwd.newpassword.email" ), args );
 
@@ -96,7 +100,7 @@
     }
 %>
 <%
-    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    Engine wiki = WikiEngine.getInstance( getServletConfig() );
 
     //Create wiki context like in Login.jsp:
     //don't check for access permissions: if you have lost your password you cannot login!
@@ -110,7 +114,7 @@
 
     ResourceBundle rb = Preferences.getBundle( wikiContext, "CoreResources" );
 
-    WikiSession wikiSession = wikiContext.getWikiSession();
+    Session wikiSession = wikiContext.getWikiSession();
     String action = request.getParameter( "action" );
 
     boolean done = false;
@@ -131,6 +135,6 @@
     response.setDateHeader( "Expires", new Date().getTime() );
     response.setDateHeader( "Last-Modified", new Date().getTime() );
 
-    String contentPage = wiki.getTemplateManager().findJSP( pageContext, wikiContext.getTemplate(), "ViewTemplate.jsp" );
+    String contentPage = wiki.getManager( TemplateManager.class ).findJSP( pageContext, wikiContext.getTemplate(), "ViewTemplate.jsp" );
 %>
 <wiki:Include page="<%=contentPage%>" />
diff --git a/jspwiki-war/src/main/webapp/Message.jsp b/jspwiki-war/src/main/webapp/Message.jsp
index fdff7a0..c2844c0 100755
--- a/jspwiki-war/src/main/webapp/Message.jsp
+++ b/jspwiki-war/src/main/webapp/Message.jsp
@@ -20,12 +20,14 @@
 <%@ page isErrorPage="true" %>
 <%@ page import="org.apache.log4j.*" %>
 <%@ page import="org.apache.wiki.*" %>
+<%@ page import="org.apache.wiki.api.core.*" %>
+<%@ page import="org.apache.wiki.ui.TemplateManager" %>
 <%@ taglib uri="http://jspwiki.apache.org/tags" prefix="wiki" %>
 <%! 
     Logger log = Logger.getLogger("JSPWiki"); 
 %>
 <%
-    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    Engine wiki = WikiEngine.getInstance( getServletConfig() );
     WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.MESSAGE );
 
     // Stash the wiki context and message text
@@ -34,6 +36,6 @@
 
     // Set the content type and include the response content
     response.setContentType( "text/html; charset=" + wiki.getContentEncoding() );
-    String contentPage = wiki.getTemplateManager().findJSP( pageContext, wikiContext.getTemplate(), "ViewTemplate.jsp" );
+    String contentPage = wiki.getManager( TemplateManager.class ).findJSP( pageContext, wikiContext.getTemplate(), "ViewTemplate.jsp" );
 
 %><wiki:Include page="<%=contentPage%>" />
\ No newline at end of file
diff --git a/jspwiki-war/src/main/webapp/NewBlogEntry.jsp b/jspwiki-war/src/main/webapp/NewBlogEntry.jsp
index f8128fa..034de4b 100644
--- a/jspwiki-war/src/main/webapp/NewBlogEntry.jsp
+++ b/jspwiki-war/src/main/webapp/NewBlogEntry.jsp
@@ -19,6 +19,7 @@
 
 <%@ page import="org.apache.log4j.*" %>
 <%@ page import="org.apache.wiki.*" %>
+<%@ page import="org.apache.wiki.api.core.*" %>
 <%@ page import="org.apache.wiki.plugin.*" %>
 <%@ page errorPage="/Error.jsp" %>
 <%@ taglib uri="http://jspwiki.apache.org/tags" prefix="wiki" %>
@@ -27,7 +28,7 @@
 %>
 
 <%
-    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    Engine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context; no need to check for authorization since the 
     // redirect will take care of that
     WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.EDIT );
diff --git a/jspwiki-war/src/main/webapp/NewGroup.jsp b/jspwiki-war/src/main/webapp/NewGroup.jsp
index a7194e2..7e6f0b8 100644
--- a/jspwiki-war/src/main/webapp/NewGroup.jsp
+++ b/jspwiki-war/src/main/webapp/NewGroup.jsp
@@ -17,30 +17,33 @@
     under the License.  
 --%>
 
+<%@ page import="java.text.*" %>
+<%@ page import="java.util.*" %>
 <%@ page import="org.apache.log4j.*" %>
 <%@ page import="org.apache.wiki.*" %>
+<%@ page import="org.apache.wiki.api.core.*" %>
 <%@ page import="org.apache.wiki.auth.NoSuchPrincipalException" %>
 <%@ page import="org.apache.wiki.auth.WikiSecurityException" %>
+<%@ page import="org.apache.wiki.auth.AuthorizationManager" %>
 <%@ page import="org.apache.wiki.auth.authorize.Group" %>
 <%@ page import="org.apache.wiki.auth.authorize.GroupManager" %>
 <%@ page import="org.apache.wiki.preferences.Preferences" %>
+<%@ page import="org.apache.wiki.ui.TemplateManager" %>
 <%@ page errorPage="/Error.jsp" %>
 <%@ taglib uri="http://jspwiki.apache.org/tags" prefix="wiki" %>
-<%@ page import="java.util.*" %>
-<%@ page import="java.text.*" %>
-<%! 
+<%!
     Logger log = Logger.getLogger("JSPWiki"); 
 %>
 
 <%
-    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    Engine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context and check for authorization
     WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.CREATE_GROUP );
-    if(!wiki.getAuthorizationManager().hasAccess( wikiContext, response )) return;
+    if(!wiki.getManager( AuthorizationManager.class ).hasAccess( wikiContext, response )) return;
     
     // Extract the current user, group name, members and action attributes
-    WikiSession wikiSession = wikiContext.getWikiSession();
-    GroupManager groupMgr = wiki.getGroupManager();
+    Session wikiSession = wikiContext.getWikiSession();
+    GroupManager groupMgr = wiki.getManager( GroupManager.class );
     Group group = null;
     try 
     {
@@ -95,9 +98,7 @@
 
     // Set the content type and include the response content
     response.setContentType("text/html; charset="+wiki.getContentEncoding() );
-    String contentPage = wiki.getTemplateManager().findJSP( pageContext,
-                                                            wikiContext.getTemplate(),
-                                                            "ViewTemplate.jsp" );
+    String contentPage = wiki.getManager( TemplateManager.class ).findJSP( pageContext, wikiContext.getTemplate(), "ViewTemplate.jsp" );
 
 %><wiki:Include page="<%=contentPage%>" />
 
diff --git a/jspwiki-war/src/main/webapp/PageInfo.jsp b/jspwiki-war/src/main/webapp/PageInfo.jsp
index ec7c848..5d11b78 100644
--- a/jspwiki-war/src/main/webapp/PageInfo.jsp
+++ b/jspwiki-war/src/main/webapp/PageInfo.jsp
@@ -19,7 +19,10 @@
 
 <%@ page import="org.apache.log4j.*" %>
 <%@ page import="org.apache.wiki.*" %>
+<%@ page import="org.apache.wiki.api.core.*" %>
+<%@ page import="org.apache.wiki.auth.AuthorizationManager" %>
 <%@ page import="org.apache.wiki.preferences.Preferences" %>
+<%@ page import="org.apache.wiki.ui.TemplateManager" %>
 <%@ page import="org.apache.wiki.util.*" %>
 <%@ page errorPage="/Error.jsp" %>
 <%@ taglib uri="http://jspwiki.apache.org/tags" prefix="wiki" %>
@@ -29,10 +32,10 @@
 %>
 
 <%
-    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    Engine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context and check for authorization
     WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.INFO );
-    if( !wiki.getAuthorizationManager().hasAccess( wikiContext, response ) ) return;
+    if( !wiki.getManager( AuthorizationManager.class ).hasAccess( wikiContext, response ) ) return;
     if( wikiContext.getCommand().getTarget() == null ) {
         response.sendRedirect( wikiContext.getURL( wikiContext.getRequestContext(), wikiContext.getName() ) );
         return;
@@ -45,9 +48,7 @@
 
     // Set the content type and include the response content
     response.setContentType("text/html; charset="+wiki.getContentEncoding() );
-    String contentPage = wiki.getTemplateManager().findJSP( pageContext,
-                                                            wikiContext.getTemplate(),
-                                                            "ViewTemplate.jsp" );
+    String contentPage = wiki.getManager( TemplateManager.class ).findJSP( pageContext, wikiContext.getTemplate(), "ViewTemplate.jsp" );
 %><wiki:Include page="<%=contentPage%>" />
 
 <% } finally { w.exitState(); } %>
\ No newline at end of file
diff --git a/jspwiki-war/src/main/webapp/PageModified.jsp b/jspwiki-war/src/main/webapp/PageModified.jsp
index b5f00a8..b815865 100644
--- a/jspwiki-war/src/main/webapp/PageModified.jsp
+++ b/jspwiki-war/src/main/webapp/PageModified.jsp
@@ -20,8 +20,12 @@
 <%@ page import="org.apache.log4j.*" %>
 <%@ page import="org.apache.commons.text.*" %>
 <%@ page import="org.apache.wiki.*" %>
+<%@ page import="org.apache.wiki.api.core.*" %>
+<%@ page import="org.apache.wiki.auth.AuthorizationManager" %>
+<%@ page import="org.apache.wiki.pages.PageManager" %>
 <%@ page import="org.apache.wiki.preferences.Preferences" %>
 <%@ page import="org.apache.wiki.ui.EditorManager" %>
+<%@ page import="org.apache.wiki.ui.TemplateManager" %>
 <%@ page import="org.apache.wiki.util.TextUtil" %>
 <%@ page errorPage="/Error.jsp" %>
 <%@ taglib uri="http://jspwiki.apache.org/tags" prefix="wiki" %>
@@ -31,10 +35,10 @@
 %>
 
 <%
-    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    Engine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context and check for authorization
     WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.CONFLICT );
-    if( !wiki.getAuthorizationManager().hasAccess( wikiContext, response ) ) return;
+    if( !wiki.getManager( AuthorizationManager.class ).hasAccess( wikiContext, response ) ) return;
     if( wikiContext.getCommand().getTarget() == null ) {
         response.sendRedirect( wikiContext.getURL( wikiContext.getRequestContext(), wikiContext.getName() ) );
         return;
@@ -46,22 +50,16 @@
     // Make the user and conflicting text presentable for display.
     usertext = StringEscapeUtils.escapeXml11( usertext );
 
-    String conflicttext = wiki.getPageManager().getText(pagereq);
+    String conflicttext = wiki.getManager( PageManager.class ).getText(pagereq);
     conflicttext = StringEscapeUtils.escapeXml11( conflicttext );
 
-    pageContext.setAttribute( "conflicttext",
-                              conflicttext,
-                              PageContext.REQUEST_SCOPE );
+    pageContext.setAttribute( "conflicttext", conflicttext, PageContext.REQUEST_SCOPE );
 
     log.info("Page concurrently modified "+pagereq);
-    pageContext.setAttribute( "usertext",
-                              usertext,
-                              PageContext.REQUEST_SCOPE );
+    pageContext.setAttribute( "usertext", usertext, PageContext.REQUEST_SCOPE );
 
     // Set the content type and include the response content
     response.setContentType("text/html; charset="+wiki.getContentEncoding() );
-    String contentPage = wiki.getTemplateManager().findJSP( pageContext,
-                                                            wikiContext.getTemplate(),
-                                                            "ViewTemplate.jsp" );
+    String contentPage = wiki.getManager( TemplateManager.class ).findJSP( pageContext, wikiContext.getTemplate(), "ViewTemplate.jsp" );
 %><wiki:Include page="<%=contentPage%>" />
 
diff --git a/jspwiki-war/src/main/webapp/Preview.jsp b/jspwiki-war/src/main/webapp/Preview.jsp
index 31d39d0..d6bfa02 100644
--- a/jspwiki-war/src/main/webapp/Preview.jsp
+++ b/jspwiki-war/src/main/webapp/Preview.jsp
@@ -17,12 +17,15 @@
     under the License.
 --%>
 
+<%@ page import="java.util.Date" %>
 <%@ page import="org.apache.log4j.*" %>
 <%@ page import="org.apache.wiki.*" %>
+<%@ page import="org.apache.wiki.api.core.*" %>
+<%@ page import="org.apache.wiki.auth.AuthorizationManager" %>
 <%@ page import="org.apache.wiki.filters.*" %>
 <%@ page import="org.apache.wiki.preferences.Preferences" %>
-<%@ page import="java.util.Date" %>
 <%@ page import="org.apache.wiki.ui.EditorManager" %>
+<%@ page import="org.apache.wiki.ui.TemplateManager" %>
 <%@ page errorPage="/Error.jsp" %>
 <%@ taglib uri="http://jspwiki.apache.org/tags" prefix="wiki" %>
 <%!
@@ -30,30 +33,24 @@
 %>
 
 <%
-    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    Engine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context and check for authorization
     WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.PREVIEW );
-    if( !wiki.getAuthorizationManager().hasAccess( wikiContext, response ) ) return;
+    if( !wiki.getManager( AuthorizationManager.class ).hasAccess( wikiContext, response ) ) return;
     if( wikiContext.getCommand().getTarget() == null ) {
         response.sendRedirect( wikiContext.getURL( wikiContext.getRequestContext(), wikiContext.getName() ) );
         return;
     }
     String pagereq = wikiContext.getName();
 
-    pageContext.setAttribute( EditorManager.ATTR_EDITEDTEXT,
-                              session.getAttribute( EditorManager.REQ_EDITEDTEXT ),
-                              PageContext.REQUEST_SCOPE );
+    pageContext.setAttribute( EditorManager.ATTR_EDITEDTEXT, session.getAttribute( EditorManager.REQ_EDITEDTEXT ), PageContext.REQUEST_SCOPE );
 
     String lastchange = SpamFilter.getSpamHash( wikiContext.getPage(), request );
 
-    pageContext.setAttribute( "lastchange",
-                              lastchange,
-                              PageContext.REQUEST_SCOPE );
+    pageContext.setAttribute( "lastchange", lastchange, PageContext.REQUEST_SCOPE );
 
     // Set the content type and include the response content
     response.setContentType("text/html; charset="+wiki.getContentEncoding() );
-    String contentPage = wiki.getTemplateManager().findJSP( pageContext,
-                                                            wikiContext.getTemplate(),
-                                                            "ViewTemplate.jsp" );
+    String contentPage = wiki.getManager( TemplateManager.class ).findJSP( pageContext, wikiContext.getTemplate(), "ViewTemplate.jsp" );
 %><wiki:Include page="<%=contentPage%>" />
 
diff --git a/jspwiki-war/src/main/webapp/Rename.jsp b/jspwiki-war/src/main/webapp/Rename.jsp
index 7d5b767..db23a86 100644
--- a/jspwiki-war/src/main/webapp/Rename.jsp
+++ b/jspwiki-war/src/main/webapp/Rename.jsp
@@ -17,29 +17,33 @@
     under the License.
 --%>
 
+<%@ page import="java.text.*" %>
+<%@ page import="java.util.*" %>
 <%@ page import="org.apache.log4j.*" %>
 <%@ page import="org.apache.wiki.*" %>
-<%@ page import="org.apache.wiki.util.HttpUtil" %>
+<%@ page import="org.apache.wiki.api.core.*" %>
 <%@ page import="org.apache.wiki.api.exceptions.WikiException" %>
+<%@ page import="org.apache.wiki.auth.AuthorizationManager" %>
+<%@ page import="org.apache.wiki.content.PageRenamer" %>
+<%@ page import="org.apache.wiki.util.HttpUtil" %>
 <%@ page import="org.apache.wiki.preferences.Preferences" %>
 <%@ page import="org.apache.wiki.tags.BreadcrumbsTag" %>
 <%@ page import="org.apache.wiki.tags.BreadcrumbsTag.FixedQueue" %>
+<%@ page import="org.apache.wiki.ui.TemplateManager" %>
 <%@ page import="org.apache.wiki.util.TextUtil" %>
 <%@ page errorPage="/Error.jsp" %>
 <%@ taglib uri="http://jspwiki.apache.org/tags" prefix="wiki" %>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
-<%@ page import="java.util.*" %>
-<%@ page import="java.text.*" %>
 <fmt:setBundle basename="CoreResources"/>
 <%!
     Logger log = Logger.getLogger("JSPWiki");
 %>
 
 <%
-    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    Engine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context and check for authorization
 	WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.RENAME );
-	if( !wiki.getAuthorizationManager().hasAccess( wikiContext, response ) ) return;
+	if( !wiki.getManager( AuthorizationManager.class ).hasAccess( wikiContext, response ) ) return;
     if( wikiContext.getCommand().getTarget() == null ) {
         response.sendRedirect( wikiContext.getURL( wikiContext.getRequestContext(), wikiContext.getName() ) );
         return;
@@ -59,16 +63,15 @@
 
     log.info("Page rename request for page '"+renameFrom+ "' to new name '"+renameTo+"' from "+HttpUtil.getRemoteAddress(request)+" by "+request.getRemoteUser() );
 
-    WikiSession wikiSession = wikiContext.getWikiSession();
+    Session wikiSession = wikiContext.getWikiSession();
     try
     {
         if (renameTo.length() > 0)
         {
-            String renamedTo = wiki.getPageRenamer().renamePage(wikiContext, renameFrom, renameTo, changeReferences);
+            String renamedTo = wiki.getManager( PageRenamer.class ).renamePage(wikiContext, renameFrom, renameTo, changeReferences);
 
             FixedQueue trail = (FixedQueue) session.getAttribute( BreadcrumbsTag.BREADCRUMBTRAIL_KEY );
-            if( trail != null )
-            {
+            if( trail != null ) {
                 trail.removeItem( renameFrom );
                 session.setAttribute( BreadcrumbsTag.BREADCRUMBTRAIL_KEY, trail );
             }
@@ -101,13 +104,8 @@
 
     }
 
-    pageContext.setAttribute( "renameto",
-                              TextUtil.replaceEntities( renameTo ),
-                              PageContext.REQUEST_SCOPE );
-
-    response.setContentType("text/html; charset="+wiki.getContentEncoding() );
-    String contentPage = wiki.getTemplateManager().findJSP( pageContext,
-                                                            wikiContext.getTemplate(),
-                                                            "ViewTemplate.jsp" );
+    pageContext.setAttribute( "renameto", TextUtil.replaceEntities( renameTo ), PageContext.REQUEST_SCOPE );
+    response.setContentType("text/html; charset=" + wiki.getContentEncoding() );
+    String contentPage = wiki.getManager( TemplateManager.class ).findJSP( pageContext, wikiContext.getTemplate(), "ViewTemplate.jsp" );
 
 %><wiki:Include page="<%=contentPage%>" />
\ No newline at end of file
diff --git a/jspwiki-war/src/main/webapp/Search.jsp b/jspwiki-war/src/main/webapp/Search.jsp
index dce8b51..2286d79 100644
--- a/jspwiki-war/src/main/webapp/Search.jsp
+++ b/jspwiki-war/src/main/webapp/Search.jsp
@@ -17,14 +17,16 @@
     under the License.
 --%>
 
+<%@ page import="java.util.*" %>
 <%@ page import="org.apache.log4j.*" %>
 <%@ page import="org.apache.wiki.*" %>
+<%@ page import="org.apache.wiki.api.core.*" %>
 <%@ page import="org.apache.wiki.auth.*" %>
 <%@ page import="org.apache.wiki.auth.permissions.*" %>
 <%@ page import="org.apache.wiki.preferences.Preferences" %>
-<%@ page import="org.apache.wiki.util.TextUtil" %>
 <%@ page import="org.apache.wiki.search.*" %>
-<%@ page import="java.util.*" %>
+<%@ page import="org.apache.wiki.ui.TemplateManager" %>
+<%@ page import="org.apache.wiki.util.TextUtil" %>
 <%@ page errorPage="/Error.jsp" %>
 <%@ taglib uri="http://jspwiki.apache.org/tags" prefix="wiki" %>
 
@@ -33,10 +35,10 @@
 %>
 
 <%
-    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    Engine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context and check for authorization
     WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.FIND );
-    if(!wiki.getAuthorizationManager().hasAccess( wikiContext, response )) return;
+    if(!wiki.getManager( AuthorizationManager.class ).hasAccess( wikiContext, response )) return;
     String pagereq = wikiContext.getName();
 
     // Get the search results
@@ -44,20 +46,13 @@
     String query = request.getParameter( "query");
     String go    = request.getParameter("go");
 
-    if( query != null )
-    {
+    if( query != null ) {
         log.info("Searching for string "+query);
 
-        try
-        {
-            list = wiki.getSearchManager().findPages( query, wikiContext );
-
-            pageContext.setAttribute( "searchresults",
-                                      list,
-                                      PageContext.REQUEST_SCOPE );
-        }
-        catch( Exception e )
-        {
+        try {
+            list = wiki.getManager( SearchManager.class ).findPages( query, wikiContext );
+            pageContext.setAttribute( "searchresults", list, PageContext.REQUEST_SCOPE );
+        } catch( Exception e ) {
             wikiContext.getWikiSession().addMessage( e.getMessage() );
         }
 
@@ -89,9 +84,7 @@
 
     // Set the content type and include the response content
     response.setContentType("text/html; charset="+wiki.getContentEncoding() );
-    String contentPage = wiki.getTemplateManager().findJSP( pageContext,
-                                                            wikiContext.getTemplate(),
-                                                            "ViewTemplate.jsp" );
+    String contentPage = wiki.getManager( TemplateManager.class ).findJSP( pageContext, wikiContext.getTemplate(), "ViewTemplate.jsp" );
 %><wiki:Include page="<%=contentPage%>" /><%
     log.debug("SEARCH COMPLETE");
 %>
diff --git a/jspwiki-war/src/main/webapp/SisterSites.jsp b/jspwiki-war/src/main/webapp/SisterSites.jsp
index d7fc719..dde554a 100644
--- a/jspwiki-war/src/main/webapp/SisterSites.jsp
+++ b/jspwiki-war/src/main/webapp/SisterSites.jsp
@@ -17,10 +17,14 @@
     under the License.  
 --%>
 
-<%@ page import="java.util.*,org.apache.wiki.*" %>
-<%@ page import="org.apache.log4j.*" %>
 <%@ page import="java.text.*" %>
+<%@ page import="java.util.*" %>
+<%@ page import="org.apache.log4j.*" %>
+<%@ page import="org.apache.wiki.*" %>
+<%@ page import="org.apache.wiki.api.core.*" %>
+<%@ page import="org.apache.wiki.auth.AuthorizationManager" %>
 <%@ page import="org.apache.wiki.preferences.Preferences" %>
+<%@ page import="org.apache.wiki.references.ReferenceManager" %>
 <%@ page import="org.apache.wiki.rss.*" %>
 <%@ page import="org.apache.wiki.util.*" %>
 <%!
@@ -33,16 +37,15 @@
      *
      *  FIXME: Does not honor the ACL's on the pages.
      */
-    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    Engine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context and check for authorization
     WikiContext wikiContext = new WikiContext( wiki, request, "rss" );
-    if(!wiki.getAuthorizationManager().hasAccess( wikiContext, response )) return;
+    if(!wiki.getManager( AuthorizationManager.class ).hasAccess( wikiContext, response )) return;
     
-    Set< String > allPages = wiki.getReferenceManager().findCreated();
+    Set< String > allPages = wiki.getManager( ReferenceManager.class ).findCreated();
     
     response.setContentType("text/plain; charset=UTF-8");
-    for( Iterator< String > i = allPages.iterator(); i.hasNext(); )
-    {
+    for( Iterator< String > i = allPages.iterator(); i.hasNext(); ) {
         String pageName = i.next();
         
         // Let's not add attachments.
diff --git a/jspwiki-war/src/main/webapp/Upload.jsp b/jspwiki-war/src/main/webapp/Upload.jsp
index db1002e..729a62d 100644
--- a/jspwiki-war/src/main/webapp/Upload.jsp
+++ b/jspwiki-war/src/main/webapp/Upload.jsp
@@ -19,7 +19,10 @@
 
 <%@ page import="org.apache.log4j.*" %>
 <%@ page import="org.apache.wiki.*" %>
+<%@ page import="org.apache.wiki.api.core.*" %>
+<%@ page import="org.apache.wiki.auth.AuthorizationManager" %>
 <%@ page import="org.apache.wiki.preferences.Preferences" %>
+<%@ page import="org.apache.wiki.ui.TemplateManager" %>
 <%@ page errorPage="/Error.jsp" %>
 <%@ taglib uri="http://jspwiki.apache.org/tags" prefix="wiki" %>
 
@@ -29,14 +32,14 @@
 %>
 
 <% 
-    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    Engine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context and check for authorization
     WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.UPLOAD );
-    if(!wiki.getAuthorizationManager().hasAccess( wikiContext, response )) return;
+    if(!wiki.getManager( AuthorizationManager.class ).hasAccess( wikiContext, response )) return;
     String pagereq = wikiContext.getName();
 
     // Set the content type and include the response content
     response.setContentType("text/html; charset="+wiki.getContentEncoding() );
-    String contentPage = wiki.getTemplateManager().findJSP( pageContext, wikiContext.getTemplate(), "UploadTemplate.jsp" );
+    String contentPage = wiki.getManager( TemplateManager.class ).findJSP( pageContext, wikiContext.getTemplate(), "UploadTemplate.jsp" );
 %><wiki:Include page="<%=contentPage%>" />
 
diff --git a/jspwiki-war/src/main/webapp/UserPreferences.jsp b/jspwiki-war/src/main/webapp/UserPreferences.jsp
index 1cc5b89..3d4c2bc 100644
--- a/jspwiki-war/src/main/webapp/UserPreferences.jsp
+++ b/jspwiki-war/src/main/webapp/UserPreferences.jsp
@@ -19,14 +19,17 @@
 
 <%@ page import="org.apache.log4j.*" %>
 <%@ page import="org.apache.wiki.WikiContext" %>
-<%@ page import="org.apache.wiki.WikiSession" %>
 <%@ page import="org.apache.wiki.WikiEngine" %>
+<%@ page import="org.apache.wiki.api.core.Engine" %>
+<%@ page import="org.apache.wiki.api.core.Session" %>
+<%@ page import="org.apache.wiki.auth.AuthorizationManager" %>
 <%@ page import="org.apache.wiki.auth.UserManager" %>
 <%@ page import="org.apache.wiki.auth.WikiSecurityException" %>
 <%@ page import="org.apache.wiki.auth.login.CookieAssertionLoginModule" %>
 <%@ page import="org.apache.wiki.auth.user.DuplicateUserException" %>
 <%@ page import="org.apache.wiki.auth.user.UserProfile" %>
 <%@ page import="org.apache.wiki.i18n.InternationalizationManager" %>
+<%@ page import="org.apache.wiki.pages.PageManager" %>
 <%@ page import="org.apache.wiki.preferences.Preferences" %>
 <%@ page import="org.apache.wiki.ui.EditorManager" %>
 <%@ page import="org.apache.wiki.ui.TemplateManager" %>
@@ -40,14 +43,14 @@
 %>
 
 <%
-    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    Engine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context and check for authorization
     WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.PREFS );
-    if(!wiki.getAuthorizationManager().hasAccess( wikiContext, response )) return;
+    if(!wiki.getManager( AuthorizationManager.class ).hasAccess( wikiContext, response ) ) return;
     
     // Extract the user profile and action attributes
-    UserManager userMgr = wiki.getUserManager();
-    WikiSession wikiSession = wikiContext.getWikiSession();
+    UserManager userMgr = wiki.getManager( UserManager.class );
+    Session wikiSession = wikiContext.getWikiSession();
 
 /* FIXME: Obsolete
     if( request.getParameter(EditorManager.PARA_EDITOR) != null )
@@ -76,7 +79,7 @@
             catch( DuplicateUserException due )
             {
                 // User collision! (full name or wiki name already taken)
-                wikiSession.addMessage( "profile", wiki.getInternationalizationManager()
+                wikiSession.addMessage( "profile", wiki.getManager( InternationalizationManager.class )
                                                        .get( InternationalizationManager.CORE_BUNDLE,
                                                     		 Preferences.getLocale( wikiContext ), 
                                                              due.getMessage(), due.getArgs() ) );
@@ -97,7 +100,7 @@
         {
             String redirectPage = request.getParameter( "redirect" );
 
-            if( !wiki.getPageManager().wikiPageExists( redirectPage ) )
+            if( !wiki.getManager( PageManager.class ).wikiPageExists( redirectPage ) )
             {
                redirectPage = wiki.getFrontPage();
             }
@@ -116,7 +119,7 @@
         CookieAssertionLoginModule.setUserCookie( response, assertedName );
 
         String redirectPage = request.getParameter( "redirect" );
-        if( !wiki.getPageManager().wikiPageExists( redirectPage ) )
+        if( !wiki.getManager( PageManager.class ).wikiPageExists( redirectPage ) )
         {
           redirectPage = wiki.getFrontPage();
         }
@@ -133,6 +136,6 @@
         return;
     }
     response.setContentType("text/html; charset="+wiki.getContentEncoding() );
-    String contentPage = wiki.getTemplateManager().findJSP( pageContext, wikiContext.getTemplate(), "ViewTemplate.jsp" );
+    String contentPage = wiki.getManager( TemplateManager.class ).findJSP( pageContext, wikiContext.getTemplate(), "ViewTemplate.jsp" );
 %><wiki:Include page="<%=contentPage%>" />
 
diff --git a/jspwiki-war/src/main/webapp/Wiki.jsp b/jspwiki-war/src/main/webapp/Wiki.jsp
index b6fc66d..5b18bdc 100644
--- a/jspwiki-war/src/main/webapp/Wiki.jsp
+++ b/jspwiki-war/src/main/webapp/Wiki.jsp
@@ -17,11 +17,14 @@
     under the License.
 --%>
 
+<%@ page import="org.apache.commons.lang3.time.StopWatch" %>
 <%@ page import="org.apache.log4j.*" %>
 <%@ page import="org.apache.wiki.*" %>
+<%@ page import="org.apache.wiki.api.core.*" %>
+<%@ page import="org.apache.wiki.auth.AuthorizationManager" %>
 <%@ page import="org.apache.wiki.preferences.Preferences" %>
+<%@ page import="org.apache.wiki.ui.TemplateManager" %>
 <%@ page import="org.apache.wiki.util.*" %>
-<%@ page import="org.apache.commons.lang3.time.StopWatch" %>
 <%@ page errorPage="/Error.jsp" %>
 <%@ taglib uri="http://jspwiki.apache.org/tags" prefix="wiki" %>
 <%!
@@ -29,10 +32,10 @@
 %>
 
 <%
-    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    Engine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context and check for authorization
     WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.VIEW );
-    if( !wiki.getAuthorizationManager().hasAccess( wikiContext, response ) ) return;
+    if( !wiki.getManager( AuthorizationManager.class ).hasAccess( wikiContext, response ) ) return;
     String pagereq = wikiContext.getName();
 
     // Redirect if request was for a special page
@@ -51,9 +54,7 @@
 
         // Set the content type and include the response content
         response.setContentType("text/html; charset="+wiki.getContentEncoding() );
-        String contentPage = wiki.getTemplateManager().findJSP( pageContext,
-                                                                wikiContext.getTemplate(),
-                                                                "ViewTemplate.jsp" );
+        String contentPage = wiki.getManager( TemplateManager.class ).findJSP( pageContext, wikiContext.getTemplate(), "ViewTemplate.jsp" );
 
 %><wiki:Include page="<%=contentPage%>" /><%
     }
diff --git a/jspwiki-war/src/main/webapp/Workflow.jsp b/jspwiki-war/src/main/webapp/Workflow.jsp
index 5c5b5d3..f9a5b14 100644
--- a/jspwiki-war/src/main/webapp/Workflow.jsp
+++ b/jspwiki-war/src/main/webapp/Workflow.jsp
@@ -21,14 +21,18 @@
 <%@ page import="java.util.Iterator" %>
 <%@ page import="org.apache.log4j.*" %>
 <%@ page import="org.apache.wiki.WikiContext" %>
-<%@ page import="org.apache.wiki.WikiSession" %>
 <%@ page import="org.apache.wiki.WikiEngine" %>
+<%@ page import="org.apache.wiki.api.core.Engine" %>
+<%@ page import="org.apache.wiki.api.core.Session" %>
+<%@ page import="org.apache.wiki.auth.AuthorizationManager" %>
 <%@ page import="org.apache.wiki.preferences.Preferences" %>
+<%@ page import="org.apache.wiki.ui.TemplateManager" %>
 <%@ page import="org.apache.wiki.workflow.Decision" %>
 <%@ page import="org.apache.wiki.workflow.DecisionQueue" %>
 <%@ page import="org.apache.wiki.workflow.NoSuchOutcomeException" %>
 <%@ page import="org.apache.wiki.workflow.Outcome" %>
 <%@ page import="org.apache.wiki.workflow.Workflow" %>
+<%@ page import="org.apache.wiki.workflow.WorkflowManager" %>
 <%@ page errorPage="/Error.jsp" %>
 <%@ taglib uri="http://jspwiki.apache.org/tags" prefix="wiki" %>
 <%!
@@ -36,16 +40,16 @@
 %>
 
 <%
-    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    Engine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context and check for authorization
     WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.WORKFLOW );
-    if(!wiki.getAuthorizationManager().hasAccess( wikiContext, response )) return;
+    if(!wiki.getManager( AuthorizationManager.class ).hasAccess( wikiContext, response )) return;
     
     // Extract the wiki session
-    WikiSession wikiSession = wikiContext.getWikiSession();
+    Session wikiSession = wikiContext.getWikiSession();
     
     // Get the current decisions
-    DecisionQueue dq = wiki.getWorkflowManager().getDecisionQueue();
+    DecisionQueue dq = wiki.getManager( WorkflowManager.class ).getDecisionQueue();
 
     if( "decide".equals(request.getParameter("action")) )
     {
@@ -83,7 +87,7 @@
           // Extract parameters for decision ID & decision outcome
           int id = Integer.parseInt( request.getParameter( "id" ) );
           // Iterate through our owner decisions and see if we can find an ID match
-          Collection< Workflow > workflows = wiki.getWorkflowManager().getOwnerWorkflows(wikiSession);
+          Collection< Workflow > workflows = wiki.getManager( WorkflowManager.class ).getOwnerWorkflows(wikiSession);
           for (Iterator< Workflow > it = workflows.iterator(); it.hasNext();)
           {
             Workflow w = it.next();
@@ -102,12 +106,10 @@
     
     // Stash the current decisions/workflows
     request.setAttribute("decisions",   dq.getActorDecisions(wikiSession));
-    request.setAttribute("workflows",   wiki.getWorkflowManager().getOwnerWorkflows(wikiSession));
+    request.setAttribute("workflows",   wiki.getManager( WorkflowManager.class ).getOwnerWorkflows( wikiSession ) );
     request.setAttribute("wikiSession", wikiSession);
     
     response.setContentType("text/html; charset="+wiki.getContentEncoding() );
-    String contentPage = wiki.getTemplateManager().findJSP( pageContext,
-                                                            wikiContext.getTemplate(),
-                                                            "ViewTemplate.jsp" );
+    String contentPage = wiki.getManager( TemplateManager.class ).findJSP( pageContext, wikiContext.getTemplate(), "ViewTemplate.jsp" );
 %><wiki:Include page="<%=contentPage%>" />
 
diff --git a/jspwiki-war/src/main/webapp/XHRHtml2Markup.jsp b/jspwiki-war/src/main/webapp/XHRHtml2Markup.jsp
index de0f96f..7a6caec 100644
--- a/jspwiki-war/src/main/webapp/XHRHtml2Markup.jsp
+++ b/jspwiki-war/src/main/webapp/XHRHtml2Markup.jsp
@@ -20,6 +20,8 @@
 <%@ page language="java" pageEncoding="UTF-8"%>
 <%@ page import="org.apache.log4j.*" %>
 <%@ page import="org.apache.wiki.*" %>
+<%@ page import="org.apache.wiki.api.core.*" %>
+<%@ page import="org.apache.wiki.auth.AuthorizationManager" %>
 <%@ page import="org.apache.wiki.htmltowiki.HtmlStringToWikiTranslator" %>
 <%@ taglib uri="http://jspwiki.apache.org/tags" prefix="wiki" %>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
@@ -29,12 +31,12 @@
     wiki = WikiEngine.getInstance( getServletConfig() );
   }
   //Logger log = Logger.getLogger("XHRHtml2Markup");
-  WikiEngine wiki;
+  Engine wiki;
 %>
 <%
   WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.VIEW );
 
-  if( !wiki.getAuthorizationManager().hasAccess( wikiContext, response ) ) return;
+  if( !wiki.getManager( AuthorizationManager.class ).hasAccess( wikiContext, response ) ) return;
 
   response.setContentType("text/html; charset="+wiki.getContentEncoding() );
   //response.setHeader( "Cache-control", "max-age=0" );
diff --git a/jspwiki-war/src/main/webapp/admin/SecurityConfig.jsp b/jspwiki-war/src/main/webapp/admin/SecurityConfig.jsp
index f0f59de..894c68b 100644
--- a/jspwiki-war/src/main/webapp/admin/SecurityConfig.jsp
+++ b/jspwiki-war/src/main/webapp/admin/SecurityConfig.jsp
@@ -21,6 +21,7 @@
 <%@ page import="java.security.Principal" %>
 <%@ page import="org.apache.log4j.*" %>
 <%@ page import="org.apache.wiki.*" %>
+<%@ page import="org.apache.wiki.api.core.*" %>
 <%@ page import="org.apache.wiki.auth.*" %>
 <%@ page import="org.apache.wiki.preferences.Preferences" %>
 <%@ page import="org.apache.wiki.util.TextUtil" %>
@@ -31,14 +32,14 @@
     wiki = WikiEngine.getInstance( getServletConfig() );
   }
   Logger log = Logger.getLogger("JSPWiki");
-  WikiEngine wiki;
+  Engine wiki;
   SecurityVerifier verifier;
 %>
 <!doctype html>
 <html lang="en" name="top">
 <%
   WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.NONE );
-  if(!wiki.getAuthorizationManager().hasAccess( wikiContext, response )) return;
+  if(!wiki.getManager( AuthorizationManager.class ).hasAccess( wikiContext, response )) return;
   response.setContentType("text/html; charset="+wiki.getContentEncoding() );
   verifier = new SecurityVerifier( wiki, wikiContext.getWikiSession() );
 
@@ -118,17 +119,14 @@ and everyone in between. You have been warned.  You can turn it off by setting</
 -->
 <h3>Container-Managed Authentication</h3>
 <%
-  boolean isContainerAuth = wiki.getAuthenticationManager().isContainerAuthenticated();
-  AuthorizationManager authorizationManager = wiki.getAuthorizationManager();
-  if ( isContainerAuth )
-  {
+  boolean isContainerAuth = wiki.getManager( AuthenticationManager.class ).isContainerAuthenticated();
+  AuthorizationManager authorizationManager = wiki.getManager( AuthorizationManager.class );
+  if( isContainerAuth ) {
 %>
     <!-- We are using container auth -->
     <p>I see that you've configured container-managed authentication. Very nice.</p>
 <%
-  }
-  else
-  {
+  } else {
 %>
     <!-- We are not using container auth -->
     <p>Container-managed authentication appears to be disabled, according to your <code>WEB-INF/web.xml</code> file.</p>
diff --git a/jspwiki-war/src/main/webapp/rss.jsp b/jspwiki-war/src/main/webapp/rss.jsp
index e60bd38..e38d3d9 100644
--- a/jspwiki-war/src/main/webapp/rss.jsp
+++ b/jspwiki-war/src/main/webapp/rss.jsp
@@ -19,16 +19,20 @@
 
 <?xml version="1.0" encoding="UTF-8"?>
 
+<%@ page import="java.text.*" %>
 <%@ page import="java.util.*" %>
+<%@ page import="net.sf.ehcache.Cache" %>
+<%@ page import="net.sf.ehcache.Element" %>
+<%@ page import="net.sf.ehcache.CacheManager" %>
 <%@ page import="org.apache.log4j.*" %>
-<%@ page import="java.text.*" %>
 <%@ page import="org.apache.wiki.*" %>
+<%@ page import="org.apache.wiki.api.core.*" %>
+<%@ page import="org.apache.wiki.auth.AuthorizationManager" %>
+<%@ page import="org.apache.wiki.plugin.WeblogPlugin" %>
+<%@ page import="org.apache.wiki.pages.PageManager" %>
 <%@ page import="org.apache.wiki.preferences.Preferences" %>
 <%@ page import="org.apache.wiki.rss.*" %>
 <%@ page import="org.apache.wiki.util.*" %>
-<%@ page import="net.sf.ehcache.Cache" %>
-<%@ page import="net.sf.ehcache.Element" %>
-<%@ page import="net.sf.ehcache.CacheManager" %>
 
 <%!
     private Logger log = Logger.getLogger("JSPWiki");
@@ -47,23 +51,20 @@
         m_rssCache = new Cache(cacheName, cacheCapacity, false, false, m_expiryPeriod, m_expiryPeriod);
         m_cacheManager.addCache(m_rssCache);
     }
-    WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
+    Engine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context and check for authorization
     WikiContext wikiContext = new WikiContext( wiki, request, "rss" );
-    if(!wiki.getAuthorizationManager().hasAccess( wikiContext, response )) return;
-    WikiPage    wikipage    = wikiContext.getPage();
+    if(!wiki.getManager( AuthorizationManager.class ).hasAccess( wikiContext, response ) ) return;
+    WikiPage wikipage = wikiContext.getPage();
 
     // Redirect if RSS generation not on
-
-    if( wiki.getRSSGenerator() == null )
-    {
+    if( wiki.getManager( RSSGenerator.class ) == null ) {
         response.sendError( 404, "RSS feeds are disabled at administrator request" );
         return;
     }
 
-    if( wikipage == null || !wiki.getPageManager().wikiPageExists(wikipage.getName()) )
-    {
-        response.sendError( 404, "No such page "+wikipage.getName() );
+    if( wikipage == null || !wiki.getManager( PageManager.class ).wikiPageExists( wikipage.getName() ) ) {
+        response.sendError( 404, "No such page " + wikipage.getName() );
         return;
     }
 
@@ -74,11 +75,12 @@
     String      mode        = request.getParameter("mode");
     String      type        = request.getParameter("type");
     
-    if( mode == null || !(mode.equals(RSSGenerator.MODE_BLOG) || mode.equals(RSSGenerator.MODE_WIKI)) ) 
+    if( mode == null || !(mode.equals(RSSGenerator.MODE_BLOG) || mode.equals(RSSGenerator.MODE_WIKI)) ) {
     	   mode = RSSGenerator.MODE_BLOG;
-    if( type == null || !(type.equals(RSSGenerator.RSS10) || type.equals(RSSGenerator.RSS20) || type.equals(RSSGenerator.ATOM)) ) 
+    }
+    if( type == null || !(type.equals(RSSGenerator.RSS10) || type.equals(RSSGenerator.RSS20) || type.equals(RSSGenerator.ATOM ) ) ) {
     	   type = RSSGenerator.RSS20;
-    
+    }
     // Set the content type and include the response content
     response.setContentType( RSSGenerator.getContentType(type)+"; charset=UTF-8");
 
@@ -95,10 +97,10 @@
     List< WikiPage > changed;
     
     if( "blog".equals( mode ) ) {
-        org.apache.wiki.plugin.WeblogPlugin plug = new org.apache.wiki.plugin.WeblogPlugin();
+        WeblogPlugin plug = new WeblogPlugin();
         changed = plug.findBlogEntries( wiki, wikipage.getName(), new Date(0L), new Date() );
     } else {
-        changed = wiki.getPageManager().getVersionHistory( wikipage.getName() );
+        changed = wiki.getManager( PageManager.class ).getVersionHistory( wikipage.getName() );
     }
     
     //
@@ -128,8 +130,7 @@
     //  based on the LastModified-date, so whenever it changes, so does
     //  the hashkey so we don't have to make any special modifications.
     //
-    //  TODO: Figure out if it would be a good idea to use a disk-based
-    //        cache here.
+    //  TODO: Figure out if it would be a good idea to use a disk-based cache here.
     //
     String hashKey = wikipage.getName()+";"+mode+";"+type+";"+latest.getTime();
     
@@ -139,11 +140,11 @@
     if (element != null) {
       rss = (String) element.getObjectValue();
     } else { 
-        rss = wiki.getRSSGenerator().generateFeed( wikiContext, changed, mode, type );
-        m_rssCache.put(new Element(hashKey,rss));
+        rss = wiki.getManager( RSSGenerator.class ).generateFeed( wikiContext, changed, mode, type );
+        m_rssCache.put( new Element( hashKey, rss ) );
     }
     
-    out.println(rss);
+    out.println( rss );
     
     w.exitState(); 
-    %>
+    %>
\ No newline at end of file
diff --git a/jspwiki-war/src/main/webapp/templates/210/EditGroupContent.jsp b/jspwiki-war/src/main/webapp/templates/210/EditGroupContent.jsp
index 7335f31..410e67a 100644
--- a/jspwiki-war/src/main/webapp/templates/210/EditGroupContent.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/EditGroupContent.jsp
@@ -21,10 +21,10 @@
 <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
 <%@ page import="java.security.Principal" %>
 <%@ page import="java.util.Arrays" %>
-<%@ page import="org.apache.wiki.auth.PrincipalComparator" %>
-<%@ page import="org.apache.wiki.auth.authorize.Group" %>
 <%@ page import="org.apache.wiki.*" %>
+<%@ page import="org.apache.wiki.auth.authorize.Group" %>
 <%@ page import="org.apache.wiki.util.TextUtil" %>
+<%@ page import="org.apache.wiki.util.comparators.PrincipalComparator" %>
 <%@ page import="org.apache.log4j.*" %>
 <%@ page import="javax.servlet.jsp.jstl.fmt.*" %>
 <%@ page errorPage="/Error.jsp" %>
diff --git a/jspwiki-war/src/main/webapp/templates/210/GroupContent.jsp b/jspwiki-war/src/main/webapp/templates/210/GroupContent.jsp
index 35b4bfc..51c270a 100644
--- a/jspwiki-war/src/main/webapp/templates/210/GroupContent.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/GroupContent.jsp
@@ -22,11 +22,11 @@
 <%@ page import="java.security.Principal" %>
 <%@ page import="java.util.*" %>
 <%@ page import="org.apache.wiki.*" %>
-<%@ page import="org.apache.wiki.auth.PrincipalComparator" %>
 <%@ page import="org.apache.wiki.auth.authorize.Group" %>
 <%@ page import="org.apache.wiki.auth.authorize.GroupManager" %>
 <%@ page import="org.apache.wiki.preferences.Preferences" %>
 <%@ page import="org.apache.wiki.util.TextUtil" %>
+<%@ page import="org.apache.wiki.util.comparators.PrincipalComparator" %>
 <%@ page import="org.apache.log4j.*" %>
 <%@ page errorPage="/Error.jsp" %>
 <%@ page import="javax.servlet.jsp.jstl.fmt.*" %>
diff --git a/jspwiki-war/src/main/webapp/templates/210/GroupTab.jsp b/jspwiki-war/src/main/webapp/templates/210/GroupTab.jsp
index 914cfbb..447ef60 100644
--- a/jspwiki-war/src/main/webapp/templates/210/GroupTab.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/GroupTab.jsp
@@ -24,10 +24,10 @@
 <%@ page import="javax.servlet.jsp.jstl.fmt.*" %>
 <%@ page import="org.apache.wiki.WikiContext" %>
 <%@ page import="org.apache.wiki.auth.*" %>
-<%@ page import="org.apache.wiki.auth.PrincipalComparator" %>
 <%@ page import="org.apache.wiki.auth.authorize.Group" %>
 <%@ page import="org.apache.wiki.auth.authorize.GroupManager" %>
 <%@ page import="org.apache.wiki.preferences.Preferences" %>
+<%@ page import="org.apache.wiki.util.comparators.PrincipalComparator" %>
 <%@ page import="org.apache.log4j.*" %>
 <%@ page errorPage="/Error.jsp" %>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
@@ -37,7 +37,7 @@
   String printWikiGroupPutGroup( Group group, String name, boolean cursor, PageContext pageContext)
   {
     Principal[] m = group.members();
-    java.util.Arrays.sort( m, new PrincipalComparator() );
+    Arrays.sort( m, new PrincipalComparator() );
 
     String delim = "\", \"";
 
diff --git a/jspwiki-war/src/main/webapp/templates/210/NewGroupContent.jsp b/jspwiki-war/src/main/webapp/templates/210/NewGroupContent.jsp
index 6008739..56f8cdb 100644
--- a/jspwiki-war/src/main/webapp/templates/210/NewGroupContent.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/NewGroupContent.jsp
@@ -22,10 +22,10 @@
 <%@ page import="java.util.Arrays" %>
 <%@ page import="java.util.ResourceBundle" %>
 <%@ page import="org.apache.wiki.*" %>
-<%@ page import="org.apache.wiki.auth.PrincipalComparator" %>
 <%@ page import="org.apache.wiki.auth.authorize.Group" %>
 <%@ page import="org.apache.wiki.auth.authorize.GroupManager" %>
 <%@ page import="org.apache.wiki.util.TextUtil" %>
+<%@ page import="org.apache.wiki.util.comparators.PrincipalComparator" %>
 <%@ page errorPage="/Error.jsp" %>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
 <%@ page import="javax.servlet.jsp.jstl.fmt.*" %>
diff --git a/jspwiki-war/src/main/webapp/templates/default/EditGroupContent.jsp b/jspwiki-war/src/main/webapp/templates/default/EditGroupContent.jsp
index bf14121..86b93e2 100644
--- a/jspwiki-war/src/main/webapp/templates/default/EditGroupContent.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/EditGroupContent.jsp
@@ -19,10 +19,10 @@
 
 <%@ page import="java.security.Principal" %>
 <%@ page import="java.util.Arrays" %>
-<%@ page import="org.apache.wiki.auth.PrincipalComparator" %>
-<%@ page import="org.apache.wiki.auth.authorize.Group" %>
-<%@ page import="org.apache.wiki.*" %>
 <%@ page import="org.apache.log4j.*" %>
+<%@ page import="org.apache.wiki.*" %>
+<%@ page import="org.apache.wiki.auth.authorize.Group" %>
+<%@ page import="org.apache.wiki.util.comparators.PrincipalComparator" %>
 <%@ page errorPage="/Error.jsp" %>
 <%@ taglib uri="http://jspwiki.apache.org/tags" prefix="wiki" %>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
diff --git a/jspwiki-war/src/main/webapp/templates/default/GroupTab.jsp b/jspwiki-war/src/main/webapp/templates/default/GroupTab.jsp
index a497f48..d3feffc 100644
--- a/jspwiki-war/src/main/webapp/templates/default/GroupTab.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/GroupTab.jsp
@@ -20,16 +20,15 @@
 <%@ page import="java.security.Principal" %>
 <%@ page import="java.text.MessageFormat" %>
 <%@ page import="java.util.*" %>
+<%@ page import="org.apache.log4j.*" %>
 <%@ page import="org.apache.wiki.WikiContext" %>
 <%@ page import="org.apache.wiki.auth.*" %>
-<%@ page import="org.apache.wiki.auth.AuthorizationManager" %>
-<%@ page import="org.apache.wiki.auth.PrincipalComparator" %>
 <%@ page import="org.apache.wiki.auth.authorize.Group" %>
 <%@ page import="org.apache.wiki.auth.authorize.GroupManager" %>
 <%@ page import="org.apache.wiki.auth.permissions.GroupPermission" %>
 <%@ page import="org.apache.wiki.auth.authorize.GroupManager" %>
 <%@ page import="org.apache.wiki.preferences.Preferences" %>
-<%@ page import="org.apache.log4j.*" %>
+<%@ page import="org.apache.wiki.util.comparators.PrincipalComparator" %>
 <%@ page errorPage="/Error.jsp" %>
 <%@ taglib uri="http://jspwiki.apache.org/tags" prefix="wiki" %>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>


[jspwiki] 33/35: move test to its testee package

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git

commit dc4b44f5be7863dc178758fa44852984a7061957
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Mar 6 17:54:45 2020 +0100

    move test to its testee package
---
 .../{ => markdown}/MarkdownRendererTest.java       | 33 +++++++++++-----------
 1 file changed, 16 insertions(+), 17 deletions(-)

diff --git a/jspwiki-markdown/src/test/java/org/apache/wiki/render/MarkdownRendererTest.java b/jspwiki-markdown/src/test/java/org/apache/wiki/render/markdown/MarkdownRendererTest.java
old mode 100755
new mode 100644
similarity index 93%
rename from jspwiki-markdown/src/test/java/org/apache/wiki/render/MarkdownRendererTest.java
rename to jspwiki-markdown/src/test/java/org/apache/wiki/render/markdown/MarkdownRendererTest.java
index fbeb7b2..c922652
--- a/jspwiki-markdown/src/test/java/org/apache/wiki/render/MarkdownRendererTest.java
+++ b/jspwiki-markdown/src/test/java/org/apache/wiki/render/markdown/MarkdownRendererTest.java
@@ -16,7 +16,7 @@
     specific language governing permissions and limitations
     under the License.
  */
-package org.apache.wiki.render;
+package org.apache.wiki.render.markdown;
 
 import net.sf.ehcache.CacheManager;
 import org.apache.wiki.TestEngine;
@@ -27,7 +27,6 @@ import org.apache.wiki.api.exceptions.WikiException;
 import org.apache.wiki.attachment.Attachment;
 import org.apache.wiki.pages.PageManager;
 import org.apache.wiki.parser.markdown.MarkdownParser;
-import org.apache.wiki.render.markdown.MarkdownRenderer;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
@@ -177,16 +176,16 @@ public class MarkdownRendererTest {
         	               "[^footnote]: footnote text\n" +
                            "with continuation";
         Assertions.assertEquals( "<p>text <sup id=\"fnref-1\"><a class=\"footnoteref\" href=\"#fn-1\">1</a></sup> embedded.</p>\n" +
-        		             "<div class=\"footnotes\">\n" +
-        		             "<hr />\n" +
-        		             "<ol>\n" +
-        		             "<li id=\"fn-1\">\n" +
-        		             "<p>footnote text\n" +
-        		             "with continuation</p>\n" +
-        		             "<a href=\"#fnref-1\" class=\"footnote-backref\">&#8617;</a>\n" +
-        		             "</li>\n" +
-        		             "</ol>\n" +
-        		             "</div>\n", translate( src ) );
+        		                 "<div class=\"footnotes\">\n" +
+        		                 "<hr />\n" +
+        		                 "<ol>\n" +
+        		                 "<li id=\"fn-1\">\n" +
+        		                 "<p>footnote text\n" +
+        		                 "with continuation</p>\n" +
+        		                 "<a href=\"#fnref-1\" class=\"footnote-backref\">&#8617;</a>\n" +
+        		                 "</li>\n" +
+        		                 "</ol>\n" +
+        		                 "</div>\n", translate( src ) );
     }
 
     @Test
@@ -265,8 +264,8 @@ public class MarkdownRendererTest {
                            "### Awesome H3";
 
         Assertions.assertEquals( "<h3 id=\"awesome-h3\">Awesome H3</h3>\n" +
-                             "<h3 id=\"awesome-h3-1\">Awesome H3</h3>\n",
-                             translate( src ) );
+                                 "<h3 id=\"awesome-h3-1\">Awesome H3</h3>\n",
+                                 translate( src ) );
     }
 
     @BeforeEach
@@ -281,8 +280,8 @@ public class MarkdownRendererTest {
     @AfterEach
     public void tearDown() {
         for( final String name : created ) {
-            testEngine.deleteTestPage(name);
-            TestEngine.deleteAttachments(name);
+            testEngine.deleteTestPage( name );
+            TestEngine.deleteAttachments( name );
         }
 
         created.clear();
@@ -293,7 +292,7 @@ public class MarkdownRendererTest {
         return translate( new WikiPage( testEngine, PAGE_NAME ), src );
     }
 
-    String translate( final WikiEngine e, final String src) throws Exception {
+    String translate( final WikiEngine e, final String src ) throws Exception {
         return translate( e, new WikiPage( testEngine, PAGE_NAME ), src );
     }
 


[jspwiki] 07/35: rename + extract interface on (Base)ModuleManager

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git

commit f0205f6f01e8c5bc00573267670ef30c307842bc
Author: juanpablo <ju...@apache.org>
AuthorDate: Mon Mar 2 19:55:39 2020 +0100

    rename + extract interface on (Base)ModuleManager
---
 .../apache/wiki/filters/DefaultFilterManager.java  | 28 +++++---
 .../org/apache/wiki/filters/FilterManager.java     | 24 ++-----
 .../{ModuleManager.java => BaseModuleManager.java} | 24 +------
 .../org/apache/wiki/modules/ModuleManager.java     | 82 +++-------------------
 .../org/apache/wiki/modules/WikiModuleInfo.java    | 28 ++++----
 .../apache/wiki/plugin/DefaultPluginManager.java   |  6 +-
 .../java/org/apache/wiki/plugin/PluginManager.java | 21 +-----
 .../org/apache/wiki/ui/DefaultEditorManager.java   |  4 +-
 .../org/apache/wiki/ui/DefaultTemplateManager.java |  4 +-
 .../java/org/apache/wiki/ui/EditorManager.java     | 14 +---
 .../java/org/apache/wiki/ui/TemplateManager.java   | 14 +---
 11 files changed, 62 insertions(+), 187 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/filters/DefaultFilterManager.java b/jspwiki-main/src/main/java/org/apache/wiki/filters/DefaultFilterManager.java
index c88e8a4..1d8a341 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/filters/DefaultFilterManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/filters/DefaultFilterManager.java
@@ -26,7 +26,7 @@ import org.apache.wiki.api.exceptions.WikiException;
 import org.apache.wiki.api.filters.PageFilter;
 import org.apache.wiki.event.WikiEventManager;
 import org.apache.wiki.event.WikiPageEvent;
-import org.apache.wiki.modules.ModuleManager;
+import org.apache.wiki.modules.BaseModuleManager;
 import org.apache.wiki.modules.WikiModuleInfo;
 import org.apache.wiki.util.ClassUtil;
 import org.apache.wiki.util.PriorityList;
@@ -84,7 +84,7 @@ import java.util.Properties;
  *
  *  The &lt;filter> -sections define the filters.  For more information, please see the PageFilterConfiguration page in the JSPWiki distribution.
  */
-public class DefaultFilterManager extends ModuleManager implements FilterManager {
+public class DefaultFilterManager extends BaseModuleManager implements FilterManager {
 
     private PriorityList< PageFilter > m_pageFilters = new PriorityList<>();
 
@@ -240,7 +240,8 @@ public class DefaultFilterManager extends ModuleManager implements FilterManager
      *
      *  @see PageFilter#preTranslate(WikiContext, String)
      */
-    @Override public String doPreTranslateFiltering( final WikiContext context, String pageData ) throws FilterException {
+    @Override
+    public String doPreTranslateFiltering( final WikiContext context, String pageData ) throws FilterException {
         fireEvent( WikiPageEvent.PRE_TRANSLATE_BEGIN, context );
         for( final PageFilter f : m_pageFilters ) {
             pageData = f.preTranslate( context, pageData );
@@ -260,7 +261,8 @@ public class DefaultFilterManager extends ModuleManager implements FilterManager
      *  @return The modified HTML
      *  @see PageFilter#postTranslate(WikiContext, String)
      */
-    @Override public String doPostTranslateFiltering( final WikiContext context, String htmlData ) throws FilterException {
+    @Override
+    public String doPostTranslateFiltering( final WikiContext context, String htmlData ) throws FilterException {
         fireEvent( WikiPageEvent.POST_TRANSLATE_BEGIN, context );
         for( final PageFilter f : m_pageFilters ) {
             htmlData = f.postTranslate( context, htmlData );
@@ -280,7 +282,8 @@ public class DefaultFilterManager extends ModuleManager implements FilterManager
      *  @return The modified WikiMarkup
      *  @see PageFilter#preSave(WikiContext, String)
      */
-    @Override public String doPreSaveFiltering( final WikiContext context, String pageData ) throws FilterException {
+    @Override
+    public String doPreSaveFiltering( final WikiContext context, String pageData ) throws FilterException {
         fireEvent( WikiPageEvent.PRE_SAVE_BEGIN, context );
         for( final PageFilter f : m_pageFilters ) {
             pageData = f.preSave( context, pageData );
@@ -300,7 +303,8 @@ public class DefaultFilterManager extends ModuleManager implements FilterManager
      *
      *  @see PageFilter#postSave(WikiContext, String)
      */
-    @Override public void doPostSaveFiltering( final WikiContext context, final String pageData ) throws FilterException {
+    @Override
+    public void doPostSaveFiltering( final WikiContext context, final String pageData ) throws FilterException {
         fireEvent( WikiPageEvent.POST_SAVE_BEGIN, context );
         for( final PageFilter f : m_pageFilters ) {
             // log.info("POSTSAVE: "+f.toString() );
@@ -316,7 +320,8 @@ public class DefaultFilterManager extends ModuleManager implements FilterManager
      *
      *  @return A List of PageFilter objects
      */
-    @Override public List< PageFilter > getFilterList()
+    @Override
+    public List< PageFilter > getFilterList()
     {
         return m_pageFilters;
     }
@@ -326,7 +331,8 @@ public class DefaultFilterManager extends ModuleManager implements FilterManager
      * Notifies PageFilters to clean up their ressources.
      *
      */
-    @Override public void destroy() {
+    @Override
+    public void destroy() {
         for( final PageFilter f : m_pageFilters ) {
             f.destroy( m_engine );
         }
@@ -391,9 +397,8 @@ public class DefaultFilterManager extends ModuleManager implements FilterManager
      *  @since 2.6.1
      */
     private static final class PageFilterInfo extends WikiModuleInfo {
-        private PageFilterInfo( final String name )
-        {
-            super(name);
+        private PageFilterInfo( final String name ) {
+            super( name );
         }
 
         protected static PageFilterInfo newInstance( final String className, final Element pluginEl ) {
@@ -406,4 +411,5 @@ public class DefaultFilterManager extends ModuleManager implements FilterManager
             return info;
         }
     }
+
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/filters/FilterManager.java b/jspwiki-main/src/main/java/org/apache/wiki/filters/FilterManager.java
index d605016..f1d26ed 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/filters/FilterManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/filters/FilterManager.java
@@ -21,13 +21,12 @@ package org.apache.wiki.filters;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.api.exceptions.FilterException;
 import org.apache.wiki.api.filters.PageFilter;
-import org.apache.wiki.modules.WikiModuleInfo;
+import org.apache.wiki.modules.ModuleManager;
 
-import java.util.Collection;
 import java.util.List;
 
-public interface FilterManager
-{
+public interface FilterManager extends ModuleManager {
+
     /** Property name for setting the filter XML property file.  Value is <tt>{@value}</tt>. */
     String PROP_FILTERXML = "jspwiki.filterConfig";
     
@@ -112,20 +111,5 @@ public interface FilterManager
      * Notifies PageFilters to clean up their ressources.
      */
     void destroy();
-    
-    /**
-     * Returns a collection of modules currently managed by this ModuleManager.  Each
-     * entry is an instance of the {@link WikiModuleInfo} class.  This method should return something
-     * which is safe to iterate over, even if the underlying collection changes.
-     * 
-     * @return A Collection of {@link WikiModuleInfo} instances.
-     */
-    Collection< WikiModuleInfo > modules();
-    
-    /**
-     * Returns the {@link WikiModuleInfo} information about the provided filterName.
-     * @param filterName
-     * @return The WikiModuleInfo
-     */
-    WikiModuleInfo getModuleInfo(String filterName);
+
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/modules/ModuleManager.java b/jspwiki-main/src/main/java/org/apache/wiki/modules/BaseModuleManager.java
similarity index 71%
copy from jspwiki-main/src/main/java/org/apache/wiki/modules/ModuleManager.java
copy to jspwiki-main/src/main/java/org/apache/wiki/modules/BaseModuleManager.java
index d3f6f7d..ffdab86 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/modules/ModuleManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/modules/BaseModuleManager.java
@@ -30,10 +30,7 @@ import java.util.TreeSet;
 /**
  *  Superclass for all JSPWiki managers for modules (plugins, etc).
  */
-public abstract class ModuleManager {
-
-    /** Location of the property-files of plugins. (Each plugin should include this property-file in its jar-file) */
-    public static final String PLUGIN_RESOURCE_LOCATION = "ini/jspwiki_module.xml";
+public abstract class BaseModuleManager implements ModuleManager {
 
     protected Engine m_engine;
 
@@ -44,7 +41,7 @@ public abstract class ModuleManager {
      *
      *  @param engine The Engine which owns this manager.
      */
-    public ModuleManager( final Engine engine ) {
+    public BaseModuleManager( final Engine engine ) {
         m_engine = engine;
     }
 
@@ -54,6 +51,7 @@ public abstract class ModuleManager {
      *  @param info The module to check
      *  @return True, if the module is compatible.
      */
+    @Override
     public boolean checkCompatibility( final WikiModuleInfo info ) {
         if( !m_loadIncompatibleModules ) {
             final String minVersion = info.getMinVersion();
@@ -65,15 +63,6 @@ public abstract class ModuleManager {
         return true;
     }
 
-    /**
-     * Returns a collection of modules currently managed by this ModuleManager.  Each
-     * entry is an instance of the WikiModuleInfo class.  This method should return something
-     * which is safe to iterate over, even if the underlying collection changes.
-     *
-     * @return A Collection of WikiModuleInfo instances.
-     */
-    public abstract Collection< WikiModuleInfo > modules();
-
     protected < T extends WikiModuleInfo > Collection< WikiModuleInfo > modules( final Iterator< T > iterator ) {
         final Set< WikiModuleInfo > ls = new TreeSet<>();
         for( final Iterator< T > i = iterator; i.hasNext(); ) {
@@ -86,11 +75,4 @@ public abstract class ModuleManager {
         return ls;
     }
 
-    /**
-     * Returns the {@link WikiModuleInfo} information about the provided moduleName.
-     *
-     * @param moduleName
-     * @return The wikiModuleInfo
-     */
-    public abstract WikiModuleInfo getModuleInfo( final String moduleName );
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/modules/ModuleManager.java b/jspwiki-main/src/main/java/org/apache/wiki/modules/ModuleManager.java
index d3f6f7d..7475092 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/modules/ModuleManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/modules/ModuleManager.java
@@ -1,52 +1,12 @@
-/*
-    Licensed to the Apache Software Foundation (ASF) under one
-    or more contributor license agreements.  See the NOTICE file
-    distributed with this work for additional information
-    regarding copyright ownership.  The ASF licenses this file
-    to you under the Apache License, Version 2.0 (the
-    "License"); you may not use this file except in compliance
-    with the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing,
-    software distributed under the License is distributed on an
-    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-    KIND, either express or implied.  See the License for the
-    specific language governing permissions and limitations
-    under the License.
- */
 package org.apache.wiki.modules;
 
-import org.apache.wiki.Release;
-import org.apache.wiki.api.core.Engine;
-
 import java.util.Collection;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.TreeSet;
 
 
-/**
- *  Superclass for all JSPWiki managers for modules (plugins, etc).
- */
-public abstract class ModuleManager {
+public interface ModuleManager {
 
     /** Location of the property-files of plugins. (Each plugin should include this property-file in its jar-file) */
-    public static final String PLUGIN_RESOURCE_LOCATION = "ini/jspwiki_module.xml";
-
-    protected Engine m_engine;
-
-    private boolean m_loadIncompatibleModules = false;
-
-    /**
-     *  Constructs the ModuleManager.
-     *
-     *  @param engine The Engine which owns this manager.
-     */
-    public ModuleManager( final Engine engine ) {
-        m_engine = engine;
-    }
+    String PLUGIN_RESOURCE_LOCATION = "ini/jspwiki_module.xml";
 
     /**
      *  Returns true, if the given module is compatible with this version of JSPWiki.
@@ -54,16 +14,15 @@ public abstract class ModuleManager {
      *  @param info The module to check
      *  @return True, if the module is compatible.
      */
-    public boolean checkCompatibility( final WikiModuleInfo info ) {
-        if( !m_loadIncompatibleModules ) {
-            final String minVersion = info.getMinVersion();
-            final String maxVersion = info.getMaxVersion();
+    boolean checkCompatibility( WikiModuleInfo info );
 
-            return Release.isNewerOrEqual( minVersion ) && Release.isOlderOrEqual( maxVersion );
-        }
-
-        return true;
-    }
+    /**
+     * Returns the {@link WikiModuleInfo} information about the provided moduleName.
+     *
+     * @param moduleName
+     * @return The wikiModuleInfo
+     */
+    WikiModuleInfo getModuleInfo( String moduleName );
 
     /**
      * Returns a collection of modules currently managed by this ModuleManager.  Each
@@ -72,25 +31,6 @@ public abstract class ModuleManager {
      *
      * @return A Collection of WikiModuleInfo instances.
      */
-    public abstract Collection< WikiModuleInfo > modules();
-
-    protected < T extends WikiModuleInfo > Collection< WikiModuleInfo > modules( final Iterator< T > iterator ) {
-        final Set< WikiModuleInfo > ls = new TreeSet<>();
-        for( final Iterator< T > i = iterator; i.hasNext(); ) {
-            final WikiModuleInfo wmi = i.next();
-            if( !ls.contains( wmi ) ) {
-                ls.add( wmi );
-            }
-        }
-
-        return ls;
-    }
+    Collection< WikiModuleInfo > modules();
 
-    /**
-     * Returns the {@link WikiModuleInfo} information about the provided moduleName.
-     *
-     * @param moduleName
-     * @return The wikiModuleInfo
-     */
-    public abstract WikiModuleInfo getModuleInfo( final String moduleName );
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/modules/WikiModuleInfo.java b/jspwiki-main/src/main/java/org/apache/wiki/modules/WikiModuleInfo.java
index e9cc051..8d564ba 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/modules/WikiModuleInfo.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/modules/WikiModuleInfo.java
@@ -86,17 +86,17 @@ public class WikiModuleInfo implements Comparable< WikiModuleInfo > {
      *  @param el The element to parse.
      */
     protected void initializeFromXML( final Element el ) {
-    	m_description        = el.getChildText("description");
-    	m_moduleUrl          = el.getChildText("url");
-    	m_moduleVersion      = el.getChildText("version");
-        m_htmlTemplate       = el.getChildText("template");
-        m_scriptLocation     = el.getChildText("script");
-        m_stylesheetLocation = el.getChildText("stylesheet");
-        m_author             = el.getChildText("author");
-        m_authorUrl          = el.getChildText("authorUrl");
-        m_minVersion         = el.getChildText("minVersion");
-        m_maxVersion         = el.getChildText("maxVersion");
-        m_adminBeanClass     = el.getChildText("adminBean");
+        m_adminBeanClass = el.getChildText( "adminBean" );
+        m_author = el.getChildText( "author" );
+        m_authorUrl = el.getChildText( "authorUrl" );
+        m_description = el.getChildText( "description" );
+        m_maxVersion = el.getChildText( "maxVersion" );
+        m_minVersion = el.getChildText( "minVersion" );
+        m_scriptLocation = el.getChildText( "script" );
+        m_stylesheetLocation = el.getChildText( "stylesheet" );
+        m_htmlTemplate = el.getChildText( "template" );
+        m_moduleUrl = el.getChildText( "url" );
+        m_moduleVersion = el.getChildText( "version" );
     }
 
     /**
@@ -229,7 +229,7 @@ public class WikiModuleInfo implements Comparable< WikiModuleInfo > {
         String spec = m_resource.toString();
     
         // Replace the 'PLUGIN_RESOURCE_LOCATION' with the requested resourceLocation.
-        final int length = ModuleManager.PLUGIN_RESOURCE_LOCATION.length();
+        final int length = BaseModuleManager.PLUGIN_RESOURCE_LOCATION.length();
         spec = spec.substring( 0, spec.length() - length ) + resourceLocation;
     
         final URL url = new URL( spec );
@@ -243,8 +243,8 @@ public class WikiModuleInfo implements Comparable< WikiModuleInfo > {
     /**
      *  {@inheritDoc}
      */
-    public int compareTo( final WikiModuleInfo mod )
-    {
+    @Override
+    public int compareTo( final WikiModuleInfo mod ) {
         return m_name.compareTo( mod.getName() );
     }
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/DefaultPluginManager.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/DefaultPluginManager.java
index 5d7aecc..8515af7 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/DefaultPluginManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/DefaultPluginManager.java
@@ -37,7 +37,7 @@ import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.exceptions.PluginException;
 import org.apache.wiki.api.plugin.InitializablePlugin;
 import org.apache.wiki.api.plugin.WikiPlugin;
-import org.apache.wiki.modules.ModuleManager;
+import org.apache.wiki.modules.BaseModuleManager;
 import org.apache.wiki.modules.WikiModuleInfo;
 import org.apache.wiki.preferences.Preferences;
 import org.apache.wiki.util.ClassUtil;
@@ -156,11 +156,11 @@ import java.util.StringTokenizer;
  *
  *  @since 1.6.1
  */
-public class DefaultPluginManager extends ModuleManager implements PluginManager {
+public class DefaultPluginManager extends BaseModuleManager implements PluginManager {
 
     private static final String PLUGIN_INSERT_PATTERN = "\\{?(INSERT)?\\s*([\\w\\._]+)[ \\t]*(WHERE)?[ \\t]*";
 
-    private static Logger log = Logger.getLogger( DefaultPluginManager.class );
+    private static final Logger log = Logger.getLogger( DefaultPluginManager.class );
 
     private static final String DEFAULT_FORMS_PACKAGE = "org.apache.wiki.forms";
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/PluginManager.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/PluginManager.java
index 3a0b330..a8fa7ad 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/PluginManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/PluginManager.java
@@ -22,15 +22,14 @@ import org.apache.oro.text.regex.Pattern;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.api.exceptions.PluginException;
 import org.apache.wiki.api.plugin.WikiPlugin;
-import org.apache.wiki.modules.WikiModuleInfo;
+import org.apache.wiki.modules.ModuleManager;
 
 import java.io.IOException;
-import java.util.Collection;
 import java.util.Map;
 import java.util.ResourceBundle;
 
 
-public interface PluginManager {
+public interface PluginManager extends ModuleManager {
 
     /** The property name defining which packages will be searched for plugin classes. */
     String PROP_SEARCHPATH = "jspwiki.plugin.searchPath";
@@ -130,22 +129,6 @@ public interface PluginManager {
      * @throws PluginException From the plugin itself, it propagates, waah!
      */
     String execute( WikiContext context, String commandline ) throws PluginException;
-
-    /**
-     * Returns a collection of modules currently managed by this ModuleManager. Each entry is an instance of the {@link WikiModuleInfo}
-     * class. This method should return something which is safe to iterate over, even if the underlying collection changes.
-     * 
-     * @return A Collection of {@link WikiModuleInfo} instances.
-     */
-    Collection< WikiModuleInfo > modules();
-
-    /**
-     * Returns the {@link WikiModuleInfo} information about the provided pluginName.
-     *
-     * @param pluginName
-     * @return The wikiPluginInfo
-     */
-    WikiModuleInfo getModuleInfo(String pluginName);
     
     /**
      * Creates a {@link WikiPlugin}.
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/DefaultEditorManager.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/DefaultEditorManager.java
index 71a1cb4..e91e76a 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/DefaultEditorManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/DefaultEditorManager.java
@@ -22,7 +22,7 @@ import org.apache.log4j.Logger;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.exceptions.NoSuchVariableException;
-import org.apache.wiki.modules.ModuleManager;
+import org.apache.wiki.modules.BaseModuleManager;
 import org.apache.wiki.modules.WikiModuleInfo;
 import org.apache.wiki.preferences.Preferences;
 import org.apache.wiki.util.XmlUtil;
@@ -55,7 +55,7 @@ import java.util.Set;
  *
  *  @since 2.4
  */
-public class DefaultEditorManager extends ModuleManager implements EditorManager {
+public class DefaultEditorManager extends BaseModuleManager implements EditorManager {
 
     private Map< String, WikiEditorInfo > m_editors;
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/DefaultTemplateManager.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/DefaultTemplateManager.java
index 85065fe..bdd4044 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/DefaultTemplateManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/DefaultTemplateManager.java
@@ -23,7 +23,7 @@ import org.apache.log4j.Logger;
 import org.apache.wiki.InternalWikiException;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.api.core.Engine;
-import org.apache.wiki.modules.ModuleManager;
+import org.apache.wiki.modules.BaseModuleManager;
 import org.apache.wiki.modules.WikiModuleInfo;
 import org.apache.wiki.preferences.Preferences;
 import org.apache.wiki.preferences.Preferences.TimeFormat;
@@ -52,7 +52,7 @@ import java.util.TreeSet;
  *
  *  @since 2.1.62
  */
-public class DefaultTemplateManager extends ModuleManager implements TemplateManager {
+public class DefaultTemplateManager extends BaseModuleManager implements TemplateManager {
 
     private static final Logger log = Logger.getLogger( DefaultTemplateManager.class );
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/EditorManager.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/EditorManager.java
index 31b0c80..b39f357 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/EditorManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/EditorManager.java
@@ -19,10 +19,9 @@
 package org.apache.wiki.ui;
 
 import org.apache.wiki.WikiContext;
-import org.apache.wiki.modules.WikiModuleInfo;
+import org.apache.wiki.modules.ModuleManager;
 
 import javax.servlet.jsp.PageContext;
-import java.util.Collection;
 import java.util.Properties;
 
 
@@ -44,7 +43,7 @@ import java.util.Properties;
  *
  *  @since 2.4
  */
-public interface EditorManager {
+public interface EditorManager extends ModuleManager {
 
     /** The property name for setting the editor. Current value is "jspwiki.editor" - not used anymore: replaced by defaultpref.template.editor */
     String PROP_EDITORTYPE = "jspwiki.editor";
@@ -117,13 +116,4 @@ public interface EditorManager {
         return usertext;
     }
 
-    /**
-     * Returns a collection of modules currently managed by this ModuleManager.  Each
-     * entry is an instance of the WikiModuleInfo class.  This method should return something
-     * which is safe to iterate over, even if the underlying collection changes.
-     *
-     * @return A Collection of WikiModuleInfo instances.
-     */
-    Collection< WikiModuleInfo > modules();
-
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/TemplateManager.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/TemplateManager.java
index 57114d1..c4cf4b8 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/TemplateManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/TemplateManager.java
@@ -21,13 +21,12 @@ package org.apache.wiki.ui;
 import org.apache.log4j.Logger;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.i18n.InternationalizationManager;
-import org.apache.wiki.modules.WikiModuleInfo;
+import org.apache.wiki.modules.ModuleManager;
 import org.apache.wiki.preferences.Preferences;
 import org.apache.wiki.util.ClassUtil;
 
 import javax.servlet.jsp.PageContext;
 import javax.servlet.jsp.jstl.fmt.LocaleSupport;
-import java.util.Collection;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
@@ -45,7 +44,7 @@ import java.util.Vector;
  *
  *  @since 2.1.62
  */
-public interface TemplateManager {
+public interface TemplateManager extends ModuleManager {
 
     String SKIN_DIRECTORY = "skins";
 
@@ -193,15 +192,6 @@ public interface TemplateManager {
     Map< String, String > listTimeFormats( final PageContext pageContext );
 
     /**
-     * Returns a collection of modules currently managed by this ModuleManager.  Each
-     * entry is an instance of the WikiModuleInfo class.  This method should return something
-     * which is safe to iterate over, even if the underlying collection changes.
-     *
-     * @return A Collection of WikiModuleInfo instances.
-     */
-    Collection< WikiModuleInfo > modules();
-
-    /**
      * List all timezones, with special marker for server timezone
      *
      * @param pageContext page context


[jspwiki] 10/35: decouple DefaultAdminBeanManager from specific module manager implementations

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git

commit 11ee43686b9a3abcccdf803b352cbb03c324ce13
Author: juanpablo <ju...@apache.org>
AuthorDate: Mon Mar 2 19:59:04 2020 +0100

    decouple DefaultAdminBeanManager from specific module manager implementations
---
 jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java  | 13 +++++++++++++
 .../src/main/java/org/apache/wiki/api/core/Engine.java      | 12 +++++++++++-
 .../org/apache/wiki/ui/admin/DefaultAdminBeanManager.java   | 12 ++++--------
 .../src/test/java/org/apache/wiki/WikiEngineTest.java       | 11 +++++++++++
 4 files changed, 39 insertions(+), 9 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
index 6e5316f..f6856b0 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
@@ -72,11 +72,13 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Date;
 import java.util.Enumeration;
+import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 import java.util.Properties;
 import java.util.TimeZone;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.stream.Collectors;
 
 
 /**
@@ -532,12 +534,23 @@ public class WikiEngine implements Engine {
 
     /** {@inheritDoc} */
     @Override
+    @SuppressWarnings( "unchecked" )
     public < T > T getManager( final Class< T > manager ) {
         return ( T )managers.get( manager );
     }
 
     /** {@inheritDoc} */
     @Override
+    @SuppressWarnings( "unchecked" )
+    public < T > List< T > getManagers( final Class< T > manager ) {
+        return ( List< T > )managers.entrySet().stream()
+                                    .filter( e -> manager.isAssignableFrom( e.getKey() ) )
+                                    .map( e -> e.getValue() )
+                                    .collect( Collectors.toList() );
+    }
+
+    /** {@inheritDoc} */
+    @Override
     public boolean isConfigured() {
         return m_isConfigured;
     }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/api/core/Engine.java b/jspwiki-main/src/main/java/org/apache/wiki/api/core/Engine.java
index 345f9e1..dbce244 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/api/core/Engine.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/api/core/Engine.java
@@ -34,6 +34,7 @@ import java.net.URL;
 import java.nio.charset.Charset;
 import java.util.Collection;
 import java.util.Date;
+import java.util.List;
 import java.util.Properties;
 
 
@@ -112,7 +113,7 @@ public interface Engine {
     }
 
     /**
-     * Retrieves the requested object instantiated by the Engine.
+     * Retrieves the object instantiated by the Engine matching the requested type.
      *
      * @param manager requested object instantiated by the Engine.
      * @param <T> type of the requested object.
@@ -121,6 +122,15 @@ public interface Engine {
     < T > T getManager( Class< T > manager );
 
     /**
+     * Retrieves the objects instantiated by the Engine that can be assigned to the requested type.
+     *
+     * @param manager requested objectx instantiated by the Engine.
+     * @param <T> type of the requested object.
+     * @return collection of requested objects instantiated by the Engine, {@code empty} list if none available.
+     */
+    < T > List< T > getManagers( Class< T > manager );
+
+    /**
      * check if the Engine has been configured.
      *
      * @return {@code true} if it has, {@code false} otherwise.
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/DefaultAdminBeanManager.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/DefaultAdminBeanManager.java
index f336fdb..1627b2c 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/DefaultAdminBeanManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/DefaultAdminBeanManager.java
@@ -24,11 +24,8 @@ import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.event.WikiEngineEvent;
 import org.apache.wiki.event.WikiEvent;
 import org.apache.wiki.event.WikiEventListener;
-import org.apache.wiki.filters.FilterManager;
+import org.apache.wiki.modules.ModuleManager;
 import org.apache.wiki.modules.WikiModuleInfo;
-import org.apache.wiki.plugin.PluginManager;
-import org.apache.wiki.ui.EditorManager;
-import org.apache.wiki.ui.TemplateManager;
 import org.apache.wiki.ui.admin.beans.CoreBean;
 import org.apache.wiki.ui.admin.beans.FilterBean;
 import org.apache.wiki.ui.admin.beans.PluginBean;
@@ -170,10 +167,9 @@ public class DefaultAdminBeanManager implements WikiEventListener, AdminBeanMana
         } catch( final NotCompliantMBeanException e ) {
             log.error( e.getMessage(), e );
         }
-        registerBeans( m_engine.getManager( EditorManager.class ).modules() );
-        registerBeans( m_engine.getManager( PluginManager.class ).modules() );
-        registerBeans( m_engine.getManager( FilterManager.class ).modules() );
-        registerBeans( m_engine.getManager( TemplateManager.class ).modules() );
+        for( final ModuleManager moduleManager : m_engine.getManagers( ModuleManager.class ) ) {
+            registerBeans( moduleManager.modules() );
+        }
     }
 
     /* (non-Javadoc)
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java b/jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java
index 7c78fed..e6f2042 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java
@@ -22,6 +22,7 @@ package org.apache.wiki;
 import net.sf.ehcache.CacheManager;
 import org.apache.wiki.attachment.Attachment;
 import org.apache.wiki.attachment.AttachmentManager;
+import org.apache.wiki.modules.ModuleManager;
 import org.apache.wiki.pages.PageManager;
 import org.apache.wiki.providers.FileSystemProvider;
 import org.apache.wiki.references.ReferenceManager;
@@ -322,4 +323,14 @@ public class WikiEngineTest {
         Assertions.assertNull( p3.getAttribute( WikiPage.CHANGENOTE ) );
     }
 
+    @Test
+    public void testGetManagers() {
+        Assertions.assertNotNull( m_engine.getManager( PageManager.class ) );
+        Assertions.assertNull( m_engine.getManager( ModuleManager.class ) );
+
+        Assertions.assertEquals( 0, m_engine.getManagers( String.class ).size() );
+        Assertions.assertEquals( 1, m_engine.getManagers( PageManager.class ).size() );
+        Assertions.assertEquals( 4, m_engine.getManagers( ModuleManager.class ).size() );
+    }
+
 }


[jspwiki] 08/35: fix compilation problems

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git

commit ff5b22641beec690d71b3c5fb1d44f6178f4049d
Author: juanpablo <ju...@apache.org>
AuthorDate: Mon Mar 2 19:57:22 2020 +0100

    fix compilation problems
---
 jspwiki-main/src/main/java/org/apache/wiki/forms/FormOutput.java  | 2 +-
 .../src/main/java/org/apache/wiki/plugin/TableOfContents.java     | 2 +-
 .../src/main/java/org/apache/wiki/tags/AdminBeanIteratorTag.java  | 2 +-
 jspwiki-main/src/main/java/org/apache/wiki/tags/PluginTag.java    | 6 ++----
 .../src/main/java/org/apache/wiki/ui/admin/beans/FilterBean.java  | 8 +++++---
 .../java/org/apache/wiki/variables/DefaultVariableManager.java    | 4 ++--
 6 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/forms/FormOutput.java b/jspwiki-main/src/main/java/org/apache/wiki/forms/FormOutput.java
index 8c56300..9c82ec2 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/forms/FormOutput.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/forms/FormOutput.java
@@ -20,10 +20,10 @@
 package org.apache.wiki.forms;
 
 import org.apache.wiki.WikiContext;
-import org.apache.wiki.api.engine.PluginManager;
 import org.apache.wiki.api.exceptions.PluginException;
 import org.apache.wiki.api.plugin.WikiPlugin;
 import org.apache.wiki.plugin.DefaultPluginManager;
+import org.apache.wiki.plugin.PluginManager;
 import org.apache.wiki.preferences.Preferences;
 import org.apache.wiki.util.FormUtil;
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/TableOfContents.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/TableOfContents.java
index 4b082d4..4ef0e13 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/TableOfContents.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/TableOfContents.java
@@ -23,9 +23,9 @@ import org.apache.wiki.InternalWikiException;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.api.core.Engine;
-import org.apache.wiki.api.engine.FilterManager;
 import org.apache.wiki.api.exceptions.PluginException;
 import org.apache.wiki.api.plugin.WikiPlugin;
+import org.apache.wiki.filters.FilterManager;
 import org.apache.wiki.pages.PageManager;
 import org.apache.wiki.parser.Heading;
 import org.apache.wiki.parser.HeadingListener;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/AdminBeanIteratorTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/AdminBeanIteratorTag.java
index 49af855..d36a2fe 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/AdminBeanIteratorTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/AdminBeanIteratorTag.java
@@ -19,8 +19,8 @@
 package org.apache.wiki.tags;
 
 import org.apache.wiki.WikiContext;
-import org.apache.wiki.api.engine.AdminBeanManager;
 import org.apache.wiki.ui.admin.AdminBean;
+import org.apache.wiki.ui.admin.AdminBeanManager;
 
 import java.util.ArrayList;
 import java.util.Collection;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/PluginTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/PluginTag.java
index c971d71..20a4413 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/PluginTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/PluginTag.java
@@ -20,8 +20,8 @@ package org.apache.wiki.tags;
 
 import org.apache.log4j.Logger;
 import org.apache.wiki.api.core.Engine;
-import org.apache.wiki.api.engine.PluginManager;
 import org.apache.wiki.api.exceptions.PluginException;
+import org.apache.wiki.plugin.PluginManager;
 
 import javax.servlet.jsp.JspException;
 import javax.servlet.jsp.tagext.BodyContent;
@@ -104,9 +104,7 @@ public class PluginTag
             argmap.put( "_body", body );
         }
 
-        final String result = pm.execute( m_wikiContext, plugin, argmap );
-
-        return result;        
+        return pm.execute( m_wikiContext, plugin, argmap );
     }
     
     /**
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/FilterBean.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/FilterBean.java
index 3b47696..639295c 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/FilterBean.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/FilterBean.java
@@ -19,7 +19,7 @@
 package org.apache.wiki.ui.admin.beans;
 
 import org.apache.wiki.api.core.Engine;
-import org.apache.wiki.api.engine.FilterManager;
+import org.apache.wiki.filters.FilterManager;
 import org.apache.wiki.modules.WikiModuleInfo;
 import org.apache.wiki.util.XHTML;
 import org.apache.wiki.util.XhtmlUtil;
@@ -38,14 +38,16 @@ public class FilterBean extends ModuleBean {
     /**
      * {@inheritDoc}
      */
-    @Override public String getTitle() {
+    @Override
+    public String getTitle() {
         return "Filters";
     }
 
     /**
      * {@inheritDoc}
      */
-    @Override public int getType() {
+    @Override
+    public int getType() {
         return CORE;
     }
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/variables/DefaultVariableManager.java b/jspwiki-main/src/main/java/org/apache/wiki/variables/DefaultVariableManager.java
index 7525759..5764fcd 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/variables/DefaultVariableManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/variables/DefaultVariableManager.java
@@ -24,14 +24,14 @@ import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.WikiProvider;
 import org.apache.wiki.WikiSession;
-import org.apache.wiki.api.engine.FilterManager;
-import org.apache.wiki.api.engine.PluginManager;
 import org.apache.wiki.api.exceptions.NoSuchVariableException;
 import org.apache.wiki.api.filters.PageFilter;
 import org.apache.wiki.attachment.AttachmentManager;
+import org.apache.wiki.filters.FilterManager;
 import org.apache.wiki.i18n.InternationalizationManager;
 import org.apache.wiki.modules.InternalModule;
 import org.apache.wiki.pages.PageManager;
+import org.apache.wiki.plugin.PluginManager;
 import org.apache.wiki.preferences.Preferences;
 
 import javax.servlet.http.HttpServletRequest;


[jspwiki] 09/35: DefaultPageManager doesn't need to be a module manager

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git

commit e07c798beca2269c89a4e45985d9582bfb6a2c4a
Author: juanpablo <ju...@apache.org>
AuthorDate: Mon Mar 2 19:57:47 2020 +0100

    DefaultPageManager doesn't need to be a module manager
---
 .../org/apache/wiki/pages/DefaultPageManager.java  | 44 ++++++++--------------
 1 file changed, 16 insertions(+), 28 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java b/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
index 3fb8d83..b74e81a 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
@@ -42,8 +42,6 @@ import org.apache.wiki.event.WikiEvent;
 import org.apache.wiki.event.WikiEventManager;
 import org.apache.wiki.event.WikiPageEvent;
 import org.apache.wiki.event.WikiSecurityEvent;
-import org.apache.wiki.modules.ModuleManager;
-import org.apache.wiki.modules.WikiModuleInfo;
 import org.apache.wiki.providers.RepositoryModifiedException;
 import org.apache.wiki.providers.WikiPageProvider;
 import org.apache.wiki.references.ReferenceManager;
@@ -78,20 +76,22 @@ import java.util.concurrent.ConcurrentHashMap;
 
 
 /**
- * Manages the WikiPages.  This class functions as an unified interface towards the page providers.  It handles initialization
+ * Manages the WikiPages. This class functions as an unified interface towards the page providers. It handles initialization
  * and management of the providers, and provides utility methods for accessing the contents.
  * <p/>
- * Saving a page is a two-stage Task; first the pre-save operations and then the actual save.  See the descriptions of the tasks
+ * Saving a page is a two-stage Task; first the pre-save operations and then the actual save. See the descriptions of the tasks
  * for further information.
  *
  * @since 2.0
  */
-public class DefaultPageManager extends ModuleManager implements PageManager {
+public class DefaultPageManager implements PageManager {
 
     private static final Logger LOG = Logger.getLogger( DefaultPageManager.class );
 
     private WikiPageProvider m_provider;
 
+    private Engine m_engine;
+
     protected ConcurrentHashMap< String, PageLock > m_pageLocks = new ConcurrentHashMap<>();
 
     private int m_expiryTime;
@@ -109,7 +109,7 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
      * @throws WikiException If anything goes wrong, you get this.
      */
     public DefaultPageManager(final Engine engine, final Properties props) throws NoSuchElementException, WikiException {
-        super(engine);
+        m_engine = engine;
         final String classname;
         final boolean useCache = "true".equals( props.getProperty( PROP_USECACHE ) );
         m_expiryTime = TextUtil.parseIntParameter( props.getProperty( PROP_LOCKEXPIRY ), 60 );
@@ -199,7 +199,8 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
      * {@inheritDoc}
      * @see org.apache.wiki.pages.PageManager#getPureText(String, int)
      */
-    @Override public String getPureText( final String page, final int version ) {
+    @Override
+    public String getPureText( final String page, final int version ) {
         String result = null;
         try {
             result = getPageText( page, version );
@@ -217,12 +218,14 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
      * {@inheritDoc}
      * @see org.apache.wiki.pages.PageManager#getText(String, int)
      */
-    @Override public String getText( final String page, final int version ) {
+    @Override
+    public String getText( final String page, final int version ) {
         final String result = getPureText( page, version );
         return TextUtil.replaceEntities( result );
     }
 
-    @Override public void saveText( final WikiContext context, final String text ) throws WikiException {
+    @Override
+    public void saveText( final WikiContext context, final String text ) throws WikiException {
         // Check if page data actually changed; bail if not
         final WikiPage page = context.getPage();
         final String oldText = getPureText( page );
@@ -366,7 +369,8 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
      * {@inheritDoc}
      * @see org.apache.wiki.pages.PageManager#getPage(java.lang.String)
      */
-    @Override public WikiPage getPage( final String pagereq ) {
+    @Override
+    public WikiPage getPage( final String pagereq ) {
         return getPage( pagereq, WikiProvider.LATEST_VERSION );
     }
 
@@ -374,7 +378,8 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
      * {@inheritDoc}
      * @see org.apache.wiki.pages.PageManager#getPage(java.lang.String, int)
      */
-    @Override public WikiPage getPage( final String pagereq, final int version ) {
+    @Override
+    public WikiPage getPage( final String pagereq, final int version ) {
         try {
             WikiPage p = getPageInfo( pagereq, version );
             if( p == null ) {
@@ -678,23 +683,6 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
     }
 
     /**
-     * {@inheritDoc}
-     */
-    @Override
-    public Collection< WikiModuleInfo > modules() {
-        return new ArrayList<>();
-    }
-
-    /**
-     * Returns null!
-     *  {@inheritDoc}
-     */
-    @Override
-    public WikiModuleInfo getModuleInfo( final String moduleName ) {
-    	return null;
-    }
-
-    /**
      * Listens for {@link org.apache.wiki.event.WikiSecurityEvent#PROFILE_NAME_CHANGED}
      * events. If a user profile's name changes, each page ACL is inspected. If an entry contains
      * a name that has changed, it is replaced with the new one. No events are emitted


[jspwiki] 06/35: remove empty o.a.w.api.engine package

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git

commit 5a95f81a1e5bf1236d1fa65068196d5664f4aa0a
Author: juanpablo <ju...@apache.org>
AuthorDate: Sun Mar 1 21:26:42 2020 +0100

    remove empty o.a.w.api.engine package
---
 .../java/org/apache/wiki/api/engine/package.html   | 36 ----------------------
 1 file changed, 36 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/api/engine/package.html b/jspwiki-main/src/main/java/org/apache/wiki/api/engine/package.html
deleted file mode 100644
index 1b8998d..0000000
--- a/jspwiki-main/src/main/java/org/apache/wiki/api/engine/package.html
+++ /dev/null
@@ -1,36 +0,0 @@
-<!--
-    Licensed to the Apache Software Foundation (ASF) under one
-    or more contributor license agreements.  See the NOTICE file
-    distributed with this work for additional information
-    regarding copyright ownership.  The ASF licenses this file
-    to you under the Apache License, Version 2.0 (the
-    "License"); you may not use this file except in compliance
-    with the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing,
-    software distributed under the License is distributed on an
-    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-    KIND, either express or implied.  See the License for the
-    specific language governing permissions and limitations
-    under the License.
--->
-
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<html lang="en">
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-<title>WikiEngine Managers</title>
-</head>
-<body>
-JSPWiki's WikiEngine Managers package.
-
-This package holds all the Managers provided by the Engine and associated classes.
-
-<h3>Package Specification</h3>
-
-<h3>Related Documentation</h3>
-
-</body>
-</html>
\ No newline at end of file


[jspwiki] 12/35: use PrincipalComparator on #compareTo( Principal ) method

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git

commit 67b36ce7160a695206e6ccaea1bd201c7380bc6f
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Mar 4 12:55:38 2020 +0100

    use PrincipalComparator on #compareTo( Principal ) method
    
    also, apply suggested fixes and format from IntelliJ
---
 .../java/org/apache/wiki/auth/WikiPrincipal.java   | 114 ++++++++++-----------
 1 file changed, 53 insertions(+), 61 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/WikiPrincipal.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/WikiPrincipal.java
index be9581e..5ade711 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/WikiPrincipal.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/WikiPrincipal.java
@@ -18,58 +18,56 @@
  */
 package org.apache.wiki.auth;
 
+import org.apache.wiki.util.comparators.PrincipalComparator;
+
 import java.io.Serializable;
 import java.security.Principal;
 import java.util.Arrays;
 import java.util.Comparator;
 
+
 /**
- *  A lightweight, immutable Principal class. WikiPrincipals can be created with
- *  and optional "type" to denote what type of user profile Principal it represents
- *  (FULL_NAME, WIKI_NAME, LOGIN_NAME). Types are used to determine suitable
- *  user and login Principals in classes like WikiSession. However, the type
- *  property of a WikiPrincipal does not affect a WikiPrincipal's logical equality
- *  or hash code; two WikiPrincipals with the same name but different types are still
- *  considered equal.
+ *  A lightweight, immutable Principal class. WikiPrincipals can be created with and optional "type" to denote what type of user
+ *  profile Principal it represents (FULL_NAME, WIKI_NAME, LOGIN_NAME). Types are used to determine suitable user and login Principals in
+ *  classes like WikiSession. However, the type property of a WikiPrincipal does not affect a WikiPrincipal's logical equality
+ *  or hash code; two WikiPrincipals with the same name but different types are still considered equal.
  *
  *  @since  2.2
  */
-public final class WikiPrincipal implements Principal, Comparable<Principal>, Serializable
-{
+public final class WikiPrincipal implements Principal, Comparable< Principal >, Serializable {
+
     private static final long serialVersionUID = 1L;
 
     /**
-     * Represents an anonymous user. WikiPrincipals may be
-     * created with an optional type designator: 
+     * Represents an anonymous user. WikiPrincipals may be created with an optional type designator:
      * LOGIN_NAME, WIKI_NAME, FULL_NAME or UNSPECIFIED.
      */
     public static final Principal GUEST = new WikiPrincipal( "Guest" );
 
     /** WikiPrincipal type denoting a user's full name. */
-    public static final String FULL_NAME  = "fullName";
+    public static final String FULL_NAME = "fullName";
     
     /** WikiPrincipal type denoting a user's login name. */
     public static final String LOGIN_NAME = "loginName";
     
     /** WikiPrincipal type denoting a user's wiki name. */
-    public static final String WIKI_NAME  = "wikiName";
+    public static final String WIKI_NAME = "wikiName";
     
     /** Generic WikiPrincipal of unspecified type. */
-    public static final String UNSPECIFIED  = "unspecified";
+    public static final String UNSPECIFIED = "unspecified";
     
     /** Static instance of Comparator that allows Principals to be sorted. */
-    public static final Comparator<Principal> COMPARATOR = new PrincipalComparator();
+    public static final Comparator< Principal > COMPARATOR = new PrincipalComparator();
     
     private static final String[] VALID_TYPES;
     
-    static
-    {
+    static {
         VALID_TYPES = new String[] { FULL_NAME, LOGIN_NAME, WIKI_NAME, UNSPECIFIED };
         Arrays.sort( VALID_TYPES );
     }
 
-    private final String          m_name;
-    private final String          m_type;
+    private final String m_name;
+    private final String m_type;
 
     /** For serialization purposes */
     protected WikiPrincipal()
@@ -78,73 +76,68 @@ public final class WikiPrincipal implements Principal, Comparable<Principal>, Se
     }
     
     /**
-     * Constructs a new WikiPrincipal with a given name and a type of
-     * {@link #UNSPECIFIED}.
+     * Constructs a new WikiPrincipal with a given name and a type of {@link #UNSPECIFIED}.
+     *
      * @param name the name of the Principal
      */
-    public WikiPrincipal( String name )
-    {
+    public WikiPrincipal( final String name ) {
         m_name = name;
         m_type = UNSPECIFIED;
     }
     
     /**
-     * Constructs a new WikiPrincipal with a given name and optional type
-     * designator. If the supplied <code>type</code> parameter is not
-     * {@link #LOGIN_NAME}, {@link #FULL_NAME}, {@link #WIKI_NAME}
-     * or {@link #WIKI_NAME}, this method throws
+     * Constructs a new WikiPrincipal with a given name and optional type designator. If the supplied <code>type</code> parameter is not
+     * {@link #LOGIN_NAME}, {@link #FULL_NAME}, {@link #WIKI_NAME} or {@link #WIKI_NAME}, this method throws
      * an {@link IllegalArgumentException}.
+     *
      * @param name the name of the Principal
-     * @param type the type for this principal, which may be {@link #LOGIN_NAME},
-     *            {@link #FULL_NAME}, {@link #WIKI_NAME} or {@link #WIKI_NAME}.
+     * @param type the type for this principal, which may be {@link #LOGIN_NAME}, {@link #FULL_NAME}, {@link #WIKI_NAME} or {@link #WIKI_NAME}.
      */
-    public WikiPrincipal( String name, String type )
-    {
+    public WikiPrincipal( final String name, final String type ) {
         m_name = name;
-        if ( Arrays.binarySearch( VALID_TYPES, type ) < 0 )
-        {
-            throw new IllegalArgumentException( "Principal type '" + type + "' is invalid.");
+        if( Arrays.binarySearch( VALID_TYPES, type ) < 0 ) {
+            throw new IllegalArgumentException( "Principal type '" + type + "' is invalid." );
         }
         m_type = type;
     }
 
     /**
-     *  Returns the wiki name of the Principal.
-     *  @return the name
+     * Returns the wiki name of the Principal.
+     *
+     * @return the name
      */
-    public String getName()
-    {
+    @Override
+    public String getName() {
         return m_name;
     }
 
     /**
-     * Two <code>WikiPrincipal</code>s are considered equal if their
-     * names are equal (case-sensitive).
+     * Two <code>WikiPrincipal</code>s are considered equal if their names are equal (case-sensitive).
+     *
      * @param obj the object to compare
      * @return the result of the equality test
      */
-    public boolean equals( Object obj )
-    {
-        if ( obj == null || !( obj instanceof WikiPrincipal ) )
-        {
+    @Override
+    public boolean equals( final Object obj ) {
+        if( !( obj instanceof WikiPrincipal ) ) {
             return false;
         }
-        return m_name.equals( ( (WikiPrincipal) obj ).getName() );
+        return m_name.equals( ( ( WikiPrincipal )obj ).getName() );
     }
 
     /**
-     *  The hashCode() returned for the WikiPrincipal is the same as
-     *  for its name.
+     *  The hashCode() returned for the WikiPrincipal is the same as for its name.
+     *
      *  @return the hash code
      */
-    public int hashCode()
-    {
+    @Override
+    public int hashCode() {
         return m_name.hashCode();
     }
     
     /**
-     * Returns the Principal "type": {@link #LOGIN_NAME}, {@link #FULL_NAME},
-     * {@link #WIKI_NAME} or {@link #WIKI_NAME}
+     * Returns the Principal "type": {@link #LOGIN_NAME}, {@link #FULL_NAME}, {@link #WIKI_NAME} or {@link #WIKI_NAME}
+     *
      * @return the type
      */
     public String getType()
@@ -154,25 +147,24 @@ public final class WikiPrincipal implements Principal, Comparable<Principal>, Se
     
     /**
      * Returns a human-readable representation of the object.
+     *
      * @return the string representation
      */
-    public String toString()
-    {
+    @Override
+    public String toString() {
         return "[WikiPrincipal (" + m_type + "): " + getName() + "]";
     }
 
     /**
-     *  Allows comparisons to any other Principal objects.  Primary sorting
-     *  order is by the principal name, as returned by getName().
+     *  Allows comparisons to any other Principal objects.  Primary sorting order is by the principal name, returned by getName(), as
+     *  defined by {@link PrincipalComparator}.
      *  
-     *  @param o {@inheritDoc}
-     *  @return {@inheritDoc}
+     *  {@inheritDoc}
      *  @since 2.7.0
      */
-    public int compareTo(Principal o)
-    {
-        return getName().compareTo( o.getName() );
+    @Override
+    public int compareTo( final Principal o ) {
+        return COMPARATOR.compare( this, o );
     }
-    
 
 }


[jspwiki] 05/35: JSPWIKI-303: move FilterManager back to o.a.w.filters package

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git

commit 6abfe2be1a9e54bd43e68129e5a390cd10ac5f02
Author: juanpablo <ju...@apache.org>
AuthorDate: Sun Mar 1 21:25:47 2020 +0100

    JSPWIKI-303: move FilterManager back to o.a.w.filters package
    
    public filter api is meant to develop new filters, so it doesn't make sense to have the FilterManager on the o.a.w.api.engine package
---
 .../src/main/java/org/apache/wiki/WikiEngine.java  |  2 +-
 .../org/apache/wiki/auth/DefaultUserManager.java   |  2 +-
 .../java/org/apache/wiki/event/WikiPageEvent.java  | 24 ++++++++++++----------
 .../apache/wiki/filters/DefaultFilterManager.java  |  1 -
 .../{api/engine => filters}/FilterManager.java     |  8 ++++----
 .../wiki/render/DefaultRenderingManager.java       |  2 +-
 .../wiki/tasks/pages/PreSaveWikiPageTask.java      |  2 +-
 .../apache/wiki/tasks/pages/SaveWikiPageTask.java  |  2 +-
 .../wiki/ui/admin/DefaultAdminBeanManager.java     |  2 +-
 .../src/main/resources/ini/classmappings.xml       |  2 +-
 .../wiki/filters/DefaultFilterManagerTest.java     |  1 -
 .../apache/wiki/workflow/ApprovalWorkflowTest.java |  2 +-
 12 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
index a090109..6e5316f 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
@@ -22,7 +22,6 @@ import org.apache.commons.lang3.StringUtils;
 import org.apache.log4j.Logger;
 import org.apache.log4j.PropertyConfigurator;
 import org.apache.wiki.api.core.Engine;
-import org.apache.wiki.api.engine.FilterManager;
 import org.apache.wiki.api.exceptions.ProviderException;
 import org.apache.wiki.api.exceptions.WikiException;
 import org.apache.wiki.attachment.AttachmentManager;
@@ -37,6 +36,7 @@ import org.apache.wiki.event.WikiEngineEvent;
 import org.apache.wiki.event.WikiEventListener;
 import org.apache.wiki.event.WikiEventManager;
 import org.apache.wiki.event.WikiPageEvent;
+import org.apache.wiki.filters.FilterManager;
 import org.apache.wiki.i18n.InternationalizationManager;
 import org.apache.wiki.pages.PageManager;
 import org.apache.wiki.plugin.PluginManager;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultUserManager.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultUserManager.java
index 5037db3..1eee920 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultUserManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultUserManager.java
@@ -26,7 +26,6 @@ import org.apache.wiki.ajax.AjaxUtil;
 import org.apache.wiki.ajax.WikiAjaxDispatcherServlet;
 import org.apache.wiki.ajax.WikiAjaxServlet;
 import org.apache.wiki.api.core.Engine;
-import org.apache.wiki.api.engine.FilterManager;
 import org.apache.wiki.api.exceptions.NoRequiredPropertyException;
 import org.apache.wiki.api.exceptions.WikiException;
 import org.apache.wiki.api.filters.PageFilter;
@@ -39,6 +38,7 @@ import org.apache.wiki.auth.user.UserProfile;
 import org.apache.wiki.event.WikiEventListener;
 import org.apache.wiki.event.WikiEventManager;
 import org.apache.wiki.event.WikiSecurityEvent;
+import org.apache.wiki.filters.FilterManager;
 import org.apache.wiki.filters.SpamFilter;
 import org.apache.wiki.i18n.InternationalizationManager;
 import org.apache.wiki.pages.PageManager;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/event/WikiPageEvent.java b/jspwiki-main/src/main/java/org/apache/wiki/event/WikiPageEvent.java
index 181e3a7..3474c39 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/event/WikiPageEvent.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/event/WikiPageEvent.java
@@ -19,6 +19,8 @@
 
 package org.apache.wiki.event;
 
+import org.apache.wiki.filters.FilterManager;
+
 
 /**
  * WikiPageEvent indicates a change in the state or processing of a WikiPage. There are basically two types of page events:
@@ -61,7 +63,7 @@ package org.apache.wiki.event;
  * <p>
  * Other WikiPageEvents include both <i>phase boundary</i> and <i>in-phase</i> events for saving, pre- and post-translating content.
  * These are very noisy event types, but are not fired unless a listener is available. They are generated by the
- * {@link org.apache.wiki.api.engine.FilterManager}, {@link org.apache.wiki.filters.PageEventFilter}, and potentially other
+ * {@link FilterManager}, {@link org.apache.wiki.filters.PageEventFilter}, and potentially other
  * implementing classes.
  * </p>
  *
@@ -90,7 +92,7 @@ public class WikiPageEvent extends WikiEvent {
     // PRE_TRANSLATE .........
 
     /** Indicates the beginning of all wiki pre-translate page events. This is based
-      * on events generated by {@link org.apache.wiki.api.engine.FilterManager}. */
+      * on events generated by {@link FilterManager}. */
     public static final int PRE_TRANSLATE_BEGIN  = 12;
 
     /** Indicates a wiki pre-translate page event. This is based on events
@@ -98,13 +100,13 @@ public class WikiPageEvent extends WikiEvent {
     public static final int PRE_TRANSLATE        = 13;
 
     /** Indicates the end of all wiki pre-translate page events. This is based
-      * on events generated by {@link org.apache.wiki.api.engine.FilterManager}. */
+      * on events generated by {@link FilterManager}. */
     public static final int PRE_TRANSLATE_END    = 14;
 
     // POST_TRANSLATE ........
 
     /** Indicates the beginning of all wiki post-translate page events. This is based
-      * on events generated by {@link org.apache.wiki.api.engine.FilterManager}. */
+      * on events generated by {@link FilterManager}. */
     public static final int POST_TRANSLATE_BEGIN = 15;
 
     /** Indicates a wiki post-translate page event. This is based on events
@@ -112,33 +114,33 @@ public class WikiPageEvent extends WikiEvent {
     public static final int POST_TRANSLATE       = 16;
 
     /** Indicates the end of all wiki post-translate page events. This is based
-      * on events generated by {@link org.apache.wiki.api.engine.FilterManager}. */
+      * on events generated by {@link FilterManager}. */
     public static final int POST_TRANSLATE_END   = 17;
 
     // PRE_SAVE ..............
 
     /** Indicates the beginning of all wiki pre-save page events. This is based
-      * on events generated by {@link org.apache.wiki.api.engine.FilterManager}. */
+      * on events generated by {@link FilterManager}. */
     public static final int PRE_SAVE_BEGIN       = 18;
 
     /** Indicates a wiki pre-save page event. This is based on events generated by {@link org.apache.wiki.filters.PageEventFilter}. */
     public static final int PRE_SAVE             = 19;
 
     /** Indicates the end of all wiki pre-save page events. This is based
-      * on events generated by {@link org.apache.wiki.api.engine.FilterManager}. */
+      * on events generated by {@link FilterManager}. */
     public static final int PRE_SAVE_END         = 20;
 
     // POST_SAVE .............
 
     /** Indicates the beginning of all wiki post-save page events. This is based
-      * on events generated by {@link org.apache.wiki.api.engine.FilterManager}. */
+      * on events generated by {@link FilterManager}. */
     public static final int POST_SAVE_BEGIN      = 21;
 
     /** Indicates a wiki post-save page event. This is based on events generated by {@link org.apache.wiki.filters.PageEventFilter}. */
     public static final int POST_SAVE            = 22;
 
     /** Indicates the end of all wiki post-save page events. This is based
-     *  on events generated by {@link org.apache.wiki.api.engine.FilterManager}. */
+     *  on events generated by {@link FilterManager}. */
     public static final int POST_SAVE_END        = 23;
 
     // PAGE REQUESTS .........
@@ -198,7 +200,7 @@ public class WikiPageEvent extends WikiEvent {
      *
      * @return a String representation of the type
      */
-    public String eventName() {
+    @Override public String eventName() {
         switch ( getType() ) {
             case PAGE_LOCK:            return "PAGE_LOCK";
             case PAGE_UNLOCK:          return "PAGE_UNLOCK";
@@ -234,7 +236,7 @@ public class WikiPageEvent extends WikiEvent {
      *
      * @return a String description of the type
      */
-    public String getTypeDescription() {
+    @Override public String getTypeDescription() {
         switch ( getType() ) {
             case PAGE_LOCK:            return "page lock event";
             case PAGE_UNLOCK:          return "page unlock event";
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/filters/DefaultFilterManager.java b/jspwiki-main/src/main/java/org/apache/wiki/filters/DefaultFilterManager.java
index 619a7e7..c88e8a4 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/filters/DefaultFilterManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/filters/DefaultFilterManager.java
@@ -21,7 +21,6 @@ package org.apache.wiki.filters;
 import org.apache.log4j.Logger;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.api.core.Engine;
-import org.apache.wiki.api.engine.FilterManager;
 import org.apache.wiki.api.exceptions.FilterException;
 import org.apache.wiki.api.exceptions.WikiException;
 import org.apache.wiki.api.filters.PageFilter;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/api/engine/FilterManager.java b/jspwiki-main/src/main/java/org/apache/wiki/filters/FilterManager.java
similarity index 99%
rename from jspwiki-main/src/main/java/org/apache/wiki/api/engine/FilterManager.java
rename to jspwiki-main/src/main/java/org/apache/wiki/filters/FilterManager.java
index a9a825e..d605016 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/api/engine/FilterManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/filters/FilterManager.java
@@ -16,16 +16,16 @@
     specific language governing permissions and limitations
     under the License.    
  */
-package org.apache.wiki.api.engine;
-
-import java.util.Collection;
-import java.util.List;
+package org.apache.wiki.filters;
 
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.api.exceptions.FilterException;
 import org.apache.wiki.api.filters.PageFilter;
 import org.apache.wiki.modules.WikiModuleInfo;
 
+import java.util.Collection;
+import java.util.List;
+
 public interface FilterManager
 {
     /** Property name for setting the filter XML property file.  Value is <tt>{@value}</tt>. */
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/render/DefaultRenderingManager.java b/jspwiki-main/src/main/java/org/apache/wiki/render/DefaultRenderingManager.java
index e0e8979..26d2c67 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/render/DefaultRenderingManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/render/DefaultRenderingManager.java
@@ -27,7 +27,6 @@ import org.apache.wiki.StringTransmutator;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.api.core.Engine;
-import org.apache.wiki.api.engine.FilterManager;
 import org.apache.wiki.api.exceptions.FilterException;
 import org.apache.wiki.api.exceptions.ProviderException;
 import org.apache.wiki.api.exceptions.WikiException;
@@ -37,6 +36,7 @@ import org.apache.wiki.event.WikiEvent;
 import org.apache.wiki.event.WikiEventListener;
 import org.apache.wiki.event.WikiEventManager;
 import org.apache.wiki.event.WikiPageEvent;
+import org.apache.wiki.filters.FilterManager;
 import org.apache.wiki.pages.PageManager;
 import org.apache.wiki.parser.JSPWikiMarkupParser;
 import org.apache.wiki.parser.MarkupParser;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tasks/pages/PreSaveWikiPageTask.java b/jspwiki-main/src/main/java/org/apache/wiki/tasks/pages/PreSaveWikiPageTask.java
index 006174e..5a2c6a4 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tasks/pages/PreSaveWikiPageTask.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tasks/pages/PreSaveWikiPageTask.java
@@ -21,8 +21,8 @@ package org.apache.wiki.tasks.pages;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.api.core.Engine;
-import org.apache.wiki.api.engine.FilterManager;
 import org.apache.wiki.api.exceptions.WikiException;
+import org.apache.wiki.filters.FilterManager;
 import org.apache.wiki.tasks.TasksManager;
 import org.apache.wiki.workflow.Outcome;
 import org.apache.wiki.workflow.Task;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tasks/pages/SaveWikiPageTask.java b/jspwiki-main/src/main/java/org/apache/wiki/tasks/pages/SaveWikiPageTask.java
index 7dcf18c..dde704c 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tasks/pages/SaveWikiPageTask.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tasks/pages/SaveWikiPageTask.java
@@ -21,8 +21,8 @@ package org.apache.wiki.tasks.pages;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.api.core.Engine;
-import org.apache.wiki.api.engine.FilterManager;
 import org.apache.wiki.api.exceptions.WikiException;
+import org.apache.wiki.filters.FilterManager;
 import org.apache.wiki.pages.PageManager;
 import org.apache.wiki.render.RenderingManager;
 import org.apache.wiki.tasks.TasksManager;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/DefaultAdminBeanManager.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/DefaultAdminBeanManager.java
index 7c131b0..f336fdb 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/DefaultAdminBeanManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/DefaultAdminBeanManager.java
@@ -21,10 +21,10 @@ package org.apache.wiki.ui.admin;
 import org.apache.log4j.Logger;
 import org.apache.wiki.Release;
 import org.apache.wiki.api.core.Engine;
-import org.apache.wiki.api.engine.FilterManager;
 import org.apache.wiki.event.WikiEngineEvent;
 import org.apache.wiki.event.WikiEvent;
 import org.apache.wiki.event.WikiEventListener;
+import org.apache.wiki.filters.FilterManager;
 import org.apache.wiki.modules.WikiModuleInfo;
 import org.apache.wiki.plugin.PluginManager;
 import org.apache.wiki.ui.EditorManager;
diff --git a/jspwiki-main/src/main/resources/ini/classmappings.xml b/jspwiki-main/src/main/resources/ini/classmappings.xml
index acb5601..39927df 100644
--- a/jspwiki-main/src/main/resources/ini/classmappings.xml
+++ b/jspwiki-main/src/main/resources/ini/classmappings.xml
@@ -52,7 +52,7 @@
     <mappedClass>org.apache.wiki.pages.DefaultPageManager</mappedClass>
   </mapping>
   <mapping>
-    <requestedClass>org.apache.wiki.api.engine.FilterManager</requestedClass>
+    <requestedClass>org.apache.wiki.filters.FilterManager</requestedClass>
     <mappedClass>org.apache.wiki.filters.DefaultFilterManager</mappedClass>
   </mapping>
   <mapping>
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/filters/DefaultFilterManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/filters/DefaultFilterManagerTest.java
index 3534901..d8a3d2e 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/filters/DefaultFilterManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/filters/DefaultFilterManagerTest.java
@@ -19,7 +19,6 @@
 package org.apache.wiki.filters;
 
 import org.apache.wiki.TestEngine;
-import org.apache.wiki.api.engine.FilterManager;
 import org.apache.wiki.api.filters.PageFilter;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/workflow/ApprovalWorkflowTest.java b/jspwiki-main/src/test/java/org/apache/wiki/workflow/ApprovalWorkflowTest.java
index a55abea..0f7defe 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/workflow/ApprovalWorkflowTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/workflow/ApprovalWorkflowTest.java
@@ -20,12 +20,12 @@ package org.apache.wiki.workflow;
 
 import org.apache.wiki.TestEngine;
 import org.apache.wiki.WikiContext;
-import org.apache.wiki.api.engine.FilterManager;
 import org.apache.wiki.api.exceptions.FilterException;
 import org.apache.wiki.api.exceptions.WikiException;
 import org.apache.wiki.api.filters.BasicPageFilter;
 import org.apache.wiki.auth.Users;
 import org.apache.wiki.auth.WikiPrincipal;
+import org.apache.wiki.filters.FilterManager;
 import org.apache.wiki.pages.PageManager;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;


[jspwiki] 34/35: JSPWIKI-303: promote o.a.w.Release to o.a.w.api package

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git

commit 0db9623ba227dd63278a2dbfb8a22abef2bd3926
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Mar 6 19:01:06 2020 +0100

    JSPWIKI-303: promote o.a.w.Release to o.a.w.api package
---
 .../java/org/apache/wiki/TranslationsCheck.java    |  46 +++---
 .../src/main/java/org/apache/wiki/WikiEngine.java  |   1 +
 .../java/org/apache/wiki/{ => api}/Release.java    |   6 +-
 .../org/apache/wiki/modules/BaseModuleManager.java |   6 +-
 .../main/java/org/apache/wiki/rss/AtomFeed.java    |  16 +--
 .../main/java/org/apache/wiki/rss/RSS20Feed.java   |   2 +-
 .../wiki/ui/admin/DefaultAdminBeanManager.java     |   2 +-
 .../org/apache/wiki/ui/admin/beans/CoreBean.java   |  31 ++--
 .../org/apache/wiki/ui/admin/beans/ModuleBean.java |   2 +-
 .../wiki/variables/DefaultVariableManager.java     |   2 +-
 .../src/test/java/org/apache/wiki/ReleaseTest.java | 156 ---------------------
 .../test/java/org/apache/wiki/api/ReleaseTest.java | 133 ++++++++++++++++++
 .../src/main/webapp/templates/210/Favorites.jsp    |   3 +-
 .../src/main/webapp/templates/210/Footer.jsp       |   1 +
 .../src/main/webapp/templates/default/Footer.jsp   |   2 +-
 15 files changed, 193 insertions(+), 216 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/TranslationsCheck.java b/jspwiki-main/src/main/java/org/apache/wiki/TranslationsCheck.java
index 17869a9..71bd2bd 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/TranslationsCheck.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/TranslationsCheck.java
@@ -13,6 +13,8 @@
  */
 package org.apache.wiki;
 
+import org.apache.wiki.api.Release;
+
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.util.ArrayList;
@@ -40,14 +42,14 @@ import java.util.TreeSet;
  */
 public class TranslationsCheck
 {
-    private static final TreeSet<String> allProps = new TreeSet<String>();  // sorted, no duplicates
-    private static final TreeSet<String> duplProps = new TreeSet<String>();
+    private static final TreeSet<String> allProps = new TreeSet<>();  // sorted, no duplicates
+    private static final TreeSet<String> duplProps = new TreeSet<>();
 
     // Change these to your settings...
     static String base = ".";
     static String suffix = null;
 
-    public static void main(String[] args) throws IOException
+    public static void main( final String[] args) throws IOException
     {
         if( args.length == 0 )
         {
@@ -71,7 +73,7 @@ public class TranslationsCheck
             diff("/CoreResources.properties", "/CoreResources_" + suffix + ".properties");
             detectDuplicates("/CoreResources_" + suffix + ".properties");
         }
-        catch( FileNotFoundException e )
+        catch( final FileNotFoundException e )
         {
             System.err.println("Unable to locate "+"/CoreResources_" + suffix + ".properties");
         }
@@ -81,7 +83,7 @@ public class TranslationsCheck
             diff("/templates/default.properties", "/templates/default_" + suffix + ".properties");
             detectDuplicates("/templates/default_" + suffix + ".properties");
         }
-        catch( FileNotFoundException e )
+        catch( final FileNotFoundException e )
         {
             System.err.println("Unable to locate "+"/templates/default_" + suffix + ".properties");
         }
@@ -94,7 +96,7 @@ public class TranslationsCheck
 
             System.out.println("Duplicates overall (two or more occurences):");
             System.out.println("--------------------------------------------");
-            Iterator< String > iter = duplProps.iterator();
+            final Iterator< String > iter = duplProps.iterator();
             if (duplProps.size() == 0)
                 System.out.println("(none)");
             else
@@ -102,7 +104,7 @@ public class TranslationsCheck
                     System.out.println(iter.next());
             System.out.println();
         }
-        catch( FileNotFoundException e )
+        catch( final FileNotFoundException e )
         {
             System.err.println("Unable to locate "+"/plugin/PluginResources_" + suffix + ".properties");
         }
@@ -112,25 +114,25 @@ public class TranslationsCheck
                 "Moving them to a special section in the file may be the better solution.");
     }
 
-    public static Map< String, Integer > diff(String source1, String source2) throws FileNotFoundException, IOException
+    public static Map< String, Integer > diff( final String source1, final String source2) throws FileNotFoundException, IOException
     {
         int missing = 0, outdated = 0;
         // Standard Properties
-        Properties p1 = new Properties();
+        final Properties p1 = new Properties();
         
         p1.load( TranslationsCheck.class.getClassLoader().getResourceAsStream( base + source1 ) );
 
-        Properties p2 = new Properties();
+        final Properties p2 = new Properties();
         p2.load( TranslationsCheck.class.getClassLoader().getResourceAsStream( base + source2 ) );
 
-        String msg = "Checking " + source2 + "...";
+        final String msg = "Checking " + source2 + "...";
         System.out.println(msg);
 
         Iterator< String > iter = sortedNames(p1).iterator();
         while (iter.hasNext())
         {
-            String name = iter.next();
-            String value = p1.getProperty(name);
+            final String name = iter.next();
+            final String value = p1.getProperty(name);
 
             if (p2.get(name) == null)
             {
@@ -151,8 +153,8 @@ public class TranslationsCheck
         iter = sortedNames(p2).iterator();
         while (iter.hasNext())
         {
-            String name = iter.next();
-            String value = p2.getProperty(name);
+            final String name = iter.next();
+            final String value = p2.getProperty(name);
 
             if (p1.get(name) == null)
             {
@@ -170,16 +172,16 @@ public class TranslationsCheck
             System.out.println();
         }
 
-        Map< String, Integer > diff = new HashMap< String, Integer >( 2 );
+        final Map< String, Integer > diff = new HashMap<>( 2 );
         diff.put( "missing", missing );
         diff.put( "outdated", outdated );
         return diff;
     }
 
-    private static List<String> sortedNames(Properties p)
+    private static List<String> sortedNames( final Properties p)
     {
-        List<String> list = new ArrayList<String>();
-        Enumeration<?> iter = p.propertyNames();
+        final List<String> list = new ArrayList<>();
+        final Enumeration<?> iter = p.propertyNames();
         while (iter.hasMoreElements())
         {
             list.add( (String)iter.nextElement() );
@@ -189,12 +191,12 @@ public class TranslationsCheck
         return list;
     }
 
-    public static int detectDuplicates(String source) throws IOException
+    public static int detectDuplicates( final String source) throws IOException
     {
-        Properties p = new Properties();
+        final Properties p = new Properties();
         p.load( TranslationsCheck.class.getClassLoader().getResourceAsStream( base + source ) );
 
-        Enumeration<?> iter = p.propertyNames();
+        final Enumeration<?> iter = p.propertyNames();
         String currentStr;
         while (iter.hasMoreElements())
         {
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
index 223817c..3b6e81a 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
@@ -21,6 +21,7 @@ package org.apache.wiki;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.log4j.Logger;
 import org.apache.log4j.PropertyConfigurator;
+import org.apache.wiki.api.Release;
 import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.exceptions.ProviderException;
 import org.apache.wiki.api.exceptions.WikiException;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/Release.java b/jspwiki-main/src/main/java/org/apache/wiki/api/Release.java
similarity index 98%
rename from jspwiki-main/src/main/java/org/apache/wiki/Release.java
rename to jspwiki-main/src/main/java/org/apache/wiki/api/Release.java
index 9300941..4bd4ab5 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/Release.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/api/Release.java
@@ -17,7 +17,7 @@
     under the License.
  */
 
-package org.apache.wiki;
+package org.apache.wiki.api;
 
 import org.apache.commons.lang3.StringUtils;
 
@@ -26,7 +26,7 @@ import org.apache.commons.lang3.StringUtils;
  *  Contains release and version information.  You may also invoke this class directly, in which case it prints
  *  out the version string.  This is a handy way of checking which JSPWiki version you have - just type from a command line:
  *  <pre>
- *  % java -cp JSPWiki.jar org.apache.wiki.Release
+ *  % java -cp JSPWiki.jar org.apache.wiki.api.Release
  *  2.5.38
  *  </pre>
  *  <p>
@@ -160,7 +160,7 @@ public final class Release {
      *  things like different command line tools.
      *  <P>Example:
      *  <PRE>
-     *  % java org.apache.wiki.Release
+     *  % java org.apache.wiki.api.Release
      *  1.9.26-cvs
      *  </PRE>
      *
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/modules/BaseModuleManager.java b/jspwiki-main/src/main/java/org/apache/wiki/modules/BaseModuleManager.java
index ffdab86..b096520 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/modules/BaseModuleManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/modules/BaseModuleManager.java
@@ -18,7 +18,7 @@
  */
 package org.apache.wiki.modules;
 
-import org.apache.wiki.Release;
+import org.apache.wiki.api.Release;
 import org.apache.wiki.api.core.Engine;
 
 import java.util.Collection;
@@ -67,9 +67,7 @@ public abstract class BaseModuleManager implements ModuleManager {
         final Set< WikiModuleInfo > ls = new TreeSet<>();
         for( final Iterator< T > i = iterator; i.hasNext(); ) {
             final WikiModuleInfo wmi = i.next();
-            if( !ls.contains( wmi ) ) {
-                ls.add( wmi );
-            }
+            ls.add( wmi );
         }
 
         return ls;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/rss/AtomFeed.java b/jspwiki-main/src/main/java/org/apache/wiki/rss/AtomFeed.java
index 887accb..a67539a 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/rss/AtomFeed.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/rss/AtomFeed.java
@@ -19,9 +19,9 @@
 package org.apache.wiki.rss;
 
 import org.apache.commons.lang3.time.DateFormatUtils;
-import org.apache.wiki.Release;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiPage;
+import org.apache.wiki.api.Release;
 import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.exceptions.ProviderException;
 import org.apache.wiki.attachment.Attachment;
@@ -132,20 +132,20 @@ public class AtomFeed extends Feed {
         Date lastModified = new Date(0L);
 
         for( final Entry e : m_entries ) {
-            if( e.getPage().getLastModified().after( lastModified ) )
+            if( e.getPage().getLastModified().after( lastModified ) ) {
                 lastModified = e.getPage().getLastModified();
+            }
         }
 
         //  Mandatory parts
-        root.addContent( getElement("title").setText( getChannelTitle() ) );
-        root.addContent( getElement("id").setText(getFeedID()) );
-        root.addContent( getElement("updated").setText(DateFormatUtils.formatUTC( lastModified,
-                                                                                  RFC3339FORMAT ) ));
+        root.addContent( getElement( "title" ).setText( getChannelTitle() ) );
+        root.addContent( getElement( "id" ).setText( getFeedID() ) );
+        root.addContent( getElement( "updated" ).setText( DateFormatUtils.formatUTC( lastModified, RFC3339FORMAT ) ) );
 
         //  Optional
         // root.addContent( getElement("author").addContent(getElement("name").setText(format())))
-        root.addContent( getElement("link").setAttribute("href",engine.getBaseURL()));
-        root.addContent( getElement("generator").setText("JSPWiki "+Release.VERSTR));
+        root.addContent( getElement( "link" ).setAttribute( "href", engine.getBaseURL() ) );
+        root.addContent( getElement( "generator" ).setText( "JSPWiki " + Release.VERSTR ) );
 
         final String rssFeedURL  = engine.getURL(WikiContext.NONE, "rss.jsp",
                                                  "page=" + engine.encodeName( m_wikiContext.getPage().getName() ) +
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/rss/RSS20Feed.java b/jspwiki-main/src/main/java/org/apache/wiki/rss/RSS20Feed.java
index a14b8d8..52874d7 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/rss/RSS20Feed.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/rss/RSS20Feed.java
@@ -18,9 +18,9 @@
  */
 package org.apache.wiki.rss;
 
-import org.apache.wiki.Release;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiPage;
+import org.apache.wiki.api.Release;
 import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.exceptions.ProviderException;
 import org.apache.wiki.attachment.Attachment;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/DefaultAdminBeanManager.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/DefaultAdminBeanManager.java
index 1627b2c..3a3aa93 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/DefaultAdminBeanManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/DefaultAdminBeanManager.java
@@ -19,7 +19,7 @@
 package org.apache.wiki.ui.admin;
 
 import org.apache.log4j.Logger;
-import org.apache.wiki.Release;
+import org.apache.wiki.api.Release;
 import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.event.WikiEngineEvent;
 import org.apache.wiki.event.WikiEvent;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/CoreBean.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/CoreBean.java
index 7d201df..537b9dd 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/CoreBean.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/CoreBean.java
@@ -18,7 +18,7 @@
  */
 package org.apache.wiki.ui.admin.beans;
 
-import org.apache.wiki.Release;
+import org.apache.wiki.api.Release;
 import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.pages.PageManager;
 import org.apache.wiki.ui.admin.SimpleAdminBean;
@@ -47,43 +47,40 @@ public class CoreBean extends SimpleAdminBean {
         return m_engine.getManager( PageManager.class ).getTotalPageCount();
     }
 
-    public String getPagesDescription()
-    {
+    public String getPagesDescription() {
         return "The total number of pages in this wiki";
     }
 
-    public String getVersion()
-    {
+    public String getVersion() {
         return Release.VERSTR;
     }
 
-    public String getVersionDescription()
-    {
+    public String getVersionDescription() {
         return "The JSPWiki engine version";
     }
 
-    @Override public String getTitle()
-    {
+    @Override
+    public String getTitle() {
         return "Core bean";
     }
 
-    @Override public int getType()
-    {
+    @Override
+    public int getType() {
         return CORE;
     }
 
-    @Override public String getId()
-    {
+    @Override
+    public String getId() {
         return "corebean";
     }
 
-    @Override public String[] getAttributeNames()
-    {
+    @Override
+    public String[] getAttributeNames() {
         return ATTRIBUTES;
     }
 
-    @Override public String[] getMethodNames()
-    {
+    @Override
+    public String[] getMethodNames() {
         return METHODS;
     }
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/ModuleBean.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/ModuleBean.java
index 228e50a..9266d1e 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/ModuleBean.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/ModuleBean.java
@@ -19,8 +19,8 @@
 package org.apache.wiki.ui.admin.beans;
 
 import org.apache.commons.lang3.StringUtils;
-import org.apache.wiki.Release;
 import org.apache.wiki.WikiContext;
+import org.apache.wiki.api.Release;
 import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.modules.WikiModuleInfo;
 import org.apache.wiki.ui.admin.SimpleAdminBean;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/variables/DefaultVariableManager.java b/jspwiki-main/src/main/java/org/apache/wiki/variables/DefaultVariableManager.java
index 4858655..d02b7f8 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/variables/DefaultVariableManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/variables/DefaultVariableManager.java
@@ -19,10 +19,10 @@
 package org.apache.wiki.variables;
 
 import org.apache.log4j.Logger;
-import org.apache.wiki.Release;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.WikiProvider;
+import org.apache.wiki.api.Release;
 import org.apache.wiki.api.core.Session;
 import org.apache.wiki.api.exceptions.NoSuchVariableException;
 import org.apache.wiki.api.filters.PageFilter;
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/ReleaseTest.java b/jspwiki-main/src/test/java/org/apache/wiki/ReleaseTest.java
deleted file mode 100644
index be9c452..0000000
--- a/jspwiki-main/src/test/java/org/apache/wiki/ReleaseTest.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
-    Licensed to the Apache Software Foundation (ASF) under one
-    or more contributor license agreements.  See the NOTICE file
-    distributed with this work for additional information
-    regarding copyright ownership.  The ASF licenses this file
-    to you under the Apache License, Version 2.0 (the
-    "License"); you may not use this file except in compliance
-    with the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing,
-    software distributed under the License is distributed on an
-    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-    KIND, either express or implied.  See the License for the
-    specific language governing permissions and limitations
-    under the License.
- */
-package org.apache.wiki;
-
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.Assertions;
-
-public class ReleaseTest
-{
-    @Test
-    public void testNewer1()
-    {
-        Assertions.assertTrue( Release.isNewerOrEqual("1.0.100") );
-    }
-
-    @Test
-    public void testNewer2()
-    {
-        Assertions.assertTrue( Release.isNewerOrEqual("2.0.0-alpha") );
-    }
-
-    @Test
-    public void testNewer3()
-    {
-        Assertions.assertFalse( Release.isNewerOrEqual("10.0.0") );
-    }
-
-    @Test
-    public void testNewer4()
-    {
-        Assertions.assertTrue( Release.isNewerOrEqual(Release.VERSTR) );
-    }
-
-    @Test
-    public void testNewer5()
-    {
-        String rel = Release.VERSION+"."+Release.REVISION+"."+(Release.MINORREVISION+1)+"-cvs";
-
-        Assertions.assertFalse( Release.isNewerOrEqual(rel) );
-    }
-
-    @Test
-    public void testNewer6()
-    {
-        String rel = null;
-
-        if( Release.MINORREVISION != 0 )
-            rel = Release.VERSION+"."+Release.REVISION+"."+(Release.MINORREVISION-1)+"-cvs";
-        else
-            rel = Release.VERSION+"."+(Release.REVISION-1)+".9999"+"-cvs";
-
-        Assertions.assertTrue( Release.isNewerOrEqual(rel) );
-    }
-
-    @Test
-    public void testNewer7()
-    {
-        String rel = Release.VERSION+"."+Release.REVISION;
-
-        Assertions.assertTrue( Release.isNewerOrEqual(rel) );
-    }
-
-    @Test
-    public void testNewer8()
-    {
-        String rel = Release.VERSION+"";
-
-        Assertions.assertTrue( Release.isNewerOrEqual(rel) );
-    }
-
-    @Test
-    public void testOlder1()
-    {
-        Assertions.assertFalse( Release.isOlderOrEqual("1.0.100") );
-    }
-
-    @Test
-    public void testOlder2()
-    {
-        Assertions.assertFalse( Release.isOlderOrEqual("2.0.0-alpha") );
-    }
-
-    @Test
-    public void testOlder3()
-    {
-        Assertions.assertTrue( Release.isOlderOrEqual("10.0.0") );
-    }
-
-    @Test
-    public void testOlder4()
-    {
-        Assertions.assertTrue( Release.isOlderOrEqual(Release.VERSTR) );
-    }
-
-    @Test
-    public void testOlder5()
-    {
-        String rel = Release.VERSION+"."+Release.REVISION+"."+(Release.MINORREVISION+1)+"-cvs";
-
-        Assertions.assertTrue( Release.isOlderOrEqual(rel) );
-    }
-
-    @Test
-    public void testOlder6()
-    {
-        String rel;
-
-        if( Release.MINORREVISION != 0 )
-            rel = Release.VERSION+"."+Release.REVISION+"."+(Release.MINORREVISION-1)+"-cvs";
-        else
-            rel = Release.VERSION+"."+(Release.REVISION-1)+".9999"+"-cvs";
-
-        Assertions.assertFalse( Release.isOlderOrEqual(rel) );
-    }
-
-    @Test
-    public void testOlder7()
-    {
-        String rel = Release.VERSION+"."+Release.REVISION;
-
-        Assertions.assertTrue( Release.isOlderOrEqual(rel) );
-    }
-
-    @Test
-    public void testOlder8()
-    {
-        String rel = Release.VERSION+"";
-
-        Assertions.assertTrue( Release.isOlderOrEqual(rel) );
-    }
-
-    @Test
-    public void testOlder9()
-    {
-        String rel = "";
-
-        Assertions.assertTrue( Release.isOlderOrEqual(rel) );
-    }
-
-}
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/api/ReleaseTest.java b/jspwiki-main/src/test/java/org/apache/wiki/api/ReleaseTest.java
new file mode 100644
index 0000000..76308bd
--- /dev/null
+++ b/jspwiki-main/src/test/java/org/apache/wiki/api/ReleaseTest.java
@@ -0,0 +1,133 @@
+/*
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+ */
+package org.apache.wiki.api;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+
+public class ReleaseTest {
+
+    @Test
+    public void testNewer1() {
+        Assertions.assertTrue( Release.isNewerOrEqual( "1.0.100" ) );
+    }
+
+    @Test
+    public void testNewer2() {
+        Assertions.assertTrue( Release.isNewerOrEqual( "2.0.0-alpha" ) );
+    }
+
+    @Test
+    public void testNewer3() {
+        Assertions.assertFalse( Release.isNewerOrEqual( "10.0.0" ) );
+    }
+
+    @Test
+    public void testNewer4() {
+        Assertions.assertTrue( Release.isNewerOrEqual( Release.VERSTR ) );
+    }
+
+    @Test
+    public void testNewer5() {
+        final String rel = Release.VERSION + "." + Release.REVISION + "." + ( Release.MINORREVISION + 1 ) + "-cvs";
+        Assertions.assertFalse( Release.isNewerOrEqual( rel ) );
+    }
+
+    @Test
+    public void testNewer6() {
+        final String rel;
+        if( Release.MINORREVISION != 0 ) {
+            rel = Release.VERSION + "." + Release.REVISION + "." + ( Release.MINORREVISION - 1 ) + "-cvs";
+        } else {
+            rel = Release.VERSION + "." + ( Release.REVISION - 1 ) + ".9999" + "-cvs";
+        }
+
+        Assertions.assertTrue( Release.isNewerOrEqual( rel ) );
+    }
+
+    @Test
+    public void testNewer7() {
+        final String rel = Release.VERSION + "." + Release.REVISION;
+        Assertions.assertTrue( Release.isNewerOrEqual( rel ) );
+    }
+
+    @Test
+    public void testNewer8() {
+        final String rel = Release.VERSION + "";
+        Assertions.assertTrue( Release.isNewerOrEqual( rel ) );
+    }
+
+    @Test
+    public void testOlder1() {
+        Assertions.assertFalse( Release.isOlderOrEqual( "1.0.100" ) );
+    }
+
+    @Test
+    public void testOlder2() {
+        Assertions.assertFalse( Release.isOlderOrEqual( "2.0.0-alpha" ) );
+    }
+
+    @Test
+    public void testOlder3() {
+        Assertions.assertTrue( Release.isOlderOrEqual( "10.0.0" ) );
+    }
+
+    @Test
+    public void testOlder4() {
+        Assertions.assertTrue( Release.isOlderOrEqual( Release.VERSTR ) );
+    }
+
+    @Test
+    public void testOlder5() {
+        final String rel = Release.VERSION + "." + Release.REVISION + "." + ( Release.MINORREVISION + 1 ) + "-cvs";
+        Assertions.assertTrue( Release.isOlderOrEqual( rel ) );
+    }
+
+    @Test
+    public void testOlder6() {
+        final String rel;
+        if( Release.MINORREVISION != 0 ) {
+            rel = Release.VERSION + "." + Release.REVISION + "." + ( Release.MINORREVISION - 1 ) + "-cvs";
+        } else {
+            rel = Release.VERSION + "." + ( Release.REVISION - 1 ) + ".9999" + "-cvs";
+        }
+
+        Assertions.assertFalse( Release.isOlderOrEqual( rel ) );
+    }
+
+    @Test
+    public void testOlder7() {
+        final String rel = Release.VERSION + "." + Release.REVISION;
+        Assertions.assertTrue( Release.isOlderOrEqual( rel ) );
+    }
+
+    @Test
+    public void testOlder8() {
+        final String rel = Release.VERSION + "";
+        Assertions.assertTrue( Release.isOlderOrEqual( rel ) );
+    }
+
+    @Test
+    public void testOlder9() {
+        final String rel = "";
+        Assertions.assertTrue( Release.isOlderOrEqual( rel ) );
+    }
+
+}
diff --git a/jspwiki-war/src/main/webapp/templates/210/Favorites.jsp b/jspwiki-war/src/main/webapp/templates/210/Favorites.jsp
index 8918836..fd2ee5d 100644
--- a/jspwiki-war/src/main/webapp/templates/210/Favorites.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/Favorites.jsp
@@ -20,9 +20,10 @@
 <%@ taglib uri="http://jspwiki.apache.org/tags" prefix="wiki" %>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
 <%@ page import="javax.servlet.jsp.jstl.fmt.*" %>
+<%@ page import="org.apache.wiki.*" %>
+<%@ page import="org.apache.wiki.api.Release" %>
 <fmt:setLocale value="${prefs.Language}" />
 <fmt:setBundle basename="templates.default"/>
-<%@ page import="org.apache.wiki.*" %>
 
 <div id="favorites">
 
diff --git a/jspwiki-war/src/main/webapp/templates/210/Footer.jsp b/jspwiki-war/src/main/webapp/templates/210/Footer.jsp
index 4bc20de..8cc7c35 100644
--- a/jspwiki-war/src/main/webapp/templates/210/Footer.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/Footer.jsp
@@ -20,6 +20,7 @@
 <%@ taglib uri="http://jspwiki.apache.org/tags" prefix="wiki" %>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
 <%@ page import="org.apache.wiki.*" %>
+<%@ page import="org.apache.wiki.api.Release" %>
 <%@ page import="javax.servlet.jsp.jstl.fmt.*" %>
 <fmt:setLocale value="${prefs.Language}" />
 <fmt:setBundle basename="templates.default"/>
diff --git a/jspwiki-war/src/main/webapp/templates/default/Footer.jsp b/jspwiki-war/src/main/webapp/templates/default/Footer.jsp
index 83bde9d..a3ee529 100644
--- a/jspwiki-war/src/main/webapp/templates/default/Footer.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/Footer.jsp
@@ -19,7 +19,7 @@
 
 <%@ taglib uri="http://jspwiki.apache.org/tags" prefix="wiki" %>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
-<%@ page import="org.apache.wiki.*" %>
+<%@ page import="org.apache.wiki.api.Release" %>
 <%@ page import="javax.servlet.jsp.jstl.fmt.*" %>
 <fmt:setLocale value="${prefs.Language}" />
 <fmt:setBundle basename="templates.default"/>


[jspwiki] 30/35: update launchers to be based on tomcat 9.0.31

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git

commit 91ff2a31fc6018e9768fe110f5e7f5bfd807818c
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Mar 6 00:02:05 2020 +0100

    update launchers to be based on tomcat 9.0.31
---
 .../tomcat/woas.app/Contents/Java/bootstrap.jar    | Bin 35204 -> 35071 bytes
 .../tomcat/woas.app/Contents/Java/tomcat-juli.jar  | Bin 49783 -> 47886 bytes
 .../src/overlay/launchers/tomcat/woas.exe          | Bin 3500245 -> 3564962 bytes
 3 files changed, 0 insertions(+), 0 deletions(-)

diff --git a/jspwiki-portable/src/overlay/launchers/tomcat/woas.app/Contents/Java/bootstrap.jar b/jspwiki-portable/src/overlay/launchers/tomcat/woas.app/Contents/Java/bootstrap.jar
index 95efd4c..9ba6c4d 100644
Binary files a/jspwiki-portable/src/overlay/launchers/tomcat/woas.app/Contents/Java/bootstrap.jar and b/jspwiki-portable/src/overlay/launchers/tomcat/woas.app/Contents/Java/bootstrap.jar differ
diff --git a/jspwiki-portable/src/overlay/launchers/tomcat/woas.app/Contents/Java/tomcat-juli.jar b/jspwiki-portable/src/overlay/launchers/tomcat/woas.app/Contents/Java/tomcat-juli.jar
index 16d0177..faea050 100644
Binary files a/jspwiki-portable/src/overlay/launchers/tomcat/woas.app/Contents/Java/tomcat-juli.jar and b/jspwiki-portable/src/overlay/launchers/tomcat/woas.app/Contents/Java/tomcat-juli.jar differ
diff --git a/jspwiki-portable/src/overlay/launchers/tomcat/woas.exe b/jspwiki-portable/src/overlay/launchers/tomcat/woas.exe
index ab59538..0d0d9de 100644
Binary files a/jspwiki-portable/src/overlay/launchers/tomcat/woas.exe and b/jspwiki-portable/src/overlay/launchers/tomcat/woas.exe differ


[jspwiki] 25/35: JSPWIKI-303: use Session instead of WikiSession (1)

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git

commit aec837ee2fc0ea830ee7695e9c088472df8e9138
Author: juanpablo <ju...@apache.org>
AuthorDate: Thu Mar 5 17:17:36 2020 +0100

    JSPWIKI-303: use Session instead of WikiSession (1)
---
 .../src/main/java/org/apache/wiki/WikiContext.java |  10 +-
 .../src/main/java/org/apache/wiki/WikiSession.java |   4 +-
 .../java/org/apache/wiki/api/core/Session.java     |  12 +-
 .../apache/wiki/auth/AuthenticationManager.java    |  18 +--
 .../org/apache/wiki/auth/AuthorizationManager.java |  12 +-
 .../main/java/org/apache/wiki/auth/Authorizer.java |   5 +-
 .../wiki/auth/DefaultAuthenticationManager.java    |  12 +-
 .../java/org/apache/wiki/auth/SessionMonitor.java  |  78 +++++------
 .../java/org/apache/wiki/auth/UserManager.java     |  13 +-
 .../java/org/apache/wiki/auth/WikiPrincipal.java   |   2 +-
 .../wiki/auth/authorize/DefaultGroupManager.java   |   3 +-
 .../java/org/apache/wiki/auth/authorize/Group.java | 151 +++++++++------------
 .../apache/wiki/auth/authorize/GroupManager.java   |   8 +-
 .../auth/authorize/WebContainerAuthorizer.java     |  12 +-
 .../apache/wiki/auth/user/DefaultUserProfile.java  |   3 +-
 .../org/apache/wiki/auth/user/UserDatabase.java    |   2 +-
 .../org/apache/wiki/auth/user/UserProfile.java     |   3 +-
 17 files changed, 158 insertions(+), 190 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java
index 8b9e53d..b80f222 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java
@@ -185,7 +185,7 @@ public class WikiContext implements Cloneable, Command {
      * Creates a new WikiContext for the given Engine, Command and HttpServletRequest.
      * </p>
      * <p>
-     * This constructor will also look up the HttpSession associated with the request, and determine if a WikiSession object is present.
+     * This constructor will also look up the HttpSession associated with the request, and determine if a Session object is present.
      * If not, a new one is created.
      * </p>
      * @param engine The Engine that is handling the request
@@ -652,11 +652,11 @@ public class WikiContext implements Cloneable, Command {
     }
 
     /**
-     *  Returns the WikiSession associated with the context. This method is guaranteed to always return a valid WikiSession.
+     *  Returns the Session associated with the context. This method is guaranteed to always return a valid Session.
      *  If this context was constructed without an associated HttpServletRequest, it will return
      *  {@link org.apache.wiki.WikiSession#guestSession(Engine)}.
      *
-     *  @return The WikiSession associate with this context.
+     *  @return The Session associated with this context.
      */
     public Session getWikiSession()
     {
@@ -672,8 +672,8 @@ public class WikiContext implements Cloneable, Command {
      *  @return Current WikiContext, or null, of no context exists.
      */
     public static WikiContext findContext( final PageContext pageContext ) {
-        final HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
-        return (WikiContext)request.getAttribute( ATTR_CONTEXT );
+        final HttpServletRequest request = ( HttpServletRequest )pageContext.getRequest();
+        return ( WikiContext )request.getAttribute( ATTR_CONTEXT );
     }
 
     /**
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiSession.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiSession.java
index 12e6f36..5f68e60 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiSession.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiSession.java
@@ -382,7 +382,7 @@ public final class WikiSession implements Session {
     /**
      * Injects GroupPrincipal objects into the user's Principal set based on the groups the user belongs to. For Groups, the algorithm
      * first calls the {@link GroupManager#getRoles()} to obtain the array of GroupPrincipals the authorizer knows about. Then, the
-     * method {@link GroupManager#isUserInRole(WikiSession, Principal)} is called for each Principal. If the user is a member of the
+     * method {@link GroupManager#isUserInRole(Session, Principal)} is called for each Principal. If the user is a member of the
      * group, an equivalent GroupPrincipal is injected into the user's principal set. Existing GroupPrincipals are flushed and replaced.
      * This method should generally be called after a user's {@link org.apache.wiki.auth.user.UserProfile} is saved. If the wiki session
      * is null, or there is no matching user profile, the method returns silently.
@@ -493,7 +493,7 @@ public final class WikiSession implements Session {
         // Look for a WikiSession associated with the user's Http Session and create one if it isn't there yet.
         final HttpSession session = request.getSession();
         final SessionMonitor monitor = SessionMonitor.getInstance( engine );
-        final WikiSession wikiSession = monitor.find( session );
+        final WikiSession wikiSession = ( WikiSession )monitor.find( session );
 
         // Attach reference to wiki engine
         wikiSession.m_engine = engine;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/api/core/Session.java b/jspwiki-main/src/main/java/org/apache/wiki/api/core/Session.java
index 8dce0d8..f2704e7 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/api/core/Session.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/api/core/Session.java
@@ -54,7 +54,7 @@ import java.util.Locale;
  * re-authenticate.
  * </p>
  * <p>In addition to methods for examining individual <code>Session</code> objects, this class also contains a number of static
- * methods for managing WikiSessions for an entire wiki. These methods allow callers to find, query and remove WikiSession objects, and
+ * methods for managing Sessions for an entire wiki. These methods allow callers to find, query and remove Session objects, and
  * to obtain a list of the current wiki session users.</p>
  */
 public interface Session extends WikiEventListener {
@@ -126,7 +126,7 @@ public interface Session extends WikiEventListener {
     /**
      *  Returns a cached Locale object for this user.  It's better to use WikiContext's corresponding getBundle() method, since that
      *  will actually react if the user changes the locale in the middle, but if that's not available (or, for some reason, you need
-     *  the speed), this method can also be used.  The Locale expires when the WikiSession expires, and currently there is no way to
+     *  the speed), this method can also be used.  The Locale expires when the Session expires, and currently there is no way to
      *  reset the Locale.
      *
      *  @return A cached Locale object
@@ -190,7 +190,7 @@ public interface Session extends WikiEventListener {
     Principal[] getPrincipals();
 
     /**
-     * Returns an array of Principal objects that represents the groups and roles that the user associated with a WikiSession possesses.
+     * Returns an array of Principal objects that represents the groups and roles that the user associated with a Session possesses.
      * The array is built by iterating through the Subject's Principal set and extracting all Role and GroupPrincipal objects into a
      * list. The list is returned as an array sorted in the natural order implied by each Principal's <code>getName</code> method. Note
      * that this method does <em>not</em> consult the external Authorizer or GroupManager; it relies on the Principals that have been
@@ -201,7 +201,7 @@ public interface Session extends WikiEventListener {
     Principal[] getRoles();
 
     /**
-     * Returns <code>true</code> if the WikiSession's Subject possess a supplied Principal. This method eliminates the need to externally
+     * Returns <code>true</code> if the Session's Subject possess a supplied Principal. This method eliminates the need to externally
      * request and inspect the JAAS subject.
      *
      * @param principal the Principal to test
@@ -209,7 +209,7 @@ public interface Session extends WikiEventListener {
      */
     boolean hasPrincipal( Principal principal );
 
-    /** Invalidates the WikiSession and resets its Subject's Principals to the equivalent of a "guest session". */
+    /** Invalidates the Session and resets its Subject's Principals to the equivalent of a "guest session". */
     void invalidate();
 
     /**
@@ -233,7 +233,7 @@ public interface Session extends WikiEventListener {
 
     /**
      * Wrapper for {@link Subject#doAsPrivileged(Subject, PrivilegedAction, java.security.AccessControlContext)}
-     * that executes an action with the privileges posssessed by a WikiSession's Subject. The action executes with a <code>null</code>
+     * that executes an action with the privileges posssessed by a Session's Subject. The action executes with a <code>null</code>
      * AccessControlContext, which has the effect of running it "cleanly" without the AccessControlContexts of the caller.
      *
      * @param session the wiki session
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthenticationManager.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthenticationManager.java
index 9360124..143c180 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthenticationManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthenticationManager.java
@@ -88,24 +88,24 @@ public interface AuthenticationManager {
     boolean isContainerAuthenticated();
 
     /**
-     * <p>Logs in the user by attempting to populate a WikiSession Subject from a web servlet request by examining the request
+     * <p>Logs in the user by attempting to populate a Session Subject from a web servlet request by examining the request
      *  for the presence of container credentials and user cookies. The processing logic is as follows:
      * </p>
      * <ul>
-     * <li>If the WikiSession had previously been unauthenticated, check to see if user has subsequently authenticated. To be considered
+     * <li>If the Session had previously been unauthenticated, check to see if user has subsequently authenticated. To be considered
      * "authenticated," the request must supply one of the following (in order of preference): the container <code>userPrincipal</code>,
      * container <code>remoteUser</code>, or authentication cookie. If the user is authenticated, this method fires event
      * {@link org.apache.wiki.event.WikiSecurityEvent#LOGIN_AUTHENTICATED} with two parameters: a Principal representing the login principal,
-     * and the current WikiSession. In addition, if the authorizer is of type WebContainerAuthorizer, this method iterates through the
+     * and the current Session. In addition, if the authorizer is of type WebContainerAuthorizer, this method iterates through the
      * container roles returned by {@link org.apache.wiki.auth.authorize.WebContainerAuthorizer#getRoles()}, tests for membership in each
      * one, and adds those that pass to the Subject's principal set.</li>
-     * <li>If, after checking for authentication, the WikiSession is still Anonymous, this method next checks to see if the user has
+     * <li>If, after checking for authentication, the Session is still Anonymous, this method next checks to see if the user has
      * "asserted" an identity by supplying an assertion cookie. If the user is found to be asserted, this method fires event
      * {@link org.apache.wiki.event.WikiSecurityEvent#LOGIN_ASSERTED} with two parameters: <code>WikiPrincipal(<em>cookievalue</em>)</code>,
-     * and the current WikiSession.</li>
-     * <li>If, after checking for authenticated and asserted status, the  WikiSession is <em>still</em> anonymous, this method fires event
+     * and the current Session.</li>
+     * <li>If, after checking for authenticated and asserted status, the  Session is <em>still</em> anonymous, this method fires event
      * {@link org.apache.wiki.event.WikiSecurityEvent#LOGIN_ANONYMOUS} with two parameters: <code>WikiPrincipal(<em>remoteAddress</em>)</code>,
-     * and the current WikiSession </li>
+     * and the current Session </li>
      * </ul>
      *
      * @param request servlet request for this user
@@ -116,7 +116,7 @@ public interface AuthenticationManager {
     boolean login( HttpServletRequest request ) throws WikiSecurityException;
     
     /**
-     * Attempts to perform a WikiSession login for the given username/password combination using JSPWiki's custom authentication mode. In
+     * Attempts to perform a Session login for the given username/password combination using JSPWiki's custom authentication mode. In
      * order to log in, the JAAS LoginModule supplied by the Engine property {@link #PROP_LOGIN_MODULE} will be instantiated, and its
      * {@link javax.security.auth.spi.LoginModule#initialize(Subject, CallbackHandler, Map, Map)} method will be invoked. By default,
      * the {@link org.apache.wiki.auth.login.UserDatabaseLoginModule} class will be used. When the LoginModule's <code>initialize</code>
@@ -134,7 +134,7 @@ public interface AuthenticationManager {
     boolean login( Session session, HttpServletRequest request, String username, String password ) throws WikiSecurityException;
 
     /**
-     * Logs the user out by retrieving the WikiSession associated with the HttpServletRequest and unbinding all of the Subject's Principals,
+     * Logs the user out by retrieving the Session associated with the HttpServletRequest and unbinding all of the Subject's Principals,
      * except for {@link Role#ALL}, {@link Role#ANONYMOUS}. is a cheap-and-cheerful way to do it without invoking JAAS LoginModules.
      * The logout operation will also flush the JSESSIONID cookie from the user's browser session, if it was set.
      *
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthorizationManager.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthorizationManager.java
index c10128e..198cf80 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthorizationManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthorizationManager.java
@@ -45,7 +45,7 @@ import java.util.Properties;
  *   <em>e.g.,</em> reading, editing, renaming
  * </ul>
  * <p>Calling classes determine whether they are entitled to perform a particular action by constructing the appropriate permission first,
- * then passing it and the current {@link org.apache.wiki.WikiSession} to the {@link #checkPermission(Session, Permission)} method. If
+ * then passing it and the current {@link Session} to the {@link #checkPermission(Session, Permission)} method. If
  * the session's Subject possesses the permission, the action is allowed.</p>
  * <p>For WikiPermissions, the decision criteria is relatively simple: the caller either possesses the permission, as granted by the wiki
  * security policy -- or not.</p>
@@ -75,10 +75,10 @@ public interface AuthorizationManager {
 
     /**
      * Returns <code>true</code> or <code>false</code>, depending on whether a Permission is allowed for the Subject associated with
-     * a supplied WikiSession. The access control algorithm works this way:
+     * a supplied Session. The access control algorithm works this way:
      * <ol>
      * <li>The {@link org.apache.wiki.auth.acl.Acl} for the page is obtained</li>
-     * <li>The Subject associated with the current {@link org.apache.wiki.WikiSession} is obtained</li>
+     * <li>The Subject associated with the current {@link org.apache.wiki.api.core.Session} is obtained</li>
      * <li>If the Subject's Principal set includes the Role Principal that is the administrator group, always allow the Permission</li>
      * <li>For all permissions, check to see if the Permission is allowed according to the default security policy. If it isn't, deny
      * the permission and halt further processing.</li>
@@ -106,7 +106,7 @@ public interface AuthorizationManager {
     boolean checkPermission( Session session, Permission permission );
 
     /**
-     * <p>Determines if the Subject associated with a supplied WikiSession contains a desired Role or GroupPrincipal. The algorithm
+     * <p>Determines if the Subject associated with a supplied Session contains a desired Role or GroupPrincipal. The algorithm
      * simply checks to see if the Subject possesses the Role or GroupPrincipal it in its Principal set. Note that any user (anonymous,
      * asserted, authenticated) can possess a built-in role. But a user <em>must</em> be authenticated to possess a role other than one
      * of the built-in ones. We do this to prevent privilege escalation.</p>
@@ -146,7 +146,7 @@ public interface AuthorizationManager {
     Authorizer getAuthorizer() throws WikiSecurityException;
 
     /**
-     * <p>Determines if the Subject associated with a supplied WikiSession contains a desired user Principal or built-in Role principal,
+     * <p>Determines if the Subject associated with a supplied Session contains a desired user Principal or built-in Role principal,
      * OR is a member a Group or external Role. The rules are as follows:</p>
      * <ol>
      * <li>First, if desired Principal is a Role or GroupPrincipal, delegate to {@link #isUserInRole(Session, Principal)} and
@@ -226,7 +226,7 @@ public interface AuthorizationManager {
      *
      * @see AccessController#checkPermission(Permission) . A caught exception (or lack thereof) determines whether the
      *       privilege is absent (or present).
-     * @param session the WikiSession whose permission status is being queried
+     * @param session the Session whose permission status is being queried
      * @param permission the Permission the Subject must possess
      * @return <code>true</code> if the Subject possesses the permission, <code>false</code> otherwise
      */
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/Authorizer.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/Authorizer.java
index 534d6a5..84468d7 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/Authorizer.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/Authorizer.java
@@ -18,7 +18,6 @@
  */
 package org.apache.wiki.auth;
 
-import org.apache.wiki.WikiSession;
 import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.core.Session;
 
@@ -29,9 +28,9 @@ import java.util.Properties;
 /**
  * Interface for service providers of authorization information. After a user successfully logs in, the
  * {@link org.apache.wiki.auth.AuthenticationManager} consults the configured Authorizer to determine which additional
- * {@link org.apache.wiki.auth.authorize.Role} principals should be added to the user's WikiSession. To determine which roles should be
+ * {@link org.apache.wiki.auth.authorize.Role} principals should be added to the user's Session. To determine which roles should be
  * injected, the Authorizer is queried for the roles it knows about by calling {@link org.apache.wiki.auth.Authorizer#getRoles()}. Then,
- * each role returned by the Authorizer is tested by calling {@link org.apache.wiki.auth.Authorizer#isUserInRole(WikiSession, Principal)}.
+ * each role returned by the Authorizer is tested by calling {@link org.apache.wiki.auth.Authorizer#isUserInRole(Session, Principal)}.
  * If this check fails, and the Authorizer is of type WebAuthorizer, AuthenticationManager checks the role again by calling
  * {@link org.apache.wiki.auth.authorize.WebAuthorizer#isUserInRole(javax.servlet.http.HttpServletRequest, Principal)}).
  * Any roles that pass the test are injected into the Subject by firing appropriate authentication events.
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultAuthenticationManager.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultAuthenticationManager.java
index 8056db8..b46b227 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultAuthenticationManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultAuthenticationManager.java
@@ -154,7 +154,7 @@ public class DefaultAuthenticationManager implements AuthenticationManager {
     @Override
     public boolean login( final HttpServletRequest request ) throws WikiSecurityException {
         final HttpSession httpSession = request.getSession();
-        final WikiSession session = SessionMonitor.getInstance( m_engine ).find( httpSession );
+        final Session session = SessionMonitor.getInstance( m_engine ).find( httpSession );
         final AuthenticationManager authenticationMgr = m_engine.getManager( AuthenticationManager.class );
         final AuthorizationManager authorizationMgr = m_engine.getManager( AuthorizationManager.class );
         CallbackHandler handler = null;
@@ -171,7 +171,7 @@ public class DefaultAuthenticationManager implements AuthenticationManager {
                 principals = authenticationMgr.doJAASLogin( CookieAuthenticationLoginModule.class, handler, options );
             }
 
-            // If the container logged the user in successfully, tell the WikiSession (and add all of the Principals)
+            // If the container logged the user in successfully, tell the Session (and add all of the Principals)
             if ( principals.size() > 0 ) {
                 fireEvent( WikiSecurityEvent.LOGIN_AUTHENTICATED, getLoginPrincipal( principals ), session );
                 for( final Principal principal : principals ) {
@@ -274,9 +274,9 @@ public class DefaultAuthenticationManager implements AuthenticationManager {
         final HttpSession session = request.getSession();
         final String sid = ( session == null ) ? "(null)" : session.getId();
         if( log.isDebugEnabled() ) {
-            log.debug( "Invalidating WikiSession for session ID=" + sid );
+            log.debug( "Invalidating Session for session ID=" + sid );
         }
-        // Retrieve the associated WikiSession and clear the Principal set
+        // Retrieve the associated Session and clear the Principal set
         final Session wikiSession = WikiSession.getWikiSession( m_engine, request );
         final Principal originalPrincipal = wikiSession.getLoginPrincipal();
         wikiSession.invalidate();
@@ -393,14 +393,14 @@ public class DefaultAuthenticationManager implements AuthenticationManager {
     }
 
     /**
-     * After successful login, this method is called to inject authorized role Principals into the WikiSession. To determine which roles
+     * After successful login, this method is called to inject authorized role Principals into the Session. To determine which roles
      * should be injected, the configured Authorizer is queried for the roles it knows about by calling  {@link Authorizer#getRoles()}.
      * Then, each role returned by the authorizer is tested by calling {@link Authorizer#isUserInRole(Session, Principal)}. If this
      * check fails, and the Authorizer is of type WebAuthorizer, the role is checked again by calling
      * {@link WebAuthorizer#isUserInRole(HttpServletRequest, Principal)}). Any roles that pass the test are injected into the Subject by
      * firing appropriate authentication events.
      *
-     * @param session the user's current WikiSession
+     * @param session the user's current Session
      * @param authorizer the Engine's configured Authorizer
      * @param request the user's HTTP session, which may be <code>null</code>
      */
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/SessionMonitor.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/SessionMonitor.java
index 0ddc03e..155d235 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/SessionMonitor.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/SessionMonitor.java
@@ -21,6 +21,7 @@ package org.apache.wiki.auth;
 import org.apache.log4j.Logger;
 import org.apache.wiki.WikiSession;
 import org.apache.wiki.api.core.Engine;
+import org.apache.wiki.api.core.Session;
 import org.apache.wiki.event.WikiEventListener;
 import org.apache.wiki.event.WikiEventManager;
 import org.apache.wiki.event.WikiSecurityEvent;
@@ -51,7 +52,7 @@ public class SessionMonitor implements HttpSessionListener {
     private static ConcurrentHashMap< Engine, SessionMonitor > c_monitors = new ConcurrentHashMap<>();
 
     /** Weak hashmap with HttpSessions as keys, and WikiSessions as values. */
-    private final Map< String, WikiSession > m_sessions = new WeakHashMap<>();
+    private final Map< String, Session > m_sessions = new WeakHashMap<>();
 
     private Engine m_engine;
 
@@ -92,16 +93,14 @@ public class SessionMonitor implements HttpSessionListener {
      *  @param session the user's HTTP session
      *  @return the WikiSession, if found
      */
-    private WikiSession findSession( final HttpSession session ) {
-        WikiSession wikiSession = null;
+    private Session findSession( final HttpSession session ) {
+        Session wikiSession = null;
         final String sid = ( session == null ) ? "(null)" : session.getId();
-        final WikiSession storedSession = m_sessions.get( sid );
+        final Session storedSession = m_sessions.get( sid );
 
         // If the weak reference returns a wiki session, return it
-        if( storedSession != null )
-        {
-            if( log.isDebugEnabled() )
-            {
+        if( storedSession != null ) {
+            if( log.isDebugEnabled() ) {
                 log.debug( "Looking up WikiSession for session ID=" + sid + "... found it" );
             }
             wikiSession = storedSession;
@@ -110,19 +109,17 @@ public class SessionMonitor implements HttpSessionListener {
         return wikiSession;
     }
     /**
-     * <p>Looks up the wiki session associated with a user's Http session
-     * and adds it to the session cache. This method will return the
-     * "guest session" as constructed by {@link org.apache.wiki.WikiSession#guestSession(Engine)}
-     * if the HttpSession is not currently associated with a WikiSession.
-     * This method is guaranteed to return a non-<code>null</code> WikiSession.</p>
-     * <p>Internally, the session is stored in a HashMap; keys are
-     * the HttpSession objects, while the values are
+     * <p>Looks up the wiki session associated with a user's Http session and adds it to the session cache. This method will return the
+     * "guest session" as constructed by {@link org.apache.wiki.WikiSession#guestSession(Engine)} if the HttpSession is not currently
+     * associated with a WikiSession. This method is guaranteed to return a non-<code>null</code> WikiSession.</p>
+     * <p>Internally, the session is stored in a HashMap; keys are the HttpSession objects, while the values are
      * {@link java.lang.ref.WeakReference}-wrapped WikiSessions.</p>
+     *
      * @param session the HTTP session
      * @return the wiki session
      */
-    public final WikiSession find( final HttpSession session ) {
-        WikiSession wikiSession = findSession(session);
+    public final Session find( final HttpSession session ) {
+        Session wikiSession = findSession( session );
         final String sid = ( session == null ) ? "(null)" : session.getId();
 
         // Otherwise, create a new guest session and stash it.
@@ -130,7 +127,7 @@ public class SessionMonitor implements HttpSessionListener {
             if( log.isDebugEnabled() ) {
                 log.debug( "Looking up WikiSession for session ID=" + sid + "... not found. Creating guestSession()" );
             }
-            wikiSession = (WikiSession)WikiSession.guestSession( m_engine );
+            wikiSession = WikiSession.guestSession( m_engine );
             synchronized( m_sessions ) {
                 m_sessions.put( sid, wikiSession );
             }
@@ -175,63 +172,57 @@ public class SessionMonitor implements HttpSessionListener {
     }
 
     /**
-     * <p>Returns the current wiki users as a sorted array of
-     * Principal objects. The principals are those returned by
-     * each WikiSession's {@link WikiSession#getUserPrincipal()}'s
-     * method.</p>
-     * <p>To obtain the list of current WikiSessions, we iterate
-     * through our session Map and obtain the list of values,
-     * which are WikiSessions wrapped in {@link java.lang.ref.WeakReference}
-     * objects. Those <code>WeakReference</code>s whose <code>get()</code>
-     * method returns non-<code>null</code> values are valid
-     * sessions.</p>
+     * <p>Returns the current wiki users as a sorted array of Principal objects. The principals are those returned by
+     * each WikiSession's {@link Session#getUserPrincipal()}'s method.</p>
+     * <p>To obtain the list of current WikiSessions, we iterate through our session Map and obtain the list of values,
+     * which are WikiSessions wrapped in {@link java.lang.ref.WeakReference} objects. Those <code>WeakReference</code>s
+     * whose <code>get()</code> method returns non-<code>null</code> values are valid sessions.</p>
+     *
      * @return the array of user principals
      */
-    public final Principal[] userPrincipals()
-    {
+    public final Principal[] userPrincipals() {
         final Collection<Principal> principals = new ArrayList<>();
         synchronized ( m_sessions ) {
-            for ( final WikiSession session : m_sessions.values()) {
+            for ( final Session session : m_sessions.values()) {
                 principals.add( session.getUserPrincipal() );
             }
         }
-        final Principal[] p = principals.toArray( new Principal[principals.size()] );
+        final Principal[] p = principals.toArray( new Principal[ principals.size() ] );
         Arrays.sort( p, m_comparator );
         return p;
     }
 
     /**
      * Registers a WikiEventListener with this instance.
+     *
      * @param listener the event listener
      * @since 2.4.75
      */
-    public final synchronized void addWikiEventListener( final WikiEventListener listener )
-    {
+    public final synchronized void addWikiEventListener( final WikiEventListener listener ) {
         WikiEventManager.addWikiEventListener( this, listener );
     }
 
     /**
      * Un-registers a WikiEventListener with this instance.
+     *
      * @param listener the event listener
      * @since 2.4.75
      */
-    public final synchronized void removeWikiEventListener( final WikiEventListener listener )
-    {
+    public final synchronized void removeWikiEventListener( final WikiEventListener listener ) {
         WikiEventManager.removeWikiEventListener( this, listener );
     }
 
     /**
      * Fires a WikiSecurityEvent to all registered listeners.
+     *
      * @param type  the event type
      * @param principal the user principal associated with this session
      * @param session the wiki session
      * @since 2.4.75
      */
-    protected final void fireEvent( final int type, final Principal principal, final WikiSession session )
-    {
-        if( WikiEventManager.isListening(this) )
-        {
-            WikiEventManager.fireEvent(this,new WikiSecurityEvent(this,type,principal,session));
+    protected final void fireEvent( final int type, final Principal principal, final Session session ) {
+        if( WikiEventManager.isListening( this ) ) {
+            WikiEventManager.fireEvent( this, new WikiSecurityEvent( this, type, principal, session ) );
         }
     }
 
@@ -241,8 +232,7 @@ public class SessionMonitor implements HttpSessionListener {
      * @param se the HTTP session event
      */
     @Override
-    public void sessionCreated( final HttpSessionEvent se )
-    {
+    public void sessionCreated( final HttpSessionEvent se ) {
         final HttpSession session = se.getSession();
         log.debug( "Created session: " + session.getId() + "." );
     }
@@ -256,7 +246,7 @@ public class SessionMonitor implements HttpSessionListener {
     public void sessionDestroyed( final HttpSessionEvent se ) {
         final HttpSession session = se.getSession();
         for( final SessionMonitor monitor : c_monitors.values() ) {
-            final WikiSession storedSession = monitor.findSession( session );
+            final Session storedSession = monitor.findSession( session );
             monitor.remove( session );
             log.debug( "Removed session " + session.getId() + "." );
             if( storedSession != null ) {
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/UserManager.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/UserManager.java
index bc0f66c..fc62bb1 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/UserManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/UserManager.java
@@ -19,7 +19,6 @@
 package org.apache.wiki.auth;
 
 import org.apache.wiki.WikiContext;
-import org.apache.wiki.WikiSession;
 import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.core.Session;
 import org.apache.wiki.api.exceptions.WikiException;
@@ -89,15 +88,15 @@ public interface UserManager {
      * and the user's credential set is refreshed; if custom authentication is used, this means the user will be automatically be logged in.
      * </p>
      * <p>
-     * When the user's profile is saved successfully, this method fires a {@link WikiSecurityEvent#PROFILE_SAVE} event with the WikiSession
+     * When the user's profile is saved successfully, this method fires a {@link WikiSecurityEvent#PROFILE_SAVE} event with the Session
      * as the source and the UserProfile as target. For existing profiles, if the user's full name changes, this method also fires a
-     * "name changed" event ({@link WikiSecurityEvent#PROFILE_NAME_CHANGED}) with the WikiSession as the source and an array containing
+     * "name changed" event ({@link WikiSecurityEvent#PROFILE_NAME_CHANGED}) with the Session as the source and an array containing
      * the old and new UserProfiles, respectively. The <code>NAME_CHANGED</code> event allows the GroupManager and PageManager can change
      * group memberships and ACLs if needed.
      * </p>
      * <p>
-     * Note that WikiSessions normally attach event listeners to the UserManager, so changes to the profile will automatically cause the
-     * correct Principals to be reloaded into the current WikiSession's Subject.
+     * Note that Sessions normally attach event listeners to the UserManager, so changes to the profile will automatically cause the
+     * correct Principals to be reloaded into the current Session's Subject.
      * </p>
      *
      * @param session the wiki session, which may not be <code>null</code>
@@ -126,7 +125,7 @@ public interface UserManager {
      * <li>In all cases, the created/last modified timestamps of the user's existing or new profile always override whatever values the user
      * supplied.</li>
      * <li>If container authentication is used, the login name property of the profile is set to the name of
-     * {@link org.apache.wiki.WikiSession#getLoginPrincipal()}. Otherwise, the value of the <code>loginname</code> parameter is used.</li>
+     * {@link org.apache.wiki.api.core.Session#getLoginPrincipal()}. Otherwise, the value of the <code>loginname</code> parameter is used.</li>
      * </ul>
      *
      * @param context the current wiki context
@@ -139,7 +138,7 @@ public interface UserManager {
      * make sure it isn't null. Otherwise, the password is checked for length and that it matches the value of the 'password2' HTTP
      * parameter. Note that we have a special case when container-managed authentication is used and the user is not authenticated;
      * this will always cause validation to fail. Any validation errors are added to the wiki session's messages collection
-     * (see {@link WikiSession#getMessages()}.
+     * (see {@link org.apache.wiki.api.core.Session#getMessages()}.
      *
      * @param context the current wiki context
      * @param profile the supplied UserProfile
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/WikiPrincipal.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/WikiPrincipal.java
index 5ade711..787fa84 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/WikiPrincipal.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/WikiPrincipal.java
@@ -29,7 +29,7 @@ import java.util.Comparator;
 /**
  *  A lightweight, immutable Principal class. WikiPrincipals can be created with and optional "type" to denote what type of user
  *  profile Principal it represents (FULL_NAME, WIKI_NAME, LOGIN_NAME). Types are used to determine suitable user and login Principals in
- *  classes like WikiSession. However, the type property of a WikiPrincipal does not affect a WikiPrincipal's logical equality
+ *  classes like Session. However, the type property of a WikiPrincipal does not affect a WikiPrincipal's logical equality
  *  or hash code; two WikiPrincipals with the same name but different types are still considered equal.
  *
  *  @since  2.2
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/DefaultGroupManager.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/DefaultGroupManager.java
index 227c453..b4f8d29 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/DefaultGroupManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/DefaultGroupManager.java
@@ -20,7 +20,6 @@ package org.apache.wiki.auth.authorize;
 
 import org.apache.commons.lang3.ArrayUtils;
 import org.apache.log4j.Logger;
-import org.apache.wiki.WikiSession;
 import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.core.Session;
 import org.apache.wiki.api.exceptions.NoRequiredPropertyException;
@@ -365,7 +364,7 @@ public class DefaultGroupManager implements GroupManager, Authorizer, WikiEventL
 
         final WikiSecurityEvent se = ( WikiSecurityEvent )event;
         if( se.getType() == WikiSecurityEvent.PROFILE_NAME_CHANGED ) {
-            final WikiSession session = se.getSrc();
+            final Session session = se.getSrc();
             final UserProfile[] profiles = ( UserProfile[] )se.getTarget();
             final Principal[] oldPrincipals = new Principal[] { new WikiPrincipal( profiles[ 0 ].getLoginName() ),
                     new WikiPrincipal( profiles[ 0 ].getFullname() ), new WikiPrincipal( profiles[ 0 ].getWikiName() ) };
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/Group.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/Group.java
index 50f7cfa..50cdf24 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/Group.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/Group.java
@@ -18,12 +18,12 @@
  */
 package org.apache.wiki.auth.authorize;
 
+import org.apache.wiki.auth.GroupPrincipal;
+
 import java.security.Principal;
 import java.util.Date;
 import java.util.Vector;
 
-import org.apache.wiki.auth.GroupPrincipal;
-
 /**
  * <p>
  * Groups are a specialized type of ad-hoc role used by the wiki system. Unlike
@@ -48,7 +48,7 @@ import org.apache.wiki.auth.GroupPrincipal;
  * </p>
  * <p>
  * Groups are related to {@link GroupPrincipal}s. A GroupPrincipal, when
- * injected into the Principal set of a WikiSession's Subject, means that the
+ * injected into the Principal set of a Session's Subject, means that the
  * user is a member of a Group of the same name -- it is, in essence, an
  * "authorization token." GroupPrincipals, unlike Groups, are thread-safe,
  * lightweight and immutable. That's why we use them in Subjects rather than the
@@ -57,13 +57,11 @@ import org.apache.wiki.auth.GroupPrincipal;
  *
  * @since 2.3
  */
-public class Group
-{
+public class Group {
 
-    static final String[]  RESTRICTED_GROUPNAMES = new String[]
-                                                  { "Anonymous", "All", "Asserted", "Authenticated" };
+    static final String[]  RESTRICTED_GROUPNAMES = new String[] { "Anonymous", "All", "Asserted", "Authenticated" };
 
-    private final Vector<Principal>    m_members             = new Vector<Principal>();
+    private final Vector<Principal>    m_members = new Vector<>();
 
     private String          m_creator             = null;
 
@@ -88,8 +86,7 @@ public class Group
      * @param name the name of the group
      * @param wiki the wiki the group belongs to
      */
-    protected Group( String name, String wiki )
-    {
+    protected Group( final String name, final String wiki ) {
         m_name = name;
         m_wiki = wiki;
         m_principal = new GroupPrincipal( name );
@@ -101,10 +98,8 @@ public class Group
      * @param user the principal to add
      * @return <code>true</code> if the operation was successful
      */
-    public synchronized boolean add( Principal user )
-    {
-        if ( isMember( user ) )
-        {
+    public synchronized boolean add( final Principal user ) {
+        if( isMember( user ) ) {
             return false;
         }
 
@@ -115,8 +110,7 @@ public class Group
     /**
      * Clears all Principals from the group list. 
      */
-    public synchronized void clear()
-    {
+    public synchronized void clear() {
         m_members.clear();
     }
 
@@ -126,29 +120,26 @@ public class Group
      * @param o the object to compare
      * @return the comparison
      */
-    public boolean equals( Object o )
-    {
-        if ( o == null || !( o instanceof Group ) )
+    @Override
+    public boolean equals( final Object o ) {
+        if( !( o instanceof Group ) ) {
             return false;
+        }
 
-        Group g = (Group) o; // Just a shortcut.
+        final Group g = ( Group )o; // Just a shortcut.
 
-        if ( g.m_members.size() != m_members.size() )
+        if( g.m_members.size() != m_members.size() ) {
             return false;
+        }
 
-        if ( getName() != null && !getName().equals( g.getName() ) )
-        {
+        if( getName() != null && !getName().equals( g.getName() ) ) {
             return false;
-        }
-        else if ( getName() == null && g.getName() != null )
-        {
+        } else if( getName() == null && g.getName() != null ) {
             return false;
         }
 
-        for( Principal principal : m_members )
-        {
-            if ( !g.isMember( principal ) )
-            {
+        for( final Principal principal : m_members ) {
+            if( !g.isMember( principal ) ) {
                 return false;
             }
         }
@@ -157,15 +148,14 @@ public class Group
     }
 
     /**
-     *  The hashcode is calculated as a XOR sum over all members of
-     *  the Group.
+     *  The hashcode is calculated as a XOR sum over all members of the Group.
+     *
      *  @return the hash code
      */
-    public int hashCode()
-    {
+    @Override
+    public int hashCode() {
         int hc = 0;
-        for( Principal member : m_members )
-        {
+        for( final Principal member : m_members ) {
             hc ^= member.hashCode();
         }
         return hc;
@@ -173,113 +163,109 @@ public class Group
     
     /**
      * Returns the creation date.
+     *
      * @return the creation date
      */
-    public synchronized Date getCreated()
-    {
+    public synchronized Date getCreated() {
         return m_created;
     }
 
     /**
      * Returns the creator of this Group.
+     *
      * @return the creator
      */
-    public final synchronized String getCreator()
-    {
+    public final synchronized String getCreator() {
         return m_creator;
     }
 
     /**
      * Returns the last-modified date.
+     *
      * @return the date and time of last modification
      */
-    public synchronized Date getLastModified()
-    {
+    public synchronized Date getLastModified() {
         return m_modified;
     }
 
     /**
      * Returns the name of the user who last modified this group.
+     *
      * @return the modifier
      */
-    public final synchronized String getModifier()
-    {
+    public final synchronized String getModifier() {
         return m_modifier;
     }
 
     /**
      * The name of the group. This is set in the class constructor.
+     *
      * @return the name of the Group
      */
-    public String getName()
-    {
+    public String getName() {
         return m_name;
     }
 
     /**
      * Returns the GroupPrincipal that represents this Group.
+     *
      * @return the group principal
      */
-    public Principal getPrincipal()
-    {
+    public Principal getPrincipal() {
         return m_principal;
     }
 
     /**
      * Returns the wiki name.
+     *
      * @return the wiki name
      */
-    public String getWiki()
-    {
+    public String getWiki() {
         return m_wiki;
     }
 
     /**
-     * Returns <code>true</code> if a Principal is a member of the group.
-     * Specifically, the Principal's <code>getName()</code> method must return
-     * the same value as one of the Principals in the group member list. The
-     * Principal's type does <em>not</em> need to match.
+     * Returns <code>true</code> if a Principal is a member of the group. Specifically, the Principal's <code>getName()</code> method must
+     * return the same value as one of the Principals in the group member list. The Principal's type does <em>not</em> need to match.
+     *
      * @param principal the principal about whom membeship status is sought
      * @return the result of the operation
      */
-    public boolean isMember( Principal principal )
-    {
+    public boolean isMember( final Principal principal ) {
         return findMember( principal.getName() ) != null;
     }
 
     /**
      * Returns the members of the group as an array of Principal objects.
+     *
      * @return the members
      */
-    public Principal[] members()
-    {
-        return m_members.toArray( new Principal[m_members.size()] );
+    public Principal[] members() {
+        return m_members.toArray( new Principal[ m_members.size() ] );
     }
 
     /**
-     * Removes a Principal from the group. 
-     * 
+     * Removes a Principal from the group.
+     *
      * @param user the principal to remove
      * @return <code>true</code> if the operation was successful
      */
-    public synchronized boolean remove( Principal user )
-    {
+    public synchronized boolean remove( Principal user ) {
         user = findMember( user.getName() );
-
-        if ( user == null )
+        if( user == null )
             return false;
 
         m_members.remove( user );
-        
+
         return true;
     }
 
     /**
      * Sets the created date.
+     *
      * @param date the creation date
      */
-    public synchronized void setCreated( Date date )
-    {
+    public synchronized void setCreated( final Date date ) {
         m_created = date;
     }
 
@@ -287,47 +273,42 @@ public class Group
      * Sets the creator of this Group.
      * @param creator the creator
      */
-    public final synchronized void setCreator( String creator )
-    {
+    public final synchronized void setCreator( final String creator ) {
         this.m_creator = creator;
     }
 
     /**
      * Sets the last-modified date
+     *
      * @param date the last-modified date
      */
-    public synchronized void setLastModified( Date date )
-    {
+    public synchronized void setLastModified( final Date date ) {
         m_modified = date;
     }
 
     /**
      * Sets the name of the user who last modified this group.
+     *
      * @param modifier the modifier
      */
-    public final synchronized void setModifier( String modifier )
-    {
+    public final synchronized void setModifier( final String modifier ) {
         this.m_modifier = modifier;
     }
 
     /**
      * Returns a string representation of the Group.
+     *
      * @return the string
      * @see java.lang.Object#toString()
      */
-    public String toString()
-    {
-    	StringBuilder sb = new StringBuilder();
-        sb.append( "(Group " + getName() + ")" );
-        return sb.toString();
+    @Override
+    public String toString() {
+        return "(Group " + getName() + ")";
     }
 
-    private Principal findMember( String name )
-    {
-        for( Principal member : m_members )
-        {
-            if ( member.getName().equals( name ) )
-            {
+    private Principal findMember( final String name ) {
+        for( final Principal member : m_members ) {
+            if( member.getName().equals( name ) ) {
                 return member;
             }
         }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/GroupManager.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/GroupManager.java
index d6a0866..ce8b856 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/GroupManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/GroupManager.java
@@ -46,7 +46,7 @@ import java.security.Principal;
  */
 public interface GroupManager extends Authorizer, WikiEventListener {
 
-    /** Key used for adding UI messages to a user's WikiSession. */
+    /** Key used for adding UI messages to a user's Session. */
     String MESSAGES_KEY = "group";
 
     String PROP_GROUPDATABASE = "jspwiki.groupdatabase";
@@ -168,8 +168,8 @@ public interface GroupManager extends Authorizer, WikiEventListener {
      * </p>
      * <p>
      * This method will register the new Group with the GroupManager. For example, {@link org.apache.wiki.auth.AuthenticationManager}
-     * attaches each WikiSession as a GroupManager listener. Thus, the act of registering a Group with <code>setGroup</code> means that
-     * all WikiSessions will automatically receive group add/change/delete events immediately.
+     * attaches each Session as a GroupManager listener. Thus, the act of registering a Group with <code>setGroup</code> means that
+     * all Sessions will automatically receive group add/change/delete events immediately.
      * </p>
      *
      * @param session the wiki session, which may not be <code>null</code>
@@ -203,7 +203,7 @@ public interface GroupManager extends Authorizer, WikiEventListener {
 
 
     /**
-     * Checks if a String is blank or a restricted Group name, and if it is, appends an error to the WikiSession's message list.
+     * Checks if a String is blank or a restricted Group name, and if it is, appends an error to the Session's message list.
      *
      * @param context the wiki context
      * @param name the Group name to test
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/WebContainerAuthorizer.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/WebContainerAuthorizer.java
index 0353266..c2b8e60 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/WebContainerAuthorizer.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/WebContainerAuthorizer.java
@@ -146,23 +146,23 @@ public class WebContainerAuthorizer implements WebAuthorizer  {
     }
 
     /**
-     * Determines whether the Subject associated with a WikiSession is in a
-     * particular role. This method takes two parameters: the WikiSession
+     * Determines whether the Subject associated with a Session is in a
+     * particular role. This method takes two parameters: the Session
      * containing the subject and the desired role ( which may be a Role or a
      * Group). If either parameter is <code>null</code>, this method must
      * return <code>false</code>.
-     * This method simply examines the WikiSession subject to see if it
+     * This method simply examines the Session subject to see if it
      * possesses the desired Principal. We assume that the method
      * {@link org.apache.wiki.ui.WikiServletFilter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)}
-     * previously executed, and that it has set the WikiSession
+     * previously executed, and that it has set the Session
      * subject correctly by logging in the user with the various login modules,
      * in particular {@link org.apache.wiki.auth.login.WebContainerLoginModule}}.
      * This is definitely a hack,
-     * but it eliminates the need for WikiSession to keep dangling
+     * but it eliminates the need for Session to keep dangling
      * references to the last WikiContext hanging around, just
      * so we can look up the HttpServletRequest.
      *
-     * @param session the current WikiSession
+     * @param session the current Session
      * @param role the role to check
      * @return <code>true</code> if the user is considered to be in the role,
      *         <code>false</code> otherwise
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/user/DefaultUserProfile.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/user/DefaultUserProfile.java
index 416cca4..9ba0121 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/user/DefaultUserProfile.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/user/DefaultUserProfile.java
@@ -19,7 +19,6 @@
 package org.apache.wiki.auth.user;
 
 import org.apache.commons.lang3.StringUtils;
-import org.apache.wiki.WikiSession;
 
 import javax.servlet.http.HttpServletRequest;
 import java.io.Serializable;
@@ -223,7 +222,7 @@ public final class DefaultUserProfile implements UserProfile {
 
     /**
      * Sets the name by which the user logs in. The login name is used as the username for custom authentication (see
-     * {@link org.apache.wiki.auth.AuthenticationManager#login(WikiSession,HttpServletRequest, String, String)}).
+     * {@link org.apache.wiki.auth.AuthenticationManager#login(org.apache.wiki.api.core.Session,HttpServletRequest, String, String)}).
      * The login name is typically a short name ("jannej"). In contrast, the wiki name is typically of type
      * FirstnameLastName ("JanneJalkanen").
      *
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/user/UserDatabase.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/user/UserDatabase.java
index 906c54b..cf649b2 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/user/UserDatabase.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/user/UserDatabase.java
@@ -53,7 +53,7 @@ public interface UserDatabase {
      * Note that if an implememtation wishes to mark one of the returned Principals as representing the user's common name, it should
      * instantiate this Principal using {@link org.apache.wiki.auth.WikiPrincipal#WikiPrincipal(String, String)} with the <code>type</code>
      * parameter set to {@link org.apache.wiki.auth.WikiPrincipal#WIKI_NAME}. The method
-     * {@link org.apache.wiki.WikiSession#getUserPrincipal()} will return this principal as the "primary" principal. Note that this method
+     * {@link org.apache.wiki.api.core.Session#getUserPrincipal()} will return this principal as the "primary" principal. Note that this method
      * can also be used to mark a WikiPrincipal as a login name or a wiki name.
      * </p>
      *
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/user/UserProfile.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/user/UserProfile.java
index cb39278..ec8afa4 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/user/UserProfile.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/user/UserProfile.java
@@ -161,7 +161,7 @@ public interface UserProfile extends Serializable
     /**
      * Sets the name by which the user logs in. The login name is used as the
      * username for custom authentication (see
-     * {@link org.apache.wiki.auth.AuthenticationManager#login(WikiSession,HttpServletRequest, String, String)},
+     * {@link org.apache.wiki.auth.AuthenticationManager#login(org.apache.wiki.api.core.Session, javax.servlet.http.HttpServletRequest, String, String)},
      * {@link org.apache.wiki.auth.login.UserDatabaseLoginModule}). The login
      * name is typically a short name ("jannej"). In contrast, the wiki name is
      * typically of type FirstnameLastName ("JanneJalkanen").
@@ -192,5 +192,6 @@ public interface UserProfile extends Serializable
      * Returns a string representation of this user profile.
      * @return the string
      */
+    @Override
     String toString();
 }


[jspwiki] 24/35: throw ProviderException instead of InternalWikiException

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git

commit 78cee041960689763863d2718a3d9d78f5d19864
Author: juanpablo <ju...@apache.org>
AuthorDate: Thu Mar 5 17:15:35 2020 +0100

    throw ProviderException instead of InternalWikiException
---
 .../src/main/java/org/apache/wiki/providers/AbstractFileProvider.java  | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/providers/AbstractFileProvider.java b/jspwiki-main/src/main/java/org/apache/wiki/providers/AbstractFileProvider.java
index fd5beb1..7eab698 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/providers/AbstractFileProvider.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/providers/AbstractFileProvider.java
@@ -20,7 +20,6 @@ package org.apache.wiki.providers;
 
 import org.apache.commons.lang3.StringUtils;
 import org.apache.log4j.Logger;
-import org.apache.wiki.InternalWikiException;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.WikiProvider;
 import org.apache.wiki.api.core.Engine;
@@ -292,7 +291,7 @@ public abstract class AbstractFileProvider implements WikiPageProvider {
 
         if( wikipages == null ) {
             log.error("Wikipages directory '" + m_pageDirectory + "' does not exist! Please check " + PROP_PAGEDIR + " in jspwiki.properties.");
-            throw new InternalWikiException( "Page directory does not exist" );
+            throw new ProviderException( "Page directory does not exist" );
         }
 
         for( final File wikipage : wikipages ) {


[jspwiki] 20/35: JSPWIKI-303: begin to use Session instead of WikiSession (1)

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git

commit f6fe5041da6b74c60355adc0f5a7e9eb00ef8896
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Mar 4 21:39:10 2020 +0100

    JSPWIKI-303: begin to use Session instead of WikiSession (1)
---
 .../src/main/java/org/apache/wiki/WikiContext.java |  8 +--
 .../apache/wiki/attachment/AttachmentServlet.java  |  3 +-
 .../apache/wiki/auth/AuthenticationManager.java    |  4 +-
 .../org/apache/wiki/auth/AuthorizationManager.java | 22 ++++----
 .../main/java/org/apache/wiki/auth/Authorizer.java |  3 +-
 .../wiki/auth/DefaultAuthenticationManager.java    | 11 ++--
 .../wiki/auth/DefaultAuthorizationManager.java     |  9 ++--
 .../org/apache/wiki/auth/DefaultUserManager.java   | 15 +++---
 .../org/apache/wiki/auth/SecurityVerifier.java     |  6 +--
 .../java/org/apache/wiki/auth/SessionMonitor.java  | 60 +++++++++++-----------
 .../java/org/apache/wiki/auth/UserManager.java     | 13 ++---
 .../wiki/auth/authorize/DefaultGroupManager.java   |  5 +-
 .../apache/wiki/auth/authorize/GroupManager.java   | 10 ++--
 .../auth/authorize/WebContainerAuthorizer.java     |  6 +--
 .../main/java/org/apache/wiki/plugin/Groups.java   |  5 +-
 15 files changed, 94 insertions(+), 86 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java
index 7fce8c9..8b9e53d 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java
@@ -20,6 +20,7 @@ package org.apache.wiki;
 
 import org.apache.log4j.Logger;
 import org.apache.wiki.api.core.Engine;
+import org.apache.wiki.api.core.Session;
 import org.apache.wiki.auth.AuthorizationManager;
 import org.apache.wiki.auth.NoSuchPrincipalException;
 import org.apache.wiki.auth.UserManager;
@@ -69,7 +70,7 @@ public class WikiContext implements Cloneable, Command {
     /** Stores the HttpServletRequest.  May be null, if the request did not come from a servlet. */
     protected HttpServletRequest m_request;
 
-    private WikiSession m_session;
+    private Session m_session;
 
     public static final String ATTR_CONTEXT = "jspwiki.context";
 
@@ -652,11 +653,12 @@ public class WikiContext implements Cloneable, Command {
 
     /**
      *  Returns the WikiSession associated with the context. This method is guaranteed to always return a valid WikiSession.
-     *  If this context was constructed without an associated HttpServletRequest, it will return {@link WikiSession#guestSession(Engine)}.
+     *  If this context was constructed without an associated HttpServletRequest, it will return
+     *  {@link org.apache.wiki.WikiSession#guestSession(Engine)}.
      *
      *  @return The WikiSession associate with this context.
      */
-    public WikiSession getWikiSession()
+    public Session getWikiSession()
     {
         return m_session;
     }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/attachment/AttachmentServlet.java b/jspwiki-main/src/main/java/org/apache/wiki/attachment/AttachmentServlet.java
index 1a1e0c4..005076f 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/attachment/AttachmentServlet.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/attachment/AttachmentServlet.java
@@ -31,6 +31,7 @@ import org.apache.wiki.WikiPage;
 import org.apache.wiki.WikiProvider;
 import org.apache.wiki.WikiSession;
 import org.apache.wiki.api.core.Engine;
+import org.apache.wiki.api.core.Session;
 import org.apache.wiki.api.exceptions.ProviderException;
 import org.apache.wiki.api.exceptions.RedirectException;
 import org.apache.wiki.api.exceptions.WikiException;
@@ -351,7 +352,7 @@ public class AttachmentServlet extends HttpServlet {
             req.getSession().removeAttribute("msg");
             res.sendRedirect( nextPage );
         } catch( final RedirectException e ) {
-            final WikiSession session = WikiSession.getWikiSession( m_engine, req );
+            final Session session = WikiSession.getWikiSession( m_engine, req );
             session.addMessage( e.getMessage() );
 
             req.getSession().setAttribute("msg", e.getMessage());
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthenticationManager.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthenticationManager.java
index e2c349b..9360124 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthenticationManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthenticationManager.java
@@ -18,8 +18,8 @@
  */
 package org.apache.wiki.auth;
 
-import org.apache.wiki.WikiSession;
 import org.apache.wiki.api.core.Engine;
+import org.apache.wiki.api.core.Session;
 import org.apache.wiki.api.exceptions.WikiException;
 import org.apache.wiki.auth.authorize.Role;
 import org.apache.wiki.event.WikiEventListener;
@@ -131,7 +131,7 @@ public interface AuthenticationManager {
      * @return true, if the username/password is valid
      * @throws org.apache.wiki.auth.WikiSecurityException if the Authorizer or UserManager cannot be obtained
      */
-    boolean login( WikiSession session, HttpServletRequest request, String username, String password ) throws WikiSecurityException;
+    boolean login( Session session, HttpServletRequest request, String username, String password ) throws WikiSecurityException;
 
     /**
      * Logs the user out by retrieving the WikiSession associated with the HttpServletRequest and unbinding all of the Subject's Principals,
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthorizationManager.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthorizationManager.java
index 5c07767..c10128e 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthorizationManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthorizationManager.java
@@ -19,8 +19,8 @@
 package org.apache.wiki.auth;
 
 import org.apache.wiki.WikiContext;
-import org.apache.wiki.WikiSession;
 import org.apache.wiki.api.core.Engine;
+import org.apache.wiki.api.core.Session;
 import org.apache.wiki.api.exceptions.WikiException;
 import org.apache.wiki.auth.authorize.Role;
 import org.apache.wiki.event.WikiEventListener;
@@ -45,7 +45,7 @@ import java.util.Properties;
  *   <em>e.g.,</em> reading, editing, renaming
  * </ul>
  * <p>Calling classes determine whether they are entitled to perform a particular action by constructing the appropriate permission first,
- * then passing it and the current {@link org.apache.wiki.WikiSession} to the {@link #checkPermission(WikiSession, Permission)} method. If
+ * then passing it and the current {@link org.apache.wiki.WikiSession} to the {@link #checkPermission(Session, Permission)} method. If
  * the session's Subject possesses the permission, the action is allowed.</p>
  * <p>For WikiPermissions, the decision criteria is relatively simple: the caller either possesses the permission, as granted by the wiki
  * security policy -- or not.</p>
@@ -54,7 +54,7 @@ import java.util.Properties;
  * security policy. In other words, the user must be named in the ACL (or belong to a group or role that is named in the ACL) <em>and</em>
  * be granted (at least) the same permission in the security policy. We do this to prevent a user from gaining more permissions than they
  * already have, based on the security policy.</p>
- * <p>See the implementation on {@link #checkPermission(WikiSession, Permission)} method for more information on the authorization logic.</p>
+ * <p>See the implementation on {@link #checkPermission(Session, Permission)} method for more information on the authorization logic.</p>
  *
  * @since 2.3
  * @see AuthenticationManager
@@ -103,7 +103,7 @@ public interface AuthorizationManager {
      * @param permission the Permission being checked
      * @return the result of the Permission check
      */
-    boolean checkPermission( WikiSession session, Permission permission );
+    boolean checkPermission( Session session, Permission permission );
 
     /**
      * <p>Determines if the Subject associated with a supplied WikiSession contains a desired Role or GroupPrincipal. The algorithm
@@ -119,7 +119,7 @@ public interface AuthorizationManager {
      *                  the result of this method always returns <code>false</code>
      * @return <code>true</code> if the Subject supplied with the WikiContext posesses the Role or GroupPrincipal, <code>false</code> otherwise
      */
-    default boolean isUserInRole( final WikiSession session, final Principal principal ) {
+    default boolean isUserInRole( final Session session, final Principal principal ) {
         if ( session == null || principal == null || AuthenticationManager.isUserPrincipal( principal ) ) {
             return false;
         }
@@ -149,7 +149,7 @@ public interface AuthorizationManager {
      * <p>Determines if the Subject associated with a supplied WikiSession contains a desired user Principal or built-in Role principal,
      * OR is a member a Group or external Role. The rules are as follows:</p>
      * <ol>
-     * <li>First, if desired Principal is a Role or GroupPrincipal, delegate to {@link #isUserInRole(WikiSession, Principal)} and
+     * <li>First, if desired Principal is a Role or GroupPrincipal, delegate to {@link #isUserInRole(Session, Principal)} and
      * return the result.</li>
      * <li>Otherwise, we're looking for a user Principal, so iterate through the Principal set and see if any share the same name as the
      * one we are looking for.</li>
@@ -163,11 +163,11 @@ public interface AuthorizationManager {
      * @return <code>true</code> if the Subject supplied with the WikiContext posesses the Role, GroupPrincipal or desired
      *         user Principal, <code>false</code> otherwise
      */
-    boolean hasRoleOrPrincipal( WikiSession session, Principal principal );
+    boolean hasRoleOrPrincipal( Session session, Principal principal );
 
     /**
      * Checks whether the current user has access to the wiki context, by obtaining the required Permission ({@link WikiContext#requiredPermission()})
-     * and delegating the access check to {@link #checkPermission(WikiSession, Permission)}. If the user is allowed, this method returns
+     * and delegating the access check to {@link #checkPermission(Session, Permission)}. If the user is allowed, this method returns
      * <code>true</code>; <code>false</code> otherwise. If access is allowed, the wiki context will be added to the request as an attribute
      * with the key name {@link org.apache.wiki.WikiContext#ATTR_CONTEXT}. Note that this method will automatically redirect the user to
      * a login or error page, as appropriate, if access fails. This is NOT guaranteed to be default behavior in the future.
@@ -184,7 +184,7 @@ public interface AuthorizationManager {
     /**
      * Checks whether the current user has access to the wiki context (and
      * optionally redirects if not), by obtaining the required Permission ({@link WikiContext#requiredPermission()})
-     * and delegating the access check to {@link #checkPermission(WikiSession, Permission)}.
+     * and delegating the access check to {@link #checkPermission(Session, Permission)}.
      * If the user is allowed, this method returns <code>true</code>;
      * <code>false</code> otherwise. Also, the wiki context will be added to the request as attribute
      * with the key name {@link org.apache.wiki.WikiContext#ATTR_CONTEXT}.
@@ -209,7 +209,7 @@ public interface AuthorizationManager {
 
     /**
      * Checks to see if the local security policy allows a particular static Permission.
-     * Do not use this method for normal permission checks; use {@link #checkPermission(WikiSession, Permission)} instead.
+     * Do not use this method for normal permission checks; use {@link #checkPermission(Session, Permission)} instead.
      *
      * @param principals the Principals to check
      * @param permission the Permission
@@ -230,7 +230,7 @@ public interface AuthorizationManager {
      * @param permission the Permission the Subject must possess
      * @return <code>true</code> if the Subject possesses the permission, <code>false</code> otherwise
      */
-    boolean checkStaticPermission( WikiSession session, Permission permission );
+    boolean checkStaticPermission( Session session, Permission permission );
 
     /**
      * <p>Given a supplied string representing a Principal's name from an Acl, this method resolves the correct type of Principal (role,
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/Authorizer.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/Authorizer.java
index efdc60e..534d6a5 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/Authorizer.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/Authorizer.java
@@ -20,6 +20,7 @@ package org.apache.wiki.auth;
 
 import org.apache.wiki.WikiSession;
 import org.apache.wiki.api.core.Engine;
+import org.apache.wiki.api.core.Session;
 
 import java.security.Principal;
 import java.util.Properties;
@@ -74,6 +75,6 @@ public interface Authorizer {
      * @param role the role to check
      * @return <code>true</code> if the user is considered to be in the role, <code>false</code> otherwise
      */
-    boolean isUserInRole( WikiSession session, Principal role );
+    boolean isUserInRole( Session session, Principal role );
 
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultAuthenticationManager.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultAuthenticationManager.java
index a5a9f13..8056db8 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultAuthenticationManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultAuthenticationManager.java
@@ -21,6 +21,7 @@ package org.apache.wiki.auth;
 import org.apache.log4j.Logger;
 import org.apache.wiki.WikiSession;
 import org.apache.wiki.api.core.Engine;
+import org.apache.wiki.api.core.Session;
 import org.apache.wiki.api.exceptions.WikiException;
 import org.apache.wiki.auth.authorize.WebAuthorizer;
 import org.apache.wiki.auth.authorize.WebContainerAuthorizer;
@@ -208,7 +209,7 @@ public class DefaultAuthenticationManager implements AuthenticationManager {
      * {@inheritDoc}
      */
     @Override
-    public boolean login( final WikiSession session, final HttpServletRequest request, final String username, final String password ) throws WikiSecurityException {
+    public boolean login( final Session session, final HttpServletRequest request, final String username, final String password ) throws WikiSecurityException {
         if ( session == null ) {
             log.error( "No wiki session provided, cannot log in." );
             return false;
@@ -276,7 +277,7 @@ public class DefaultAuthenticationManager implements AuthenticationManager {
             log.debug( "Invalidating WikiSession for session ID=" + sid );
         }
         // Retrieve the associated WikiSession and clear the Principal set
-        final WikiSession wikiSession = WikiSession.getWikiSession( m_engine, request );
+        final Session wikiSession = WikiSession.getWikiSession( m_engine, request );
         final Principal originalPrincipal = wikiSession.getLoginPrincipal();
         wikiSession.invalidate();
 
@@ -284,7 +285,7 @@ public class DefaultAuthenticationManager implements AuthenticationManager {
         WikiSession.removeWikiSession( m_engine, request );
 
         // We need to flush the HTTP session too
-        if ( session != null ) {
+        if( session != null ) {
             session.invalidate();
         }
 
@@ -394,7 +395,7 @@ public class DefaultAuthenticationManager implements AuthenticationManager {
     /**
      * After successful login, this method is called to inject authorized role Principals into the WikiSession. To determine which roles
      * should be injected, the configured Authorizer is queried for the roles it knows about by calling  {@link Authorizer#getRoles()}.
-     * Then, each role returned by the authorizer is tested by calling {@link Authorizer#isUserInRole(WikiSession, Principal)}. If this
+     * Then, each role returned by the authorizer is tested by calling {@link Authorizer#isUserInRole(Session, Principal)}. If this
      * check fails, and the Authorizer is of type WebAuthorizer, the role is checked again by calling
      * {@link WebAuthorizer#isUserInRole(HttpServletRequest, Principal)}). Any roles that pass the test are injected into the Subject by
      * firing appropriate authentication events.
@@ -403,7 +404,7 @@ public class DefaultAuthenticationManager implements AuthenticationManager {
      * @param authorizer the Engine's configured Authorizer
      * @param request the user's HTTP session, which may be <code>null</code>
      */
-    private void injectAuthorizerRoles( final WikiSession session, final Authorizer authorizer, final HttpServletRequest request ) {
+    private void injectAuthorizerRoles( final Session session, final Authorizer authorizer, final HttpServletRequest request ) {
         // Test each role the authorizer knows about
         for( final Principal role : authorizer.getRoles() ) {
             // Test the Authorizer
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultAuthorizationManager.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultAuthorizationManager.java
index b64834e..0506df0 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultAuthorizationManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultAuthorizationManager.java
@@ -23,6 +23,7 @@ import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.WikiSession;
 import org.apache.wiki.api.core.Engine;
+import org.apache.wiki.api.core.Session;
 import org.apache.wiki.api.exceptions.NoRequiredPropertyException;
 import org.apache.wiki.api.exceptions.WikiException;
 import org.apache.wiki.auth.acl.Acl;
@@ -94,7 +95,7 @@ public class DefaultAuthorizationManager implements AuthorizationManager {
 
     /** {@inheritDoc} */
     @Override
-    public boolean checkPermission( final WikiSession session, final Permission permission ) {
+    public boolean checkPermission( final Session session, final Permission permission ) {
         // A slight sanity check.
         if( session == null || permission == null ) {
             fireEvent( WikiSecurityEvent.ACCESS_DENIED, null, permission );
@@ -172,7 +173,7 @@ public class DefaultAuthorizationManager implements AuthorizationManager {
 
     /** {@inheritDoc} */
     @Override
-    public boolean hasRoleOrPrincipal( final WikiSession session, final Principal principal ) {
+    public boolean hasRoleOrPrincipal( final Session session, final Principal principal ) {
         // If either parameter is null, always deny
         if( session == null || principal == null ) {
             return false;
@@ -315,8 +316,8 @@ public class DefaultAuthorizationManager implements AuthorizationManager {
 
     /** {@inheritDoc} */
     @Override
-    public boolean checkStaticPermission( final WikiSession session, final Permission permission ) {
-        return ( Boolean )WikiSession.doPrivileged( session, ( PrivilegedAction< Boolean > )() -> {
+    public boolean checkStaticPermission( final Session session, final Permission permission ) {
+        return ( Boolean )Session.doPrivileged( session, ( PrivilegedAction< Boolean > )() -> {
             try {
                 // Check the JVM-wide security policy first
                 AccessController.checkPermission( permission );
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultUserManager.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultUserManager.java
index 1eee920..0b8db6f 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultUserManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultUserManager.java
@@ -21,11 +21,11 @@ package org.apache.wiki.auth;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.log4j.Logger;
 import org.apache.wiki.WikiContext;
-import org.apache.wiki.WikiSession;
 import org.apache.wiki.ajax.AjaxUtil;
 import org.apache.wiki.ajax.WikiAjaxDispatcherServlet;
 import org.apache.wiki.ajax.WikiAjaxServlet;
 import org.apache.wiki.api.core.Engine;
+import org.apache.wiki.api.core.Session;
 import org.apache.wiki.api.exceptions.NoRequiredPropertyException;
 import org.apache.wiki.api.exceptions.WikiException;
 import org.apache.wiki.api.filters.PageFilter;
@@ -90,7 +90,7 @@ public class DefaultUserManager implements UserManager {
     private static final Logger log = Logger.getLogger( DefaultUserManager.class);
 
     /** Associates wiki sessions with profiles */
-    private final Map< WikiSession, UserProfile > m_profiles = new WeakHashMap<>();
+    private final Map< Session, UserProfile > m_profiles = new WeakHashMap<>();
 
     /** The user database loads, manages and persists user identities */
     private UserDatabase m_database;
@@ -147,7 +147,7 @@ public class DefaultUserManager implements UserManager {
 
     /** {@inheritDoc} */
     @Override
-    public UserProfile getUserProfile( final WikiSession session ) {
+    public UserProfile getUserProfile( final Session session ) {
         // Look up cached user profile
         UserProfile profile = m_profiles.get( session );
         boolean newProfile = profile == null;
@@ -179,7 +179,7 @@ public class DefaultUserManager implements UserManager {
 
     /** {@inheritDoc} */
     @Override
-    public void setUserProfile( final WikiSession session, final UserProfile profile ) throws DuplicateUserException, WikiException {
+    public void setUserProfile( final Session session, final UserProfile profile ) throws DuplicateUserException, WikiException {
         // Verify user is allowed to save profile!
         final Permission p = new WikiPermission( m_engine.getApplicationName(), WikiPermission.EDIT_PROFILE_ACTION );
         if ( !m_engine.getManager( AuthorizationManager.class ).checkPermission( session, p ) ) {
@@ -250,7 +250,7 @@ public class DefaultUserManager implements UserManager {
 
     /** {@inheritDoc} */
     @Override
-    public void startUserProfileCreationWorkflow( final WikiSession session, final UserProfile profile ) throws WikiException {
+    public void startUserProfileCreationWorkflow( final Session session, final UserProfile profile ) throws WikiException {
         final WorkflowBuilder builder = WorkflowBuilder.getBuilder( m_engine );
         final Principal submitter = session.getUserPrincipal();
         final Step completionTask = m_engine.getManager( TasksManager.class ).buildSaveUserProfileTask( m_engine, session.getLocale() );
@@ -300,8 +300,7 @@ public class DefaultUserManager implements UserManager {
         fullname = InputValidator.isBlank( fullname ) ? null : fullname;
         email = InputValidator.isBlank( email ) ? null : email;
 
-        // A special case if we have container authentication
-        // If authenticated, login name is always taken from container
+        // A special case if we have container authentication: if authenticated, login name is always taken from container
         if ( m_engine.getManager( AuthenticationManager.class ).isContainerAuthenticated() && context.getWikiSession().isAuthenticated() ) {
             loginName = context.getWikiSession().getLoginPrincipal().getName();
         }
@@ -318,7 +317,7 @@ public class DefaultUserManager implements UserManager {
     @Override
     public void validateProfile( final WikiContext context, final UserProfile profile ) {
         final boolean isNew = profile.isNew();
-        final WikiSession session = context.getWikiSession();
+        final Session session = context.getWikiSession();
         final InputValidator validator = new InputValidator( SESSION_MESSAGES, context );
         final ResourceBundle rb = Preferences.getBundle( context, InternationalizationManager.CORE_BUNDLE );
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/SecurityVerifier.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/SecurityVerifier.java
index dfc4a20..97a6e94 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/SecurityVerifier.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/SecurityVerifier.java
@@ -20,8 +20,8 @@ package org.apache.wiki.auth;
 
 import org.apache.commons.lang3.ArrayUtils;
 import org.apache.log4j.Logger;
-import org.apache.wiki.WikiSession;
 import org.apache.wiki.api.core.Engine;
+import org.apache.wiki.api.core.Session;
 import org.apache.wiki.api.exceptions.WikiException;
 import org.apache.wiki.auth.authorize.Group;
 import org.apache.wiki.auth.authorize.GroupDatabase;
@@ -67,7 +67,7 @@ public final class SecurityVerifier {
 
     private Principal[]           m_policyPrincipals           = new Principal[0];
 
-    private WikiSession           m_session;
+    private Session               m_session;
 
     /** Message prefix for errors. */
     public static final String    ERROR                        = "Error.";
@@ -150,7 +150,7 @@ public final class SecurityVerifier {
      * @param engine the wiki engine
      * @param session the wiki session (typically, that of an administrator)
      */
-    public SecurityVerifier( final Engine engine, final WikiSession session ) {
+    public SecurityVerifier( final Engine engine, final Session session ) {
         m_engine = engine;
         m_session = session;
         m_session.clearMessages();
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/SessionMonitor.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/SessionMonitor.java
index 52f8e54..0ddc03e 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/SessionMonitor.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/SessionMonitor.java
@@ -26,6 +26,7 @@ import org.apache.wiki.event.WikiEventManager;
 import org.apache.wiki.event.WikiSecurityEvent;
 import org.apache.wiki.util.comparators.PrincipalComparator;
 
+import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpSession;
 import javax.servlet.http.HttpSessionEvent;
 import javax.servlet.http.HttpSessionListener;
@@ -38,10 +39,9 @@ import java.util.WeakHashMap;
 import java.util.concurrent.ConcurrentHashMap;
 
 /**
- *  <p>Manages WikiSession's for different Engine's.</p>
- *  <p>The WikiSession's are stored both in the remote user HttpSession and in the SessionMonitor for the WikeEngine.
- *  This class must be configured as a session listener in the web.xml for the wiki web application.
- *  </p>
+ *  <p>Manages Sessions for different Engines.</p>
+ *  <p>The Sessions are stored both in the remote user HttpSession and in the SessionMonitor for the Engine.
+ *  This class must be configured as a session listener in the web.xml for the wiki web application.</p>
  */
 public class SessionMonitor implements HttpSessionListener {
 
@@ -64,29 +64,20 @@ public class SessionMonitor implements HttpSessionListener {
      * @return the session monitor
      */
     public static SessionMonitor getInstance( final Engine engine ) {
-        if( engine == null )
-        {
+        if( engine == null ) {
             throw new IllegalArgumentException( "Engine cannot be null." );
         }
-        SessionMonitor monitor;
-
-          monitor = c_monitors.get(engine);
-          if( monitor == null )
-          {
-              monitor = new SessionMonitor(engine);
-
-              c_monitors.put( engine, monitor );
-
-          }
+        SessionMonitor monitor = c_monitors.get( engine );
+        if( monitor == null ) {
+            monitor = new SessionMonitor( engine );
+            c_monitors.put( engine, monitor );
+        }
 
         return monitor;
     }
 
-    /**
-     * Construct the SessionListener
-     */
-    public SessionMonitor()
-    {
+    /** Construct the SessionListener */
+    public SessionMonitor() {
     }
 
     private SessionMonitor( final Engine engine ) {
@@ -139,7 +130,7 @@ public class SessionMonitor implements HttpSessionListener {
             if( log.isDebugEnabled() ) {
                 log.debug( "Looking up WikiSession for session ID=" + sid + "... not found. Creating guestSession()" );
             }
-            wikiSession = WikiSession.guestSession( m_engine );
+            wikiSession = (WikiSession)WikiSession.guestSession( m_engine );
             synchronized( m_sessions ) {
                 m_sessions.put( sid, wikiSession );
             }
@@ -149,18 +140,27 @@ public class SessionMonitor implements HttpSessionListener {
     }
 
     /**
-     * Removes the wiki session associated with the user's HttpSession
-     * from the session cache.
+     * Removes the wiki session associated with the user's HttpRequest from the session cache.
+     *
+     * @param request the user's HTTP request
+     */
+    public final void remove( final HttpServletRequest request ) {
+        if( request == null ) {
+            throw new IllegalArgumentException( "Request cannot be null." );
+        }
+        remove( request.getSession() );
+    }
+
+    /**
+     * Removes the wiki session associated with the user's HttpSession from the session cache.
+     *
      * @param session the user's HTTP session
      */
-    public final void remove( final HttpSession session )
-    {
-        if ( session == null )
-        {
+    public final void remove( final HttpSession session ) {
+        if( session == null ) {
             throw new IllegalArgumentException( "Session cannot be null." );
         }
-        synchronized ( m_sessions )
-        {
+        synchronized( m_sessions ) {
             m_sessions.remove( session.getId() );
         }
     }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/UserManager.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/UserManager.java
index f68dda1..bc0f66c 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/UserManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/UserManager.java
@@ -21,6 +21,7 @@ package org.apache.wiki.auth;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiSession;
 import org.apache.wiki.api.core.Engine;
+import org.apache.wiki.api.core.Session;
 import org.apache.wiki.api.exceptions.WikiException;
 import org.apache.wiki.auth.user.DuplicateUserException;
 import org.apache.wiki.auth.user.UserDatabase;
@@ -64,7 +65,7 @@ public interface UserManager {
     UserDatabase getUserDatabase();
 
     /**
-     * <p>Retrieves the {@link org.apache.wiki.auth.user.UserProfile} for the user in a wiki session. If the user is authenticated, the
+     * <p>Retrieves the {@link org.apache.wiki.auth.user.UserProfile} for the user in a session. If the user is authenticated, the
      * UserProfile returned will be the one stored in the user database; if one does not exist, a new one will be initialized and returned.
      * If the user is anonymous or asserted, the UserProfile will <i>always</i> be newly initialized to prevent spoofing of identities.
      * If a UserProfile needs to be initialized, its {@link org.apache.wiki.auth.user.UserProfile#isNew()} method will return
@@ -74,11 +75,11 @@ public interface UserManager {
      * <code>false</code>, this method throws an {@link IllegalStateException}. This is meant as a quality check for UserDatabase providers;
      * it should only be thrown if the implementation is faulty.</p>
      *
-     * @param session the wiki session, which may not be <code>null</code>
+     * @param session the session, which may not be <code>null</code>
      * @return the user's profile, which will be newly initialized if the user is anonymous or asserted, or if the user cannot be found in
      *         the user database
      */
-    UserProfile getUserProfile( WikiSession session );
+    UserProfile getUserProfile( Session session );
 
     /**
      * <p>
@@ -108,9 +109,9 @@ public interface UserManager {
      * {@link org.apache.wiki.workflow.DecisionRequiredException}. All other WikiException
      * indicate a condition that is not normal is probably due to mis-configuration
      */
-    void setUserProfile( WikiSession session, UserProfile profile ) throws DuplicateUserException, WikiException;
+    void setUserProfile( Session session, UserProfile profile ) throws DuplicateUserException, WikiException;
 
-    void startUserProfileCreationWorkflow( WikiSession session, UserProfile profile ) throws WikiException;
+    void startUserProfileCreationWorkflow( Session session, UserProfile profile ) throws WikiException;
 
     /**
      * <p> Extracts user profile parameters from the HTTP request and populates a UserProfile with them. The UserProfile will either be a
@@ -177,7 +178,7 @@ public interface UserManager {
      * @param session    the wiki session supporting the event
      * @param profile    the user profile (or array of user profiles), which may be <code>null</code>
      */
-    default void fireEvent( final int type, final WikiSession session, final Object profile ) {
+    default void fireEvent( final int type, final Session session, final Object profile ) {
         if( WikiEventManager.isListening( this ) ) {
             WikiEventManager.fireEvent( this, new WikiSecurityEvent( session, type, profile ) );
         }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/DefaultGroupManager.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/DefaultGroupManager.java
index e24ba71..227c453 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/DefaultGroupManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/DefaultGroupManager.java
@@ -22,6 +22,7 @@ import org.apache.commons.lang3.ArrayUtils;
 import org.apache.log4j.Logger;
 import org.apache.wiki.WikiSession;
 import org.apache.wiki.api.core.Engine;
+import org.apache.wiki.api.core.Session;
 import org.apache.wiki.api.exceptions.NoRequiredPropertyException;
 import org.apache.wiki.api.exceptions.WikiException;
 import org.apache.wiki.auth.AuthenticationManager;
@@ -175,7 +176,7 @@ public class DefaultGroupManager implements GroupManager, Authorizer, WikiEventL
 
     /** {@inheritDoc} */
     @Override
-    public boolean isUserInRole( final WikiSession session, final Principal role ) {
+    public boolean isUserInRole( final Session session, final Principal role ) {
         // Always return false if session/role is null, or if role isn't a GroupPrincipal
         if ( session == null || !( role instanceof GroupPrincipal ) || !session.isAuthenticated() ) {
             return false;
@@ -273,7 +274,7 @@ public class DefaultGroupManager implements GroupManager, Authorizer, WikiEventL
 
     /** {@inheritDoc} */
     @Override
-    public void setGroup( final WikiSession session, final Group group ) throws WikiSecurityException {
+    public void setGroup( final Session session, final Group group ) throws WikiSecurityException {
         // TODO: check for appropriate permissions
 
         // If group already exists, delete it; fire GROUP_REMOVE event
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/GroupManager.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/GroupManager.java
index 7c38ac5..d6a0866 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/GroupManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/GroupManager.java
@@ -20,7 +20,7 @@ package org.apache.wiki.auth.authorize;
 
 import org.apache.commons.lang3.ArrayUtils;
 import org.apache.wiki.WikiContext;
-import org.apache.wiki.WikiSession;
+import org.apache.wiki.api.core.Session;
 import org.apache.wiki.auth.Authorizer;
 import org.apache.wiki.auth.NoSuchPrincipalException;
 import org.apache.wiki.auth.WikiSecurityException;
@@ -82,7 +82,7 @@ public interface GroupManager extends Authorizer, WikiEventListener {
      * parameter contains the member list. If these differ from those in the existing group, the passed values override the old values.
      * </p>
      * <p>
-     * This method does not commit the new Group to the GroupManager cache. To do that, use {@link #setGroup(WikiSession, Group)}.
+     * This method does not commit the new Group to the GroupManager cache. To do that, use {@link #setGroup(Session, Group)}.
      * </p>
      * @param name the name of the group to construct
      * @param memberLine the line of text containing the group membership list
@@ -106,7 +106,7 @@ public interface GroupManager extends Authorizer, WikiEventListener {
      * parameter contains the member list. If these differ from those in the existing group, the passed values override the old values.
      * </p>
      * <p>
-     * This method does not commit the new Group to the GroupManager cache. To do that, use {@link #setGroup(WikiSession, Group)}.
+     * This method does not commit the new Group to the GroupManager cache. To do that, use {@link #setGroup(Session, Group)}.
      * </p>
      * @param context the current wiki context
      * @param create whether this method should create a new, empty Group if one with the requested name is not found. If <code>false</code>,
@@ -176,11 +176,11 @@ public interface GroupManager extends Authorizer, WikiEventListener {
      * @param group the Group, which may not be <code>null</code>
      * @throws WikiSecurityException if the Group cannot be saved by the back-end
      */
-    void setGroup( final WikiSession session, final Group group ) throws WikiSecurityException;
+    void setGroup( final Session session, final Group group ) throws WikiSecurityException;
 
     /**
      * Validates a Group, and appends any errors to the session errors list. Any validation errors are added to the wiki session's messages
-     * collection (see {@link WikiSession#getMessages()}.
+     * collection (see {@link Session#getMessages()}.
      *
      * @param context the current wiki context
      * @param group the supplied Group
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/WebContainerAuthorizer.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/WebContainerAuthorizer.java
index a4c4968..0353266 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/WebContainerAuthorizer.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/WebContainerAuthorizer.java
@@ -20,8 +20,8 @@ package org.apache.wiki.auth.authorize;
 
 import org.apache.log4j.Logger;
 import org.apache.wiki.InternalWikiException;
-import org.apache.wiki.WikiSession;
 import org.apache.wiki.api.core.Engine;
+import org.apache.wiki.api.core.Session;
 import org.jdom2.Document;
 import org.jdom2.Element;
 import org.jdom2.JDOMException;
@@ -166,10 +166,10 @@ public class WebContainerAuthorizer implements WebAuthorizer  {
      * @param role the role to check
      * @return <code>true</code> if the user is considered to be in the role,
      *         <code>false</code> otherwise
-     * @see org.apache.wiki.auth.Authorizer#isUserInRole(org.apache.wiki.WikiSession, java.security.Principal)
+     * @see org.apache.wiki.auth.Authorizer#isUserInRole(org.apache.wiki.api.core.Session, java.security.Principal)
      */
     @Override
-    public boolean isUserInRole( final WikiSession session, final Principal role ) {
+    public boolean isUserInRole( final Session session, final Principal role ) {
         if ( session == null || role == null ) {
             return false;
         }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/Groups.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/Groups.java
index 6447a49..1e5facc 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/Groups.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/Groups.java
@@ -22,9 +22,9 @@ import org.apache.wiki.WikiContext;
 import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.exceptions.PluginException;
 import org.apache.wiki.api.plugin.WikiPlugin;
-import org.apache.wiki.auth.PrincipalComparator;
 import org.apache.wiki.auth.authorize.GroupManager;
 import org.apache.wiki.url.URLConstructor;
+import org.apache.wiki.util.comparators.PrincipalComparator;
 
 import java.security.Principal;
 import java.util.Arrays;
@@ -47,7 +47,8 @@ public class Groups implements WikiPlugin {
     /**
      *  {@inheritDoc}
      */
-    @Override public String execute( final WikiContext context, final Map<String, String> params ) throws PluginException {
+    @Override
+    public String execute( final WikiContext context, final Map<String, String> params ) throws PluginException {
         // Retrieve groups, and sort by name
         final Engine engine = context.getEngine();
         final GroupManager groupMgr = engine.getManager( GroupManager.class );


[jspwiki] 29/35: update tomcat server files from 8.5 to 9.0

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git

commit 875552d286b6ae7e76ce9fd953a7724eb6e1bc93
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Mar 6 00:01:23 2020 +0100

    update tomcat server files from 8.5 to 9.0
---
 .../src/overlay/tomcat/conf/catalina.properties    | 48 ++++++------
 .../src/overlay/tomcat/conf/server.xml             | 87 +++++++++++++++-------
 jspwiki-portable/src/overlay/tomcat/conf/web.xml   | 50 +++++++++++--
 3 files changed, 127 insertions(+), 58 deletions(-)

diff --git a/jspwiki-portable/src/overlay/tomcat/conf/catalina.properties b/jspwiki-portable/src/overlay/tomcat/conf/catalina.properties
index d1ef1c2..b4a7601 100644
--- a/jspwiki-portable/src/overlay/tomcat/conf/catalina.properties
+++ b/jspwiki-portable/src/overlay/tomcat/conf/catalina.properties
@@ -45,8 +45,13 @@ org.apache.jasper.,org.apache.naming.,org.apache.tomcat.
 #     "foo/*.jar": Add all the JARs of the specified folder as class
 #                  repositories
 #     "foo/bar.jar": Add bar.jar as a class repository
-# common.loader=${catalina.base}/lib,${catalina.base}/lib/*.jar,${catalina.home}/lib,${catalina.home}/lib/*.jar
-common.loader=${catalina.base}/lib,${catalina.base}/lib/*.jar,${catalina.home}/lib,${catalina.home}/lib/*.jar,${catalina.home}/jspwiki/lib,${catalina.home}/jspwiki/lib/*.jar
+#
+# Note: Values are enclosed in double quotes ("...") in case either the
+#       ${catalina.base} path or the ${catalina.home} path contains a comma.
+#       Because double quotes are used for quoting, the double quote character
+#       may not appear in a path.
+#common.loader="${catalina.base}/lib","${catalina.base}/lib/*.jar","${catalina.home}/lib","${catalina.home}/lib/*.jar"
+common.loader="${catalina.base}/lib","${catalina.base}/lib/*.jar","${catalina.home}/lib","${catalina.home}/lib/*.jar","${catalina.home}/jspwiki/lib","${catalina.home}/jspwiki/lib/*.jar"
 
 #
 # List of comma-separated paths defining the contents of the "server"
@@ -59,6 +64,11 @@ common.loader=${catalina.base}/lib,${catalina.base}/lib/*.jar,${catalina.home}/l
 #     "foo/*.jar": Add all the JARs of the specified folder as class
 #                  repositories
 #     "foo/bar.jar": Add bar.jar as a class repository
+#
+# Note: Values may be enclosed in double quotes ("...") in case either the
+#       ${catalina.base} path or the ${catalina.home} path contains a comma.
+#       Because double quotes are used for quoting, the double quote character
+#       may not appear in a path.
 server.loader=
 
 #
@@ -73,15 +83,21 @@ server.loader=
 #     "foo/bar.jar": Add bar.jar as a class repository
 # Please note that for single jars, e.g. bar.jar, you need the URL form
 # starting with file:.
+#
+# Note: Values may be enclosed in double quotes ("...") in case either the
+#       ${catalina.base} path or the ${catalina.home} path contains a comma.
+#       Because double quotes are used for quoting, the double quote character
+#       may not appear in a path.
 shared.loader=
 
-# List of JAR files that should not be scanned using the JarScanner
+# Default list of JAR files that should not be scanned using the JarScanner
 # functionality. This is typically used to scan JARs for configuration
 # information. JARs that do not contain such information may be excluded from
 # the scan to speed up the scanning process. This is the default list. JARs on
-# this list are excluded from all scans. Scan specific lists (to exclude JARs
-# from individual scans) follow this. The list must be a comma separated list of
-# JAR file names.
+# this list are excluded from all scans. The list must be a comma separated list
+# of JAR file names.
+# The list of JARs to skip may be over-ridden at a Context level for individual
+# scan types by configuring a JarScanner with a nested JarScanFilter.
 # The JARs listed below include:
 # - Tomcat Bootstrap JARs
 # - Tomcat API JARs
@@ -100,10 +116,9 @@ aspectj*.jar,\
 bootstrap.jar,\
 catalina-ant.jar,\
 catalina-ha.jar,\
-catalina-jmx-remote.jar,\
+catalina-ssi.jar,\
 catalina-storeconfig.jar,\
 catalina-tribes.jar,\
-catalina-ws.jar,\
 catalina.jar,\
 cglib-*.jar,\
 cobertura-*.jar,\
@@ -157,11 +172,7 @@ tagsoup-*.jar,\
 tomcat-api.jar,\
 tomcat-coyote.jar,\
 tomcat-dbcp.jar,\
-tomcat-i18n-en.jar,\
-tomcat-i18n-es.jar,\
-tomcat-i18n-fr.jar,\
-tomcat-i18n-ja.jar,\
-tomcat-i18n-ru.jar,\
+tomcat-i18n-*.jar,\
 tomcat-jdbc.jar,\
 tomcat-jni.jar,\
 tomcat-juli-adapters.jar,\
@@ -189,17 +200,6 @@ log4j-web*.jar,\
 log4javascript*.jar,\
 slf4j-taglib*.jar
 
-# Additional JARs (over and above the default JARs listed above) to skip when
-# scanning for Servlet 3.0 pluggability features. These features include web
-# fragments, annotations, SCIs and classes that match @HandlesTypes. The list
-# must be a comma separated list of JAR file names.
-org.apache.catalina.startup.ContextConfig.jarsToSkip=
-
-# Additional JARs (over and above the default JARs listed above) to skip when
-# scanning for TLDs. The list must be a comma separated list of JAR file names.
-org.apache.catalina.startup.TldConfig.jarsToSkip=tomcat-websocket.jar
-
-#
 # String cache configuration.
 tomcat.util.buf.StringCache.byte.enabled=true
 #tomcat.util.buf.StringCache.char.enabled=true
diff --git a/jspwiki-portable/src/overlay/tomcat/conf/server.xml b/jspwiki-portable/src/overlay/tomcat/conf/server.xml
index facd6ad..20a7630 100644
--- a/jspwiki-portable/src/overlay/tomcat/conf/server.xml
+++ b/jspwiki-portable/src/overlay/tomcat/conf/server.xml
@@ -1,4 +1,4 @@
-<?xml version='1.0' encoding='utf-8'?>
+<?xml version="1.0" encoding="UTF-8"?>
 <!--
   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
@@ -20,16 +20,16 @@
      Documentation at /docs/config/server.html
  -->
 <Server port="8025" shutdown="SHUTDOWN">
-  <Listener className="org.apache.catalina.startup.VersionLoggerListener"/>
+  <Listener className="org.apache.catalina.startup.VersionLoggerListener" />
   <!-- Security listener. Documentation at /docs/config/listeners.html
   <Listener className="org.apache.catalina.security.SecurityListener" />
   -->
   <!--APR library loader. Documentation at /docs/apr.html -->
-  <Listener SSLEngine="on" className="org.apache.catalina.core.AprLifecycleListener"/>
+  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
   <!-- Prevent memory leaks due to use of particular java/javax APIs-->
-  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>
-  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
-  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener"/>
+  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
+  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
+  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
 
   <!-- Global JNDI resources
        Documentation at /docs/jndi-resources-howto.html
@@ -38,11 +38,11 @@
     <!-- Editable user database that can also be used by
          UserDatabaseRealm to authenticate users
     -->
-    <Resource name="UserDatabase" auth="Container" 
-	          description="User database that can be updated and saved" 
-			  factory="org.apache.catalina.users.MemoryUserDatabaseFactory" 
-			  pathname="conf/tomcat-users.xml" 
-			  type="org.apache.catalina.UserDatabase" />
+    <Resource name="UserDatabase" auth="Container"
+              description="User database that can be updated and saved"
+              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
+              pathname="conf/tomcat-users.xml"
+              type="org.apache.catalina.UserDatabase" />
   </GlobalNamingResources>
 
   <!-- A "Service" is a collection of one or more "Connectors" that share
@@ -53,17 +53,20 @@
   <Service name="Catalina">
 
     <!--The connectors can use a shared executor, you can define one or more named thread pools-->
-    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-" maxThreads="150" minSpareThreads="4"/>
+    <!--
+    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
+        maxThreads="150" minSpareThreads="4"/>
+    -->
+
 
     <!-- A "Connector" represents an endpoint by which requests are received
          and responses are returned. Documentation at :
-         Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
+         Java HTTP Connector: /docs/config/http.html
          Java AJP  Connector: /docs/config/ajp.html
          APR (HTTP/AJP) Connector: /docs/apr.html
-         Define a non-SSL HTTP/1.1 Connector on port 8080
+         Define a non-SSL/TLS HTTP/1.1 Connector on port 8080
     -->
-    <Connector executor="tomcatThreadPool" port="9627" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="9643" compression="on"/>
-
+    <Connector port="9627" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="9643" />
     <!-- A "Connector" using the shared thread pool-->
     <!--
     <Connector executor="tomcatThreadPool"
@@ -71,19 +74,49 @@
                connectionTimeout="20000"
                redirectPort="8443" />
     -->
-    <!-- Define a SSL HTTP/1.1 Connector on port 8443
-         This connector uses the JSSE configuration, when using APR, the
-         connector should be using the OpenSSL style configuration
-         described in the APR documentation -->
+    <!-- Define an SSL/TLS HTTP/1.1 Connector on port 8443
+         This connector uses the NIO implementation. The default
+         SSLImplementation will depend on the presence of the APR/native
+         library and the useOpenSSL attribute of the
+         AprLifecycleListener.
+         Either JSSE or OpenSSL style configuration may be used regardless of
+         the SSLImplementation selected. JSSE style configuration is used below.
+    -->
     <!--
-    <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
-               maxThreads="150" scheme="https" secure="true"
-               clientAuth="false" sslProtocol="TLS" />
+    <Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
+               maxThreads="150" SSLEnabled="true">
+        <SSLHostConfig>
+            <Certificate certificateKeystoreFile="conf/localhost-rsa.jks"
+                         type="RSA" />
+        </SSLHostConfig>
+    </Connector>
+    -->
+    <!-- Define an SSL/TLS HTTP/1.1 Connector on port 8443 with HTTP/2
+         This connector uses the APR/native implementation which always uses
+         OpenSSL for TLS.
+         Either JSSE or OpenSSL style configuration may be used. OpenSSL style
+         configuration is used below.
+    -->
+    <!--
+    <Connector port="8443" protocol="org.apache.coyote.http11.Http11AprProtocol"
+               maxThreads="150" SSLEnabled="true" >
+        <UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" />
+        <SSLHostConfig>
+            <Certificate certificateKeyFile="conf/localhost-rsa-key.pem"
+                         certificateFile="conf/localhost-rsa-cert.pem"
+                         certificateChainFile="conf/localhost-rsa-chain.pem"
+                         type="RSA" />
+        </SSLHostConfig>
+    </Connector>
     -->
 
     <!-- Define an AJP 1.3 Connector on port 8009 -->
-    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
-
+    <!--
+    <Connector protocol="AJP/1.3"
+               address="::1"
+               port="8009"
+               redirectPort="8443" />
+    -->
 
     <!-- An Engine represents the entry point (within Catalina) that processes
          every request.  The Engine implementation for Tomcat stand alone
@@ -126,11 +159,9 @@
         <!-- Access log processes all example.
              Documentation at: /docs/config/valve.html
              Note: The pattern used is equivalent to using pattern="common" -->
-        <!--     
         <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
-               prefix="localhost_access_log." suffix=".txt"
+               prefix="localhost_access_log" suffix=".txt"
                pattern="%h %l %u %t &quot;%r&quot; %s %b" />
-        -->
 
       </Host>
     </Engine>
diff --git a/jspwiki-portable/src/overlay/tomcat/conf/web.xml b/jspwiki-portable/src/overlay/tomcat/conf/web.xml
index f6a32d2..584d6d2 100644
--- a/jspwiki-portable/src/overlay/tomcat/conf/web.xml
+++ b/jspwiki-portable/src/overlay/tomcat/conf/web.xml
@@ -18,8 +18,8 @@
 <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
-                      http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
-  version="3.1">
+                      http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
+  version="4.0">
 
   <!-- ======================== Introduction ============================== -->
   <!-- This document defines default values for *all* web applications      -->
@@ -48,6 +48,11 @@
   <!--   fileEncoding        Encoding to be used to read static resources   -->
   <!--                       [platform default]                             -->
   <!--                                                                      -->
+  <!--   useBomIfPresent     If a static file contains a byte order mark    -->
+  <!--                       (BOM), should this be used to determine the    -->
+  <!--                       file encoding in preference to fileEncoding.   -->
+  <!--                       [true]                                         -->
+  <!--                                                                      -->
   <!--   input               Input buffer size (in bytes) when reading      -->
   <!--                       resources to be served.  [2048]                -->
   <!--                                                                      -->
@@ -99,6 +104,11 @@
   <!--   showServerInfo      Should server information be presented in the  -->
   <!--                       response sent to clients when directory        -->
   <!--                       listings is enabled? [true]                    -->
+  <!--                                                                      -->
+  <!--   allowPartialPut     Should the server treat an HTTP PUT request    -->
+  <!--                       with a Range header as a partial PUT? Note     -->
+  <!--                       that RFC 7233 clarified that Range headers are -->
+  <!--                       only valid for GET requests. [true]            -->
 
     <servlet>
         <servlet-name>default</servlet-name>
@@ -138,9 +148,9 @@
   <!--                       pages.  See the jasper documentation for more  -->
   <!--                       information.                                   -->
   <!--                                                                      -->
-  <!--   compilerSourceVM    Compiler source VM. [1.7]                      -->
+  <!--   compilerSourceVM    Compiler source VM. [1.8]                      -->
   <!--                                                                      -->
-  <!--   compilerTargetVM    Compiler target VM. [1.7]                      -->
+  <!--   compilerTargetVM    Compiler target VM. [1.8]                      -->
   <!--                                                                      -->
   <!--   development         Is Jasper used in development mode? If true,   -->
   <!--                       the frequency at which JSPs are checked for    -->
@@ -233,7 +243,13 @@
   <!--                       debugging be suppressed?  [false]              -->
   <!--                                                                      -->
   <!--   trimSpaces          Should template text that consists entirely of -->
-  <!--                       whitespace be removed from the output? [false] -->
+  <!--                       whitespace be removed from the output (true),  -->
+  <!--                       replaced with a single space (single) or left  -->
+  <!--                       unchanged (false)? Note that if a JSP page or  -->
+  <!--                       tag file specifies a trimDirectiveWhitespaces  -->
+  <!--                       value of true, that will take precedence over  -->
+  <!--                       this configuration setting for that page/tag.  -->
+  <!--                       [false]                                        -->
   <!--                                                                      -->
   <!--   xpoweredBy          Determines whether X-Powered-By response       -->
   <!--                       header is added by generated servlet.  [false] -->
@@ -335,10 +351,32 @@
   <!--                        If not set, then webAppRootDir is used.       -->
   <!--                        Recommended value: WEB-INF/cgi                -->
   <!--                                                                      -->
+  <!--  cmdLineArgumentsDecoded                                             -->
+  <!--                        Only used when enableCmdLineArguments is      -->
+  <!--                        true. The pattern that individual decoded     -->
+  <!--                        command line arguments must match else the    -->
+  <!--                        request will be rejected. This is to          -->
+  <!--                        work-around various issues when Java passes   -->
+  <!--                        the arguments to the OS. See the CGI How-To   -->
+  <!--                        for more details. The default varies by       -->
+  <!--                        platform.                                     -->
+  <!--                        Windows: [[a-zA-Z0-9\Q-_.\\/:\E]+]            -->
+  <!--                        Others:  [.*]                                 -->
+  <!--                        Note that internally the CGI Servlet treats   -->
+  <!--                        [.*] as a special case to improve performance -->
+  <!--                                                                      -->
+  <!--   cmdLineArgumentsEncoded                                            -->
+  <!--                        Only used when enableCmdLineArguments is      -->
+  <!--                        true. The pattern that individual encoded     -->
+  <!--                        command line arguments must match else the    -->
+  <!--                        request will be rejected. The default matches -->
+  <!--                        the allowed values defined by RFC3875.        -->
+  <!--                        [[a-zA-Z0-9\Q%;/?:@&,$-_.!~*'()\E]+]          -->
+  <!--                                                                      -->
   <!--   enableCmdLineArguments                                             -->
   <!--                        Are command line parameters generated from    -->
   <!--                        the query string as per section 4.4 of 3875   -->
-  <!--                        RFC? [true]                                   -->
+  <!--                        RFC? [false]                                  -->
   <!--                                                                      -->
   <!--   executable           Name of the executable used to run the        -->
   <!--                        script. [perl]                                -->


[jspwiki] 17/35: add missing license

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git

commit fdfd05dafccc1c01c45e7ff453f198b056e90109
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Mar 4 20:14:48 2020 +0100

    add missing license
---
 .../wiki/util/comparators/PrincipalComparatorTest.java | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/jspwiki-util/src/test/java/org/apache/wiki/util/comparators/PrincipalComparatorTest.java b/jspwiki-util/src/test/java/org/apache/wiki/util/comparators/PrincipalComparatorTest.java
index dfbf187..7aa136f 100644
--- a/jspwiki-util/src/test/java/org/apache/wiki/util/comparators/PrincipalComparatorTest.java
+++ b/jspwiki-util/src/test/java/org/apache/wiki/util/comparators/PrincipalComparatorTest.java
@@ -1,3 +1,21 @@
+/*
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+ */
 package org.apache.wiki.util.comparators;
 
 import org.junit.jupiter.api.Assertions;


[jspwiki] 31/35: update README.md to recommend Tomcat 9.x + link to configuration needed to run JSPWiki on Tomcat 8.x

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git

commit 0191302ca60452627cc8aa6d6897730422a3c35e
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Mar 6 00:06:04 2020 +0100

    update README.md to recommend Tomcat 9.x + link to configuration needed to run JSPWiki on Tomcat 8.x
---
 README.md | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md
index baceda9..2304904 100644
--- a/README.md
+++ b/README.md
@@ -35,9 +35,10 @@ Okay, so you wanna Wiki?  You'll need the following things:
 
 REQUIRED:
 
-* A JSP engine that supports Servlet API 3.1.  We recommend Tomcat from
-  http://tomcat.apache.org/ for a really easy installation.
-  Tomcat 8.x or later is supported.
+* A JSP engine that supports Servlet API 3.1.  We recommend [Apache Tomcat](http://tomcat.apache.org/)
+  for a really easy installation. Tomcat 9.x or later is recommended, although Tomcat 8.x 
+  is supported too; see [additional configuration](https://jspwiki-wiki.apache.org/Wiki.jsp?page=Getting%20Started#section-Getting+Started-Tomcat8.x) 
+  that must be set up in order to run JSPWiki on Tomcat 8.x.
 
 * Some previous administration experience...  If you've ever installed
   Apache or any other web server, you should be pretty well off.


[jspwiki] 13/35: replace lambda with method reference while streaming managers

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git

commit 2190448fc4fb0ac691ef28eda476538f8bea2238
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Mar 4 12:56:30 2020 +0100

    replace lambda with method reference while streaming managers
---
 jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
index f6856b0..223817c 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
@@ -545,7 +545,7 @@ public class WikiEngine implements Engine {
     public < T > List< T > getManagers( final Class< T > manager ) {
         return ( List< T > )managers.entrySet().stream()
                                     .filter( e -> manager.isAssignableFrom( e.getKey() ) )
-                                    .map( e -> e.getValue() )
+                                    .map( Map.Entry::getValue )
                                     .collect( Collectors.toList() );
     }
 


[jspwiki] 18/35: move isIPV4Address( String ) method from WikiSession to HttpUtil

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git

commit e68871423703b8db67a236ea4a931e4d01a9b396
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Mar 4 20:17:28 2020 +0100

    move isIPV4Address( String ) method from WikiSession to HttpUtil
---
 .../main/java/org/apache/wiki/util/HttpUtil.java   | 126 ++++++++++++---------
 .../java/org/apache/wiki/util/HttpUtilTest.java    |  50 ++++++++
 2 files changed, 123 insertions(+), 53 deletions(-)

diff --git a/jspwiki-util/src/main/java/org/apache/wiki/util/HttpUtil.java b/jspwiki-util/src/main/java/org/apache/wiki/util/HttpUtil.java
index 3cd7f5d..7ad7399 100644
--- a/jspwiki-util/src/main/java/org/apache/wiki/util/HttpUtil.java
+++ b/jspwiki-util/src/main/java/org/apache/wiki/util/HttpUtil.java
@@ -38,7 +38,10 @@ import java.util.Date;
  */
 public final class HttpUtil {
 
-    static Logger log = Logger.getLogger( HttpUtil.class );
+    private static final Logger log = Logger.getLogger( HttpUtil.class );
+    private static final int    ONE                   = 48;
+    private static final int    NINE                  = 57;
+    private static final int    DOT                   = 46;
     
     /** Private constructor to prevent direct instantiation. */
     private HttpUtil() {
@@ -51,29 +54,27 @@ public final class HttpUtil {
      * @param req http request
      * @return remote address associated to the request.
      */
-    public static String getRemoteAddress( HttpServletRequest req ) {
+    public static String getRemoteAddress( final HttpServletRequest req ) {
 		return StringUtils.isNotEmpty ( req.getHeader( "X-Forwarded-For" ) ) ? req.getHeader( "X-Forwarded-For" ) : 
-			                                                                   req.getRemoteAddr();
+			                                                                          req.getRemoteAddr();
 	}
 
     /**
-     *  Attempts to retrieve the given cookie value from the request.
-     *  Returns the string value (which may or may not be decoded
-     *  correctly, depending on browser!), or null if the cookie is
-     *  not found. The algorithm will automatically trim leading
+     *  Attempts to retrieve the given cookie value from the request. Returns the string value (which may or may not be decoded
+     *  correctly, depending on browser!), or null if the cookie is not found. The algorithm will automatically trim leading
      *  and trailing double quotes, if found.
      *
      *  @param request The current request
      *  @param cookieName The name of the cookie to fetch.
      *  @return Value of the cookie, or null, if there is no such cookie.
      */
-    public static String retrieveCookieValue( HttpServletRequest request, String cookieName ) {
-        Cookie[] cookies = request.getCookies();
+    public static String retrieveCookieValue( final HttpServletRequest request, final String cookieName ) {
+        final Cookie[] cookies = request.getCookies();
 
         if( cookies != null ) {
-            for( int i = 0; i < cookies.length; i++ ) {
-                if( cookies[i].getName().equals( cookieName ) ) {
-                    String value = cookies[i].getValue();
+            for( final Cookie cookie : cookies ) {
+                if( cookie.getName().equals( cookieName ) ) {
+                    String value = cookie.getValue();
                     if( value.length() == 0 ) {
                         return null;
                     }
@@ -89,83 +90,67 @@ public final class HttpUtil {
     }
 
     /**
-     *  Creates an ETag based on page information.  An ETag is unique to each page
-     *  and version, so it can be used to check if the page has changed.  Do not
-     *  assume that the ETag is in any particular format.
+     *  Creates an ETag based on page information. An ETag is unique to each page and version, so it can be used to check if the page has
+     *  changed. Do not assume that the ETag is in any particular format.
      *  
      *  @param pageName  The page name for which the ETag should be created.
      *  @param lastModified  The page last modified date for which the ETag should be created.
      *  @return A String depiction of an ETag.
      */
-    public static String createETag( String pageName, Date lastModified ) {
+    public static String createETag( final String pageName, final Date lastModified ) {
         return Long.toString( pageName.hashCode() ^ lastModified.getTime() );
     }
     
     /**
      *  If returns true, then should return a 304 (HTTP_NOT_MODIFIED)
+     *
      *  @param req the HTTP request
      *  @param pageName the wiki page name to check for
      *  @param lastModified the last modified date of the wiki page to check for
      *  @return the result of the check
      */
-    public static boolean checkFor304( HttpServletRequest req, String pageName, Date lastModified ) {
-        //
-        //  We'll do some handling for CONDITIONAL GET (and return a 304)
-        //  If the client has set the following headers, do not try for a 304.
-        //
+    public static boolean checkFor304( final HttpServletRequest req, final String pageName, final Date lastModified ) {
+        // We'll do some handling for CONDITIONAL GET (and return a 304). If the client has set the following headers, do not try for a 304.
         //    pragma: no-cache
         //    cache-control: no-cache
-        //
-
         if( "no-cache".equalsIgnoreCase( req.getHeader( "Pragma" ) )
             || "no-cache".equalsIgnoreCase( req.getHeader( "cache-control" ) ) ) {
             // Wants specifically a fresh copy
         } else {
-            //
             //  HTTP 1.1 ETags go first
-            //
-            String thisTag = createETag( pageName, lastModified );
-                        
-            String eTag = req.getHeader( "If-None-Match" );
+            final String thisTag = createETag( pageName, lastModified );
+            final String eTag = req.getHeader( "If-None-Match" );
             
             if( eTag != null && eTag.equals(thisTag) ) {
                 return true;
             }
             
-            //
             //  Next, try if-modified-since
-            //
-            DateFormat rfcDateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z");
+            final DateFormat rfcDateFormat = new SimpleDateFormat( "EEE, dd MMM yyyy HH:mm:ss z" );
 
             try {
-                long ifModifiedSince = req.getDateHeader( "If-Modified-Since" );
+                final long ifModifiedSince = req.getDateHeader( "If-Modified-Since" );
 
-                //log.info("ifModifiedSince:"+ifModifiedSince);
                 if( ifModifiedSince != -1 ) {
-                    long lastModifiedTime = lastModified.getTime();
-
-                    //log.info("lastModifiedTime:" + lastModifiedTime);
+                    final long lastModifiedTime = lastModified.getTime();
                     if( lastModifiedTime <= ifModifiedSince ) {
                         return true;
                     }
                 } else {
                     try {
-                        String s = req.getHeader("If-Modified-Since");
-
+                        final String s = req.getHeader("If-Modified-Since");
                         if( s != null ) {
-                            Date ifModifiedSinceDate = rfcDateFormat.parse(s);
-                            //log.info("ifModifiedSinceDate:" + ifModifiedSinceDate);
-                            if( lastModified.before(ifModifiedSinceDate) ) {
+                            final Date ifModifiedSinceDate = rfcDateFormat.parse( s );
+                            if( lastModified.before( ifModifiedSinceDate ) ) {
                                 return true;
                             }
                         }
-                    } catch (ParseException e) {
-                        log.warn(e.getLocalizedMessage(), e);
+                    } catch( final ParseException e ) {
+                        log.warn( e.getLocalizedMessage(), e );
                     }
                 }
-            } catch( IllegalArgumentException e ) {
-                // Illegal date/time header format.
-                // We fail quietly, and return false.
+            } catch( final IllegalArgumentException e ) {
+                // Illegal date/time header format.  We fail quietly, and return false.
                 // FIXME: Should really move to ETags.
             }
         }
@@ -174,13 +159,12 @@ public final class HttpUtil {
     }
 
     /**
-     *  Attempts to form a valid URI based on the string given.  Currently
-     *  it can guess email addresses (mailto:).  If nothing else is given,
-     *  it assumes it to be an http:// url.
+     * Attempts to form a valid URI based on the string given.  Currently it can guess email addresses (mailto:).  If nothing else is given,
+     * it assumes it to be an http:// url.
      * 
-     *  @param uri  URI to take a poke at
-     *  @return Possibly a valid URI
-     *  @since 2.2.8
+     * @param uri  URI to take a poke at
+     * @return Possibly a valid URI
+     * @since 2.2.8
      */
     public static String guessValidURI( String uri ) {
         if( uri.indexOf( '@' ) != -1 ) {
@@ -204,7 +188,6 @@ public final class HttpUtil {
      *
      *  @param request The HTTP request to parse.
      *  @return The query string. If the query string is null, returns an empty string.
-     *
      *  @since 2.1.3 (method moved from WikiEngine on 2.11.0.M6)
      */
     public static String safeGetQueryString( final HttpServletRequest request, final Charset contentEncoding ) {
@@ -234,4 +217,41 @@ public final class HttpUtil {
         return res;
     }
 
+    /**
+     * Verifies whether a String represents an IPv4 address. The algorithm is extremely efficient and does not allocate any objects.
+     *
+     * @param name the address to test
+     * @return the result
+     */
+    public static boolean isIPV4Address( final String name ) {
+        if( StringUtils.isEmpty( name ) || name.charAt( 0 ) == DOT || name.charAt( name.length() - 1 ) == DOT ) {
+            return false;
+        }
+
+        final int[] addr = new int[] { 0, 0, 0, 0 };
+        int currentOctet = 0;
+        for( int i = 0; i < name.length(); i++ ) {
+            if( currentOctet > 3 ) {
+                return false;
+            }
+            final int ch = name.charAt( i );
+            final boolean isDigit = ch >= ONE && ch <= NINE;
+            final boolean isDot = ch == DOT;
+            if( !isDigit && !isDot ) {
+                return false;
+            }
+            if( isDigit ) {
+                addr[ currentOctet ] = 10 * addr[ currentOctet ] + ( ch - ONE );
+                if( addr[ currentOctet ] > 255 ) {
+                    return false;
+                }
+            } else if( name.charAt( i - 1 ) == DOT ) {
+                return false;
+            } else {
+                currentOctet++;
+            }
+        }
+        return currentOctet == 3;
+    }
+
 }
diff --git a/jspwiki-util/src/test/java/org/apache/wiki/util/HttpUtilTest.java b/jspwiki-util/src/test/java/org/apache/wiki/util/HttpUtilTest.java
new file mode 100644
index 0000000..28d02d4
--- /dev/null
+++ b/jspwiki-util/src/test/java/org/apache/wiki/util/HttpUtilTest.java
@@ -0,0 +1,50 @@
+/*
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+ */
+package org.apache.wiki.util;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+
+public class HttpUtilTest {
+
+    @Test
+    public void testIsIPV4Address() {
+        Assertions.assertFalse( HttpUtil.isIPV4Address( null ) );
+        Assertions.assertFalse( HttpUtil.isIPV4Address( "" ) );
+        Assertions.assertFalse( HttpUtil.isIPV4Address( ".123.123.123.123" ) );
+        Assertions.assertFalse( HttpUtil.isIPV4Address( "123.123.123.123." ) );
+        Assertions.assertFalse( HttpUtil.isIPV4Address( "123.123.123" ) );
+        Assertions.assertFalse( HttpUtil.isIPV4Address( "123.123.123.123.123" ) );
+        Assertions.assertFalse( HttpUtil.isIPV4Address( "abc.123.123.123" ) );
+        Assertions.assertFalse( HttpUtil.isIPV4Address( "Me" ) );
+        Assertions.assertFalse( HttpUtil.isIPV4Address( "Guest" ) );
+        Assertions.assertFalse( HttpUtil.isIPV4Address( "1207.0.0.1" ) );
+        Assertions.assertFalse( HttpUtil.isIPV4Address( "127..0.1" ) );
+        Assertions.assertFalse( HttpUtil.isIPV4Address( "1207.0.0." ) );
+        Assertions.assertFalse( HttpUtil.isIPV4Address( ".0.0.1" ) );
+        Assertions.assertFalse( HttpUtil.isIPV4Address( "..." ) );
+
+        Assertions.assertTrue( HttpUtil.isIPV4Address( "127.0.0.1" ) );
+        Assertions.assertTrue( HttpUtil.isIPV4Address( "12.123.123.123" ) );
+        Assertions.assertTrue( HttpUtil.isIPV4Address( "012.123.123.123" ) );
+        Assertions.assertTrue( HttpUtil.isIPV4Address( "123.123.123.123" ) );
+    }
+
+}


[jspwiki] 28/35: use repo1.maven.org instead of search.maven.org, as the latter redirects to the former, to download appbundler

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git

commit b266b55eeca89371a621fba5558cb9c970d14880
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Mar 6 00:00:13 2020 +0100

    use repo1.maven.org instead of search.maven.org, as the latter redirects to the former, to download appbundler
---
 jspwiki-portable/build.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/jspwiki-portable/build.xml b/jspwiki-portable/build.xml
index be9b056..0d67832 100644
--- a/jspwiki-portable/build.xml
+++ b/jspwiki-portable/build.xml
@@ -233,7 +233,7 @@
     <target name="woas:download-appbundler-for-mac" description="Download the Mac OS X appbundler library">
         <delete dir="${jspwiki.appbundler.install.dir}"/>
         <mkdir dir="${jspwiki.appbundler.install.dir}"/>
-        <get src="http://search.maven.org/remotecontent?filepath=com/panayotis/appbundler/1.1.0/appbundler-1.1.0.jar" dest="${jspwiki.appbundler.install.dir}/appbundler-1.1.0.jar"/>
+        <get src="https://repo1.maven.org/fromsearch?filepath=com/panayotis/appbundler/1.1.0/appbundler-1.1.0.jar" dest="${jspwiki.appbundler.install.dir}/appbundler-1.1.0.jar"/>
     </target>
 
 </project>