JBStrap Hardlink solution
HardLinks are used to send an email to a user with a link to a page. This email may contain sensitive information in an encrypted form. Let’s say you need to create a registration process where the address for confirmation emails needs to be verified. The registration is only successful if the user confirms the address by clicking on a link in the email.
- Create a page on which the user can enter their information and specify an email address for confirmation emails.
- Create a link to navigate users to a specific point in the application.
- You can use the SoftLink solution for this, but the parameters in the URL contain sensitive information such as the user’s password.
- If you use SoftLink, this information will be exposed to everyone seeing the URL, which creates security vulnerabilities.
- So, it is recommended that you use a HardLink for this purpose, as it has encrypted parameters where the sensitive information is not readable by the user or others.
Create and handle HardLinks using the HardLink class. You can create a URL like this:
Creating a HardLink
In the above example, you create a URL address containing the user’s name. This generated link can be then included in confirmation message, and sent to the user.
If the user clicks on this link, the framework will navigate them automatically to the previously specified (with the targetPageId parameter) page. If this page contains private content and the user is not logged in or has no permission to view the content, they will be redirected to the login page. If the user enters their login details, they can view the content.
Continuing with the same example, the page that the link points to, has to read has just confirmed their address, as there can be multiple pending registrations at the same time. For this, it needs to read parameters, stored in the HardLink.
Getting the HardLink parameters
All parameters can be read from the HardLink, which are returned to you in a Map. The Map key is the parameter name (String type) and the Map value is the parameter value. The parameter value is in the same type as it was specified (e.g., if you added a Long value parameter to the link, you will receive a Long value parameter in the Map as well).