第3章 Securing a sample application

Now that you have an admin account, a realm, and a user, you can use Red Hat Single Sign-On to secure a sample JBoss EAP servlet application. You install a JBoss EAP client adapter, register the application in the admin console, modify the JBoss EAP instance to work with Red Hat Single Sign-On, and use Red Hat Single Sign-On with some sample code to secure the application.

Prerequisites

  • You need to adjust the port used by Red Hat Single Sign-On to avoid port conflicts with JBoss EAP.

3.1. Adjusting the port used by Red Hat Single Sign-On

The instructions in this guide apply to running JBoss EAP on the same machine as the Red Hat Single Sign-On server. In this situation, even though JBoss EAP is bundled with Red Hat Single Sign-On, you cannot use JBoss EAP as an application container. You must run a separate JBoss EAP instance for your servlet application.

To avoid port conflicts, you need different ports to run Red Hat Single Sign-On and JBoss EAP.

Prerequisites

  • You have an admin account for the admin console.
  • You created a demo realm.
  • You created a user in the demo realm.

Procedure

  1. Download JBoss EAP 7.3 from the Red Hat customer portal.
  2. Unzip the downloaded JBoss EAP.

    $ unzip <filename>.zip
  3. Change to the Red Hat Single Sign-On root directory.
  4. Start the Red Hat Single Sign-On server by supplying a value for the jboss.socket.binding.port-offset system property. This value is added to the base value of every port opened by the Red Hat Single Sign-On server. In this example, 100 is the value.

    Linux/Unix

    $ cd bin
    $ ./standalone.sh -Djboss.socket.binding.port-offset=100

    Windows

    > ...\bin\standalone.bat -Djboss.socket.binding.port-offset=100

    Windows Powershell

    > ...\bin\standalone.bat -D"jboss.socket.binding.port-offset=100"

  5. Confirm that the Red Hat Single Sign-On server is running. Go to http://localhost:8180/auth/admin/ .

    If the admin console opens, you are ready to install a client adapter that enables JBoss EAP to work with Red Hat Single Sign-On.