Test the Application

After you integrate a web application with Oracle Identity Cloud Service, you can test the application. To test a web application, you register the application, set up the application, import the Oracle Identity Cloud Service certificate into the application server, and then run the application.

Before You Begin

Before you test web application, ensure that you have:
  • Experience developing in Java.

  • Access to Oracle Identity Cloud Service with authorization to manage applications. You must be an Identity Domain Administrator, a Security Administrator, or an Application Administrator.

  • Installed NetBeans IDE 8.1 (use the All or Java Platform, Enterprise Edition (Java EE) bundle).

  • Access to GitHub: https://github.com/oracle/idm-samples.

  • Cloned or downloaded the idm-samples repository on GitHub.

The Customer Quotes (sample code) application is provided “AS IS” with no express or implied warranty for accuracy or accessibility. The sample code is intended to demonstrate the basic integration between Oracle Identity Cloud Service and custom applications and does not represent, by any means, the recommended approach nor is it intended to be used in development or production environments.

Register the Application

The following steps show how to register the example Customer Quotes application in Oracle Identity Cloud Service. As part of the application registration process, you configure and activate the web application in Oracle Identity Cloud Service. During configuration, you define how Oracle Identity Cloud Service integrates with your web application.

  1. In the Identity Cloud Service console, expand the Navigation Drawer, click Applications, and then click Add.
  2. Select Trusted Application.
  3. Enter the following information, and then click Next.
    • Name: Customer Quotes
    • Description: Web application that works as a hub for all your quotations.
  4. Select Configure this application as a client now.
  5. In the Authorization section, select Authorization Code, and then enter the following information:
    • Redirect URL: https://localhost:8181/cquotes/return
    • Logout URL: https://localhost:8181/cquotes/logout
    • Post Logout Redirect URL: https://localhost:8181/cquotes
  6. On the panes that follow, click Next until you reach the last pane, and then click Finish.
  7. Record the values for the Client ID and the Client Secret, and then click Close.
  8. Click Activate, and then click Activate Application.
You now have an application entry with a client ID and a client secret for integrating your application with Oracle Identity Cloud Service.

Set Up the Application

After you register the web application, configure the web application to connect with Oracle Identity Cloud Service during authentication.

  1. Open the CQUOTES_LOCATION/src/main/java/com/example/utils/ClientConfig.java file.
    The ClientConfig.java file contains the settings that the Customer Quotes application uses during runtime to connect to Oracle Identity Cloud Service.
  2. Add the Client ID and the Client Secret values, and the URL of your Oracle Identity Cloud Service. The IDCS_URL value must be the base URL of your Oracle Identity Cloud Service instance.
    //YOUR IDENTITY DOMAIN AND APPLICATION CREDENTIALS
    public static final String CLIENT_ID = "";
    public static final String CLIENT_SECRET = "";
    public static final String IDCS_URL = "https://idcs-abcd1234.identity.oraclecloud.com";
  3. Save the ClientConfig.java file.

Import the Oracle Identity Cloud Service Certificate into the Application Server

Export the SSL certificate from the Oracle Identity Cloud Service UI and import it into NetBeans GlassFish Server trust store. This step is required for the custom web application to communicate with Oracle Identity Cloud Service by using HTTPS.

  1. Access the Oracle Identity Cloud Service console by using Google Chrome on Windows.
  2. In the browser address bar, click View site information (the lock icon), and then click the certificate link under the Certificate section.
  3. Click the Details tab, and then click Copy to File.
  4. Click Next, select Base-64 encoded X.509 (.CER), and then click Next.
  5. Save the certificate as oracle.cer in a temporary folder such as c:\temp, click Next, and then click Finish.
  6. Click OK to close the certification message (if necessary).
  7. Click OK to close the Certificate dialog box, and then close your browser.
  8. Start NetBeans.
  9. Click the Services tab, expand Servers, right-click GlassFish Server, and then click Properties. Record the value in the GlassFish Domains Folder field.
  10. Click the Java tab, and then click Manage Platforms. Record the value in the Platform Folder field.
  11. Close NetBeans.
  12. At the command prompt as an administrator, run the following commands to import the certificate into your Oracle GlassFish Server.

    In the command, JAVA_PLATFORM_FOLDER is the NetBeans GlassFish Java home location and GLASSFISH_DOMAIN_FOLDER is the Domains Folder that you noted in the Step 9.

    set PATH=%PATH%;JAVA_PLATFORM_FOLDER\bin
    cd %GLASSFISH_DOMAIN_FOLDER%\domain1\config
    keytool -import -keystore "cacerts.jks" -trustcacerts -file "C:\temp\oracle.cer" -alias idcs -storepass changeit
  13. Enter yes when prompted.
  14. Confirm that the certificate is successfully imported, by running the following command:
    keytool -list -keystore "cacerts.jks" -alias idcs -storepass changeit

Run the Application

After you import the Oracle Identity Cloud Service Certificate into Oracle GlassFish Server Run the web application by building it in NetBeans.

Prerequisites:

An internet connection to run the cquotes build.

No proxy settings preventing the internet connection.

Disconnected from VPN.

  1. In NetBeans, open the cquotes project, right-click cquotes, and then click Build.
  2. After the build is successfully completed, right-click cquotes, and then click Run.
  3. On the Select deployment server dialog box, select the server from the Server list.
    Your web browser displays the Customer Quotes application.
  4. Access https://localhost:8181/cquotes/ (to open the example Customer Quotes application in HTTPS.
  5. Click Login with Identity Cloud Service.
  6. Enter your credentials.
    After a successful authentication, Oracle Identity Cloud Service redirects you back to the Customer Quotes application, which displays a welcome message.
  7. Access the My Profile page by performing one of the following actions:
    • On the horizontal bar at the top of the page, click My Profile.
    • If you do not see My Profile on the horizontal bar, then expand the menu in the upper-right corner, and then click My Profile.
  8. Return to the Customer Quotes window, in the upper-right corner, expand the menu and then click Logout.
    You should be redirected to the Oracle Technology Network website.
  9. Access https://localhost:8181/cquotes/, and then the Oracle Identity Cloud Service UI.
    If you are not recognized as a signed-in user for the Customer Quotes application or the Oracle Identity Cloud Service UI, then the logout worked.