This project highlights how developers can customize and manipulate with user login procedure in CUBA.
Let’s assume that our CUBA application should be licensed as following:
- More than X concurrent users cannot access the system.
- The license has global expiration date when all users will not be able to login.
To add custom behaviour for user login we need to extend the LoginWorkerBean
declared in the platform by following the specified steps:
-
In
core
module, under the main project package (in our casecom.company.loginrestrictions
) we create the security subpackage (to keep clear structure and high code readability). -
Under the
com.company.loginrestrictions.security
package we createMyLoginWorkerBean
to extend the platform’s implementation of theLoginWorkerBean
and overridelogin()
andloginByRememberMe()
methods. -
To replace the original worker implementation with our
MyLoginWorkerBean
we register our class inspring.xml
of thecore
module by adding:<bean id="cuba_LoginWorker" class="com.company.loginworkersample.security.MyLoginWorkerBean"/>
. Now the overridden methods of theMyLoginWorkerBean
class will be used when user logs in. -
To access the license properties we use standard configuration interfaces mechanism provided by the CUBA Platform. See the
LicenseConfig
interface. It contains the default values of the license parameters. -
The default license parameters are overridden in the
app.properties
file of thecore
module. See thelicense.concurrentSessionsLimit
property.
Based on CUBA Platform 6.0.9