I want to add a custom FTL-page to the existing Keycloak pages.
Let's call it 'special-number.ftl' that contains a form where you can enter a number and send it to the backend. The submit button should trigger custom java code that I wrote.
How do I do this? How do I trigger a custom FTL-page to be shown and trigger some code I wrote with a click on the submit button?
Assuming you have created a page in your local, then run the following command from a cli:
docker cp special-number.ftl containerId:/opt/jboss/keycloak/themes/base/account
ContainerId will be your docker container id.
In the above example, it is going to the base themes, you can change it to wherever you want it to go.
Related
Does anybody know how can I log to a file the creation/deletion event for an user in Liferay 6.2? Is there any 'listener' that I must watch for or any action (struts action) that can be overwritten to achieve this?
I successfully used a hook to log the login and logout events, using custom action and portal properties.
If anybody knows a way to log certain events (e.g. adding user to an usergroup or something similar) using custom code (maybe JSP), please share with me.
This will be helpful
Its a tutorial to override liferay service action.
http://proliferay.com/liferay-service-hook-override-liferay-service/
I have to create a little webshop for a school-project, but entered in to a problem during the process by updating/refreshing the Servlets.
Description:
I created an index.html file which includes two servlets via iframes, the left side for Navigation-Servlet and on the right the Controller-Servlet does something to show a welcome page (or shows off the categories etc.) - works all fine.
But now I have to implement a login with an small administration.
By clicking in the navigation on Administration, it leads to another Servlet called Administration-Servlet, in the right iframe (actually not over the Controller-Servlet).
There comes up a login mask, where the user put in his username and password. If the login was correct, it leads then to the administration content (not finished by now).
The upcoming problem is now that I somehow have to update/refresh the Navigation iframe too, when the login was successful because there must be the Logout-Button and some entries have to be hidden.
By which "technique" or pattern I can solve this problem? Maybe a little code example would be helpful. :)
Best greets.
Instead of using Iframes to put together the different parts of your site, use dynamic include in your servlets. This will allow you to build the response page server side and therefore dynamically change what is included in a page. When you log in you send the authentication request to the servlet which will then dynamically construct the new response from multiple JSP files.
<jsp:include page="..." />
Another solution is to use a scripting language like Apache Velocity Template scripts to build your responses dynamically. Allowing you to include or exclude information depending on parameters or session context.
I'm implementing a signup system by using UsernamePasswordProvider. I want a user to be able to signup directly instead of firstly putting his/her email and waiting for a token. Moreover, I want to modify the signup form by adding/deleting some input fields. However, I can't find any document mentioned how to achieve these requirements. Any help would be appreciated.
The current stable version - 2.1.3 as of this writing - does not make it easy to customize the flow. With the latest changes in master you can override the built in registration controller and add the changes you need.
To accomplish what you want the best would be to not include the default registration routes and add your own that point to your custom controllers directly.
Keep in mind that the default flow prevents leaking information about the user base. If you make your users fill a form and they enter an existing email address you will have to show an error saying the account exists. That can give information to a potential attacker to target specific emails.
You should create custom views that extend TemplatesPlugin (or ViewsPlugin, in the newest version). This information is explained in securesocial website.
In my application, I want my users to be able to configure their db-properties the first time they launch the application. The db-properties will be stored in a property-file locally and spring will use this file for db-setup in the future.
The workflow will be something like:
Start application for the first time
-> 2. display a page with a db-configuration form
-> 3. user submits the form and the input is written to the db property-file locally
-> 4. spring reads the db-properties from the property-file and instantiates datasource, transaction-nmanager, entitymanager-factory and so on.
So the challenge is how spring can start without any db-setup and then instantiate it dynamically without restarting the server when the form is submitted.
Any suggestions? :-)
You can use Spring's Java Config rather than XML, to instantiate the beans programmatically. This will allow you to read the properties file.
I'm working on a project in Java using the spring framework, hibernate and tomcat.
Background:
I have a form page which takes data, validates, processes it and ultimately persists the data using hibernate. In processing the data I do some special command (model)
manipulation prior to persisting using hibernate.
Problem:
For some reason my onSubmit method is being called twice, the first time through things
are processed properly. However the second time through they are not; and the incorrect
information is being persisted.
I've also noticed that on other pages which are simply pulling information from the data
base and displaying on screen; Double requests are happening there too.
Is there something misconfigured, am I not using spring properly..any help on this would
be great!
Additional Information:
The app is still being developed. In testing the app I'm running into this problem. I'm using the app as I would expect it to be used (single clicks,valid data,etc...)
If you are testing in IE, make note that in some versions of IE it sometimes submits two requests. What browsers are you testing the app in?
There is the javascript issue, if an on click handler is associated with submit button and calls submit() and does not return false to cancel the event bubble.
Could be as simple as users clicking on a link twice, re-submitting a form while the server is still processing the first request, or hitting refresh on a POST-ed page.
Are you doing anything on the server side to account for duplicate requests such as these from your users?
This is a very common problem faced by someone who is starting off. And not very sure about the application eco-system.
To deploy a spring app, we build the war file.
Then we put it inside 'webapps' folder of tomcat.
Then we run the tomcat instance using terminal (I am presuming a linux system).
Now, we set up env in that terminal.
The problem arises when we set up our environment for the spring application where there can be more than one war files to be deployed.
Then we must cater to the fact that the env must be exclusive to a specific war file.
To achieve this, what we can do is create exclusive env files for every war. (e.g. war_1.sh,war_2.sh,.....,war_n.sh) and so on.
Now we can source that particular env file for which we have to deploy its corresponding war. This way we can segregate the multiple wars (applications) and their environment.