Level: Beginner Technologies: Servlet, JSP Summary: Servlet and JSP application Target Product: Keycloak, JBoss Fuse Source: https://github.com/redhat-developer/redhat-sso-quickstarts
The app-war-jsp quickstart demonstrates how to write a Servlet JSP application, which is packaged as a WAR. The application will be secured by Keycloak and deployed to JBoss Fuse.
The application provides simple UI where you can login/logout and see Account management built-in Keycloak page. Also it allows you to invoke service REST endpoint, which will be typically provided either by Apache Camel or Apache CXF service quickstarts.
You need to have JBoss Fuse 6.3.0
All you need to build this project is Java 8.0 (Java SDK 1.8) or later and Maven 3.1.1 or later.
Prior to running the quickstart you need to create a client in Keycloak and download the installation file.
The following steps shows how to create the client required for this quickstart:
- Open the Keycloak admin console
- Select
Clientsfrom the menu - Click
Create - Add the following values:
- Client ID: You choose (for example
fuse-app-jsp) - Client Protocol:
openid-connect - Root URL: URL to the application (for example
http://localhost:8181/app-war-jsp)
- Client ID: You choose (for example
- Click
Save
Once saved you need to change the Access Type to confidential and click Save.
If you deploy the application somewhere else change the hostname and port of the URLs accordingly.
Finally you need to configure the adapter, this is done by retrieving the adapter configuration file:
- Click on
Installationin the tab for the client you created - Select
<span>Keycloak</span> OIDC JSON - Click
Download - Move the file
keycloak.jsonto theconfig/directory in the root of the quickstart
As an alternative you can create the client by importing the file client-import.json and
copying config/keycloak-example.json to config/keycloak.json.
- Open a terminal and navigate to the fuse63 directory.
mvn clean install
You can access the application with the following URL: http://localhost:8181/app-war-jsp.
The application provides buttons that allows invoking the different endpoints on the service:
- Invoke public - Invokes the public endpoint and doesn't require a user to be logged-in
- Invoke secured - Invokes the secured endpoint and requires a user with the role
userto be logged-in - Invoke admin - Invokes the secured endpoint and requires a user with the role
adminto be logged-in
If you invoke the endpoints without the required permissions an error will be shown.