4.6. Portal Components
In this manual, a portal is a client block, which can solve the following problems:
-
provide an alternative web-interface, which is usually intended for users outside of the organization;
-
provide an interface for integration with mobile applications and third-party systems.
A specific application may contain several portal modules intended for different purposes; for example, in an application, which automates business tasks, it can be a public web site for customers, an integration module for a mobile application for ordering a taxi, an integration module for a mobile application for drivers, etc.
The cuba application component includes the portal module, which is a template to create portals in projects. It provides basic functionality of the client block to work with Middleware. Besides, the universal REST API, included to the portal module as a dependency, is turned on by default.
Below is an overview of the main components provided by the platform in the portal module.
-
PortalAppContextLoader
– the AppContext loader; must be registered in thelistener
element of theweb.xml
file. -
PortalDispatcherServlet
– the central servlet that distributes requests to Spring MVC controllers, for both the web interface and REST API. The set of Spring context configuration files is defined by the cuba.dispatcherSpringContextConfig application property. This servlet must be registered inweb.xml
and mapped to the root URL of the web application. -
App
– the object that contains information on the current HTTP request and the reference toConnection
object. TheApp
instance can be obtained in the application code by calling theApp.getInstance()
static method. -
Connection
– allows a user to log in/out of the Middleware. -
PortalSession
– the object of a user session that is specific for the portal. It is returned by the UserSessionSource infrastructure interface and by thePortalSessionProvider.getUserSession()
static method.It has an additional
isAuthenticated()
method, which returnstrue
if this session belongs to a non-anonymous user, i.e. a user explicitly registered with the login and password.When a user first accesses the portal, the
SecurityContextHandlerInterceptor
creates an anonymous session for him (or ties to an already existing one) by registering at Middleware with a user name specified in the cuba.portal.anonymousUserLogin application property. The registration is made by loginTrusted() method, so it is necessary to set the cuba.trustedClientPassword property in the portal block as well. Thus, any anonymous user of the portal can work with Middleware withcuba.portal.anonymousUserLogin
user rights.If the portal contains user registration page with name and password
SecurityContextHandlerInterceptor
assigns the session of the explicitly registered user to the execution thread afterConnection.login()
is executed, and the work with Middleware is performed on this user’s behalf. -
PortalLogoutHandler
– handles the navigation to the logout page. It must be registered in theportal-security-spring.xml
project file.