Skip to content

Latest commit

 

History

History
99 lines (65 loc) · 3.51 KB

README.md

File metadata and controls

99 lines (65 loc) · 3.51 KB

app-jee-jsp: JSP Service Invocation Application

Level: Beginner Technologies: JavaEE Summary: JSP Service Invocation Application Target Product: Red Hat SSO, JBoss EAP Source: https://github.com/redhat-developer/redhat-sso-quickstarts

What is it?

The app-jee-jsp quickstart demonstrates how to write an application with JavaEE that authenticates using Red Hat SSO. Once authenticated the application shows how to invoke a service secured with Red Hat SSO.

System Requirements

The quickstart requires that you have one of the example services or Node.js example services running. It assumes the services are located on the same host as the application. If the service is running elsewhere you need to set the URL of the service as an environment variable (SERVICE_URL) and restart JBoss EAP.

If you are deploying the application as a WAR you need to have JBoss EAP 7.1.0 running.

All you need to build this project is Java 8.0 (Java SDK 1.8) or later and Maven 3.1.1 or later.

Configuration in Red Hat SSO

Prior to running the quickstart you need to create a client in Red Hat SSO and download the installation file.

The following steps show how to create the client required for this quickstart:

  • Open the Red Hat SSO admin console
  • Select Clients from the menu
  • Click Create
  • Add the following values:
    • Client ID: You choose (for example app-jsp)
    • Client Protocol: openid-connect
    • Root URL: URL to the application (for example http://localhost:8080/app-jsp)
  • 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 Installation in the tab for the client you created
  • Select Keycloak OIDC JSON
  • Click Download
  • Move the file keycloak.json to the config/ 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.

Build and Deploy the Quickstart

  1. Open a terminal and navigate to the root directory of this quickstart.

  2. The following shows the command to deploy the quickstart:

    mvn install wildfly:deploy
    

If you prefer to secure WARs via Red Hat SSO subsystem:

mvn install -Dsubsystem wildfly:deploy

Access the Quickstart

You can access the application with the following URL: http://localhost:8080/app-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 user to be logged-in
  • Invoke admin - Invokes the secured endpoint and requires a user with the role admin to be logged-in

If you invoke the endpoints without the required permissions an error will be shown.

Undeploy the Quickstart

  1. Open a terminal and navigate to the root directory of this quickstart.

  2. The following shows the command to undeploy the quickstart:

    mvn wildfly:undeploy