Cloud: Java Cloud Service SDK

#

## Sample Introduction

This sample demonstrates public accessibility of an application in Oracle Java Cloud Service. It has the following web modules:

- sso-fully-secured - A WAR in which all the resources are secured using Single Sign-On mode of authentication; therefore, by default all pages are secured in this web module.
- sso-unsecured - A WAR in which all the resources are public. An application has to explicitly opt out of the default security.
- sso-partially-secured - A WAR in which selected sections of the resources are secured.
- sso-perimeter-security - A WAR without any security configuration specified. The application is not accessible to public. This is the default security posture to prevent the application from unintentionally being publicly accessible. Although by default, we challenge the users for SSO, this application is executed with an anonymous user only.

After you run the sample, the sample main page listing entrances to above these SSO applications will be displayed. Users can choose to visit unsecured applications without authentication or to log in to access the secured resources.

## Prepare the Sample

### Prerequisites for Deploying the Sample Locally

1. Install Oracle WebLogic Server and configure it. This is required only if you want to deploy applications locally.
2. In the `SDK_HOME/samples/myenv.*` script, set the MW_HOME environment variable to the directory where WebLogic Server is installed.
3. Run the script:
   - On Linux, run: `. ./myenv.sh`
   - On Windows, run: `myenv.cmd`
4. Set the following environment variables in the `SDK_HOME/samples/build.common.properties` properties file:
   - set local to true, the default value is false.
   - set identity-domain to the identity domain name where you will deploy the application.
   - set service-instance to the service instance name where you will deploy the application.
   - set local-admin-url to the URL of the local WebLogic admin server.
   - set local-admin-user to the admin user who has permission to deploy the application.
   - set local-app-users-group to the app-users-group by which the application is secured.

You can also refer to Preparing Applications for Java Cloud Service Deployment in Using Oracle Java Cloud Service and the sample main page for more details.

### Prerequisites for Deploying the Sample on Java Cloud Service

If you are going to install your application only on a remote Java Cloud Service instance, you will not need to have WebLogic Server installed locally. Just make sure that "ant" and "javac" are available in the path.

Set the following environment variables in the `SDK_HOME/samples/build.common.properties` properties file:

- set identity-domain to the identity domain name where you will deploy the application.
- set service-instance to the service instance name where you will deploy the application.
- set cloud-admin-url to the admin URL that is used to deploy the application on Oracle Cloud.
- set cloud-admin-user to the admin user who has permission to deploy the application on Oracle Cloud.
- set cloud-app-users-group to the app-users-group by which the application is secured. You must also use the My Service Security page to create a new role that is of the form `<service-instance>.JavaUsers`, and then assign that role to the user who will log onto the sample after it is deployed on Oracle Cloud.

## Build and Deploy the Sample

To build the sample, follow these steps:

1. Change to the `SDK_HOME/samples/security/greeting-form-auth` directory, where SDK_HOME refers to the main Java Cloud service SDK installation directory, such as `/home/user/oracle-javacloud-sdk`.
2. Execute the following command in the shell. (If you deploy the sample to local environment, choose the shell where you run the `myenv.*` script.)
   `ant clean`
   This command cleans the build directory
   `ant build`
   This command compiles and stages the sample.
3. Execute the following command in the shell. (If you deploy the sample to local environment, choose the shell where you run the `myenv.*` script.)
   `ant install`
   This command installs the sample on the local WebLogic Server or a remote Java Cloud Service.

The Ant command uses the `build.xml` file in the `SDK_HOME/samples/security/sso-advanced` directory to build the sample.

## Run the Sample

1. Complete the steps in the "Prepare the Sample" section.
2. Use your web browser to open the following application URL patterns:
   - http://server:port/sso-fully-secured
   - http://server:port/sso-partially-secured
   - http://server:port/sso-perimeter-security
   - http://server:port/sso-unsecured

   Where the server would include the identity domain and service instance name. For example, `https://java1-wnctrial.java.dc1.c9labga.us.oracle.com/sso-fully-secured`, where `java1` is the service instance name and `wnctrial` is the identity domain. The rest of the host name `java.dc1.c9labga.us.oracle.com` is based on the environment. The actual URL should be printed when you run the sample.